Examples of RigidBodyControl


Examples of com.jme3.bullet.control.RigidBodyControl

    floorGeometry.setMaterial(material);
    floorGeometry.setLocalTranslation(0, -0.25f, 0);
    // Plane plane = new Plane();
    // plane.setOriginNormal(new Vector3f(0, 0.25f, 0), Vector3f.UNIT_Y);
    // floorGeometry.addControl(new RigidBodyControl(new PlaneCollisionShape(plane), 0));
    floorGeometry.addControl(new RigidBodyControl(0));
    rootNode.attachChild(floorGeometry);
    space.add(floorGeometry);

    // movable spheres
    for (int i = 0; i < 5; i++) {
      Sphere sphere = new Sphere(16, 16, .5f);
      Geometry ballGeometry = new Geometry("Soccer ball", sphere);
      ballGeometry.setMaterial(material);
      ballGeometry.setLocalTranslation(i, 2, -3);
      // RigidBodyControl automatically uses Sphere collision shapes when attached to single geometry with sphere mesh
      ballGeometry.addControl(new RigidBodyControl(.001f));
      ballGeometry.getControl(RigidBodyControl.class).setRestitution(1);
      rootNode.attachChild(ballGeometry);
      space.add(ballGeometry);
    }

    // immovable Box with mesh collision shape
    Box box = new Box(1, 1, 1);
    Geometry boxGeometry = new Geometry("Box", box);
    boxGeometry.setMaterial(material);
    boxGeometry.setLocalTranslation(4, 1, 2);
    boxGeometry.addControl(new RigidBodyControl(new MeshCollisionShape(box), 0));
    rootNode.attachChild(boxGeometry);
    space.add(boxGeometry);

  }
View Full Code Here

Examples of com.jme3.bullet.control.RigidBodyControl

    material.setTexture("ColorMap", assetManager.loadTexture("Interface/Logo/Monkey.jpg"));
    Box box = new Box(0.25f, 0.25f, 0.25f);
    Geometry boxGeometry = new Geometry("Box", box);
    boxGeometry.setMaterial(material);
    // RigidBodyControl automatically uses box collision shapes when attached to single geometry with box mesh
    boxGeometry.addControl(new RigidBodyControl(2));
    return boxGeometry;
  }
View Full Code Here

Examples of com.jme3.bullet.control.RigidBodyControl

    material.setTexture("ColorMap", assetManager.loadTexture("Interface/Logo/Monkey.jpg"));
    Sphere sphere = new Sphere(8, 8, 0.25f);
    Geometry boxGeometry = new Geometry("Sphere", sphere);
    boxGeometry.setMaterial(material);
    // RigidBodyControl automatically uses sphere collision shapes when attached to single geometry with sphere mesh
    boxGeometry.addControl(new RigidBodyControl(2));
    return boxGeometry;
  }
View Full Code Here

Examples of com.jme3.bullet.control.RigidBodyControl

   * @return
   */
  public static Node createPhysicsTestNode(AssetManager manager, CollisionShape shape, float mass) {

    Node node = new Node("PhysicsNode");
    RigidBodyControl control = new RigidBodyControl(shape, mass);
    node.addControl(control);
    return node;
  }
View Full Code Here

Examples of com.jme3.bullet.control.RigidBodyControl

        if (name.equals("shoot") && !keyPressed) {
          Geometry bulletg = new Geometry("bullet", bullet);
          bulletg.setMaterial(mat2);
          bulletg.setShadowMode(ShadowMode.CastAndReceive);
          bulletg.setLocalTranslation(app.getCamera().getLocation());
          RigidBodyControl bulletControl = new RigidBodyControl(1);
          bulletg.addControl(bulletControl);
          bulletControl.setLinearVelocity(app.getCamera().getDirection().mult(25));
          bulletg.addControl(bulletControl);
          rootNode.attachChild(bulletg);
          space.add(bulletControl);
        }
      }
View Full Code Here

Examples of com.jme3.bullet.control.RigidBodyControl

    // The PlaneCollisionShape causes collision listeners to ALWAYS fire for some reason. This
    // is a hacky workaround.
    int num = (int)radius * (int)radius;
    float[] height = new float[num];
    shape = new HeightfieldCollisionShape(height);// , new Vector3f(radius, 0, radius));
    physics = new RigidBodyControl(shape, 0);
  }
View Full Code Here

Examples of com.jme3.bullet.control.RigidBodyControl

        Spatial underground = assetManager.loadModel("main.scene");
        underground.setLocalScale(2f);
        scene.attachChild(underground);
        CollisionShape sceneShape =
            CollisionShapeFactory.createMeshShape(scene);
        RigidBodyControl landscape;
        landscape = new RigidBodyControl(sceneShape, 0);
        scene.addControl(landscape);
        bulletAppState.getPhysicsSpace().add(scene);
        //Todo
    }
View Full Code Here

Examples of com.jme3.bullet.control.RigidBodyControl

      spatial.setShadowMode(ShadowMode.Off);
      physics = new GhostControl(shape);
    }
    else {
      spatial.setShadowMode(ShadowMode.CastAndReceive);
      physics = new RigidBodyControl(shape, mass);
    }
    spatial.addControl(physics);
  }
View Full Code Here

Examples of com.jme3.bullet.control.RigidBodyControl

        physicsSpace = bulletAppState.getPhysicsSpace();
        physicsSpace.setGravity(new Vector3f(0f, -12f, 0f));
        physicsSpace.setAccuracy(0.005f);
        //gives the world floor colision with 0 gravity so it doesent fall
       
        root.addControl(new RigidBodyControl(0.0f));
        //attaches the world floor to the bulletAppState
        physicsSpace.add(root);


    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.