Using node ID

Hello, is secure use Node.getChildIndex(Spatial sp)? If for every node i put in the root node i ask for it's ID and then use this ID to remove/find the node in the rootNode is it secure? or jme will change the id's on the run?

And why public int attachChild(Spatial child) return the number of nodes and not the id of the inserted node?

thank for reply

Hello lesto,



The method getChildIndex() on the Node class will return you the index of the Spatial in the List of the Node's children.



Is it secure? Well that really depends on how you're intending to use it. Personally I'd avoid using it as it's only a location in a list, so it's not really an identifier (if you are interested in the List class, check the out Sun Javadoc on it).



attachChild(Spatial child) returns the size of the list, and the Spatial you have just attached as a child is put onto the end of the list, which is the value returned.