jmoneky get geometry from spatil
public Geometry getMyGeometry(Spatial spatial){
//System.out.println("getMyGeometry()");
Node node = (Node)spatial;
Geometry g = null;
final List<Spatial> ants = new LinkedList<Spatial>();
//node.breadthFirstTraversal(new SceneGraphVisitor() {
node.depthFirstTraversal(new SceneGraphVisitor() {
@Override
public void visit(Spatial spatial) {
//System.out.println("visit class is " + spatial.getClass().getName());
//System.out.println("visit spatial is " + spatial);
if (spatial.getClass().getName().equals("com.jme3.scene.Geometry")) {
ants.add(spatial);
}
}
});
if (!ants.isEmpty()) {
//redundant - borrowed from Quixote TerrainTrackControl
for (int i = 0;i < ants.size();i++){
if (ants.get(i).getClass().getName().equals("com.jme3.scene.Geometry")){
g = (Geometry)ants.get(i);
//System.out.println("g (" + i + "/" + (ants.size() - 1) + ")=" + g);
return(g);
}
}
}
else
{
System.out.println("getMyGeometry()-Geometry not found");
}
return(g);
}
Комментарии
Отправить комментарий