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());
}
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);
}
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);
}
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);
}
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;
}
Aggregations