Search in sources :

Example 1 with CompoundCollisionShape

use of com.jme3.bullet.collision.shapes.CompoundCollisionShape in project jmonkeyengine by jMonkeyEngine.

the class RollingTheMonkey method simpleInitApp.

@Override
public void simpleInitApp() {
    flyCam.setEnabled(false);
    cam.setLocation(new Vector3f(0.0f, 12.0f, 21.0f));
    viewPort.setBackgroundColor(new ColorRGBA(0.2118f, 0.0824f, 0.6549f, 1.0f));
    // init physics
    BulletAppState bulletState = new BulletAppState();
    stateManager.attach(bulletState);
    space = bulletState.getPhysicsSpace();
    space.addCollisionListener(this);
    // create light
    DirectionalLight sun = new DirectionalLight();
    sun.setDirection((new Vector3f(-0.7f, -0.3f, -0.5f)).normalizeLocal());
    System.out.println("Here We Go: " + sun.getDirection());
    sun.setColor(ColorRGBA.White);
    rootNode.addLight(sun);
    // create materials
    Material materialRed = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
    materialRed.setBoolean("UseMaterialColors", true);
    materialRed.setBoolean("HardwareShadows", true);
    materialRed.setColor("Diffuse", new ColorRGBA(0.9451f, 0.0078f, 0.0314f, 1.0f));
    materialRed.setColor("Specular", ColorRGBA.White);
    materialRed.setFloat("Shininess", 64.0f);
    Material materialGreen = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
    materialGreen.setBoolean("UseMaterialColors", true);
    materialGreen.setBoolean("HardwareShadows", true);
    materialGreen.setColor("Diffuse", new ColorRGBA(0.0431f, 0.7725f, 0.0078f, 1.0f));
    materialGreen.setColor("Specular", ColorRGBA.White);
    materialGreen.setFloat("Shininess", 64.0f);
    Material logoMaterial = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
    logoMaterial.setBoolean("UseMaterialColors", true);
    logoMaterial.setBoolean("HardwareShadows", true);
    logoMaterial.setTexture("DiffuseMap", assetManager.loadTexture("com/jme3/app/Monkey.png"));
    logoMaterial.setColor("Diffuse", ColorRGBA.White);
    logoMaterial.setColor("Specular", ColorRGBA.White);
    logoMaterial.setFloat("Shininess", 32.0f);
    Material materialYellow = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
    materialYellow.setBoolean("UseMaterialColors", true);
    materialYellow.setBoolean("HardwareShadows", true);
    materialYellow.setColor("Diffuse", new ColorRGBA(0.9529f, 0.7843f, 0.0078f, 1.0f));
    materialYellow.setColor("Specular", ColorRGBA.White);
    materialYellow.setFloat("Shininess", 64.0f);
    // create level spatial
    // TODO: create your own level mesh
    Node level = new Node("level");
    level.setShadowMode(ShadowMode.CastAndReceive);
    Geometry floor = new Geometry("floor", new Box(22.0f, 0.5f, 22.0f));
    floor.setShadowMode(ShadowMode.Receive);
    floor.setLocalTranslation(0.0f, -0.5f, 0.0f);
    floor.setMaterial(materialGreen);
    Geometry wallNorth = new Geometry("wallNorth", new Box(22.0f, 2.0f, 0.5f));
    wallNorth.setLocalTranslation(0.0f, 2.0f, 21.5f);
    wallNorth.setMaterial(materialRed);
    Geometry wallSouth = new Geometry("wallSouth", new Box(22.0f, 2.0f, 0.5f));
    wallSouth.setLocalTranslation(0.0f, 2.0f, -21.5f);
    wallSouth.setMaterial(materialRed);
    Geometry wallEast = new Geometry("wallEast", new Box(0.5f, 2.0f, 21.0f));
    wallEast.setLocalTranslation(-21.5f, 2.0f, 0.0f);
    wallEast.setMaterial(materialRed);
    Geometry wallWest = new Geometry("wallWest", new Box(0.5f, 2.0f, 21.0f));
    wallWest.setLocalTranslation(21.5f, 2.0f, 0.0f);
    wallWest.setMaterial(materialRed);
    level.attachChild(floor);
    level.attachChild(wallNorth);
    level.attachChild(wallSouth);
    level.attachChild(wallEast);
    level.attachChild(wallWest);
    // The easy way: level.addControl(new RigidBodyControl(0));
    // create level Shape
    CompoundCollisionShape levelShape = new CompoundCollisionShape();
    BoxCollisionShape floorShape = new BoxCollisionShape(new Vector3f(22.0f, 0.5f, 22.0f));
    BoxCollisionShape wallNorthShape = new BoxCollisionShape(new Vector3f(22.0f, 2.0f, 0.5f));
    BoxCollisionShape wallSouthShape = new BoxCollisionShape(new Vector3f(22.0f, 2.0f, 0.5f));
    BoxCollisionShape wallEastShape = new BoxCollisionShape(new Vector3f(0.5f, 2.0f, 21.0f));
    BoxCollisionShape wallWestShape = new BoxCollisionShape(new Vector3f(0.5f, 2.0f, 21.0f));
    levelShape.addChildShape(floorShape, new Vector3f(0.0f, -0.5f, 0.0f));
    levelShape.addChildShape(wallNorthShape, new Vector3f(0.0f, 2.0f, -21.5f));
    levelShape.addChildShape(wallSouthShape, new Vector3f(0.0f, 2.0f, 21.5f));
    levelShape.addChildShape(wallEastShape, new Vector3f(-21.5f, 2.0f, 0.0f));
    levelShape.addChildShape(wallEastShape, new Vector3f(21.5f, 2.0f, 0.0f));
    level.addControl(new RigidBodyControl(levelShape, 0));
    rootNode.attachChild(level);
    space.addAll(level);
    // create Pickups
    // TODO: create your own pickUp mesh
    //       create single mesh for all pickups
    // HINT: think particles.
    pickUps = new Node("pickups");
    Quaternion rotation = new Quaternion();
    Vector3f translation = new Vector3f(0.0f, PICKUP_SIZE * 1.5f, -PICKUP_RADIUS);
    int index = 0;
    float ammount = FastMath.TWO_PI / PICKUP_COUNT;
    for (float angle = 0; angle < FastMath.TWO_PI; angle += ammount) {
        Geometry pickUp = new Geometry("pickUp" + (index++), new Box(PICKUP_SIZE, PICKUP_SIZE, PICKUP_SIZE));
        pickUp.setShadowMode(ShadowMode.CastAndReceive);
        pickUp.setMaterial(materialYellow);
        pickUp.setLocalRotation(rotation.fromAngles(FastMath.rand.nextFloat() * FastMath.TWO_PI, FastMath.rand.nextFloat() * FastMath.TWO_PI, FastMath.rand.nextFloat() * FastMath.TWO_PI));
        rotation.fromAngles(0.0f, angle, 0.0f);
        rotation.mult(translation, pickUp.getLocalTranslation());
        pickUps.attachChild(pickUp);
        pickUp.addControl(new GhostControl(new SphereCollisionShape(PICKUP_SIZE)));
        space.addAll(pickUp);
    //space.addCollisionListener(pickUpControl);
    }
    rootNode.attachChild(pickUps);
    // Create player
    // TODO: create your own player mesh
    Geometry playerGeometry = new Geometry("player", new Sphere(16, 32, PLAYER_RADIUS));
    playerGeometry.setShadowMode(ShadowMode.CastAndReceive);
    playerGeometry.setLocalTranslation(PLAYER_START.clone());
    playerGeometry.setMaterial(logoMaterial);
    // Store control for applying forces
    // TODO: create your own player control
    player = new RigidBodyControl(new SphereCollisionShape(PLAYER_RADIUS), PLAYER_MASS);
    player.setRestitution(PLAYER_REST);
    playerGeometry.addControl(player);
    rootNode.attachChild(playerGeometry);
    space.addAll(playerGeometry);
    inputManager.addMapping(INPUT_MAPPING_FORWARD, new KeyTrigger(KeyInput.KEY_UP), new KeyTrigger(KeyInput.KEY_W));
    inputManager.addMapping(INPUT_MAPPING_BACKWARD, new KeyTrigger(KeyInput.KEY_DOWN), new KeyTrigger(KeyInput.KEY_S));
    inputManager.addMapping(INPUT_MAPPING_LEFT, new KeyTrigger(KeyInput.KEY_LEFT), new KeyTrigger(KeyInput.KEY_A));
    inputManager.addMapping(INPUT_MAPPING_RIGHT, new KeyTrigger(KeyInput.KEY_RIGHT), new KeyTrigger(KeyInput.KEY_D));
    inputManager.addMapping(INPUT_MAPPING_RESET, new KeyTrigger(KeyInput.KEY_R));
    inputManager.addListener(this, INPUT_MAPPING_FORWARD, INPUT_MAPPING_BACKWARD, INPUT_MAPPING_LEFT, INPUT_MAPPING_RIGHT, INPUT_MAPPING_RESET);
    // init UI
    infoText = new BitmapText(guiFont, false);
    infoText.setText(INFO_MESSAGE);
    guiNode.attachChild(infoText);
    scoreText = new BitmapText(guiFont, false);
    scoreText.setText("Score: 0");
    guiNode.attachChild(scoreText);
    messageText = new BitmapText(guiFont, false);
    messageText.setText(MESSAGE);
    messageText.setLocalScale(0.0f);
    guiNode.attachChild(messageText);
    infoText.setLocalTranslation(0.0f, cam.getHeight(), 0.0f);
    scoreText.setLocalTranslation((cam.getWidth() - scoreText.getLineWidth()) / 2.0f, scoreText.getLineHeight(), 0.0f);
    messageText.setLocalTranslation((cam.getWidth() - messageText.getLineWidth()) / 2.0f, (cam.getHeight() - messageText.getLineHeight()) / 2, 0.0f);
    // init shadows
    FilterPostProcessor processor = new FilterPostProcessor(assetManager);
    DirectionalLightShadowFilter filter = new DirectionalLightShadowFilter(assetManager, 2048, 1);
    filter.setLight(sun);
    processor.addFilter(filter);
    viewPort.addProcessor(processor);
}
Also used : CompoundCollisionShape(com.jme3.bullet.collision.shapes.CompoundCollisionShape) SphereCollisionShape(com.jme3.bullet.collision.shapes.SphereCollisionShape) Quaternion(com.jme3.math.Quaternion) Node(com.jme3.scene.Node) KeyTrigger(com.jme3.input.controls.KeyTrigger) Material(com.jme3.material.Material) Box(com.jme3.scene.shape.Box) BoxCollisionShape(com.jme3.bullet.collision.shapes.BoxCollisionShape) FilterPostProcessor(com.jme3.post.FilterPostProcessor) DirectionalLightShadowFilter(com.jme3.shadow.DirectionalLightShadowFilter) RigidBodyControl(com.jme3.bullet.control.RigidBodyControl) Geometry(com.jme3.scene.Geometry) Sphere(com.jme3.scene.shape.Sphere) ColorRGBA(com.jme3.math.ColorRGBA) BitmapText(com.jme3.font.BitmapText) GhostControl(com.jme3.bullet.control.GhostControl) Vector3f(com.jme3.math.Vector3f) BulletAppState(com.jme3.bullet.BulletAppState) DirectionalLight(com.jme3.light.DirectionalLight)

