How to make a copy of a Mesh?

Hi!



I've a model loaded from collada and I need to have a copy of this model - I need to change all nodes of type TriMesh to my custom TriMesh inheritor class.



When I just copied vertexes, normals colors and texrure coordinates - the copy of model seems like texture-less.



What should I do to get textures there?



Thanks.

You should also copy the renderstates (e.g. in this case the TextureState), that holds the textures used by the mesh.

Thanks! That works.



But now my model is highlighted just from one side  :?

Are there any other states that I should copy?



Here is the code I use:


      copy.setRenderState(aTriMesh.getRenderState(StateType.Texture));
      copy.setRenderState(aTriMesh.getRenderState(StateType.Cull));
      copy.setRenderState(aTriMesh.getRenderState(StateType.Shade));
      copy.setRenderState(aTriMesh.getRenderState(StateType.Material));
      copy.setRenderState(aTriMesh.getRenderState(StateType.ZBuffer));
      copy.setRenderState(aTriMesh.getRenderState(StateType.Light));


Try this (copied from SharedNode):


    private void copyNode(Node original, Node copy) {
        copy.setName(original.getName());
        copy.setCullHint(original.getLocalCullHint());
        copy.setLightCombineMode(original.getLocalLightCombineMode());
        copy.getLocalRotation().set(original.getLocalRotation());
        copy.getLocalScale().set(original.getLocalScale());
        copy.getLocalTranslation().set(original.getLocalTranslation());
        copy.setRenderQueueMode(original.getLocalRenderQueueMode());
        copy.setTextureCombineMode(original.getLocalTextureCombineMode());
        copy.setZOrder(original.getZOrder());
       
       
        for (RenderState.StateType type : RenderState.StateType.values()) {
            RenderState state = original.getRenderState( type );
            if (state != null) {
                copy.setRenderState(state );
            }
        }
    }