Okay, so I’m working on a better version of the code I posted for creating a mesh from a heightmap, I need some code that I can seriously use to create a third-person game for my research.
I have a question that relates to Panda’s rendering internals.
What I thought was a major issue in the posted code was that it simply translated the entire height map, regardless of its size, to one big mesh. All of the vertices were packed into a single GeomVertexData, all the rendering primitives belonged to a single GeomTriangles, and there was a single Geom and a single GeomNode and a single NodePath for the whole thing.
In the posted code the entire mesh is displayed on-screen at once. In the new code, I want to scale it up to be a large section of terrain which an Actor could walk around on, so it will not all be on-screen at one time.
So it seems obvious that at some point the data from the heightmap must be split up into different ‘cells’, but my question is, at what point in the mesh creation should this happen?
Will it be most efficient to split it up first thing, so that multiple GeomVertexData’s and corresponding multiple everything else are created? Or should I split it up later, creating just one GeomVertexData but multiple GeomPrimitive’s?
I guess there must be some size limit on a GeomVertexData, but should I go right up to this limit or have many much smaller GeomVertexData representing ‘cells’ of the terrain?
This page (http://panda3d.org/manual/index.php/Creating_Geometry_from_Scratch) in the manual certainly suggests that I would want multiple GeomPrimitive’s representing ‘cells’ of the terrain for efficient culling (exactly how big each cell should be is a different question), because I don’t want parts of the terrain that are far away and not on-screen to be rendered, but it doesn’t clarify whether they should all share one GeomVertexData or should have one each.
Aside from the GeomVertexData question, I think what the manual suggests is that every cell of the terrain should have its own GeomPrimitive and (for fast culling) its own GeomNode (and therefore its own Geom and NodePath as well), which seems to suggest that culling in Panda3D occurs at the GeomNode level. After that, all the NodePaths could be attached to a single dummy node allowing them to be manipulated at once.