[SOLVED] Vertex References in Egg File

Hi all,

Briefly –
I just started messing around with Panda3D and have a few questions about the egg format.

What happens to an egg file at runtime or in a bam file?
Are unreferenced vertices ignored?
Are vertices that occupy the same space on an object merged?

And More Detail –
I’m using XSI 4.2 and more specifically here’s my problem;

The DirectX exporter for XSI appears to export a vertex for each UV coordinate. So a textured cube with 8 vertices ends up being exported as a .x file with 24 vertices and 24 UV coordinates.

When I run x2egg on the .x file the resulting .egg file ends up with 48 vertex entries.

What happens with all these extra vertices when inside Panda3D or in a bam file?

I could write a “simple” .egg exporter but even after trying to consolidate or “merge” the redundant vertex entries I’d still end up as many vertices as there are UV coordinates since (from my understanding) the UVs must be speficied in a vertex entry. Are these extra vertices okay because they’ll be merged or something at runtime or in a bam file?

Thanks,

Right, the egg loader will generally do the “right” thing and consolidate redundant vertices. So don’t worry too much about optimizing the vertex use within the egg file.

David

you can have multiple UV’s per vertex. they are referenced by name. What I have seen is that if there is only 1 set of uv coordinates, the name is left blank.

each texture can have a UV set associated to it (possibly more than one)

each vertex could then have multiple named UV’s that reference that texture.

