Search in sources :

Example 91 with Node

use of com.jme3.scene.Node 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);
}
Also used : Node(com.jme3.scene.Node)

Example 92 with Node

use of com.jme3.scene.Node 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();
    }
}
Also used : PhysicsCharacter(com.jme3.bullet.objects.PhysicsCharacter) Spatial(com.jme3.scene.Spatial) Node(com.jme3.scene.Node) HashMap(java.util.HashMap) Map(java.util.Map)

Example 93 with Node

use of com.jme3.scene.Node in project jmonkeyengine by jMonkeyEngine.

the class BulletGhostObjectDebugControl method controlUpdate.

@Override
protected void controlUpdate(float tpf) {
    if (myShape != body.getCollisionShape()) {
        Node node = (Node) this.spatial;
        node.detachChild(geom);
        geom = DebugShapeFactory.getDebugShape(body.getCollisionShape());
        geom.setMaterial(debugAppState.DEBUG_YELLOW);
        node.attachChild(geom);
    }
    applyPhysicsTransform(body.getPhysicsLocation(location), body.getPhysicsRotation(rotation));
    geom.setLocalScale(body.getCollisionShape().getScale());
}
Also used : Node(com.jme3.scene.Node)

Example 94 with Node

use of com.jme3.scene.Node 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);
}
Also used : Node(com.jme3.scene.Node)

Example 95 with Node

use of com.jme3.scene.Node in project jmonkeyengine by jMonkeyEngine.

the class BulletJointDebugControl method setSpatial.

@Override
public void setSpatial(Spatial spatial) {
    if (spatial != null && spatial instanceof Node) {
        Node node = (Node) spatial;
        node.attachChild(geomA);
        node.attachChild(geomB);
    } else if (spatial == null && this.spatial != null) {
        Node node = (Node) this.spatial;
        node.detachChild(geomA);
        node.detachChild(geomB);
    }
    super.setSpatial(spatial);
}
Also used : Node(com.jme3.scene.Node)

Aggregations

Node (com.jme3.scene.Node)135 Vector3f (com.jme3.math.Vector3f)81 Geometry (com.jme3.scene.Geometry)64 Spatial (com.jme3.scene.Spatial)53 Material (com.jme3.material.Material)51 DirectionalLight (com.jme3.light.DirectionalLight)35 Quaternion (com.jme3.math.Quaternion)32 RigidBodyControl (com.jme3.bullet.control.RigidBodyControl)26 Box (com.jme3.scene.shape.Box)24 Sphere (com.jme3.scene.shape.Sphere)19 AmbientLight (com.jme3.light.AmbientLight)17 BulletAppState (com.jme3.bullet.BulletAppState)16 ColorRGBA (com.jme3.math.ColorRGBA)15 AnimControl (com.jme3.animation.AnimControl)14 KeyTrigger (com.jme3.input.controls.KeyTrigger)14 FilterPostProcessor (com.jme3.post.FilterPostProcessor)14 HashMap (java.util.HashMap)14 CameraNode (com.jme3.scene.CameraNode)13 ArrayList (java.util.ArrayList)13 ActionListener (com.jme3.input.controls.ActionListener)12