Attach one node multiple times

Hello there,

I have probably a very simple question concerning attaching a single node many times.

Therefore I load an obj-model and convert it into a node (houseL). This node i would like to spread many times on my landscape. Here I have the code for the house-spreading:



     

   for(int i=0;i<s;i++){

             for(int j=0;j<s;j++){

                if(hm2d[i][j]==h){                   

                    

                      houseL.setLocalTranslation(j, h*0.05f, i);

                      houseL.setModelBound(new BoundingSphere());

                      houseL.updateModelBound();

                      lsn.attachChild(houseL);

                }

             }





Thank you for helping!

Richard

Take a look at com.jme.scene.SharedNode and com.jme.scene.SharedMesh.  This allows you to duplicate the same mesh multiple times without having multiple copies in memory.  Be sure to not use the original TriMesh or Node outside the shared instances.