use of com.jme3.scene.debug.Arrow in project jmonkeyengine by jMonkeyEngine.
the class BulletVehicleDebugControl method createVehicle.
private void createVehicle() {
suspensionNode.detachAllChildren();
for (int i = 0; i < body.getNumWheels(); i++) {
VehicleWheel physicsVehicleWheel = body.getWheel(i);
Vector3f location = physicsVehicleWheel.getLocation().clone();
Vector3f direction = physicsVehicleWheel.getDirection().clone();
Vector3f axle = physicsVehicleWheel.getAxle().clone();
float restLength = physicsVehicleWheel.getRestLength();
float radius = physicsVehicleWheel.getRadius();
Arrow locArrow = new Arrow(location);
Arrow axleArrow = new Arrow(axle.normalizeLocal().multLocal(0.3f));
Arrow wheelArrow = new Arrow(direction.normalizeLocal().multLocal(radius));
Arrow dirArrow = new Arrow(direction.normalizeLocal().multLocal(restLength));
Geometry locGeom = new Geometry("WheelLocationDebugShape" + i, locArrow);
Geometry dirGeom = new Geometry("WheelDirectionDebugShape" + i, dirArrow);
Geometry axleGeom = new Geometry("WheelAxleDebugShape" + i, axleArrow);
Geometry wheelGeom = new Geometry("WheelRadiusDebugShape" + i, wheelArrow);
dirGeom.setLocalTranslation(location);
axleGeom.setLocalTranslation(location.add(direction));
wheelGeom.setLocalTranslation(location.add(direction));
locGeom.setMaterial(debugAppState.DEBUG_MAGENTA);
dirGeom.setMaterial(debugAppState.DEBUG_MAGENTA);
axleGeom.setMaterial(debugAppState.DEBUG_MAGENTA);
wheelGeom.setMaterial(debugAppState.DEBUG_MAGENTA);
suspensionNode.attachChild(locGeom);
suspensionNode.attachChild(dirGeom);
suspensionNode.attachChild(axleGeom);
suspensionNode.attachChild(wheelGeom);
}
}
use of com.jme3.scene.debug.Arrow 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;
}
use of com.jme3.scene.debug.Arrow in project jmonkeyengine by jMonkeyEngine.
the class TerrainTestModifyHeight method simpleUpdate.
@Override
public void simpleUpdate(float tpf) {
Vector3f intersection = getWorldIntersection();
updateHintText(intersection);
if (raiseTerrain) {
if (intersection != null) {
adjustHeight(intersection, 64, tpf * 60);
}
} else if (lowerTerrain) {
if (intersection != null) {
adjustHeight(intersection, 64, -tpf * 60);
}
}
if (terrain != null && intersection != null) {
float h = terrain.getHeight(new Vector2f(intersection.x, intersection.z));
Vector3f tl = terrain.getWorldTranslation();
marker.setLocalTranslation(tl.add(new Vector3f(intersection.x, h, intersection.z)));
markerNormal.setLocalTranslation(tl.add(new Vector3f(intersection.x, h, intersection.z)));
Vector3f normal = terrain.getNormal(new Vector2f(intersection.x, intersection.z));
((Arrow) markerNormal.getMesh()).setArrowExtent(normal);
}
}
use of com.jme3.scene.debug.Arrow in project jmonkeyengine by jMonkeyEngine.
the class TestDebugShapes method putArrow.
public void putArrow(Vector3f pos, Vector3f dir, ColorRGBA color) {
Arrow arrow = new Arrow(dir);
putShape(arrow, color, 4).setLocalTranslation(pos);
}
use of com.jme3.scene.debug.Arrow in project jmonkeyengine by jMonkeyEngine.
the class BulletVehicleDebugControl method controlUpdate.
@Override
protected void controlUpdate(float tpf) {
for (int i = 0; i < body.getNumWheels(); i++) {
VehicleWheel physicsVehicleWheel = body.getWheel(i);
Vector3f location = physicsVehicleWheel.getLocation().clone();
Vector3f direction = physicsVehicleWheel.getDirection().clone();
Vector3f axle = physicsVehicleWheel.getAxle().clone();
float restLength = physicsVehicleWheel.getRestLength();
float radius = physicsVehicleWheel.getRadius();
Geometry locGeom = (Geometry) suspensionNode.getChild("WheelLocationDebugShape" + i);
Geometry dirGeom = (Geometry) suspensionNode.getChild("WheelDirectionDebugShape" + i);
Geometry axleGeom = (Geometry) suspensionNode.getChild("WheelAxleDebugShape" + i);
Geometry wheelGeom = (Geometry) suspensionNode.getChild("WheelRadiusDebugShape" + i);
Arrow locArrow = (Arrow) locGeom.getMesh();
locArrow.setArrowExtent(location);
Arrow axleArrow = (Arrow) axleGeom.getMesh();
axleArrow.setArrowExtent(axle.normalizeLocal().multLocal(0.3f));
Arrow wheelArrow = (Arrow) wheelGeom.getMesh();
wheelArrow.setArrowExtent(direction.normalizeLocal().multLocal(radius));
Arrow dirArrow = (Arrow) dirGeom.getMesh();
dirArrow.setArrowExtent(direction.normalizeLocal().multLocal(restLength));
dirGeom.setLocalTranslation(location);
axleGeom.setLocalTranslation(location.addLocal(direction));
wheelGeom.setLocalTranslation(location);
i++;
}
applyPhysicsTransform(body.getPhysicsLocation(location), body.getPhysicsRotation(rotation));
}
Aggregations