コード例 #1
0
ファイル: Trapeeze.java プロジェクト: smashsenpai/trapeeze
  public Trapeeze(Game game) {
    Cylinder pole = new Cylinder(10, 10, radius, height, true);
    leftPole = new Geometry("leftPole", pole);
    leftPole.rotate(90f * FastMath.DEG_TO_RAD, 0, 0);
    leftPole.setLocalTranslation(-1f, height / 2f, 0f);
    leftPole.setShadowMode(RenderQueue.ShadowMode.Cast);

    rightPole = new Geometry("rightPole", pole);
    rightPole.rotate(90f * FastMath.DEG_TO_RAD, 0, 0);
    rightPole.setLocalTranslation(1f, height / 2f, 0f);
    rightPole.setShadowMode(RenderQueue.ShadowMode.Cast);

    float betweenPoles = rightPole.getLocalTranslation().x - leftPole.getLocalTranslation().x;
    Box seat = new Box(betweenPoles, radius, radius * 4);
    swing = new Geometry("swing", seat);
    swing.rotate(90f * FastMath.DEG_TO_RAD, 0, 0);
    swing.setLocalTranslation(0f, 3, 0f);
    swing.setShadowMode(RenderQueue.ShadowMode.Cast);

    swing.move(-4.0f, 6f, 0.0f);
    leftPole.move(-4.0f, 10f, 0.0f);
    rightPole.move(-4.0f, 10f, 0.0f);

    setTrapeezeMaterial(Main.matOrange);

    collisionShape = CollisionShapeFactory.createBoxShape(leftPole);
    collisionShape = CollisionShapeFactory.createBoxShape(rightPole);
    collisionShape = CollisionShapeFactory.createBoxShape(swing);

    this.attachChild(leftPole);
    this.attachChild(swing);
  }
コード例 #2
0
ファイル: BarrelModel.java プロジェクト: drxaos/robo3d
  public void init(Env env, TmxMapObject mapObject) {
    CollisionShape shape = CollisionShapeFactory.createDynamicMeshShape(this);
    physic = new RigidBodyControl(shape, 0.5f);
    this.addControl(physic);
    physic.setDamping(0.9f, 0.9f);
    env.getApp().getBulletAppState().getPhysicsSpace().add(physic);

    // Optimizer.optimize(this, true);
  }
コード例 #3
0
  private void resetWallPhysics(PhysicsSpace space) {
    List<Spatial> children = ((Node) getTerrainNode().getChild("Walls")).getChildren();
    for (Spatial wallNode : children) {
      Spatial wall = ((Node) wallNode).getChild("Wall");
      wall.scale(6f);

      space.removeAll(wallNode);

      CollisionShape meshShape = CollisionShapeFactory.createMeshShape(wall);

      wall.scale(1f / 6f);
      RigidBodyControl wallPhysics = new RigidBodyControl(meshShape, 0);
      wallPhysics.setCollideWithGroups(CollisionGroups.NONE);

      wallPhysics.setFriction(0.5f);
      wall.addControl(wallPhysics);
      wall.getControl(RigidBodyControl.class).setCollisionGroup(CollisionGroups.WALLS);

      space.addAll(wall);
    }
  }
コード例 #4
0
ファイル: Main.java プロジェクト: njTaljaard/Laminin
 private void initScene() {
   sceneModel = assetManager.loadModel("Scenes/Scene.j3o");
   CollisionShape sceneShape = CollisionShapeFactory.createMeshShape(sceneModel);
   if (sceneModel == null) System.out.println("not loaded");
   rootNode.attachChild(sceneModel);
 }
