Search in sources :

Example 1 with Arrow

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);
    }
}
Also used : Arrow(com.jme3.scene.debug.Arrow) Geometry(com.jme3.scene.Geometry) VehicleWheel(com.jme3.bullet.objects.VehicleWheel) Vector3f(com.jme3.math.Vector3f)

Example 2 with Arrow

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

Example 3 with Arrow

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);
    }
}
Also used : Arrow(com.jme3.scene.debug.Arrow) Vector2f(com.jme3.math.Vector2f) Vector3f(com.jme3.math.Vector3f)

Example 4 with Arrow

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);
}
Also used : Arrow(com.jme3.scene.debug.Arrow)

Example 5 with Arrow

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));
}
Also used : Geometry(com.jme3.scene.Geometry) Arrow(com.jme3.scene.debug.Arrow) VehicleWheel(com.jme3.bullet.objects.VehicleWheel) Vector3f(com.jme3.math.Vector3f)

Aggregations

Arrow (com.jme3.scene.debug.Arrow)9 Vector3f (com.jme3.math.Vector3f)7 Geometry (com.jme3.scene.Geometry)6 Material (com.jme3.material.Material)5 VehicleWheel (com.jme3.bullet.objects.VehicleWheel)2 Node (com.jme3.scene.Node)2 KeyTrigger (com.jme3.input.controls.KeyTrigger)1 ColorRGBA (com.jme3.math.ColorRGBA)1 Quaternion (com.jme3.math.Quaternion)1 Vector2f (com.jme3.math.Vector2f)1 FilterPostProcessor (com.jme3.post.FilterPostProcessor)1 BloomFilter (com.jme3.post.filters.BloomFilter)1 Sphere (com.jme3.scene.shape.Sphere)1 NanoTimer (com.jme3.system.NanoTimer)1