Package javax.vecmath

Examples of javax.vecmath.Vector3f


  }

  private void buildLimbConstraints() {

    Vector3f tmp = new Vector3f();

    for (int i = 0; i < JointType.JOINT_COUNT.ordinal(); ++i) {
      if (joints[i] != null) {
        ownerWorld.removeConstraint(joints[i]);
      }
    }

    ///////////////////////////// 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,
              -(limbLengths[BodyPart.BODYPART_SPINE.ordinal()] + limbLengths[BodyPart.BODYPART_NECK
                  .ordinal()]), 0f);

      localB.origin.set(0f,
          limbLengths[BodyPart.BODYPART_HEAD.ordinal()], 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_NECK_HEAD.ordinal()] = joint6DOF;
      ownerWorld.addConstraint(
          joints[JointType.JOINT_NECK_HEAD.ordinal()], true);

    }
    /// *************************** ///

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

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

      joint6DOF.setLimit(0, 1, 0); // Disable X axis limits
      joint6DOF.setLimit(1, 1, 0); // Disable Y axis limits
      joint6DOF.setLimit(2, 0, 0); // Set the Z axis to always be equal to zero
      joint6DOF.setLimit(3, 0, 0); // Disable X rotational axes
      joint6DOF.setLimit(4, 0, 0); // Disable Y rotational axes
      joint6DOF.setLimit(5, 1, 0); // Uncap the rotational axes
      //#endif
      joints[JointType.JOINT_PLANE.ordinal()] = joint6DOF;
      ownerWorld.addConstraint(joints[JointType.JOINT_PLANE.ordinal()],
          true);

      bodies[BodyPart.BODYPART_SPINE.ordinal()]
          .setAngularFactor(new Vector3f(0, 0, 1));

    }
    /// *************************** ///

    if (hasArms) {

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

       
       
        localA.origin.set(0f,
            -limbLengths[BodyPart.BODYPART_SPINE.ordinal()],
            limbWidths[BodyPart.BODYPART_SPINE.ordinal()] * 1.2f); //joint on spine
        MatrixUtil.setEulerZYX(localB.basis, BulletGlobals.SIMD_PI, BulletGlobals.SIMD_PI, BulletGlobals.SIMD_PI);
        localB.origin
            .set(0f, limbLengths[BodyPart.BODYPART_LEFT_UPPER_ARM
                .ordinal()], 0f); // upper arm

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

           
        tmp.set(-BulletGlobals.SIMD_EPSILON,
            -BulletGlobals.SIMD_EPSILON,
            BulletGlobals.SIMD_HALF_PI * 0.5f);
        joint6DOF.setAngularLowerLimit(tmp);
        tmp.set(BulletGlobals.SIMD_HALF_PI * 0.6f,
            BulletGlobals.SIMD_EPSILON,
            -BulletGlobals.SIMD_HALF_PI * 1.3f); //bend foward
        joint6DOF.setAngularUpperLimit(tmp);

       
        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(0f,
            -limbLengths[BodyPart.BODYPART_SPINE.ordinal()],
            -limbWidths[BodyPart.BODYPART_SPINE.ordinal()] * 1.2f); //joint on spine
        //MatrixUtil.setEulerZYX(localB.basis,BulletGlobals.SIMD_PI, BulletGlobals.SIMD_PI, BulletGlobals.SIMD_PI);
        localB.origin
            .set(0f, limbLengths[BodyPart.BODYPART_RIGHT_UPPER_ARM
                .ordinal()], 0f); // upper arm
        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_EPSILON,
            -BulletGlobals.SIMD_EPSILON,
            BulletGlobals.SIMD_HALF_PI * 0.5f);
        joint6DOF.setAngularLowerLimit(tmp);
        tmp.set(BulletGlobals.SIMD_HALF_PI * 0.6f,
            BulletGlobals.SIMD_EPSILON,
            -BulletGlobals.SIMD_HALF_PI * 1.3f); //bend foward
        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, -limbLengths[BodyPart.BODYPART_LEFT_UPPER_ARM
                .ordinal()], 0f); // upper arm
        localB.origin
            .set(0f, -limbLengths[BodyPart.BODYPART_LEFT_LOWER_ARM
                .ordinal()], 0f); // lower arm
        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_HALF_PI * 0.5f);
        joint6DOF.setAngularLowerLimit(tmp);
        tmp.set(BulletGlobals.SIMD_HALF_PI * 0.6f,
            BulletGlobals.SIMD_EPSILON,
            BulletGlobals.SIMD_HALF_PI * 1.3f); //bend foward
        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, -limbLengths[BodyPart.BODYPART_LEFT_UPPER_ARM
                .ordinal()], 0f); // upper arm
        localB.origin
            .set(0f, -limbLengths[BodyPart.BODYPART_LEFT_LOWER_ARM
                .ordinal()], 0f); // lower arm
        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_HALF_PI * 0.5f);
        joint6DOF.setAngularLowerLimit(tmp);
        tmp.set(BulletGlobals.SIMD_HALF_PI * 0.6f,
            BulletGlobals.SIMD_EPSILON,
            BulletGlobals.SIMD_HALF_PI * 1.3f); //bend foward
        joint6DOF.setAngularUpperLimit(tmp);
        //#endif

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

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

        localA.origin
            .set(0f, limbLengths[BodyPart.BODYPART_RIGHT_LOWER_ARM
                .ordinal()], 0f); // upper arm
        localB.origin.set(0f,
            -limbLengths[BodyPart.BODYPART_RIGHT_HAND.ordinal()],
            0f); // lower arm
        joint6DOF = new Generic6DofConstraint(
            bodies[BodyPart.BODYPART_RIGHT_LOWER_ARM.ordinal()],
            bodies[BodyPart.BODYPART_RIGHT_HAND.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_WRIST.ordinal()] = joint6DOF;
        ownerWorld.addConstraint(
            joints[JointType.JOINT_RIGHT_WRIST.ordinal()], true);
      }
      /// *************************** ///

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

        localA.origin
            .set(0f, limbLengths[BodyPart.BODYPART_LEFT_LOWER_ARM
                .ordinal()], 0f); // upper arm
        localB.origin
            .set(0f, -limbLengths[BodyPart.BODYPART_LEFT_HAND
                .ordinal()], 0f); // lower arm
        joint6DOF = new Generic6DofConstraint(
            bodies[BodyPart.BODYPART_LEFT_LOWER_ARM.ordinal()],
            bodies[BodyPart.BODYPART_LEFT_HAND.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_WRIST.ordinal()] = joint6DOF;
        ownerWorld.addConstraint(
            joints[JointType.JOINT_LEFT_WRIST.ordinal()], true);
      }
      /// *************************** ///
      
      
    }

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

      localA.origin.set(0f,
          limbLengths[BodyPart.BODYPART_PELVIS.ordinal()],
          limbWidths[BodyPart.BODYPART_PELVIS.ordinal()]);

      localB.origin
          .set(0f, -limbLengths[BodyPart.BODYPART_LEFT_UPPER_LEG
              .ordinal()] * .6f, 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_EPSILON,
          -BulletGlobals.SIMD_EPSILON,
          -BulletGlobals.SIMD_HALF_PI * 0.5f);
      joint6DOF.setAngularLowerLimit(tmp);
      tmp.set(BulletGlobals.SIMD_HALF_PI * 0.6f,
          BulletGlobals.SIMD_EPSILON,
          BulletGlobals.SIMD_HALF_PI * 1.3f); //bend foward
      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(0f,
          limbLengths[BodyPart.BODYPART_PELVIS.ordinal()],
          -limbWidths[BodyPart.BODYPART_PELVIS.ordinal()]);

      localB.origin
          .set(0f, -limbLengths[BodyPart.BODYPART_RIGHT_UPPER_LEG
              .ordinal()] * .6f, 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.6f,
          -BulletGlobals.SIMD_EPSILON,
          -BulletGlobals.SIMD_HALF_PI * 0.5f);
      joint6DOF.setAngularLowerLimit(tmp);
      tmp.set(BulletGlobals.SIMD_EPSILON, BulletGlobals.SIMD_EPSILON,
          BulletGlobals.SIMD_HALF_PI * 1.3f);
      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, limbLengths[BodyPart.BODYPART_LEFT_UPPER_LEG
              .ordinal()], 0f);
      localB.origin.set(0f,
          -limbLengths[BodyPart.BODYPART_LEFT_LOWER_LEG.ordinal()],
          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_PI * .9f);
      joint6DOF.setAngularLowerLimit(tmp);
      tmp.set(BulletGlobals.SIMD_EPSILON, 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();
      HingeConstraint jointHinge = null;
      localA.origin.set(0f,
          limbLengths[BodyPart.BODYPART_RIGHT_UPPER_LEG.ordinal()],
          0f);
      localB.origin.set(0f,
          -limbLengths[BodyPart.BODYPART_RIGHT_LOWER_LEG.ordinal()],
          0f);
      joint6DOF = new Generic6DofConstraint(
          bodies[BodyPart.BODYPART_RIGHT_UPPER_LEG.ordinal()],
          bodies[BodyPart.BODYPART_RIGHT_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_PI * .9f);
      joint6DOF.setAngularLowerLimit(tmp);
      tmp.set(BulletGlobals.SIMD_EPSILON, BulletGlobals.SIMD_EPSILON,
          BulletGlobals.SIMD_EPSILON);
      joint6DOF.setAngularUpperLimit(tmp);
      //#endif
      joints[JointType.JOINT_RIGHT_KNEE.ordinal()] = joint6DOF;
      ownerWorld.addConstraint(
          joints[JointType.JOINT_RIGHT_KNEE.ordinal()], true);
    }
    /// *************************** ///

    /// ******* RIGHT FOOT ******** ///
    {
      localA.setIdentity();
      localB.setIdentity();
      HingeConstraint jointHinge = null;
      localA.origin.set(0f,
          limbLengths[BodyPart.BODYPART_RIGHT_LOWER_LEG.ordinal()],
          0f);
      localB.origin.set(0f,
          -limbLengths[BodyPart.BODYPART_RIGHT_FOOT.ordinal()] * .5f,
          0f);
      joint6DOF = new Generic6DofConstraint(
          bodies[BodyPart.BODYPART_RIGHT_LOWER_LEG.ordinal()],
          bodies[BodyPart.BODYPART_RIGHT_FOOT.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_EPSILON, BulletGlobals.SIMD_EPSILON,
          BulletGlobals.SIMD_PI * .7f);
      joint6DOF.setAngularUpperLimit(tmp);
      //#endif
      joints[JointType.JOINT_RIGHT_ANKLE.ordinal()] = joint6DOF;
      ownerWorld.addConstraint(
          joints[JointType.JOINT_RIGHT_ANKLE.ordinal()], true);
    }
    /// *************************** ///

    /// ******* LEFT FOOT ******** ///
    {
      localA.setIdentity();
      localB.setIdentity();
      HingeConstraint jointHinge = null;
      localA.origin
          .set(0f, limbLengths[BodyPart.BODYPART_LEFT_LOWER_LEG
              .ordinal()], 0f);
      localB.origin.set(0f,
          -limbLengths[BodyPart.BODYPART_LEFT_FOOT.ordinal()] * .5f,
          0f);
      joint6DOF = new Generic6DofConstraint(
          bodies[BodyPart.BODYPART_LEFT_LOWER_LEG.ordinal()],
          bodies[BodyPart.BODYPART_LEFT_FOOT.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_EPSILON, BulletGlobals.SIMD_EPSILON,
          BulletGlobals.SIMD_PI * .7f);
      joint6DOF.setAngularUpperLimit(tmp);
      //#endif
      joints[JointType.JOINT_LEFT_ANKLE.ordinal()] = joint6DOF;
      ownerWorld.addConstraint(
View Full Code Here


     * the Z rotational axes //#endif
     */
    // GLOBAL.jBullet.myWorld.addConstraint(this.chairCentreConstraint,
    // true);
    // this.rigidBody.setAngularFactor(.001f);
    this.rigidBody.setAngularFactor(new Vector3f(0, 0, 1));

    // GLOBAL.jBullet.myWorld
    // EnableVelocityXYZ(body,true,true,false);
    // EnableRotationXYZ(body,false,false,true);

View Full Code Here

   * Set the current designs position as the start position to start from after rewinding.
   */
  public void setCurrentPositionAsStartTransform() {
    Transform startTransform = new Transform();

    Vector3f localInertia = new Vector3f(0, 0, 0);
    float mass = this.getMass();
    trimesh.calculateLocalInertia(mass, localInertia);
    startTransform.origin.set(
        this.rigidBody.getMotionState().getWorldTransform(
            currentWorldTransform).origin.x,
View Full Code Here

    float scaleBy = 1f / GLOBAL.jBullet.getScale();
    Transform myTransform = new Transform();
    myTransform = rigidBody.getMotionState().getWorldTransform(myTransform);

    Vector3f center = new Vector3f();
    rigidBody.getCenterOfMassPosition(center);

    return new Vec3D(center.x, center.y, center.z);
  }
View Full Code Here

    // if(indexVertexArrays.getIndexedMeshArray().size() < 2)
    // return;

    trimesh = new GImpactMeshShape(indexVertexArrays);
    trimesh.setLocalScaling(new Vector3f(1f, 1f, 1f));
    trimesh.updateBound();

    if (trimesh == null)
      return;

    CollisionDispatcher dispatcher = (CollisionDispatcher) GLOBAL.jBullet.myWorld
        .getDispatcher();
    if (dispatcher == null)
      return;

    GImpactCollisionAlgorithm.registerAlgorithm(dispatcher);
    Transform startTransform = new Transform();

    Vector3f localInertia = new Vector3f(0, 0, 0);
    float mass = this.getMass();
    trimesh.calculateLocalInertia(mass, localInertia);
    startTransform.origin.set(centreOfMass.x, centreOfMass.y,
        centreOfMass.z);
    DefaultMotionState myMotionState = new DefaultMotionState(
View Full Code Here

      float scaleBy = 1f / GLOBAL.jBullet.getScale();
      Transform myTransform = new Transform();
      myTransform = rigidBody.getMotionState().getWorldTransform(
          myTransform);

      Vector3f center = new Vector3f();
      rigidBody.getCenterOfMassPosition(center);

      g.translate(myTransform.origin.x * scaleBy,
          (myTransform.origin.y * scaleBy),
          (myTransform.origin.z * scaleBy));
 
View Full Code Here

  /**
   * Move the design by a delta amount inside the physics engine.
   * @param offset
   */
  public void drag(Vec3D offset) {
    Vector3f offset3f = new Vector3f(offset.x, offset.y, offset.z);
    offset3f.scale(GLOBAL.jBullet.scale);
    this.rigidBody.translate(offset3f);
    GLOBAL.jBullet.update();
    this.setCurrentPositionAsStartTransform();
    //this.startWorldTransform.origin.set(offset3f);
  }
View Full Code Here

      float scaleBy = 1f / GLOBAL.jBullet.getScale();
      Transform myTransform = new Transform();
      myTransform = rigidBody.getMotionState().getWorldTransform(
          myTransform);

      Vector3f center = new Vector3f();
      rigidBody.getCenterOfMassPosition(center);
      LOGGER.debug("getCenterOfMassPosition" + center);
      /*
      p.addSelf(new Vec3D(center.x * scaleBy,
              (center.y * scaleBy), center.z
View Full Code Here

        VertexData vd = indexVertexArrays
            .getLockedReadOnlyVertexIndexBase(i);

        for (int t = 0; t < vd.getIndexCount() / 3; t++) {

          Vector3f[] triangle = new Vector3f[] { new Vector3f(),
              new Vector3f(), new Vector3f() };
          Vector3f scale = new Vector3f(1 / GLOBAL.jBullet.scale, -1
              / GLOBAL.jBullet.scale, 1 / GLOBAL.jBullet.scale);
          vd.getTriangle(t * 3, scale, triangle);
          g.stroke(255, 0, 0);
          g.beginShape();
          g.vertex(triangle[0].x, triangle[0].y, triangle[0].z);
View Full Code Here

        VertexData vd = indexVertexArrays
            .getLockedReadOnlyVertexIndexBase(i);

        for (int t = 0; t < vd.getIndexCount() / 3; t++) {

          Vector3f[] triangle = new Vector3f[] { new Vector3f(),
              new Vector3f(), new Vector3f() };
          Vector3f scale = new Vector3f(1 / GLOBAL.jBullet.scale, -1
              / GLOBAL.jBullet.scale, 1 / GLOBAL.jBullet.scale);
          vd.getTriangle(t * 3, scale, triangle);

          float screenX = g.screenX(triangle[0].x, triangle[0].y,
              triangle[0].z);
View Full Code Here

TOP

Related Classes of javax.vecmath.Vector3f

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.