Creating EggData from GeomPrimitive


We generate a heightfield in panda with GeomTriangles, so that we can access the VertexData to change the Vertices z position (if we want to flatten the heightfield for an exemple).

Our problem is that we have to compute the normal by hand…but we saw that EggDatas (and Egg library in general) do that, and other features.

SO the question is : how can we create an EggData from a GeomPrimitive?

Thanks a lot

I’m sure you have seen this by now but … just in case … … b0bf2e27b8

Yeah we’ve seen this thanks.

In fact we’re looking for information about the way to create the EggData with vertex coming from a VertexData. This post doesn’t explain that…

I don’t know if there is a API command that converts from a GeomVertexData to EggData in a single call.

But you can always do it by hand:

  • create an empty EggData and EggVertexPool
  • loop over your GeomVertexData and create and EggVertex for each vertex
  • loop over your GeomPrimitive and create and EggPolygon for each triangle

If you modify e.g. a terrain during runtime (maybe a crater from a bomb explosion), then you are probably better off if you compute the normals by hand, since you only have to re-compute them in a small affected area.


we try to do this, but whit our 4.000.000 vertices the time to compute is too long, we try to found another way

Are we talking about 4.000.000 vertices that all have to be modified at runtime, that is between two frames?

If you compute the normals yourself (without the EggLib) you’ll be able, for example, to recompute only the updated vertices if the mesh is modified at runtime.
It’s only a sum of cross products normalized.