コード例 #5
0
ファイル: Main.java プロジェクト: Wigglez/GSP362
  @Override
  public void simpleInitApp() {

    //        setUpKeys();
    flyCam.setEnabled(false);

    bulletAppState = new BulletAppState();
    stateManager.attach(bulletAppState);
    bulletAppState.getPhysicsSpace().enableDebug(assetManager);

    Juggernaut = new Character(this, bulletAppState);

    setUpCameraBoxes();
    // Load in the level
    // Material m = assetManager.loadMaterial("Models/levelLayout - Update.mtl");
    Spatial map = assetManager.loadModel("Models/levelLayout - Update_cameraPos.obj");
    rootNode.attachChild(map);

    Material mark_mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
    //       mark_mat.setColor("Color", ColorRGBA.White);
    //       mark.setMaterial(mark_mat);
    //        mark.setLocalTranslation(1f,1f,1f);
    //        rootNode.attachChild(mark);

    CollisionShape sceneShape = CollisionShapeFactory.createMeshShape(map);
    landscape = new RigidBodyControl(sceneShape, 0);
    map.addControl(landscape);
    landscape.setCollisionGroup(1);
    landscape.removeCollideWithGroup(2);

    //        //Load Ninja as filler for character model
    //        ninja = assetManager.loadModel("Models/Ninja/Ninja.mesh.xml");
    //        //ninja.rotate(0, -1.5f, 0);
    //        ninja.scale(0.02f, 0.02f, 0.02f);
    //        ninja.setLocalTranslation(new Vector3f(341, 300, 0));
    //        //ninja.setMaterial(mark_mat);
    //        rootNode.attachChild(ninja);
    //        CapsuleCollisionShape capsuleShape = new CapsuleCollisionShape(1f, 2f);
    //        player = new CharacterControl(capsuleShape, .05f);
    //        player.setJumpSpeed(50);
    //        player.setFallSpeed(50);
    //        player.setGravity(120);
    //        player.setPhysicsLocation(new Vector3f(1f,8f,1f));
    //        player.setViewDirection(new Vector3f(-1.0f, 0, 0));
    //        player.setCollideWithGroups(2);
    //
    //
    //
    //        playerDebug = player.createDebugShape(assetManager);
    //        ninja.addControl(player);
    //        rootNode.attachChild(playerDebug);
    //
    //        bulletAppState.getPhysicsSpace().add(player);
    bulletAppState.getPhysicsSpace().add(landscape);

    // Elevator 1
    elevator1 = new Geometry("Elevator1", new Box(4, 1, 5));
    elevator1.setLocalTranslation(304, 20, 0);
    elevator1.setMaterial(mark_mat);
    elvtr1 = new RigidBodyControl(10);

    elevator1.addControl(elvtr1);
    elvtr1.setFriction(1000.0f);
    elvtr1.setKinematic(true);
    bulletAppState.getPhysicsSpace().add(elvtr1);
    rootNode.attachChild(elevator1);

    // Elevator 2
    elevator2 = new Geometry("Elevator2", new Box(4, 1, 5));
    elevator2.setLocalTranslation(192, 208, 0);
    elevator2.setMaterial(mark_mat);
    elvtr2 = new RigidBodyControl(1000000000);

    elevator2.addControl(elvtr2);
    elvtr2.setAngularDamping(100000.0f);
    elvtr2.setFriction(1000.0f);
    //        elvtr2.setKinematic(true);
    bulletAppState.getPhysicsSpace().add(elvtr2);
    rootNode.attachChild(elevator2);

    // Add lights to see the models
    DirectionalLight sun = new DirectionalLight();
    sun.setDirection(new Vector3f(-0.1f, -0.7f, -1.0f));
    rootNode.addLight(sun);

    AmbientLight al = new AmbientLight();
    al.setColor(ColorRGBA.White);
    rootNode.addLight(al);

    //        cam.setLocation(new Vector3f(player.getPhysicsLocation().x,
    // player.getPhysicsLocation().y + 5, player.getPhysicsLocation().z +40 ));
    //        cam.lookAt(player.getPhysicsLocation(), Vector3f.UNIT_Y);
    cam.setLocation(new Vector3f(0, 5, 40));
    cam.lookAt(new Vector3f(0, 5, 0), Vector3f.UNIT_Y);
  }
コード例 #6
0
 private void makeSolid(BulletAppState physicsEngine) {
   CollisionShape boxShape = CollisionShapeFactory.createBoxShape(this);
   RigidBodyControl rigidBody = new RigidBodyControl(boxShape, 0.0f);
   addControl(rigidBody);
   physicsEngine.getPhysicsSpace().add(rigidBody);
 }