SharedNode aren't rendered

I've try to follow the TestSharedNode example, but uf I use SharedNode instead a Node the model isn't rendered. why?

I want make sure i load a model only one time and then reuse it, here the working code, with the "right" instruction (what i want do) commented. please help!!


public static Node loadModelXML(String name){
      
      Node loadedNode=null;// = loadedModel.get(name);
      
      if (loadedNode == null){
         
         URL f = null;
         try {
            f = new URL("file:"+name);
         } catch (MalformedURLException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
         }
         System.out.println("loading: "+name+" "+f);
         try {
            loadedNode=(Node) xmlImporter.load( f );
            loadedNode.setLocalScale(0.5f); //to box2d scale
            loadedNode.setName(name);
            loadedNode.setLocalTranslation(0, 0, 0);
            loadedNode.setModelBound( new BoundingBox() );
            loadedNode.updateModelBound();
            loadedModel.put(name, loadedNode);
            
         } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
         } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
         }
         
         
      }
      //SharedNode shaNode = new SharedNode(name+" model:"+i, loadedNode);

      return loadedNode;//new SharedNode("Shared1", loadedNode);
   }

I think you have to keep a reference to the original node because otherwise it will get garbage collected, also did you updateRenderstate() your rootNode after attaching?

with the instuction

loadedModel.put(name, loadedNode);


I put the loaded Node in an HashMap, so I load the xml file only one time and then use a shared node for every object that try to load it... so 1 load for X objects :) ah ant becouse the Node is in an hashmap it will not be garbage

And i'm doung updateRenderstate() and updateGeometricState(...) at the end of every gamestate update, I'm also calling the method every time I change an object or create it but nothing appear...

here the actual class loader code:

public class ModelLoaderXML {
   static XMLImporter xmlImporter = XMLImporter.getInstance();
   
   static HashMap<String, Node> loadedModel = new HashMap<String, Node>();
   
   static int i=0;
   
   public static Node loadModelXML(String name){
      
      Node loadedNode=loadedModel.get(name);
      
      if (loadedNode == null){
         
         URL f = null;
         try {
            f = new URL("file:"+name);
         } catch (MalformedURLException e1) {
            // TODO Auto-generated catch block
            e1.printStackTrace();
         }
         System.out.println("loading: "+name+" "+f);
         try {
            loadedNode=(Node) xmlImporter.load( f );
            loadedNode.setLocalScale(0.5f); //to box2d scale
            loadedNode.setName(name);
            loadedNode.setLocalTranslation(0, 0, 0);
            loadedNode.setModelBound( new BoundingBox() );
            loadedNode.updateModelBound();
            loadedNode.updateRenderState();
            loadedModel.put(name, loadedNode);
            
         } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
         } catch (Exception e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
         }
         
         
      }
      SharedNode shaNode = new SharedNode(name+" model:"+i, loadedNode);

      return shaNode;
   }
}

ahah i've got news: now SharedNode works only for some model of …

Seems that the problem is quadmesh (here two example, but i've got many…)

astronave 2.xml works, astronave-higres.xml doesn't. Maybe a bug?

up, there no way to make quadmesh work on sharednode?? :?

Is quadmesh a mesh consiting out of quads?



In this case I think easyest is to save it as a trimesh or convert it while loading (1quad = 2 tris)

how can i translate a quadmesh in a trimesh (sorry my math is very basic)

It would probably be easiest to do it inside your 3D content creation tool, eg. MAX or Blender or whatever you're using.