[SOLVED] Texture references in .egg file from Blender export

I have a little problem. Say I want to achieve this pipeline:
Blender+Photoshop -> [some resource package containing .egg, textures and materials]

Consider this .egg file:

<Texture> tref1 {
  colormap.png
}
<Material> mref1 {
  <Scalar> diffr { 0.6 }
  <Scalar> diffg { 0.6 }
  <Scalar> diffb { 0.6 }
  <Scalar> specr { 0.5 }
  <Scalar> specg { 0.5 }
  <Scalar> specb { 0.5 }
  <Scalar> shininess { 90.0 }
}
<Group>
{
 <VertexPool> vpool1
 {
        <Vertex> 0 {
          -1 1 0
          <UV> { 0 1 }
          <Normal> { 0 0 1 }
        }
        <Vertex> 1 {
          1 1 0
          <UV> { 1 1 }
          <Normal> { 0 0 1 }
        }
        <Vertex> 2 {
          1 -1 0
          <UV> { 1 0 }
          <Normal> { 0 0 1 }
        }
        <Vertex> 3 {
          -1 -1 0
          <UV> { 0 0 }
          <Normal> { 0 0 1 }
        }
      }

      <Polygon> {
        <RGBA> { 0.6 0.6 0.6 1 }
        <TRef> { tref1 }
        <MRef> { mref1 }
        <VertexRef> { 0 1 2 3 <Ref> { vpool1 } }
 }
}

If I want to add more texture-references in there I just add for example:

<Texture> tref2 {
  normalmap.png
}

AND I have to add the reference to the polygon… EACH polygon to use the texture:

<Polygon> {
        <RGBA> { 0.6 0.6 0.6 1 }
        <TRef> { tref1 }
        <TRef> { tref2 }
        <MRef> { mref1 }
        <VertexRef> { 0 1 2 3 <Ref> { vpool1 } }
 }

Well now… There is no way I’m doing that manually for models that may contain hundreds of polygons or more.

I know there is YABEE but it isn’t reliable as it isn’t maintained and it doesn’t seem compatible with latest versions of Blender (2.72 while writing this).

I looked into exporting from blender to .x files and then convert from .x to .egg. Thats how I got the .egg file I’ve presented. However, I can’t seem to make a .x-file reference more than one texture.
Look at the bottom of this .x file:

xof 0303txt 0032

Frame Root {
  FrameTransformMatrix {
     1.000000, 0.000000, 0.000000, 0.000000,
     0.000000, 1.000000, 0.000000, 0.000000,
     0.000000, 0.000000, 1.000000, 0.000000,
     0.000000, 0.000000, 0.000000, 1.000000;;
  }
  Frame obj_plane_000 {
    FrameTransformMatrix {
       1.000000, 0.000000, 0.000000, 0.000000,
       0.000000, 1.000000, 0.000000, 0.000000,
       0.000000, 0.000000, 1.000000, 0.000000,
       0.000000, 0.000000, 0.000000, 1.000000;;
    }
    Mesh {
      4;
      -1.000000;-1.000000; 0.000000;,
       1.000000;-1.000000; 0.000000;,
       1.000000; 1.000000; 0.000000;,
      -1.000000; 1.000000; 0.000000;;
      1;
      4;0,1,2,3;;
      MeshNormals {
        1;
         0.000000; 0.000000; 1.000000;;
        1;
        4;0,0,0,0;;
      }
      MeshTextureCoords {
        4;
         0.000000; 1.000000;,
         1.000000; 1.000000;,
         1.000000; 0.000000;,
         0.000000; 0.000000;;
      }
      MeshMaterialList {
        1;
        1;
        0;;
        Material mat_plane_000 {
           0.640000; 0.640000; 0.640000; 1.000000;;
           96.078431;
           0.500000; 0.500000; 0.500000;;
           0.000000; 0.000000; 0.000000;;
          TextureFilename {"colormap.png";}
        }
      }
    }
  }
}

We got a reference to a texture called “colormap.png”.
But I can’t seem to add more references! I’ve looked everywhere on the net and nowhere does there appear to be a desire among people to create models with more than one texture!

I’ve tried:

Material mat_plane_000 {
           0.640000; 0.640000; 0.640000; 1.000000;;
           96.078431;
           0.500000; 0.500000; 0.500000;;
           0.000000; 0.000000; 0.000000;;
          TextureFilename {"colormap.png";"normalmap.png"}
}
Material mat_plane_000 {
           0.640000; 0.640000; 0.640000; 1.000000;;
           96.078431;
           0.500000; 0.500000; 0.500000;;
           0.000000; 0.000000; 0.000000;;
          TextureFilename {"colormap.png";}
          TextureFilename {"normalmap.png";}
}
Material mat_plane_000 {
           0.640000; 0.640000; 0.640000; 1.000000;;
           96.078431;
           0.500000; 0.500000; 0.500000;;
           0.000000; 0.000000; 0.000000;;
          TextureFilename texture1 {"colormap.png";}
          TextureFilename texture2 {"normalmap.png";}
}

I can’t think of anything else. I’m considering just writing a program that deals with .egg files and sets them up the way I want but sigh I… dont… want to… if I don’t have to…

Most text editors have a search&replace function.
You just need to replace all ’ { tref1 }’ with ’ { tref1 } { tref2}’ no newlines are needed.

If you do this a lot a python parser is a fine solution, and often simpler then making an exporters work the way you’d want em to work.

Oh my… thank you! Thank you! hahaha! No way! Awesome mate!

YABEE is capable of exporting multi-texture materials just fine, including normal maps. Perhaps there’s something about the configuration? You have to take care that the textures are assigned to the appropriate slots (and only one slot at a time), use UVs. For the normal map specifically, it should be mapped only to the Nor slot and you should configure it to sample as a Tangent Normal Map.

I think that the objection to YABEE wasn’t that it has any problem with multiple textures, but rather concerns about it not being maintained and not being compatible with the latest version of Blender. The former I’m not sure about, but I do seem to recall that the latter is true.

That said, I’ve generally had good results from YABEE–but then I’m happy to stick with Blender version 2.66a for now, I believe.