Hi there,
i`m loading spatials via:
[java]
Spatial flashlight = assetManager.loadModel(“Models/flashlight/flashlight3.j3o”);
[/java]
Now i attach them to the rootNode and try to shoot them. I use this code for shooting inside the onAction-Method of the ActionListener-Class:
[java]
CollisionResults results = new CollisionResults();
Ray ray = new Ray(cam.getLocation(), cam.getDirection());
rootNode.collideWith(ray, results);
for (int i = 0; i < results.size(); i++) {
CollisionResult colRes = results.getCollision(i);
String hit = colRes.getGeometry().getName();
float distance = colRes.getDistance();
System.out.println(hit);
break;
}
[/java]
Works fine so far! The Problem is that the spatial`s name (variable: hit) is “flashlight”. When i try to set the name of the spatial during import with “flashlight.setName(“SHOOTABLE_Flashlight”);” it has no effect. And when i cast it to Node and check all names of the Node-children, there is no child with the name “flashlight”.
Now the question: How can i set a Geometry name during asset import so i can see this name when i shoot it?
I need some kind of mapping here because some loaded spatials are wrapped by another class. This classes contain the spatial itself and some other information about this spatial. I want the name to map it to the class these geometry belongs to.
Thanks!