How to get TriMesh from Node (ModelLoader)

Iam using ModelLoader to load models but the problem is that is returns Node instead of TriMesh. How do I access the underlaying TriMesh?

I want to create Shared meshes to save memory and avoid long loading times.

Additionally I notived that objects seems not to be culled, they are rendered inside AND outside. How can I fix this?

I tried calling node.setCullMode(Node.CULL_DYNAMIC); but then the object was gone :frowning:

simply do a recursive call.

something like this

private TriMesh getMesh(Node node) {
   if(node.getChild(0) instanceof TriMesh) return (TriMesh)node.getChild(0);
   else getMesh((Node)node.getChild(0));

this is just a simple example, i wrote it here, so no testing at all, but it should guide u on the right path.

Thanks that does it. Iam wondering why Modelloader returns a Node in the first place???

I also got backface culling working, it seems it is not enabled by default:

        CullState cullState = DisplaySystem.getDisplaySystem().getRenderer().createCullState();




it is not enabled by default coz in alot of cases u actually wont want that.

glad i cloud help

ModelLoader returns a node because your object may contain more than a single mesh. Some loads may create a node at the top of the scene graph even though there's only a single mesh.

For CULL_DYNAMIC to work, you need to make sure your object has a bounding volume:

mesh.setModelBound(new BoundingSphere());

I need do this, i can

You can use SharedNode to do the same thing with nodes. You can only join two meshes if they have the same material settings, but that part should be done on the modeling stage, not in the application…