use of com.jme3.scene.Spatial in project jmonkeyengine by jMonkeyEngine.
the class RagdollUtils method buildPointMap.
public static Map<Integer, List<Float>> buildPointMap(Spatial model) {
Map<Integer, List<Float>> map = new HashMap<Integer, List<Float>>();
if (model instanceof Geometry) {
Geometry g = (Geometry) model;
buildPointMapForMesh(g.getMesh(), map);
} else if (model instanceof Node) {
Node node = (Node) model;
for (Spatial s : node.getChildren()) {
if (s instanceof Geometry) {
Geometry g = (Geometry) s;
buildPointMapForMesh(g.getMesh(), map);
}
}
}
return map;
}
use of com.jme3.scene.Spatial in project jmonkeyengine by jMonkeyEngine.
the class AbstractPhysicsDebugControl method applyPhysicsTransform.
protected void applyPhysicsTransform(Vector3f worldLocation, Quaternion worldRotation, Spatial spatial) {
if (spatial != null) {
Vector3f localLocation = spatial.getLocalTranslation();
Quaternion localRotationQuat = spatial.getLocalRotation();
if (spatial.getParent() != null) {
localLocation.set(worldLocation).subtractLocal(spatial.getParent().getWorldTranslation());
localLocation.divideLocal(spatial.getParent().getWorldScale());
tmp_inverseWorldRotation.set(spatial.getParent().getWorldRotation()).inverseLocal().multLocal(localLocation);
localRotationQuat.set(worldRotation);
tmp_inverseWorldRotation.set(spatial.getParent().getWorldRotation()).inverseLocal().mult(localRotationQuat, localRotationQuat);
spatial.setLocalTranslation(localLocation);
spatial.setLocalRotation(localRotationQuat);
} else {
spatial.setLocalTranslation(worldLocation);
spatial.setLocalRotation(worldRotation);
}
}
}
use of com.jme3.scene.Spatial in project jmonkeyengine by jMonkeyEngine.
the class BulletCharacterDebugControl method setSpatial.
@Override
public void setSpatial(Spatial spatial) {
if (spatial != null && spatial instanceof Node) {
Node node = (Node) spatial;
node.attachChild(geom);
} else if (spatial == null && this.spatial != null) {
Node node = (Node) this.spatial;
node.detachChild(geom);
}
super.setSpatial(spatial);
}
use of com.jme3.scene.Spatial in project jmonkeyengine by jMonkeyEngine.
the class BulletDebugAppState method updateCharacters.
private void updateCharacters() {
HashMap<PhysicsCharacter, Spatial> oldObjects = characters;
characters = new HashMap<PhysicsCharacter, Spatial>();
Collection<PhysicsCharacter> current = space.getCharacterList();
//create new map
for (Iterator<PhysicsCharacter> it = current.iterator(); it.hasNext(); ) {
PhysicsCharacter physicsObject = it.next();
//copy existing spatials
if (oldObjects.containsKey(physicsObject)) {
Spatial spat = oldObjects.get(physicsObject);
characters.put(physicsObject, spat);
oldObjects.remove(physicsObject);
} else {
if (filter == null || filter.displayObject(physicsObject)) {
logger.log(Level.FINE, "Create new debug Character");
//create new spatial
Node node = new Node(physicsObject.toString());
node.addControl(new BulletCharacterDebugControl(this, physicsObject));
characters.put(physicsObject, node);
physicsDebugRootNode.attachChild(node);
}
}
}
//remove leftover spatials
for (Map.Entry<PhysicsCharacter, Spatial> entry : oldObjects.entrySet()) {
PhysicsCharacter object = entry.getKey();
Spatial spatial = entry.getValue();
spatial.removeFromParent();
}
}
use of com.jme3.scene.Spatial in project jmonkeyengine by jMonkeyEngine.
the class BulletGhostObjectDebugControl method setSpatial.
@Override
public void setSpatial(Spatial spatial) {
if (spatial != null && spatial instanceof Node) {
Node node = (Node) spatial;
node.attachChild(geom);
} else if (spatial == null && this.spatial != null) {
Node node = (Node) this.spatial;
node.detachChild(geom);
}
super.setSpatial(spatial);
}
Aggregations