Copy an object (node), that i dont have to load model again

Hi,

I would like to insert some models in front of my car in a random distance, that works fine, but now I want to use a class that imports my model and it doesn't work anymore.



My Question is, how can I copy an Node an set it up somwhere else…so that I do not have to load that model again … 50 times.





:slight_smile:



I tried it this way:

     

 Geometry geo = (Geometry)strassenSperre.getChild(0);

      Geometry geo2 = clone(geo);

      geo2.setLocalTranslation(new Vector3f(rnd2, 0, -rnd-50));

      b.attachChild(geo2);

      rootNode.attachChild(b);





and this way


      Node strassenSperre2 = clone(strassenSperre);
      strassenSperre2.setLocalTranslation(new Vector3f(rnd2+10, 0, -rnd-100));
      b.attachChild(strassenSperre2);
      rootNode.attachChild(b);



But I get NullPointerException all the time...

The clone() method on a Spatial or a Node object seems to be what you are looking for

I am new to JME, could you explain that further?



I clicked at cloneNode in eclipse… i got it as a tooltip opened…