Package com.bulletphysics.dynamics

Examples of com.bulletphysics.dynamics.RigidBody


      CollisionWorld.ClosestRayResultCallback rayCallback = new CollisionWorld.ClosestRayResultCallback(
          cameraPosition, rayTo);
      myWorld.rayTest(cameraPosition, rayTo, rayCallback);
      if (rayCallback.hasHit()) {

        RigidBody body = RigidBody.upcast(rayCallback.collisionObject);
        if (body != null) {

          //if physics is off turn it on
          //if(  !SETTINGS.physics_on)
          //  SETTINGS.physics_on = true;

          // other exclusions?
          if (!(body.isStaticObject() || body.isKinematicObject())) {
            pickedBody = body;
            pickedBody
                .setActivationState(CollisionObject.DISABLE_DEACTIVATION);

            Vector3f pickPos = new Vector3f(
                rayCallback.hitPointWorld);

            Transform tmpTrans = body
                .getCenterOfMassTransform(new Transform());
            tmpTrans.inverse();
            Vector3f localPivot = new Vector3f(pickPos);
            tmpTrans.transform(localPivot);
View Full Code Here


    Iterator ite = myWorld.getCollisionObjectArray().iterator();

    while (ite.hasNext()) {

      RigidBody rBody = (RigidBody) ite.next();

      Transform myTransform = new Transform();
      myTransform = rBody.getMotionState().getWorldTransform(myTransform);

      g.pushMatrix();

      g.translate(myTransform.origin.x, myTransform.origin.y,
          myTransform.origin.z);

      g.applyMatrix(myTransform.basis.m00, myTransform.basis.m01,
          myTransform.basis.m02, 0, myTransform.basis.m10,
          myTransform.basis.m11, myTransform.basis.m12, 0,
          myTransform.basis.m20, myTransform.basis.m21,
          myTransform.basis.m22, 0, 0, 0, 0, 1);
      // rBody.
      // rBody.
      // System.out.println(myTransform.origin.y);
      // fill(fallRigidBody.c);
      // do the actual drawing of the object

      CollisionShape col = rBody.getCollisionShape();
      //if (col.isPolyhedral()) {
        Vector3f posP = new Vector3f();
        float[] sizeP = { 0 };
        col.getBoundingSphere(posP, sizeP);
        g.pushMatrix();
View Full Code Here

    //myWorld.getGravity(gravity);
    myWorld.setGravity(new Vector3f(0, 0, 0));

    Iterator ite = myWorld.getCollisionObjectArray().iterator();
    while (ite.hasNext()) {
      RigidBody rBody = (RigidBody) ite.next();
      // rBody.setCollisionFlags(CollisionFlags.NO_CONTACT_RESPONSE);
      rBody.clearForces();
      rBody.setAngularVelocity(new Vector3f(0, 0, 0));
      rBody.setLinearVelocity(new Vector3f(0, 0, 0));
      rBody.clearForces();
      rBody.activate(false);

    }

    float ms = getDeltaTimeMicroseconds();

    //if(ms > 100)
    try {
      myWorld.stepSimulation(ms / 1000f);
    } catch (Exception ex) {
    }

    ite = myWorld.getCollisionObjectArray().iterator();

    while (ite.hasNext()) {
      RigidBody rBody = (RigidBody) ite.next();
      rBody.activate(true);
      // rBody.setCollisionFlags(CollisionFlags);

    }
    myWorld.setGravity(new Vector3f(0, SETTINGS.gravity, 0));
View Full Code Here

      localA.origin.set(0f, 0f, 0f);

      localB.origin.set(0f, 0f, 0f);

      CollisionShape ZeroShape = null;
      GLOBAL.jBullet.ZeroBody = new RigidBody(0.0f, null, ZeroShape);

      Transform Rotation = new Transform();
      Rotation.setIdentity();
      GLOBAL.jBullet.ZeroBody.setWorldTransform(Rotation);
View Full Code Here

    }
  }

  public void dragScale(float mouseX, float mouseY) {
    this.freeze();
    RigidBody body = GLOBAL.jBullet.getOver(mouseX, mouseY);

    if (body == bodies[BodyPart.BODYPART_PELVIS.ordinal()]
        || body == bodies[BodyPart.BODYPART_SPINE.ordinal()]
        || body == bodies[BodyPart.BODYPART_HEAD.ordinal()]
        || body == bodies[BodyPart.BODYPART_LEFT_UPPER_LEG.ordinal()]
View Full Code Here

    DefaultMotionState myMotionState = new DefaultMotionState(
        startTransform);
    RigidBodyConstructionInfo rbInfo = new RigidBodyConstructionInfo(mass,
        myMotionState, shape, localInertia);
    rbInfo.additionalDamping = true;
    RigidBody body = new RigidBody(rbInfo);

    ownerWorld.addRigidBody(body);

    return body;
  }
View Full Code Here

      localA.origin.set(0f, 0f, 0f);

      localB.origin.set(0f, 0f, 0f);

      CollisionShape ZeroShape = null;
      GLOBAL.jBullet.ZeroBody = new RigidBody(0.0f, null, ZeroShape);

      Transform Rotation = new Transform();
      Rotation.setIdentity();
      GLOBAL.jBullet.ZeroBody.setWorldTransform(Rotation);
View Full Code Here

    DefaultMotionState myMotionState = new DefaultMotionState(
        startTransform);
    RigidBodyConstructionInfo rbInfo = new RigidBodyConstructionInfo(mass,
        myMotionState, shape, localInertia);
    rbInfo.additionalDamping = true;
    RigidBody body = new RigidBody(rbInfo);

    ownerWorld.addRigidBody(body);

    return body;
  }
View Full Code Here


  }

  public boolean mouseOver(float mouseX, float mouseY) {
    RigidBody body = GLOBAL.jBullet.getOver(mouseX, mouseY);
    if (body == null || !this.on) {
      return false;
    } else {

      if (body != null
View Full Code Here

      Vector3f localInertia = new Vector3f(0, 0, 0);
      RigidBodyConstructionInfo rbInfo = new RigidBodyConstructionInfo(0,
          motionState, groundShape, localInertia);

      // Create the rigid body and add it to the dynamicsworld.
      RigidBody body = new RigidBody(rbInfo);
      getDynamicsWorld().addRigidBody(body);

      // Set friction.
      //body.setFriction(1);

      // Store locally.
      this.ground = body;

    }

    else {
      System.out.println("Using chess surface ground");
      BoxShape bShape = new BoxShape(new Vector3f(20, 10, 20));

      for (int i = 0; i < 20; i++) {
        for (int j = 0; j < 21; j++) {
          // Create transform to store ground's location.
          Transform transform = new Transform();
          transform.setIdentity();
          float x = -10 * 40 + i * 40;
          float z = -10 * 40 + j * 40;
          transform.origin.set(new Vector3f(x, -10, z));

          // Create new MotionState to keep track of object.
          DefaultMotionState motionState = new DefaultMotionState(
              transform);
          Vector3f localInertia = new Vector3f(0, 0, 0);
          RigidBodyConstructionInfo rbInfo = new RigidBodyConstructionInfo(
              0, motionState, bShape, localInertia);

          // Create the rigid body and add it to the dynamicsworld.
          RigidBody body = new RigidBody(rbInfo);
          getDynamicsWorld().addRigidBody(body);

          // Set friction.
          body.setFriction(1);
          body.setRestitution(1);
        }
      }
    }

    // Set gravity.
View Full Code Here

TOP

Related Classes of com.bulletphysics.dynamics.RigidBody

Copyright © 2018 www.massapicom. 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.