Package com.bulletphysics.dynamics.constraintsolver

Examples of com.bulletphysics.dynamics.constraintsolver.HingeConstraint


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


    /// ******* 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()],
View Full Code Here

            (elementSize.x * relax),
            elementSize.y,
            0);
      }
     
      HingeConstraint con = new HingeConstraint(
          env.getAgent(idCounter-2).getRigidBody(),
          env.getAgent(idCounter-1).getRigidBody(),
          pivotLeft,
          pivotRight,
          new Vector3f(0,0,1),
          new Vector3f(0,0,1));
     
      env.getDynamicsWorld().addConstraint(con,false);
    }
   
    currentAgentPosition = new Vector3f (
        currentAgentPosition.x - distanceBetweenElements,
        endElementSize.y,
        0);
   
    BridgeAgent endAgentRight = new BridgeAgent(
        idCounter++,
        env,
        env.getCollisionShapes().getQuick(0),
        currentAgentPosition,
        null,
        0);
    env.addAgent(endAgentRight);
   
    HingeConstraint con = new HingeConstraint(
        env.getAgent(idCounter-2).getRigidBody(),
        env.getAgent(idCounter-1).getRigidBody(),
        new Vector3f (
            (-elementSize.x * relax),
            elementSize.y,
 
View Full Code Here

   
   
    // (RigidBody rbA, RigidBody rbB,
    // Vector3f pivotInA, Vector3f pivotInB,
    // Vector3f axisInA, Vector3f axisInB)
    HingeConstraint gelenk1 = new HingeConstraint(
        groundAgent.getRigidBody(),
        armAgent1.getRigidBody(),
        new Vector3f (0,1,0),
        new Vector3f (5,-.5f,0),
        new Vector3f (0,0,1),
        new Vector3f (0,0,1));
   
    gelenk1.setLimit((float) Math.toRadians(20), (float) Math.toRadians(80));
   
   
    HingeConstraint gelenk2 = new HingeConstraint(
        armAgent1.getRigidBody(),
        armAgent2.getRigidBody(),
        new Vector3f (-5,0.55f,0),
        new Vector3f (-5,-0.55f,0),
        new Vector3f (0,0,1),
        new Vector3f (0,0,1));
   
    gelenk2.setLimit((float) Math.toRadians(-140), (float) Math.toRadians(-50));
       
    Point2PointConstraint gewichtBefestigung = new Point2PointConstraint(
        armAgent2.getRigidBody(),
        gewichtAgent.getRigidBody(),
        new Vector3f (5,0,0),
View Full Code Here

    //
    // set per-frame sinusoidal position targets using angular motor (hacky?)
    //
    for (int r=0; r<rigs.size(); r++) {
      for (int i=0; i<2*TestRig.NUM_LEGS; i++) {
        HingeConstraint hingeC = (HingeConstraint)(rigs.getQuick(r).getJoints()[i]);
        float curAngle = hingeC.getHingeAngle();

        float targetPercent = ((int)(time / 1000) % (int)(cyclePeriod)) / cyclePeriod;
        float targetAngle = 0.5f * (1.0f + (float)Math.sin(BulletGlobals.SIMD_2_PI * targetPercent));
        float targetLimitAngle = hingeC.getLowerLimit() + targetAngle * (hingeC.getUpperLimit() - hingeC.getLowerLimit());
        float angleError = targetLimitAngle - curAngle;
        float desiredAngularVel = 1000000.f * angleError/ms;
        hingeC.enableAngularMotor(true, desiredAngularVel, muscleStrength);
      }
    }
   
    if (dynamicsWorld != null) {
      dynamicsWorld.stepSimulation(ms / 1000000.f);
View Full Code Here

    }

    //
    // Setup the constraints
    //
    HingeConstraint hingeC;
    //ConeTwistConstraint* coneC;

    Transform localA = new Transform();
    Transform localB = new Transform();
    Transform localC = new Transform();

    for ( i=0; i<NUM_LEGS; i++)
    {
      float angle = BulletGlobals.SIMD_2_PI * i / NUM_LEGS;
      float sin = (float)Math.sin(angle);
      float cos = (float)Math.cos(angle);

      // hip joints
      localA.setIdentity();
      localB.setIdentity();
      MatrixUtil.setEulerZYX(localA.basis, 0, -angle,0);
      localA.origin.set(cos*bodySize, 0.0f, sin*bodySize);
      tmpTrans.inverse(bodies[1+2*i].getWorldTransform(new Transform()));
      tmpTrans.mul(tmpTrans, bodies[0].getWorldTransform(new Transform()));
      localB.mul(tmpTrans, localA);
      hingeC = new HingeConstraint(bodies[0], bodies[1+2*i], localA, localB);
      hingeC.setLimit(-0.75f * BulletGlobals.SIMD_2_PI * 0.125f, BulletGlobals.SIMD_2_PI * 0.0625f);
      //hingeC.setLimit(-0.1f, 0.1f);
      joints[2*i] = hingeC;
      ownerWorld.addConstraint(joints[2*i], true);

      // knee joints
      localA.setIdentity();
      localB.setIdentity();
      localC.setIdentity();
      MatrixUtil.setEulerZYX(localA.basis, 0, -angle,0);
      localA.origin.set(cos*(bodySize+legLength), 0.0f, sin*(bodySize+legLength));
      tmpTrans.inverse(bodies[1+2*i].getWorldTransform(new Transform()));
      tmpTrans.mul(tmpTrans, bodies[0].getWorldTransform(new Transform()));
      localB.mul(tmpTrans, localA) ;
      tmpTrans.inverse(bodies[2+2*i].getWorldTransform(new Transform()));
      tmpTrans.mul(tmpTrans, bodies[0].getWorldTransform(new Transform()));
      localC.mul(tmpTrans, localA) ;
      hingeC = new HingeConstraint(bodies[1+2*i], bodies[2+2*i], localB, localC);
      //hingeC.setLimit(-0.01f, 0.01f);
      hingeC.setLimit(- BulletGlobals.SIMD_2_PI * 0.0625f, 0.2f);
      joints[1+2*i] = hingeC;
      ownerWorld.addConstraint(joints[1+2*i], true);
    }
  }
View Full Code Here

      localB.setIdentity();
      MatrixUtil.setEulerZYX(localA.basis, 0, PI_2, 0);
      localA.origin.set(0.0f, 1.0f, 3.05f);
      MatrixUtil.setEulerZYX(localB.basis, 0, PI_2, 0);
      localB.origin.set(0.0f, -1.5f, -0.05f);
      liftHinge = new HingeConstraint(carChassis,liftBody, localA, localB);
      liftHinge.setLimit(-LIFT_EPS, LIFT_EPS);
      dynamicsWorld.addConstraint(liftHinge, true);

      CollisionShape forkShapeA = new BoxShape(new Vector3f(1.0f,0.1f,0.1f));
      collisionShapes.add(forkShapeA);
View Full Code Here

TOP

Related Classes of com.bulletphysics.dynamics.constraintsolver.HingeConstraint

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.