Hierarchy of Objects in JME

Hi all… I'd like to know / see a hierarchy chart of the objects in JME(e.g. Spatials, Geometry, Node, TriMesh)… so I could know whether to cast something with something or not… because my problem is that, I'm getting the ClassCastException for casting ColladaImporter.getModel()'s return (which is a Node) into a Geometry… it is because I would need it to become a geometry for later mousePicking via the getTargetMesh() function which returns only geometries… here's my stacktrace…


Exception in thread "AWT-EventQueue-0" java.lang.ClassCastException: com.jme.scene.Node cannot be cast to com.jme.scene.TriMesh
   at terrainModeling.TerrainModeler.addObject(TerrainModeler.java:1287)
   at terrainModeling.addObjectDialog$2.actionPerformed(addObjectDialog.java:180)
   at javax.swing.AbstractButton.fireActionPerformed(Unknown Source)
   at javax.swing.AbstractButton$Handler.actionPerformed(Unknown Source)
   at javax.swing.DefaultButtonModel.fireActionPerformed(Unknown Source)
   at javax.swing.DefaultButtonModel.setPressed(Unknown Source)
   at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(Unknown Source)
   at java.awt.Component.processMouseEvent(Unknown Source)
   at javax.swing.JComponent.processMouseEvent(Unknown Source)
   at java.awt.Component.processEvent(Unknown Source)
   at java.awt.Container.processEvent(Unknown Source)
   at java.awt.Component.dispatchEventImpl(Unknown Source)
   at java.awt.Container.dispatchEventImpl(Unknown Source)
   at java.awt.Component.dispatchEvent(Unknown Source)
   at java.awt.LightweightDispatcher.retargetMouseEvent(Unknown Source)
   at java.awt.LightweightDispatcher.processMouseEvent(Unknown Source)
   at java.awt.LightweightDispatcher.dispatchEvent(Unknown Source)
   at java.awt.Container.dispatchEventImpl(Unknown Source)
   at java.awt.Window.dispatchEventImpl(Unknown Source)
   at java.awt.Component.dispatchEvent(Unknown Source)
   at java.awt.EventQueue.dispatchEvent(Unknown Source)
   at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
   at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
   at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
   at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
   at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
   at java.awt.EventDispatchThread.run(Unknown Source)



thanks in advance for any help

LOL… you two are both speedy… thanks for all the help sbook… btw congrats to normen… Long Live JME!!!

The javadoc contains this info http://www.jmonkeyengine.com/doc/

Notice the inheritance tree and “Direct Known Subclasses:” info at the top of each classes javadoc file.

Spatial is the base class for scenegraph objects.

ColladaImporter.getModel() returns a Node, which is a subclass of a Spatial.  TriMesh also subclasses a Spatial.



For mousepicking, you can simply use:



Spatial s = results.getPickData(0).getTargetMesh();
while(!s instanceof Node){
     s = s.getParent();
}



Clearly that could be done with a recursive function but this seemed simpler to explain :)  When you come out of the while loop, you should have the Node that was given to you by the ColladaImporter.getModel(); method (That's assuming that you've combined your meshes in your modeling application before exporting the COLLADA file)

EDIT:  normen... he's speedy!

:smiley: I just have to press "Apple-2" to see "All Recent Posts" and I do so each time I have my browser open and my brain is idling :wink:

mhelz0001 said:

LOL... you two are both speedy.... thanks for all the help sbook.... btw congrats to normen... Long Live JME!!!


I haven't forgotten your other COLLADA thread either, I have to do some Maya tinkering a little bit later so I'll take a look at the models and load them then :)