<VertexPool> mymesh.verts {	
        <Vertex> 0 {	
          -31.9837 -16.2158 0
          <UV> detailUV { -1.13374 -0.040558 }
          <UV> lightmapUV { 0.280204 0.491786 }	
          <Normal> { 0 0 1 }	
        }	

look here:
discourse.panda3d.org/viewtopic.php?t=1788

the Egg interface has just about everything you need to manipulate the Egg file.

one differentiation is that, yes, every vertex has a set of UV coordinates but all of these UV Coordinates can be from the same UV set.

not sure if it makes a difference that the model is being split up like that.

post your egg file and I will be happy to take a look.

Thanks drwr!

bradford6 Thanks for posting that link, that will come in handy in the future.

I don’t think multiple UV sets would help me in this case though because the supplied UVs are supposed to be one set of UVs or correspond to one texture. I thought about trying to create separate UV sets for each UV cluster or island but it seemed that would just complicate things further and in the event I actually had multiple UVs it would just be a big mess… for me at least.

Here’s the .egg file. If you want to see the .x and .xsi file let me know and I can zip everything up for you.

I appreciate the help.

<CoordinateSystem> { Y-Up-Left }

<Comment> {
  "x2egg -o cube.egg cube.x"
}
<Texture> tref1 {
  noIcon.jpeg
}
<Material> mref1 {
  <Scalar> diffr { 0.7 }
  <Scalar> diffg { 0.7 }
  <Scalar> diffb { 0.7 }
  <Scalar> specr { 1 }
  <Scalar> specg { 1 }
  <Scalar> specb { 1 }
  <Scalar> shininess { 50 }
}
<Group> Scene_Root {
  <Group> light {
    <Transform> {
      <Matrix4> {
        1 0 0 0
        0 1 0 0
        0 0 1 0
        0 0 0 1
      }
    }
  }
  <Group> cube {
    <Transform> {
      <Matrix4> {
        1 0 0 0
        0 1 0 0
        0 0 1 0
        0 0 0 1
      }
    }
    <Group> cube_obj {
      <VertexPool> cube_obj {
        <Vertex> 0 {
          4 -4 -4
          <UV> { 0 1 }
          <Normal> { 0 0 -1 }
        }
        <Vertex> 1 {
          4 4 -4
          <UV> { 0 0 }
          <Normal> { 0 0 -1 }
        }
        <Vertex> 2 {
          -4 4 -4
          <UV> { 1 0 }
          <Normal> { 0 0 -1 }
        }
        <Vertex> 3 {
          -4 -4 -4
          <UV> { 1 1 }
          <Normal> { 0 0 -1 }
        }
        <Vertex> 4 {
          -4 -4 4
          <UV> { 0 0 }
          <Normal> { 0 -1 0 }
        }
        <Vertex> 5 {
          4 -4 4
          <UV> { 1 0 }
          <Normal> { 0 -1 0 }
        }
        <Vertex> 6 {
          4 -4 -4
          <UV> { 1 1 }
          <Normal> { 0 -1 0 }
        }
        <Vertex> 7 {
          -4 -4 -4
          <UV> { 0 1 }
          <Normal> { 0 -1 0 }
        }
        <Vertex> 8 {
          -4 4 -4
          <UV> { 0 0 }
          <Normal> { -1 0 0 }
        }
        <Vertex> 9 {
          -4 4 4
          <UV> { 1 0 }
          <Normal> { -1 0 0 }
        }
        <Vertex> 10 {
          -4 -4 4
          <UV> { 1 1 }
          <Normal> { -1 0 0 }
        }
        <Vertex> 11 {
          -4 -4 -4
          <UV> { 0 1 }
          <Normal> { -1 0 0 }
        }
        <Vertex> 12 {
          4 -4 4
          <UV> { 0 1 }
          <Normal> { 1 0 0 }
        }
        <Vertex> 13 {
          4 4 4
          <UV> { 0 0 }
          <Normal> { 1 0 0 }
        }
        <Vertex> 14 {
          4 4 -4
          <UV> { 1 0 }
          <Normal> { 1 0 0 }
        }
        <Vertex> 15 {
          4 -4 -4
          <UV> { 1 1 }
          <Normal> { 1 0 0 }
        }
        <Vertex> 16 {
          4 4 -4
          <UV> { 1 0 }
          <Normal> { 0 1 0 }
        }
        <Vertex> 17 {
          4 4 4
          <UV> { 1 1 }
          <Normal> { 0 1 0 }
        }
        <Vertex> 18 {
          -4 4 4
          <UV> { 0 1 }
          <Normal> { 0 1 0 }
        }
        <Vertex> 19 {
          -4 4 -4
          <UV> { 0 0 }
          <Normal> { 0 1 0 }
        }
        <Vertex> 20 {
          -4 4 4
          <UV> { 0 0 }
          <Normal> { 0 0 1 }
        }
        <Vertex> 21 {
          4 4 4
          <UV> { 1 0 }
          <Normal> { 0 0 1 }
        }
        <Vertex> 22 {
          4 -4 4
          <UV> { 1 1 }
          <Normal> { 0 0 1 }
        }
        <Vertex> 23 {
          -4 -4 4
          <UV> { 0 1 }
          <Normal> { 0 0 1 }
        }
        <Vertex> 24 {
          -4 -4 -4
          <UV> { 1 1 }
          <Normal> { -0.57735 -0.57735 -0.57735 }
        }
        <Vertex> 25 {
          -4 -4 -4
          <UV> { 0 1 }
          <Normal> { -0.57735 -0.57735 -0.57735 }
        }
        <Vertex> 26 {
          -4 -4 -4
          <UV> { 0 1 }
          <Normal> { -0.57735 -0.57735 -0.57735 }
        }
        <Vertex> 27 {
          -4 -4 4
          <UV> { 0 0 }
          <Normal> { -0.57735 -0.57735 0.57735 }
        }
        <Vertex> 28 {
          -4 -4 4
          <UV> { 1 1 }
          <Normal> { -0.57735 -0.57735 0.57735 }
        }
        <Vertex> 29 {
          -4 -4 4
          <UV> { 0 1 }
          <Normal> { -0.57735 -0.57735 0.57735 }
        }
        <Vertex> 30 {
          -4 4 -4
          <UV> { 1 0 }
          <Normal> { -0.57735 0.57735 -0.57735 }
        }
        <Vertex> 31 {
          -4 4 -4
          <UV> { 0 0 }
          <Normal> { -0.57735 0.57735 -0.57735 }
        }
        <Vertex> 32 {
          -4 4 -4
          <UV> { 0 0 }
          <Normal> { -0.57735 0.57735 -0.57735 }
        }
        <Vertex> 33 {
          -4 4 4
          <UV> { 1 0 }
          <Normal> { -0.57735 0.57735 0.57735 }
        }
        <Vertex> 34 {
          -4 4 4
          <UV> { 0 1 }
          <Normal> { -0.57735 0.57735 0.57735 }
        }
        <Vertex> 35 {
          -4 4 4
          <UV> { 0 0 }
          <Normal> { -0.57735 0.57735 0.57735 }
        }
        <Vertex> 36 {
          4 -4 -4
          <UV> { 0 1 }
          <Normal> { 0.57735 -0.57735 -0.57735 }
        }
        <Vertex> 37 {
          4 -4 -4
          <UV> { 1 1 }
          <Normal> { 0.57735 -0.57735 -0.57735 }
        }
        <Vertex> 38 {
          4 -4 -4
          <UV> { 1 1 }
          <Normal> { 0.57735 -0.57735 -0.57735 }
        }
        <Vertex> 39 {
          4 -4 4
          <UV> { 1 0 }
          <Normal> { 0.57735 -0.57735 0.57735 }
        }
        <Vertex> 40 {
          4 -4 4
          <UV> { 0 1 }
          <Normal> { 0.57735 -0.57735 0.57735 }
        }
        <Vertex> 41 {
          4 -4 4
          <UV> { 1 1 }
          <Normal> { 0.57735 -0.57735 0.57735 }
        }
        <Vertex> 42 {
          4 4 -4
          <UV> { 0 0 }
          <Normal> { 0.57735 0.57735 -0.57735 }
        }
        <Vertex> 43 {
          4 4 -4
          <UV> { 1 0 }
          <Normal> { 0.57735 0.57735 -0.57735 }
        }
        <Vertex> 44 {
          4 4 -4
          <UV> { 1 0 }
          <Normal> { 0.57735 0.57735 -0.57735 }
        }
        <Vertex> 45 {
          4 4 4
          <UV> { 0 0 }
          <Normal> { 0.57735 0.57735 0.57735 }
        }
        <Vertex> 46 {
          4 4 4
          <UV> { 1 1 }
          <Normal> { 0.57735 0.57735 0.57735 }
        }
        <Vertex> 47 {
          4 4 4
          <UV> { 1 0 }
          <Normal> { 0.57735 0.57735 0.57735 }
        }
      }
      <Polygon> {
        <RGBA> { 0.7 0.7 0.7 1 }
        <TRef> { tref1 }
        <MRef> { mref1 }
        <VertexRef> { 36 42 30 24 <Ref> { cube_obj } }
      }
      <Polygon> {
        <RGBA> { 0.7 0.7 0.7 1 }
        <TRef> { tref1 }
        <MRef> { mref1 }
        <VertexRef> { 27 39 37 25 <Ref> { cube_obj } }
      }
      <Polygon> {
        <RGBA> { 0.7 0.7 0.7 1 }
        <TRef> { tref1 }
        <MRef> { mref1 }
        <VertexRef> { 31 33 28 26 <Ref> { cube_obj } }
      }
      <Polygon> {
        <RGBA> { 0.7 0.7 0.7 1 }
        <TRef> { tref1 }
        <MRef> { mref1 }
        <VertexRef> { 40 45 43 38 <Ref> { cube_obj } }
      }
      <Polygon> {
        <RGBA> { 0.7 0.7 0.7 1 }
        <TRef> { tref1 }
        <MRef> { mref1 }
        <VertexRef> { 44 46 34 32 <Ref> { cube_obj } }
      }
      <Polygon> {
        <RGBA> { 0.7 0.7 0.7 1 }
        <TRef> { tref1 }
        <MRef> { mref1 }
        <VertexRef> { 35 47 41 29 <Ref> { cube_obj } }
      }
    }
  }
}

you can remove vertices 0-23 with no effect from the egg file. these are unreferenced by any polygons.

i yanked them out and it loaded just fine.

every exporter seems to have a unique way of doing things.

Yeah, I was thinking with the first 24 vertices being unreferenced I could remove them without any problem. Thanks for clarifying though!

You can remove them, but there’s no need to do so. The egg loader will ignore them automatically.

David