Example 2 with CompoundCollisionShape

use of com.jme3.bullet.collision.shapes.CompoundCollisionShape in project jmonkeyengine by jMonkeyEngine.

the class TestPhysicsCar method buildPlayer.

private void buildPlayer() {
    Material mat = new Material(getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
    mat.getAdditionalRenderState().setWireframe(true);
    mat.setColor("Color", ColorRGBA.Red);
    //create a compound shape and attach the BoxCollisionShape for the car body at 0,1,0
    //this shifts the effective center of mass of the BoxCollisionShape to 0,-1,0
    CompoundCollisionShape compoundShape = new CompoundCollisionShape();
    BoxCollisionShape box = new BoxCollisionShape(new Vector3f(1.2f, 0.5f, 2.4f));
    compoundShape.addChildShape(box, new Vector3f(0, 1, 0));
    //create vehicle node
    Node vehicleNode = new Node("vehicleNode");
    vehicle = new VehicleControl(compoundShape, 400);
    vehicleNode.addControl(vehicle);
    //setting suspension values for wheels, this can be a bit tricky
    //see also https://docs.google.com/Doc?docid=0AXVUZ5xw6XpKZGNuZG56a3FfMzU0Z2NyZnF4Zmo&hl=en
    //200=f1 car
    float stiffness = 60.0f;
    //(should be lower than damp)
    float compValue = .3f;
    float dampValue = .4f;
    vehicle.setSuspensionCompression(compValue * 2.0f * FastMath.sqrt(stiffness));
    vehicle.setSuspensionDamping(dampValue * 2.0f * FastMath.sqrt(stiffness));
    vehicle.setSuspensionStiffness(stiffness);
    vehicle.setMaxSuspensionForce(10000.0f);
    //Create four wheels and add them at their locations
    // was 0, -1, 0
    Vector3f wheelDirection = new Vector3f(0, -1, 0);
    // was -1, 0, 0
    Vector3f wheelAxle = new Vector3f(-1, 0, 0);
    float radius = 0.5f;
    float restLength = 0.3f;
    float yOff = 0.5f;
    float xOff = 1f;
    float zOff = 2f;
    Cylinder wheelMesh = new Cylinder(16, 16, radius, radius * 0.6f, true);
    Node node1 = new Node("wheel 1 node");
    Geometry wheels1 = new Geometry("wheel 1", wheelMesh);
    node1.attachChild(wheels1);
    wheels1.rotate(0, FastMath.HALF_PI, 0);
    wheels1.setMaterial(mat);
    vehicle.addWheel(node1, new Vector3f(-xOff, yOff, zOff), wheelDirection, wheelAxle, restLength, radius, true);
    Node node2 = new Node("wheel 2 node");
    Geometry wheels2 = new Geometry("wheel 2", wheelMesh);
    node2.attachChild(wheels2);
    wheels2.rotate(0, FastMath.HALF_PI, 0);
    wheels2.setMaterial(mat);
    vehicle.addWheel(node2, new Vector3f(xOff, yOff, zOff), wheelDirection, wheelAxle, restLength, radius, true);
    Node node3 = new Node("wheel 3 node");
    Geometry wheels3 = new Geometry("wheel 3", wheelMesh);
    node3.attachChild(wheels3);
    wheels3.rotate(0, FastMath.HALF_PI, 0);
    wheels3.setMaterial(mat);
    vehicle.addWheel(node3, new Vector3f(-xOff, yOff, -zOff), wheelDirection, wheelAxle, restLength, radius, false);
    Node node4 = new Node("wheel 4 node");
    Geometry wheels4 = new Geometry("wheel 4", wheelMesh);
    node4.attachChild(wheels4);
    wheels4.rotate(0, FastMath.HALF_PI, 0);
    wheels4.setMaterial(mat);
    vehicle.addWheel(node4, new Vector3f(xOff, yOff, -zOff), wheelDirection, wheelAxle, restLength, radius, false);
    vehicleNode.attachChild(node1);
    vehicleNode.attachChild(node2);
    vehicleNode.attachChild(node3);
    vehicleNode.attachChild(node4);
    rootNode.attachChild(vehicleNode);
    getPhysicsSpace().add(vehicle);
}
Also used : Geometry(com.jme3.scene.Geometry) Cylinder(com.jme3.scene.shape.Cylinder) CompoundCollisionShape(com.jme3.bullet.collision.shapes.CompoundCollisionShape) Vector3f(com.jme3.math.Vector3f) Node(com.jme3.scene.Node) VehicleControl(com.jme3.bullet.control.VehicleControl) Material(com.jme3.material.Material) BoxCollisionShape(com.jme3.bullet.collision.shapes.BoxCollisionShape)

Example 3 with CompoundCollisionShape

use of com.jme3.bullet.collision.shapes.CompoundCollisionShape in project jmonkeyengine by jMonkeyEngine.

the class BufferedTriangleCallback method getDebugShape.

/**
     * Creates a debug shape from the given collision shape. This is mostly used internally.<br>
     * To attach a debug shape to a physics object, call <code>attachDebugShape(AssetManager manager);</code> on it.
     * @param collisionShape
     * @return
     */
public static Spatial getDebugShape(CollisionShape collisionShape) {
    if (collisionShape == null) {
        return null;
    }
    Spatial debugShape;
    if (collisionShape instanceof CompoundCollisionShape) {
        CompoundCollisionShape shape = (CompoundCollisionShape) collisionShape;
        List<ChildCollisionShape> children = shape.getChildren();
        Node node = new Node("DebugShapeNode");
        for (Iterator<ChildCollisionShape> it = children.iterator(); it.hasNext(); ) {
            ChildCollisionShape childCollisionShape = it.next();
            CollisionShape ccollisionShape = childCollisionShape.shape;
            Geometry geometry = createDebugShape(ccollisionShape);
            // apply translation
            geometry.setLocalTranslation(childCollisionShape.location);
            // apply rotation
            TempVars vars = TempVars.get();
            Matrix3f tempRot = vars.tempMat3;
            tempRot.set(geometry.getLocalRotation());
            childCollisionShape.rotation.mult(tempRot, tempRot);
            geometry.setLocalRotation(tempRot);
            vars.release();
            node.attachChild(geometry);
        }
        debugShape = node;
    } else {
        debugShape = createDebugShape(collisionShape);
    }
    if (debugShape == null) {
        return null;
    }
    debugShape.updateGeometricState();
    return debugShape;
}
Also used : Geometry(com.jme3.scene.Geometry) CompoundCollisionShape(com.jme3.bullet.collision.shapes.CompoundCollisionShape) ChildCollisionShape(com.jme3.bullet.collision.shapes.infos.ChildCollisionShape) CollisionShape(com.jme3.bullet.collision.shapes.CollisionShape) CompoundCollisionShape(com.jme3.bullet.collision.shapes.CompoundCollisionShape) Spatial(com.jme3.scene.Spatial) Matrix3f(com.jme3.math.Matrix3f) Node(com.jme3.scene.Node) ChildCollisionShape(com.jme3.bullet.collision.shapes.infos.ChildCollisionShape) TempVars(com.jme3.util.TempVars)

Example 4 with CompoundCollisionShape

use of com.jme3.bullet.collision.shapes.CompoundCollisionShape in project jmonkeyengine by jMonkeyEngine.

the class CompoundCollisionShape method addChildShape.

/**
     * adds a child shape at the given local translation
     * @param shape the child shape to add
     * @param location the local location of the child shape
     */
public void addChildShape(CollisionShape shape, Vector3f location, Matrix3f rotation) {
    if (shape instanceof CompoundCollisionShape) {
        throw new IllegalStateException("CompoundCollisionShapes cannot have CompoundCollisionShapes as children!");
    }
    Transform transA = new Transform(Converter.convert(rotation));
    Converter.convert(location, transA.origin);
    Converter.convert(rotation, transA.basis);
    children.add(new ChildCollisionShape(location.clone(), rotation.clone(), shape));
    ((CompoundShape) cShape).addChildShape(transA, shape.getCShape());
}
Also used : ChildCollisionShape(com.jme3.bullet.collision.shapes.infos.ChildCollisionShape) CompoundShape(com.bulletphysics.collision.shapes.CompoundShape) Transform(com.bulletphysics.linearmath.Transform)

Example 5 with CompoundCollisionShape

use of com.jme3.bullet.collision.shapes.CompoundCollisionShape in project jmonkeyengine by jMonkeyEngine.

the class TestAttachDriver method buildPlayer.

private void buildPlayer() {
    Material mat = new Material(getAssetManager(), "Common/MatDefs/Misc/Unshaded.j3md");
    mat.getAdditionalRenderState().setWireframe(true);
    mat.setColor("Color", ColorRGBA.Red);
    //create a compound shape and attach the BoxCollisionShape for the car body at 0,1,0
    //this shifts the effective center of mass of the BoxCollisionShape to 0,-1,0
    CompoundCollisionShape compoundShape = new CompoundCollisionShape();
    BoxCollisionShape box = new BoxCollisionShape(new Vector3f(1.2f, 0.5f, 2.4f));
    compoundShape.addChildShape(box, new Vector3f(0, 1, 0));
    //create vehicle node
    Node vehicleNode = new Node("vehicleNode");
    vehicle = new VehicleControl(compoundShape, 800);
    vehicleNode.addControl(vehicle);
    //setting suspension values for wheels, this can be a bit tricky
    //see also https://docs.google.com/Doc?docid=0AXVUZ5xw6XpKZGNuZG56a3FfMzU0Z2NyZnF4Zmo&hl=en
    //200=f1 car
    float stiffness = 60.0f;
    //(should be lower than damp)
    float compValue = .3f;
    float dampValue = .4f;
    vehicle.setSuspensionCompression(compValue * 2.0f * FastMath.sqrt(stiffness));
    vehicle.setSuspensionDamping(dampValue * 2.0f * FastMath.sqrt(stiffness));
    vehicle.setSuspensionStiffness(stiffness);
    vehicle.setMaxSuspensionForce(10000.0f);
    //Create four wheels and add them at their locations
    // was 0, -1, 0
    Vector3f wheelDirection = new Vector3f(0, -1, 0);
    // was -1, 0, 0
    Vector3f wheelAxle = new Vector3f(-1, 0, 0);
    float radius = 0.5f;
    float restLength = 0.3f;
    float yOff = 0.5f;
    float xOff = 1f;
    float zOff = 2f;
    Cylinder wheelMesh = new Cylinder(16, 16, radius, radius * 0.6f, true);
    Node node1 = new Node("wheel 1 node");
    Geometry wheels1 = new Geometry("wheel 1", wheelMesh);
    node1.attachChild(wheels1);
    wheels1.rotate(0, FastMath.HALF_PI, 0);
    wheels1.setMaterial(mat);
    vehicle.addWheel(node1, new Vector3f(-xOff, yOff, zOff), wheelDirection, wheelAxle, restLength, radius, true);
    Node node2 = new Node("wheel 2 node");
    Geometry wheels2 = new Geometry("wheel 2", wheelMesh);
    node2.attachChild(wheels2);
    wheels2.rotate(0, FastMath.HALF_PI, 0);
    wheels2.setMaterial(mat);
    vehicle.addWheel(node2, new Vector3f(xOff, yOff, zOff), wheelDirection, wheelAxle, restLength, radius, true);
    Node node3 = new Node("wheel 3 node");
    Geometry wheels3 = new Geometry("wheel 3", wheelMesh);
    node3.attachChild(wheels3);
    wheels3.rotate(0, FastMath.HALF_PI, 0);
    wheels3.setMaterial(mat);
    vehicle.addWheel(node3, new Vector3f(-xOff, yOff, -zOff), wheelDirection, wheelAxle, restLength, radius, false);
    Node node4 = new Node("wheel 4 node");
    Geometry wheels4 = new Geometry("wheel 4", wheelMesh);
    node4.attachChild(wheels4);
    wheels4.rotate(0, FastMath.HALF_PI, 0);
    wheels4.setMaterial(mat);
    vehicle.addWheel(node4, new Vector3f(xOff, yOff, -zOff), wheelDirection, wheelAxle, restLength, radius, false);
    vehicleNode.attachChild(node1);
    vehicleNode.attachChild(node2);
    vehicleNode.attachChild(node3);
    vehicleNode.attachChild(node4);
    rootNode.attachChild(vehicleNode);
    getPhysicsSpace().add(vehicle);
    //driver
    Node driverNode = new Node("driverNode");
    driverNode.setLocalTranslation(0, 2, 0);
    driver = new RigidBodyControl(new BoxCollisionShape(new Vector3f(0.2f, .5f, 0.2f)));
    driverNode.addControl(driver);
    rootNode.attachChild(driverNode);
    getPhysicsSpace().add(driver);
    //joint
    slider = new SliderJoint(driver, vehicle, Vector3f.UNIT_Y.negate(), Vector3f.UNIT_Y, true);
    slider.setUpperLinLimit(.1f);
    slider.setLowerLinLimit(-.1f);
    getPhysicsSpace().add(slider);
    Node pole1Node = new Node("pole1Node");
    Node pole2Node = new Node("pole1Node");
    Node bridgeNode = new Node("pole1Node");
    pole1Node.setLocalTranslation(new Vector3f(-2, -1, 4));
    pole2Node.setLocalTranslation(new Vector3f(2, -1, 4));
    bridgeNode.setLocalTranslation(new Vector3f(0, 1.4f, 4));
    RigidBodyControl pole1 = new RigidBodyControl(new BoxCollisionShape(new Vector3f(0.2f, 1.25f, 0.2f)), 0);
    pole1Node.addControl(pole1);
    RigidBodyControl pole2 = new RigidBodyControl(new BoxCollisionShape(new Vector3f(0.2f, 1.25f, 0.2f)), 0);
    pole2Node.addControl(pole2);
    bridge = new RigidBodyControl(new BoxCollisionShape(new Vector3f(2.5f, 0.2f, 0.2f)));
    bridgeNode.addControl(bridge);
    rootNode.attachChild(pole1Node);
    rootNode.attachChild(pole2Node);
    rootNode.attachChild(bridgeNode);
    getPhysicsSpace().add(pole1);
    getPhysicsSpace().add(pole2);
    getPhysicsSpace().add(bridge);
}
Also used : Geometry(com.jme3.scene.Geometry) Cylinder(com.jme3.scene.shape.Cylinder) CompoundCollisionShape(com.jme3.bullet.collision.shapes.CompoundCollisionShape) SliderJoint(com.jme3.bullet.joints.SliderJoint) Node(com.jme3.scene.Node) VehicleControl(com.jme3.bullet.control.VehicleControl) Material(com.jme3.material.Material) BoxCollisionShape(com.jme3.bullet.collision.shapes.BoxCollisionShape) RigidBodyControl(com.jme3.bullet.control.RigidBodyControl)

Aggregations

CompoundCollisionShape (com.jme3.bullet.collision.shapes.CompoundCollisionShape)6 ChildCollisionShape (com.jme3.bullet.collision.shapes.infos.ChildCollisionShape)5 Geometry (com.jme3.scene.Geometry)5 Node (com.jme3.scene.Node)5 Vector3f (com.jme3.math.Vector3f)4 BoxCollisionShape (com.jme3.bullet.collision.shapes.BoxCollisionShape)3 Material (com.jme3.material.Material)3 Matrix3f (com.jme3.math.Matrix3f)3 CollisionShape (com.jme3.bullet.collision.shapes.CollisionShape)2 RigidBodyControl (com.jme3.bullet.control.RigidBodyControl)2 VehicleControl (com.jme3.bullet.control.VehicleControl)2 Spatial (com.jme3.scene.Spatial)2 Cylinder (com.jme3.scene.shape.Cylinder)2 TempVars (com.jme3.util.TempVars)2 CompoundShape (com.bulletphysics.collision.shapes.CompoundShape)1 Transform (com.bulletphysics.linearmath.Transform)1 BulletAppState (com.jme3.bullet.BulletAppState)1 CapsuleCollisionShape (com.jme3.bullet.collision.shapes.CapsuleCollisionShape)1 SphereCollisionShape (com.jme3.bullet.collision.shapes.SphereCollisionShape)1 GhostControl (com.jme3.bullet.control.GhostControl)1