Package javax.vecmath

Examples of javax.vecmath.Vector3f


  }

  public void update() {
    //Vector3f gravity = null;
    //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


  }

  private void buildLimbConstraints() {

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

      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);
    }
    /// *************************** ///

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

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

        MatrixUtil.setEulerZYX(localB.basis,
            BulletGlobals.SIMD_HALF_PI, 0,
            -BulletGlobals.SIMD_HALF_PI);
        localB.origin.set(0f, 0.18f * this.buildScale, 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(0f, 0.15f * -this.buildScale, -0.2f
            * this.buildScale);
        MatrixUtil.setEulerZYX(localB.basis, 0, 0,
            BulletGlobals.SIMD_HALF_PI);
        localB.origin.set(0f, 0.18f * this.buildScale, 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 * this.buildScale, 0f);
        localB.origin.set(0f, -0.14f * this.buildScale, 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 * this.buildScale, 0f);
        localB.origin.set(0f, -0.14f * this.buildScale, 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 * this.buildScale, 0f);
      MatrixUtil.setEulerZYX(localB.basis, 0, BulletGlobals.SIMD_HALF_PI,
          0);
      localB.origin.set(0f, 0.15f * this.buildScale, 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);
    }
    /// *************************** ///

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

      localA.origin.set(0f, 0.10f * this.buildScale,
          0.08f * this.buildScale);

      localB.origin.set(0f, -0.225f * this.buildScale, 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, 0.10f * this.buildScale, -0.08f
          * this.buildScale);
      localB.origin.set(0f, -0.225f * this.buildScale, 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, 0.265f * this.buildScale, 0f);
      localB.origin.set(0f, -0.225f * this.buildScale, 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, 0.265f * this.buildScale, 0f);
      localB.origin.set(0f, -0.225f * this.buildScale, 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(
View Full Code Here

  private RigidBody localCreateRigidBody(float mass,
      Transform startTransform, CollisionShape shape) {
    boolean isDynamic = (mass != 0f);

    Vector3f localInertia = new Vector3f();
    localInertia.set(0f, 0f, 0f);
    if (isDynamic) {
      shape.calculateLocalInertia(mass, localInertia);
    }

    DefaultMotionState myMotionState = new DefaultMotionState(
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);
 
View Full Code Here

  private RigidBody localCreateRigidBody(float mass,
      Transform startTransform, CollisionShape shape) {
    boolean isDynamic = (mass != 0f);

    Vector3f localInertia = new Vector3f();
    localInertia.set(0f, 0f, 0f);
    if (isDynamic) {
      shape.calculateLocalInertia(mass, localInertia);
    }

    DefaultMotionState myMotionState = new DefaultMotionState(
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
    int partNum = 0;
    this.buildProportions();

    // Setup some damping on the m_bodies
View Full Code Here

  }

  public void printOrigins() {

    Transform transform = new Transform();
    Vector3f origin = new Vector3f();
    Matrix4f matrix = new Matrix4f();

    bodies[BodyPart.BODYPART_HEAD.ordinal()].getMotionState()
        .getWorldTransform(transform);
    transform.getMatrix(matrix);
View Full Code Here

   
   

    makeBody(this.ownerWorld, this.startPos, this.scale);
    float footWidth = limbLengths[BodyPart.BODYPART_RIGHT_FOOT.ordinal()];
    Vector3f out = new Vector3f();
    joints[JointType.JOINT_RIGHT_ANKLE.ordinal()].getRigidBodyB()
        .getCenterOfMassPosition(out);

    this.translate((x - out.x) + (footWidth * 2), y - out.y, z - out.z);

View Full Code Here

  }

  void translate(float x, float y, float z) {

    Vector3f offset3f = new Vector3f(x, y, z);

    // Setup some damping on the m_bodies
    for (int i = 0; i < BodyPart.BODYPART_COUNT.ordinal(); ++i) {
      if (bodies[i] != null) {
        bodies[i].translate(offset3f);
        bodies[i].clearForces();
        bodies[i].setAngularVelocity(new Vector3f(0, 0, 0));
        bodies[i].setLinearVelocity(new Vector3f(0, 0, 0));

      }
    }

    GLOBAL.jBullet.update();
View Full Code Here

    float maxX = -1;

    for (int i = 0; i < this.getPath().size(); i++) {
      SketchPoint v = (SketchPoint) this.getPath().get(i);

      Vector3f vecWorld = new Vector3f(
          v.x
              / getParentSketch().getSketchGlobals().physicsEngineScale,
          v.y
              / getParentSketch().getSketchGlobals().physicsEngineScale,
          0);
      currentWorldTransform.transform(vecWorld);
      vecWorld.x -= currentWorldTransform.origin.x;
      vecWorld.scale(getParentSketch().getSketchGlobals().physicsEngineScale);

      if (i == 0 || vecWorld.x > maxX)
        maxX = vecWorld.x;
    }
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.