Search in sources :

Example 96 with Node

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

the class BulletRigidBodyDebugControl 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());
        node.attachChild(geom);
    }
    if (body.isActive()) {
        geom.setMaterial(debugAppState.DEBUG_MAGENTA);
    } else {
        geom.setMaterial(debugAppState.DEBUG_BLUE);
    }
    applyPhysicsTransform(body.getPhysicsLocation(location), body.getPhysicsRotation(rotation));
    geom.setLocalScale(body.getCollisionShape().getScale());
}
Also used : Node(com.jme3.scene.Node)

Example 97 with Node

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

the class BulletRigidBodyDebugControl 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 98 with Node

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

the class BulletVehicleDebugControl method setSpatial.

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

Example 99 with Node

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

the class ShaderNodeDefinitionLoader method load.

@Override
public Object load(AssetInfo assetInfo) throws IOException {
    AssetKey k = assetInfo.getKey();
    if (!(k instanceof ShaderNodeDefinitionKey)) {
        throw new IOException("ShaderNodeDefinition file must be loaded via ShaderNodeDefinitionKey");
    }
    ShaderNodeDefinitionKey key = (ShaderNodeDefinitionKey) k;
    loaderDelegate = new ShaderNodeLoaderDelegate();
    InputStream in = assetInfo.openStream();
    List<Statement> roots = BlockLanguageParser.parse(in);
    if (roots.size() == 2) {
        Statement exception = roots.get(0);
        String line = exception.getLine();
        if (line.startsWith("Exception")) {
            throw new AssetLoadException(line.substring("Exception ".length()));
        } else {
            throw new MatParseException("In multiroot shader node definition, expected first statement to be 'Exception'", exception);
        }
    } else if (roots.size() != 1) {
        throw new MatParseException("Too many roots in J3SN file", roots.get(0));
    }
    return loaderDelegate.readNodesDefinitions(roots.get(0).getContents(), key);
}
Also used : AssetKey(com.jme3.asset.AssetKey) ShaderNodeDefinitionKey(com.jme3.asset.ShaderNodeDefinitionKey) InputStream(java.io.InputStream) Statement(com.jme3.util.blockparser.Statement) IOException(java.io.IOException) AssetLoadException(com.jme3.asset.AssetLoadException)

Example 100 with Node

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

the class TerrainTestAdvanced method createAxisMarker.

protected Node createAxisMarker(float arrowSize) {
    Material redMat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    redMat.getAdditionalRenderState().setWireframe(true);
    redMat.setColor("Color", ColorRGBA.Red);
    Material greenMat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    greenMat.getAdditionalRenderState().setWireframe(true);
    greenMat.setColor("Color", ColorRGBA.Green);
    Material blueMat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    blueMat.getAdditionalRenderState().setWireframe(true);
    blueMat.setColor("Color", ColorRGBA.Blue);
    Node axis = new Node();
    // create arrows
    Geometry arrowX = new Geometry("arrowX", new Arrow(new Vector3f(arrowSize, 0, 0)));
    arrowX.setMaterial(redMat);
    Geometry arrowY = new Geometry("arrowY", new Arrow(new Vector3f(0, arrowSize, 0)));
    arrowY.setMaterial(greenMat);
    Geometry arrowZ = new Geometry("arrowZ", new Arrow(new Vector3f(0, 0, arrowSize)));
    arrowZ.setMaterial(blueMat);
    axis.attachChild(arrowX);
    axis.attachChild(arrowY);
    axis.attachChild(arrowZ);
    //axis.setModelBound(new BoundingBox());
    return axis;
}
Also used : Geometry(com.jme3.scene.Geometry) Arrow(com.jme3.scene.debug.Arrow) Node(com.jme3.scene.Node) Vector3f(com.jme3.math.Vector3f) Material(com.jme3.material.Material)

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