0

Im working with the jMonkeySDK on a 3D java game at the moment. I really need to know how I can get the mesh from my spatial (3D model). Does anyone have experience with this engine and knows how I can have access to the mesh?

I searched in the documentation and read a lot of tutorials. But I dont find a way. Hope someone can help me

Richard Tingle
  • 16,906
  • 5
  • 52
  • 77
Dawesign
  • 643
  • 1
  • 7
  • 25
  • Hmm, is the spatial castable to Geometry (some spatials are), if so it's easy from that point – Richard Tingle Nov 28 '13 at 15:51
  • Ehm, I dont know... I found this http://hub.jmonkeyengine.org/forum/topic/cast-spatial-to-geometry/ But I dont know really what the actual fix there was...? – Dawesign Nov 28 '13 at 15:59
  • within your code, where you've got your spatial as `spatial` type `System.out.println("Is castable:" + spatial instanceof Geometry);` and that will give you your answer – Richard Tingle Nov 28 '13 at 16:03
  • The reason it might not be castable is because a spacial can be either a geometry (woo!) or a node (boo!) that may have several geometrys connected to it (woo?) – Richard Tingle Nov 28 '13 at 16:07

1 Answers1

0

Models inside jME3 are stored as Spatials, with Spatials mostly being either a Node or a Geometry.

Nodes just contain other Spatials (but can transform their position, rotation, etc) while Geometries just contain Meshes and the Materials and other information associated with the Mesh.

The easiest way to do this is to open the model in the SDK and use the Scene Explorer window to view the layout of Nodes and Meshes. You can then determine what you need to do, as often you need to drill down through a few Nodes, find the Geometry you are interested in, and then get the Mesh from that Geometry.

Alternatively programmatically you can just recurse down through the Node structure, iterating over each child. If the child is a Node then scan that too, if it is a Geometry then get the Mesh.

Tim B
  • 40,716
  • 16
  • 83
  • 128