I have a object with two childs inside
physic
model
Loading works fine.
Now I want to add both of them seperate textures.
My problem is, that I cant get the children.
Node mesh; (<-- Model loaded inside)
System.out.println(this.getName()); --> "Mesh"
System.out.println(this.getChild(0).getName()); --> "TDS Scene" !!!
System.out.println(this.getChild(1).getName()); --> ERROR, java.lang.IndexOutOfBoundsException
WHERE THE HELL ARE MY CHILDREN!!! I MISS THEM! I SWEAR!
Hope somebody can help me! Thanks
I found the problem
attachChild removes the Child from the node :-o
It's clear why, but I haven't thought about this simple solution.
private void cleanNode(String name){
Node buffer = (Node) this.getChild(name);
for(Spatial s : buffer.getChildren()) {
System.out.println(buffer.getChild(0));
this.attachChild(buffer.getChild(0));
}
this.detachChildNamed(name);
}
Thanks for everything!
What is the type of child 0?
Should be Node
CODE:
loaded_model = (Node) BinaryImporter.getInstance().load(new ByteArrayInputStream(BO.toByteArray()));
this.attachChild(loaded_model);
info:
this = Node mesh
basixs, master of the un-seen; has this vision…
you are using 3DS models
your chilun are under the "TDS Scene" node
they are lonely and scared…
basics, master of the un-seen, has the VISION!!!
You are right. They are really scared… :evil:
Should work with this, right?
this.getChildByName("TDS Scene").getChild(0).getName; ?
Is their a good solution, where you can print every children inside the node?
mesh-model
-physic
-TDS Scene-childs…
Just list the children with a simple method like the one below. It should show you what is attached and where:
public static void printNodeChildren(Node n) {
if(n == null) {System.err.println("printNodeChildren: Node provided was null."); return;}
System.out.println("********** Child list begins for node " + n.getName() + " **********");
for(Spatial s : n.getChildren()) {
System.out.println(s);
if(s instanceof Node) printNodeChildren((Node)s);
}
System.out.println("********** Node child list ends (" + n.getName() + ") **********");
}
Thanks, your methode is working!
Another problem
I wrote a methode to remove TDS Scene
private void cleanNode(String name){
Node buffer = (Node) this.getChild(name);
for(Spatial s : buffer.getChildren()) {
System.out.println(s);
this.attachChild(s);
}
this.detachChildNamed(name);
}
My methode only attach the first element (physic);
If I remove
this.attachChild(s);
it's working!
DarkPhoenixX said:
Should work with this, right?
this.getChildByName("TDS Scene").getChild(0).getName; ?
Is their a good solution, where you can print every children inside the node?
-physic
-TDS Scene-childs.....
http://www.jmonkeyengine.com/wiki/doku.php?id=code_snippets_-_jme_2
try this one, kinda helps at debugging.
I think Empire Phoenix meant to link this: http://www.jmonkeyengine.com/wiki/doku.php?id=scene_monitor
Yes and no,
For this i meant only the Scenemonitor,
But the other tools can help for different things too, so it's usefull to have the link to the side with all of them XD
also there is another quite similar tool, wich I nver used myself, but non the less it should be given a cance i guess.