Generate mesh from scene graph

Hello :slight_smile:

Today I was facing a crazy problem: the representation of a model (exported from blender 2.59 to .x, then used x2egg) and how it was interacting with ODE was different. I eventually found that the problem is that, when exporting, Blender exports the scenegraph nicely using the egg tag to indicate position, size, and rotation of objects. However, this information was not affecting how the model was being converted into an “OdeTriMeshData”. Also, I checked that changing the scale with “setScale” in the node prior passing it to the odeTriMeshData constructor did not affect it.

A hackish solution is to export the model to .obj, load it into Wings3d, then export it to .x, then to .egg, and Wings3d seems to erase the transform information applying the transform it to the actual geometry.

However, that makes our working pipeline too slow and hase some nasty side-effects on materials and normals. Also, playing with the scale of objects on the code is very nice, and being unable to scale the physics geometry on the code is a show stoper.

Thus, I may ask, is there a way for Panda3D to “erase transforms” generating a single mesh out of a scene graph?

Thanks a lot :slight_smile:

root.flattenLight() will apply all transforms at root and below onto the vertices, removing them from nodes.

If you actually want to further reduce it to a single mesh, you can use root.flattenStrong() to apply transforms as above, and then combine meshes together. But it doesn’t sound like this is really what you want.

David

That’s a fast and accurate response! Worked great, thanks!