Package com.bulletphysics.linearmath

Examples of com.bulletphysics.linearmath.Transform


  public void update() {

    //this.setAtGroundHeight();

    if (this.rigidBody != null) {
      Transform myTransform = new Transform();
      myTransform = rigidBody.getMotionState().getWorldTransform(
          myTransform);
      this.currentWorldTransform = myTransform;
    }
View Full Code Here


        this.rigidBody.setCollisionShape(trimesh);

      if (this.rigidBody == null || trimesh == null)
        return;

      Transform transform = new Transform();
      MotionState motionstate = rigidBody.getMotionState();
      motionstate.getWorldTransform(transform);
      Matrix4f chairMatrix = new Matrix4f();
      transform.getMatrix(chairMatrix);
      //  LOGGER.debug("current origin"+transform.origin.toString());

      //this is overwritten when settign the chair matrix
      //transform.origin.set(this.centreOfMass.x, this.centreOfMass.y,
      //    this.centreOfMass.z);

      LOGGER.debug("delta x" + deltaCentreOfmass.x);
      LOGGER.debug("delta y" + deltaCentreOfmass.y);
      LOGGER.debug("delta z" + deltaCentreOfmass.z);

      float newX = ((chairMatrix.m00) * deltaCentreOfmass.x)
          + ((chairMatrix.m01) * deltaCentreOfmass.y)
          + ((chairMatrix.m02) * deltaCentreOfmass.z);
      float newY = (((chairMatrix.m10) * deltaCentreOfmass.x)
          + ((chairMatrix.m11) * deltaCentreOfmass.y) + ((chairMatrix.m12) * deltaCentreOfmass.z));
      float newZ = ((chairMatrix.m20) * deltaCentreOfmass.x)
          + ((chairMatrix.m21) * deltaCentreOfmass.y)
          + ((chairMatrix.m22) * deltaCentreOfmass.z);

      //these are the origin
      chairMatrix.m03 -= deltaCentreOfmass.x;//10;//deltaCentreOfmass.x;
      chairMatrix.m13 -= deltaCentreOfmass.y;//deltaCentreOfmass.y;
      chairMatrix.m23 += deltaCentreOfmass.z;//deltaCentreOfmass.z;

      //chairMatrix.m03 = this.centreOfMass.x;
      //chairMatrix.m13 = this.centreOfMass.y;
      //chairMatrix.m23 = this.centreOfMass.z;

      LOGGER.debug("delta x t " + newX);
      LOGGER.debug("delta y t " + newY);
      LOGGER.debug("delta z t " + newZ);

      transform.set(chairMatrix);
      motionstate.setWorldTransform(transform);
      rigidBody.setMotionState(motionstate);

      Vector3f center = new Vector3f();
      rigidBody.getCenterOfMassPosition(center);
View Full Code Here

    //get the chair matrix
    Matrix4f chairMatrix = new Matrix4f();
    Vec3D chairCentreOfMass = new Vec3D();
    if (GLOBAL.sketchChairs.getCurChair() != null
        && GLOBAL.sketchChairs.getCurChair().rigidBody != null) {
      Transform transform = new Transform();
      GLOBAL.sketchChairs.getCurChair().rigidBody
          .getWorldTransform(transform);
      transform.getMatrix(chairMatrix);
      chairCentreOfMass = GLOBAL.sketchChairs.getCurChair().centreOfMass;
    }

    if (GLOBAL.sketchChairs.getCurChair() != null
        && GLOBAL.sketchChairs.getCurChair().rigidBody != null
View Full Code Here

    //get the chair matrix
    Matrix4f chairMatrix = new Matrix4f();
    Vec3D chairCentreOfMass = new Vec3D();
    if (GLOBAL.sketchChairs.getCurChair() != null
        && GLOBAL.sketchChairs.getCurChair().rigidBody != null) {
      Transform transform = new Transform();
      GLOBAL.sketchChairs.getCurChair().rigidBody
          .getWorldTransform(transform);
      transform.getMatrix(chairMatrix);
      chairCentreOfMass = GLOBAL.sketchChairs.getCurChair().centreOfMass;
    }

    Plane plane = new Plane(planeIn.copy(), planeIn.normal.copy());
View Full Code Here

    CollisionShape groundShape = new StaticPlaneShape(
        new Vector3f(0, -1, 0), 1);

    collisionShapes.add(groundShape);

    Transform groundTransform = new Transform();
    groundTransform.setIdentity();
    groundTransform.origin.set(this.scaleVal(600), this.scaleVal(1600),
        this.scaleVal(600));

    CollisionShape constrainPlane = new StaticPlaneShape(new Vector3f(0, 0,
        1), 1);

    Vector3f localInertia2 = new Vector3f(0, 0, 0);
    Transform planeTransform = new Transform();
    planeTransform.setIdentity();
    planeTransform.origin.set(this.scaleVal(600), this.scaleVal(600),
        this.scaleVal(0));

    // using motionstate is recommended, it provides interpolation
    // capabilities, and only synchronizes 'active' objects
View Full Code Here

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

            Point2PointConstraint p2p = new Point2PointConstraint(
                body, localPivot);
            myWorld.addConstraint(p2p);
            pickConstraint = p2p;
View Full Code Here

    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,
View Full Code Here

    Vector3f tmp = new Vector3f();

    ///////////////////////////// SETTING THE CONSTRAINTS /////////////////////////////////////////////7777
    // Now setup the constraints
    Generic6DofConstraint joint6DOF;
    Transform localA = new Transform(), localB = new Transform();
    boolean useLinearReferenceFrameA = true;
    /// ******* SPINE HEAD ******** ///
    {
      localA.setIdentity();
      localB.setIdentity();

      localA.origin.set(0f, -0.30f * this.buildScale, 0f);

      localB.origin.set(0f, 0.14f * this.buildScale, 0f);

      joint6DOF = new Generic6DofConstraint(
          bodies[BodyPart.BODYPART_SPINE.ordinal()],
          bodies[BodyPart.BODYPART_HEAD.ordinal()], localA, localB,
          useLinearReferenceFrameA);

      //#ifdef RIGID
      //joint6DOF->setAngularLowerLimit(btVector3(-SIMD_EPSILON,-SIMD_EPSILON,-SIMD_EPSILON));
      //joint6DOF->setAngularUpperLimit(btVector3(SIMD_EPSILON,SIMD_EPSILON,SIMD_EPSILON));
      //#else

      tmp.set(-BulletGlobals.SIMD_PI * 0.2f, -BulletGlobals.FLT_EPSILON,
          -BulletGlobals.SIMD_PI * 0.1f);
      joint6DOF.setAngularLowerLimit(tmp);
      tmp.set(BulletGlobals.SIMD_PI * 0.1f, BulletGlobals.FLT_EPSILON,
          BulletGlobals.SIMD_PI * 0.10f);
      joint6DOF.setAngularUpperLimit(tmp);
      //#endif
      joints[JointType.JOINT_SPINE_HEAD.ordinal()] = joint6DOF;
      ownerWorld.addConstraint(
          joints[JointType.JOINT_SPINE_HEAD.ordinal()], true);
    }
    /// *************************** ///

    /// ******* SPINE 2D ******** ///
    {
      localA.setIdentity();
      localB.setIdentity();

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

      joint6DOF = new Generic6DofConstraint(
          bodies[BodyPart.BODYPART_SPINE.ordinal()],
          GLOBAL.jBullet.ZeroBody, localA, localB, false);
View Full Code Here

  void makeBody(DynamicsWorld ownerWorld, Vector3f positionOffset,
      float scale_ragdoll) {

    this.buildScale = scale_ragdoll;
    Transform tmpTrans = new Transform();
    Vector3f tmp = new Vector3f();
    // Setup the geometry
    shapes[BodyPart.BODYPART_PELVIS.ordinal()] = new CapsuleShape(
        scale_ragdoll * 0.11f, scale_ragdoll * 0.20f);
    shapes[BodyPart.BODYPART_SPINE.ordinal()] = new CapsuleShape(
        scale_ragdoll * 0.13f, scale_ragdoll * 0.28f);
    shapes[BodyPart.BODYPART_HEAD.ordinal()] = new CapsuleShape(
        scale_ragdoll * 0.10f, scale_ragdoll * 0.1f);
    shapes[BodyPart.BODYPART_LEFT_UPPER_LEG.ordinal()] = new CapsuleShape(
        scale_ragdoll * 0.08f, scale_ragdoll * 0.45f);
    shapes[BodyPart.BODYPART_LEFT_LOWER_LEG.ordinal()] = new CapsuleShape(
        scale_ragdoll * 0.06f, scale_ragdoll * 0.45f);
    shapes[BodyPart.BODYPART_RIGHT_UPPER_LEG.ordinal()] = new CapsuleShape(
        scale_ragdoll * 0.08f, scale_ragdoll * 0.45f);
    shapes[BodyPart.BODYPART_RIGHT_LOWER_LEG.ordinal()] = new CapsuleShape(
        scale_ragdoll * 0.06f, scale_ragdoll * 0.45f);
    if (hasArms) {
      shapes[BodyPart.BODYPART_LEFT_UPPER_ARM.ordinal()] = new CapsuleShape(
          scale_ragdoll * 0.05f, scale_ragdoll * 0.33f);
      shapes[BodyPart.BODYPART_LEFT_LOWER_ARM.ordinal()] = new CapsuleShape(
          scale_ragdoll * 0.04f, scale_ragdoll * 0.25f);
      shapes[BodyPart.BODYPART_RIGHT_UPPER_ARM.ordinal()] = new CapsuleShape(
          scale_ragdoll * 0.05f, scale_ragdoll * 0.33f);
      shapes[BodyPart.BODYPART_RIGHT_LOWER_ARM.ordinal()] = new CapsuleShape(
          scale_ragdoll * 0.04f, scale_ragdoll * 0.25f);
    }
    // Setup all the rigid bodies
    Transform offset = new Transform();
    offset.setIdentity();
    offset.origin.set(positionOffset);

    Transform transform = new Transform();
    transform.setIdentity();
    transform.origin.set(0f, scale_ragdoll * -1f, 0f);
    tmpTrans.mul(offset, transform);
    bodies[BodyPart.BODYPART_PELVIS.ordinal()] = localCreateRigidBody(3f,
        tmpTrans, shapes[BodyPart.BODYPART_PELVIS.ordinal()]);

    transform.setIdentity();
    transform.origin.set(0f, scale_ragdoll * -1.2f, 0f);
    tmpTrans.mul(offset, transform);
    bodies[BodyPart.BODYPART_SPINE.ordinal()] = localCreateRigidBody(.1f,
        tmpTrans, shapes[BodyPart.BODYPART_SPINE.ordinal()]);

    transform.setIdentity();
    transform.origin.set(0f, scale_ragdoll * -1.6f, 0f);
    tmpTrans.mul(offset, transform);
    bodies[BodyPart.BODYPART_HEAD.ordinal()] = localCreateRigidBody(.1f,
        tmpTrans, shapes[BodyPart.BODYPART_HEAD.ordinal()]);

    transform.setIdentity();
    transform.origin.set(0f, -0.7f * scale_ragdoll, 0.08f * scale_ragdoll);
    tmpTrans.mul(offset, transform);
    bodies[BodyPart.BODYPART_LEFT_UPPER_LEG.ordinal()] = localCreateRigidBody(
        .7f, tmpTrans,
        shapes[BodyPart.BODYPART_LEFT_UPPER_LEG.ordinal()]);

    transform.setIdentity();
    transform.origin.set(0f, -0.2f * scale_ragdoll, 0.06f * scale_ragdoll);
    tmpTrans.mul(offset, transform);
    bodies[BodyPart.BODYPART_LEFT_LOWER_LEG.ordinal()] = localCreateRigidBody(
        1.0f, tmpTrans,
        shapes[BodyPart.BODYPART_LEFT_LOWER_LEG.ordinal()]);

    transform.setIdentity();
    transform.origin.set(0f, -0.7f * scale_ragdoll, -0.08f * scale_ragdoll);
    tmpTrans.mul(offset, transform);
    bodies[BodyPart.BODYPART_RIGHT_UPPER_LEG.ordinal()] = localCreateRigidBody(
        .7f, tmpTrans,
        shapes[BodyPart.BODYPART_RIGHT_UPPER_LEG.ordinal()]);

    transform.setIdentity();
    transform.origin.set(0f, -0.2f * scale_ragdoll, -0.08f * scale_ragdoll);
    tmpTrans.mul(offset, transform);
    bodies[BodyPart.BODYPART_RIGHT_LOWER_LEG.ordinal()] = localCreateRigidBody(
        1.0f, tmpTrans,
        shapes[BodyPart.BODYPART_RIGHT_LOWER_LEG.ordinal()]);

    if (hasArms) {
      transform.setIdentity();
      transform.origin.set(0f, -1.75f * scale_ragdoll,
          0.35f * scale_ragdoll);
      MatrixUtil.setEulerZYX(transform.basis, BulletGlobals.SIMD_HALF_PI,
          0, 0);
      tmpTrans.mul(offset, transform);
      bodies[BodyPart.BODYPART_LEFT_UPPER_ARM.ordinal()] = localCreateRigidBody(
          1f, tmpTrans,
          shapes[BodyPart.BODYPART_LEFT_UPPER_ARM.ordinal()]);

      transform.setIdentity();
      transform.origin.set(0f, -1.75f * scale_ragdoll,
          0.7f * scale_ragdoll);
      MatrixUtil.setEulerZYX(transform.basis, BulletGlobals.SIMD_HALF_PI,
          0, 0);
      tmpTrans.mul(offset, transform);
      bodies[BodyPart.BODYPART_LEFT_LOWER_ARM.ordinal()] = localCreateRigidBody(
          1f, tmpTrans,
          shapes[BodyPart.BODYPART_LEFT_LOWER_ARM.ordinal()]);

      transform.setIdentity();
      transform.origin.set(0f, -1.75f * scale_ragdoll, -0.35f
          * scale_ragdoll);
      MatrixUtil.setEulerZYX(transform.basis,
          -BulletGlobals.SIMD_HALF_PI, 0, 0);
      tmpTrans.mul(offset, transform);
      bodies[BodyPart.BODYPART_RIGHT_UPPER_ARM.ordinal()] = localCreateRigidBody(
          1f, tmpTrans,
          shapes[BodyPart.BODYPART_RIGHT_UPPER_ARM.ordinal()]);

      transform.setIdentity();
      transform.origin.set(0f, -1.75f * scale_ragdoll, -0.7f
          * scale_ragdoll);
      MatrixUtil.setEulerZYX(transform.basis,
          -BulletGlobals.SIMD_HALF_PI, 0, 0);
      tmpTrans.mul(offset, transform);
View Full Code Here

  public void render(float renderScale, PGraphics g) {
    g.pushMatrix();
    g.scale(renderScale);
    g.noStroke();
    g.fill(SETTINGS.ERGODOLL_FILL_COLOUR);
    Transform myTransform = new Transform();

    g.sphereDetail(SETTINGS.sphere_res);
    //head

    float ratio = .9f;
View Full Code Here

TOP

Related Classes of com.bulletphysics.linearmath.Transform

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.