Package com.bulletphysics.linearmath

Examples of com.bulletphysics.linearmath.Transform


    }

    for (int i=2; i>=0; i--) {
      CollisionObject obj = dynamicsWorld.getCollisionObjectArray().getQuick(i);
      RigidBody body = RigidBody.upcast(obj);
      drawFrame(body.getWorldTransform(new Transform()));
    }
   
    renderme();

    //glFlush();
View Full Code Here


  }

  public RagDoll(DynamicsWorld ownerWorld, Vector3f positionOffset, float scale_ragdoll) {
    this.ownerWorld = ownerWorld;

    Transform tmpTrans = new Transform();
    Vector3f tmp = new Vector3f();

    // Setup the geometry
    shapes[BodyPart.BODYPART_PELVIS.ordinal()] = new CapsuleShape(scale_ragdoll * 0.15f, scale_ragdoll * 0.20f);
    shapes[BodyPart.BODYPART_SPINE.ordinal()] = new CapsuleShape(scale_ragdoll * 0.15f, scale_ragdoll * 0.28f);
    shapes[BodyPart.BODYPART_HEAD.ordinal()] = new CapsuleShape(scale_ragdoll * 0.10f, scale_ragdoll * 0.05f);
    shapes[BodyPart.BODYPART_LEFT_UPPER_LEG.ordinal()] = new CapsuleShape(scale_ragdoll * 0.07f, scale_ragdoll * 0.45f);
    shapes[BodyPart.BODYPART_LEFT_LOWER_LEG.ordinal()] = new CapsuleShape(scale_ragdoll * 0.05f, scale_ragdoll * 0.37f);
    shapes[BodyPart.BODYPART_RIGHT_UPPER_LEG.ordinal()] = new CapsuleShape(scale_ragdoll * 0.07f, scale_ragdoll * 0.45f);
    shapes[BodyPart.BODYPART_RIGHT_LOWER_LEG.ordinal()] = new CapsuleShape(scale_ragdoll * 0.05f, scale_ragdoll * 0.37f);
    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(1f, 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(-0.18f * scale_ragdoll, 0.65f * scale_ragdoll, 0f);
    tmpTrans.mul(offset, transform);
    bodies[BodyPart.BODYPART_LEFT_UPPER_LEG.ordinal()] = localCreateRigidBody(1f, tmpTrans, shapes[BodyPart.BODYPART_LEFT_UPPER_LEG.ordinal()]);

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

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

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

    transform.setIdentity();
    transform.origin.set(-0.35f * scale_ragdoll, 1.45f * scale_ragdoll, 0f);
    MatrixUtil.setEulerZYX(transform.basis, 0, 0, BulletGlobals.SIMD_HALF_PI);
    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(-0.7f * scale_ragdoll, 1.45f * scale_ragdoll, 0f);
    MatrixUtil.setEulerZYX(transform.basis, 0, 0, BulletGlobals.SIMD_HALF_PI);
    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(0.35f * scale_ragdoll, 1.45f * scale_ragdoll, 0f);
    MatrixUtil.setEulerZYX(transform.basis, 0, 0, -BulletGlobals.SIMD_HALF_PI);
    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(0.7f * scale_ragdoll, 1.45f * scale_ragdoll, 0f);
    MatrixUtil.setEulerZYX(transform.basis, 0, 0, -BulletGlobals.SIMD_HALF_PI);
    tmpTrans.mul(offset, transform);
    bodies[BodyPart.BODYPART_RIGHT_LOWER_ARM.ordinal()] = localCreateRigidBody(1f, tmpTrans, shapes[BodyPart.BODYPART_RIGHT_LOWER_ARM.ordinal()]);

    // Setup some damping on the m_bodies
    for (int i = 0; i < BodyPart.BODYPART_COUNT.ordinal(); ++i) {
      bodies[i].setDamping(0.05f, 0.85f);
      bodies[i].setDeactivationTime(0.8f);
      bodies[i].setSleepingThresholds(1.6f, 2.5f);
    }

    ///////////////////////////// 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 * scale_ragdoll, 0f);

      localB.origin.set(0f, -0.14f * scale_ragdoll, 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.3f, -BulletGlobals.FLT_EPSILON, -BulletGlobals.SIMD_PI * 0.3f);
      joint6DOF.setAngularLowerLimit(tmp);
      tmp.set(BulletGlobals.SIMD_PI * 0.5f, BulletGlobals.FLT_EPSILON, BulletGlobals.SIMD_PI * 0.3f);
      joint6DOF.setAngularUpperLimit(tmp);
      //#endif
      joints[JointType.JOINT_SPINE_HEAD.ordinal()] = joint6DOF;
      ownerWorld.addConstraint(joints[JointType.JOINT_SPINE_HEAD.ordinal()], true);
    }
    /// *************************** ///

    /// ******* LEFT SHOULDER ******** ///
    {
      localA.setIdentity();
      localB.setIdentity();

      localA.origin.set(-0.2f * scale_ragdoll, 0.15f * scale_ragdoll, 0f);

      MatrixUtil.setEulerZYX(localB.basis, BulletGlobals.SIMD_HALF_PI, 0, -BulletGlobals.SIMD_HALF_PI);
      localB.origin.set(0f, -0.18f * scale_ragdoll, 0f);

      joint6DOF = new Generic6DofConstraint(bodies[BodyPart.BODYPART_SPINE.ordinal()], bodies[BodyPart.BODYPART_LEFT_UPPER_ARM.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.8f, -BulletGlobals.FLT_EPSILON, -BulletGlobals.SIMD_PI * 0.5f);
      joint6DOF.setAngularLowerLimit(tmp);
      tmp.set(BulletGlobals.SIMD_PI * 0.8f, BulletGlobals.FLT_EPSILON, BulletGlobals.SIMD_PI * 0.5f);
      joint6DOF.setAngularUpperLimit(tmp);
      //#endif
      joints[JointType.JOINT_LEFT_SHOULDER.ordinal()] = joint6DOF;
      ownerWorld.addConstraint(joints[JointType.JOINT_LEFT_SHOULDER.ordinal()], true);
    }
    /// *************************** ///

    /// ******* RIGHT SHOULDER ******** ///
    {
      localA.setIdentity();
      localB.setIdentity();

      localA.origin.set(0.2f * scale_ragdoll, 0.15f * scale_ragdoll, 0f);
      MatrixUtil.setEulerZYX(localB.basis, 0, 0, BulletGlobals.SIMD_HALF_PI);
      localB.origin.set(0f, -0.18f * scale_ragdoll, 0f);
      joint6DOF = new Generic6DofConstraint(bodies[BodyPart.BODYPART_SPINE.ordinal()], bodies[BodyPart.BODYPART_RIGHT_UPPER_ARM.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.8f, -BulletGlobals.SIMD_EPSILON, -BulletGlobals.SIMD_PI * 0.5f);
      joint6DOF.setAngularLowerLimit(tmp);
      tmp.set(BulletGlobals.SIMD_PI * 0.8f, BulletGlobals.SIMD_EPSILON, BulletGlobals.SIMD_PI * 0.5f);
      joint6DOF.setAngularUpperLimit(tmp);
      //#endif
      joints[JointType.JOINT_RIGHT_SHOULDER.ordinal()] = joint6DOF;
      ownerWorld.addConstraint(joints[JointType.JOINT_RIGHT_SHOULDER.ordinal()], true);
    }
    /// *************************** ///

    /// ******* LEFT ELBOW ******** ///
    {
      localA.setIdentity();
      localB.setIdentity();

      localA.origin.set(0f, 0.18f * scale_ragdoll, 0f);
      localB.origin.set(0f, -0.14f * scale_ragdoll, 0f);
      joint6DOF = new Generic6DofConstraint(bodies[BodyPart.BODYPART_LEFT_UPPER_ARM.ordinal()], bodies[BodyPart.BODYPART_LEFT_LOWER_ARM.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_EPSILON, -BulletGlobals.SIMD_EPSILON, -BulletGlobals.SIMD_EPSILON);
      joint6DOF.setAngularLowerLimit(tmp);
      tmp.set(BulletGlobals.SIMD_PI * 0.7f, BulletGlobals.SIMD_EPSILON, BulletGlobals.SIMD_EPSILON);
      joint6DOF.setAngularUpperLimit(tmp);
      //#endif
      joints[JointType.JOINT_LEFT_ELBOW.ordinal()] = joint6DOF;
      ownerWorld.addConstraint(joints[JointType.JOINT_LEFT_ELBOW.ordinal()], true);
    }
    /// *************************** ///

    /// ******* RIGHT ELBOW ******** ///
    {
      localA.setIdentity();
      localB.setIdentity();

      localA.origin.set(0f, 0.18f * scale_ragdoll, 0f);
      localB.origin.set(0f, -0.14f * scale_ragdoll, 0f);
      joint6DOF = new Generic6DofConstraint(bodies[BodyPart.BODYPART_RIGHT_UPPER_ARM.ordinal()], bodies[BodyPart.BODYPART_RIGHT_LOWER_ARM.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_EPSILON, -BulletGlobals.SIMD_EPSILON, -BulletGlobals.SIMD_EPSILON);
      joint6DOF.setAngularLowerLimit(tmp);
      tmp.set(BulletGlobals.SIMD_PI * 0.7f, BulletGlobals.SIMD_EPSILON, BulletGlobals.SIMD_EPSILON);
      joint6DOF.setAngularUpperLimit(tmp);
      //#endif

      joints[JointType.JOINT_RIGHT_ELBOW.ordinal()] = joint6DOF;
      ownerWorld.addConstraint(joints[JointType.JOINT_RIGHT_ELBOW.ordinal()], true);
    }
    /// *************************** ///


    /// ******* PELVIS ******** ///
    {
      localA.setIdentity();
      localB.setIdentity();

      MatrixUtil.setEulerZYX(localA.basis, 0, BulletGlobals.SIMD_HALF_PI, 0);
      localA.origin.set(0f, 0.15f * scale_ragdoll, 0f);
      MatrixUtil.setEulerZYX(localB.basis, 0, BulletGlobals.SIMD_HALF_PI, 0);
      localB.origin.set(0f, -0.15f * scale_ragdoll, 0f);
      joint6DOF = new Generic6DofConstraint(bodies[BodyPart.BODYPART_PELVIS.ordinal()], bodies[BodyPart.BODYPART_SPINE.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.SIMD_EPSILON, -BulletGlobals.SIMD_PI * 0.3f);
      joint6DOF.setAngularLowerLimit(tmp);
      tmp.set(BulletGlobals.SIMD_PI * 0.2f, BulletGlobals.SIMD_EPSILON, BulletGlobals.SIMD_PI * 0.6f);
      joint6DOF.setAngularUpperLimit(tmp);
      //#endif
      joints[JointType.JOINT_PELVIS_SPINE.ordinal()] = joint6DOF;
      ownerWorld.addConstraint(joints[JointType.JOINT_PELVIS_SPINE.ordinal()], true);
    }
    /// *************************** ///

    /// ******* LEFT HIP ******** ///
    {
      localA.setIdentity();
      localB.setIdentity();

      localA.origin.set(-0.18f * scale_ragdoll, -0.10f * scale_ragdoll, 0f);

      localB.origin.set(0f, 0.225f * scale_ragdoll, 0f);

      joint6DOF = new Generic6DofConstraint(bodies[BodyPart.BODYPART_PELVIS.ordinal()], bodies[BodyPart.BODYPART_LEFT_UPPER_LEG.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_HALF_PI * 0.5f, -BulletGlobals.SIMD_EPSILON, -BulletGlobals.SIMD_EPSILON);
      joint6DOF.setAngularLowerLimit(tmp);
      tmp.set(BulletGlobals.SIMD_HALF_PI * 0.8f, BulletGlobals.SIMD_EPSILON, BulletGlobals.SIMD_HALF_PI * 0.6f);
      joint6DOF.setAngularUpperLimit(tmp);
      //#endif
      joints[JointType.JOINT_LEFT_HIP.ordinal()] = joint6DOF;
      ownerWorld.addConstraint(joints[JointType.JOINT_LEFT_HIP.ordinal()], true);
    }
    /// *************************** ///


    /// ******* RIGHT HIP ******** ///
    {
      localA.setIdentity();
      localB.setIdentity();

      localA.origin.set(0.18f * scale_ragdoll, -0.10f * scale_ragdoll, 0f);
      localB.origin.set(0f, 0.225f * scale_ragdoll, 0f);

      joint6DOF = new Generic6DofConstraint(bodies[BodyPart.BODYPART_PELVIS.ordinal()], bodies[BodyPart.BODYPART_RIGHT_UPPER_LEG.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_HALF_PI * 0.5f, -BulletGlobals.SIMD_EPSILON, -BulletGlobals.SIMD_HALF_PI * 0.6f);
      joint6DOF.setAngularLowerLimit(tmp);
      tmp.set(BulletGlobals.SIMD_HALF_PI * 0.8f, BulletGlobals.SIMD_EPSILON, BulletGlobals.SIMD_EPSILON);
      joint6DOF.setAngularUpperLimit(tmp);
      //#endif
      joints[JointType.JOINT_RIGHT_HIP.ordinal()] = joint6DOF;
      ownerWorld.addConstraint(joints[JointType.JOINT_RIGHT_HIP.ordinal()], true);
    }
    /// *************************** ///


    /// ******* LEFT KNEE ******** ///
    {
      localA.setIdentity();
      localB.setIdentity();

      localA.origin.set(0f, -0.225f * scale_ragdoll, 0f);
      localB.origin.set(0f, 0.185f * scale_ragdoll, 0f);
      joint6DOF = new Generic6DofConstraint(bodies[BodyPart.BODYPART_LEFT_UPPER_LEG.ordinal()], bodies[BodyPart.BODYPART_LEFT_LOWER_LEG.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_EPSILON, -BulletGlobals.SIMD_EPSILON, -BulletGlobals.SIMD_EPSILON);
      joint6DOF.setAngularLowerLimit(tmp);
      tmp.set(BulletGlobals.SIMD_PI * 0.7f, BulletGlobals.SIMD_EPSILON, BulletGlobals.SIMD_EPSILON);
      joint6DOF.setAngularUpperLimit(tmp);
      //#endif
      joints[JointType.JOINT_LEFT_KNEE.ordinal()] = joint6DOF;
      ownerWorld.addConstraint(joints[JointType.JOINT_LEFT_KNEE.ordinal()], true);
    }
    /// *************************** ///

    /// ******* RIGHT KNEE ******** ///
    {
      localA.setIdentity();
      localB.setIdentity();

      localA.origin.set(0f, -0.225f * scale_ragdoll, 0f);
      localB.origin.set(0f, 0.185f * scale_ragdoll, 0f);
      joint6DOF = new Generic6DofConstraint(bodies[BodyPart.BODYPART_RIGHT_UPPER_LEG.ordinal()], bodies[BodyPart.BODYPART_RIGHT_LOWER_LEG.ordinal()], localA, localB, useLinearReferenceFrameA);

View Full Code Here

    float distance = 0f;
    Vector3f normalInB = Stack.alloc(Vector3f.class);
    normalInB.set(0f, 0f, 0f);
    Vector3f pointOnA = Stack.alloc(Vector3f.class), pointOnB = Stack.alloc(Vector3f.class);
    Transform localTransA = Stack.alloc(input.transformA);
    Transform localTransB = Stack.alloc(input.transformB);
    Vector3f positionOffset = Stack.alloc(Vector3f.class);
    positionOffset.add(localTransA.origin, localTransB.origin);
    positionOffset.scale(0.5f);
    localTransA.origin.sub(positionOffset);
    localTransB.origin.sub(positionOffset);

    float marginA = minkowskiA.getMargin();
    float marginB = minkowskiB.getMargin();

    BulletStats.gNumGjkChecks++;

    // for CCD we don't use margins
    if (ignoreMargin) {
      marginA = 0f;
      marginB = 0f;
    }

    curIter = 0;
    int gGjkMaxIter = 1000; // this is to catch invalid input, perhaps check for #NaN?
    cachedSeparatingAxis.set(0f, 1f, 0f);

    boolean isValid = false;
    boolean checkSimplex = false;
    boolean checkPenetration = true;
    degenerateSimplex = 0;

    lastUsedMethod = -1;

    {
      float squaredDistance = BulletGlobals.SIMD_INFINITY;
      float delta = 0f;

      float margin = marginA + marginB;

      simplexSolver.reset();

      Vector3f seperatingAxisInA = Stack.alloc(Vector3f.class);
      Vector3f seperatingAxisInB = Stack.alloc(Vector3f.class);
     
      Vector3f pInA = Stack.alloc(Vector3f.class);
      Vector3f qInB = Stack.alloc(Vector3f.class);
     
      Vector3f pWorld = Stack.alloc(Vector3f.class);
      Vector3f qWorld = Stack.alloc(Vector3f.class);
      Vector3f w = Stack.alloc(Vector3f.class);
     
      Vector3f tmpPointOnA = Stack.alloc(Vector3f.class), tmpPointOnB = Stack.alloc(Vector3f.class);
      Vector3f tmpNormalInB = Stack.alloc(Vector3f.class);
     
      for (;;) //while (true)
      {
        seperatingAxisInA.negate(cachedSeparatingAxis);
        MatrixUtil.transposeTransform(seperatingAxisInA, seperatingAxisInA, input.transformA.basis);

        seperatingAxisInB.set(cachedSeparatingAxis);
        MatrixUtil.transposeTransform(seperatingAxisInB, seperatingAxisInB, input.transformB.basis);

        minkowskiA.localGetSupportingVertexWithoutMargin(seperatingAxisInA, pInA);
        minkowskiB.localGetSupportingVertexWithoutMargin(seperatingAxisInB, qInB);

        pWorld.set(pInA);
        localTransA.transform(pWorld);
       
        qWorld.set(qInB);
        localTransB.transform(qWorld);

        w.sub(pWorld, qWorld);

        delta = cachedSeparatingAxis.dot(w);
View Full Code Here

    //btScalar epsilon = btScalar(0.001);

    int numIter = 0;
    // first solution, using GJK

    Transform identityTrans = Stack.alloc(Transform.class);
    identityTrans.setIdentity();

    //result.drawCoordSystem(sphereTr);

    PointCollector pointCollector = new PointCollector();
View Full Code Here

    /**
     * Calc the transformation relative  1 to 0. Inverts matrics by transposing.
     */
    public void calc_from_homogenic(Transform trans0, Transform trans1) {
      Transform temp_trans = Stack.alloc(Transform.class);
      temp_trans.inverse(trans0);
      temp_trans.mul(trans1);

      T1to0.set(temp_trans.origin);
      R1to0.set(temp_trans.basis);

      calc_absolute_matrix();
View Full Code Here

      ConcaveShape concaveshape = (ConcaveShape) shape1;
      gimpact_vs_concave(body0, body1, shape0, concaveshape, swapped);
      return;
    }

    Transform orgtrans0 = body0.getWorldTransform(Stack.alloc(Transform.class));
    Transform orgtrans1 = body1.getWorldTransform(Stack.alloc(Transform.class));

    IntArrayList collided_results = new IntArrayList();

    gimpact_vs_shape_find_pairs(orgtrans0, orgtrans1, shape0, shape1, collided_results);

    if (collided_results.size() == 0) {
      return;
    }
    shape0.lockChildShapes();

    GIM_ShapeRetriever retriever0 = new GIM_ShapeRetriever(shape0);

    boolean child_has_transform0 = shape0.childrenHasTransform();

    Transform tmpTrans = Stack.alloc(Transform.class);

    int i = collided_results.size();

    while ((i--) != 0) {
      int child_index = collided_results.get(i);
      if (swapped) {
        triface1 = child_index;
      }
      else {
        triface0 = child_index;
      }
      CollisionShape colshape0 = retriever0.getChildShape(child_index);

      if (child_has_transform0) {
        tmpTrans.mul(orgtrans0, shape0.getChildTransform(child_index));
        body0.setWorldTransform(tmpTrans);
      }

      // collide two shapes
      if (swapped) {
View Full Code Here

    shape0.unlockChildShapes();
  }
 
  public void gimpact_vs_compoundshape(CollisionObject body0, CollisionObject body1, GImpactShapeInterface shape0, CompoundShape shape1, boolean swapped) {
    Transform orgtrans1 = body1.getWorldTransform(Stack.alloc(Transform.class));
    Transform childtrans1 = Stack.alloc(Transform.class);
    Transform tmpTrans = Stack.alloc(Transform.class);

    int i = shape1.getNumChildShapes();
    while ((i--) != 0) {
      CollisionShape colshape1 = shape1.getChildShape(i);
      childtrans1.mul(orgtrans1, shape1.getChildTransform(i, tmpTrans));
View Full Code Here

    tricallback.gimpactshape0 = shape0;
    tricallback.swapped = swapped;
    tricallback.margin = shape1.getMargin();

    // getting the trimesh AABB
    Transform gimpactInConcaveSpace = Stack.alloc(Transform.class);

    body1.getWorldTransform(gimpactInConcaveSpace);
    gimpactInConcaveSpace.inverse();
    gimpactInConcaveSpace.mul(body0.getWorldTransform(Stack.alloc(Transform.class)));

    Vector3f minAABB = Stack.alloc(Vector3f.class), maxAABB = Stack.alloc(Vector3f.class);
    shape0.getAabb(gimpactInConcaveSpace, minAABB, maxAABB);

    shape1.processAllTriangles(tricallback, minAABB, maxAABB);
View Full Code Here

  */
 
  void collide_sat_triangles(CollisionObject body0, CollisionObject body1, GImpactMeshShapePart shape0, GImpactMeshShapePart shape1, PairSet pairs, int pair_count) {
    Vector3f tmp = Stack.alloc(Vector3f.class);

    Transform orgtrans0 = body0.getWorldTransform(Stack.alloc(Transform.class));
    Transform orgtrans1 = body1.getWorldTransform(Stack.alloc(Transform.class));

    PrimitiveTriangle ptri0 = Stack.alloc(PrimitiveTriangle.class);
    PrimitiveTriangle ptri1 = Stack.alloc(PrimitiveTriangle.class);
    TriangleContact contact_data = Stack.alloc(TriangleContact.class);

View Full Code Here

  protected void gimpact_vs_shape_find_pairs(Transform trans0, Transform trans1, GImpactShapeInterface shape0, CollisionShape shape1, IntArrayList collided_primitives) {
    AABB boxshape = Stack.alloc(AABB.class);

    if (shape0.hasBoxSet()) {
      Transform trans1to0 = Stack.alloc(Transform.class);
      trans1to0.inverse(trans0);
      trans1to0.mul(trans1);

      shape1.getAabb(trans1to0, boxshape.min, boxshape.max);

      shape0.getBoxSet().boxQuery(boxshape, collided_primitives);
    }
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.