Adding Modeled Geometry to Procedural Geomerty

I’m building an applet that will allow me to create a race track model from a line drawing. I’ve gotten to the point where I’m building the track geometry, and I’m confident that I can handle it.

The part that concerns me is what comes next: adding additional details along the track. Things like a gate around the finish line, and posts along the edge. I have ways to locate the positions and rotations for these things, but if I simply add them as their own models and position/rotate them, I’ll be sending a large number of low poly (100-200 tris) model nodes to the GPU. Potentially hundreds. I’m not worried about the number of polygons, but I recall that Panda3D starts to get serious graphics lag when there are large numbers of model nodes.

The solution, as far as I know, is to embed all of the track detail models into a single egg, as if I had made them all in place in a modeling program. I’m wondering if anyone has any advice to accomplish this. If I re-create the modeled details in code I could offset the vertices to position them, but I think rotation would require some matrix math or something. That is not my forte.

My other thought is maybe I can load up one of the detail models, position and rotate it at each point where I want one, and then get the vertex info from that model and duplicate it into an egg, thus creating an egg that contains all of the details in a single geom. I don’t know if it’s possible to get the info I would need from the model, though.

Any thoughts?

You don’t need to load all the pieces from a single egg file. Simply arrange the individual pieces as you like, then call root.flattenStrong() on the parent node of the whole scene. If there are individual pieces that came from their own egg files, you might also need to call root.clearModelNodes() first to make the flattenStrong() more effective.