Package com.bulletphysics.collision.shapes

Examples of com.bulletphysics.collision.shapes.CapsuleShape


    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();
View Full Code Here


    float ratio = .9f;
    //shapes[BodyPart.BODYPART_HEAD.ordinal()].
    //HEAD//
    g.pushMatrix();
    CapsuleShape capsule = (CapsuleShape) shapes[BodyPart.BODYPART_HEAD
        .ordinal()];
    float radius = capsule.getRadius();
    float halfHeight = capsule.getHalfHeight();
    myTransform = bodies[BodyPart.BODYPART_HEAD.ordinal()].getMotionState()
        .getWorldTransform(myTransform);
    //g.fill(0);
    applyMatrix(myTransform, g);

    if (this.scaling) {
      g.pushMatrix();
      g.scale(GLOBAL.jBullet.getScale());
      g.fill(SETTINGS.person_height_text_fill_colour);
      g.text((int) (this.scale * 6.9f) + " cm", -50, (-radius - 2)
          * (1 / GLOBAL.jBullet.getScale()));
      g.fill(SETTINGS.ERGODOLL_FILL_COLOUR);
      g.popMatrix();

    }

    functions.cylinder(radius, radius * ratio, halfHeight * 2,
        SETTINGS.cylinder_res, g);

    g.translate(0, halfHeight, 0);
    g.sphere(radius * ratio); //jaw
    g.translate(0, -halfHeight * 2, 0);
    g.sphere(radius);

    this.renderFace(g);
    g.popMatrix();

    //gl.drawCylinder(radius, halfHeight, upAxis);

    ratio = .8f;
    //SPINE
    g.pushMatrix();
    capsule = (CapsuleShape) shapes[BodyPart.BODYPART_SPINE.ordinal()];
    radius = capsule.getRadius();
    halfHeight = capsule.getHalfHeight();
    myTransform = bodies[BodyPart.BODYPART_SPINE.ordinal()]
        .getMotionState().getWorldTransform(myTransform);
    applyMatrix(myTransform, g);
    functions.cylinder(radius, radius * ratio, halfHeight * 2,
        SETTINGS.cylinder_res, g);
    g.translate(0, halfHeight, 0);
    g.sphere(radius * ratio);
    g.translate(0, -halfHeight * 2, 0);
    g.sphere(radius); // top
    g.popMatrix();

    //Pelvis
    ratio = .7f;
    g.pushMatrix();
    capsule = (CapsuleShape) shapes[BodyPart.BODYPART_PELVIS.ordinal()];
    radius = capsule.getRadius();
    halfHeight = capsule.getHalfHeight();
    myTransform = bodies[BodyPart.BODYPART_PELVIS.ordinal()]
        .getMotionState().getWorldTransform(myTransform);
    applyMatrix(myTransform, g);
    functions.cylinder(radius * ratio, radius, halfHeight * 2,
        SETTINGS.cylinder_res, g);
    g.translate(0, halfHeight, 0);
    g.sphere(radius);
    g.translate(0, -halfHeight * 2, 0);
    g.sphere(radius * ratio); // top
    g.popMatrix();

    //leg
    ratio = .7f;

    g.pushMatrix();
    capsule = (CapsuleShape) shapes[BodyPart.BODYPART_LEFT_UPPER_LEG
        .ordinal()];
    radius = capsule.getRadius();
    halfHeight = capsule.getHalfHeight();
    myTransform = bodies[BodyPart.BODYPART_LEFT_UPPER_LEG.ordinal()]
        .getMotionState().getWorldTransform(myTransform);
    applyMatrix(myTransform, g);
    functions.cylinder(radius, radius * ratio, halfHeight * 2,
        SETTINGS.cylinder_res, g);
    g.translate(0, -halfHeight, 0);
    g.sphere(radius);
    g.popMatrix();

    g.pushMatrix();
    capsule = (CapsuleShape) shapes[BodyPart.BODYPART_RIGHT_UPPER_LEG
        .ordinal()];
    radius = capsule.getRadius();
    halfHeight = capsule.getHalfHeight();
    myTransform = bodies[BodyPart.BODYPART_RIGHT_UPPER_LEG.ordinal()]
        .getMotionState().getWorldTransform(myTransform);
    applyMatrix(myTransform, g);
    functions.cylinder(radius, radius * ratio, halfHeight * 2,
        SETTINGS.cylinder_res, g);
    g.translate(0, -halfHeight, 0);
    g.sphere(radius);
    g.popMatrix();

    //LOWER LEFT LEG
    g.pushMatrix();
    capsule = (CapsuleShape) shapes[BodyPart.BODYPART_LEFT_LOWER_LEG
        .ordinal()];
    radius = capsule.getRadius();
    halfHeight = capsule.getHalfHeight();
    myTransform = bodies[BodyPart.BODYPART_LEFT_LOWER_LEG.ordinal()]
        .getMotionState().getWorldTransform(myTransform);
    applyMatrix(myTransform, g);
    functions.cylinder(radius, radius * .5f, halfHeight * 2,
        SETTINGS.cylinder_res, g);
    g.translate(0, halfHeight, 0);
    g.sphere(radius * 0.7f); //jaw

    g.translate(0, -halfHeight * 2, 0);
    g.sphere(radius * 1.1f);
    g.popMatrix();

    //LOWER RIGHT LEG
    g.pushMatrix();
    capsule = (CapsuleShape) shapes[BodyPart.BODYPART_RIGHT_LOWER_LEG
        .ordinal()];
    radius = capsule.getRadius();
    halfHeight = capsule.getHalfHeight();
    myTransform = bodies[BodyPart.BODYPART_RIGHT_LOWER_LEG.ordinal()]
        .getMotionState().getWorldTransform(myTransform);
    applyMatrix(myTransform, g);
    functions.cylinder(radius, radius * .5f, halfHeight * 2,
        SETTINGS.cylinder_res, g);
    g.translate(0, halfHeight, 0);
    g.sphere(radius * 0.7f); //jaw
    g.translate(0, -halfHeight * 2, 0);
    g.sphere(radius * 1.1f);
    g.popMatrix();

    if (this.hasArms) {

      //LOWER RIGHT LEG
      g.pushMatrix();
      capsule = (CapsuleShape) shapes[BodyPart.BODYPART_RIGHT_UPPER_ARM
          .ordinal()];
      radius = capsule.getRadius();
      halfHeight = capsule.getHalfHeight();
      myTransform = bodies[BodyPart.BODYPART_RIGHT_UPPER_ARM.ordinal()]
          .getMotionState().getWorldTransform(myTransform);
      applyMatrix(myTransform, g);
      functions.cylinder(radius, radius * .5f, halfHeight * 2,
          SETTINGS.cylinder_res, g);
      g.translate(0, halfHeight, 0);
      g.sphere(radius * 0.7f); //jaw
      g.translate(0, -halfHeight * 2, 0);
      g.sphere(radius * 1.1f);
      g.popMatrix();

      //LOWER RIGHT LEG
      g.pushMatrix();
      capsule = (CapsuleShape) shapes[BodyPart.BODYPART_LEFT_UPPER_ARM
          .ordinal()];
      radius = capsule.getRadius();
      halfHeight = capsule.getHalfHeight();
      myTransform = bodies[BodyPart.BODYPART_LEFT_UPPER_ARM.ordinal()]
          .getMotionState().getWorldTransform(myTransform);
      applyMatrix(myTransform, g);
      functions.cylinder(radius, radius * .5f, halfHeight * 2,
          SETTINGS.cylinder_res, g);
      g.translate(0, halfHeight, 0);
      g.sphere(radius * 0.7f); //jaw
      g.translate(0, -halfHeight * 2, 0);
      g.sphere(radius * 1.1f);
      g.popMatrix();

      //LOWER RIGHT LEG
      g.pushMatrix();
      capsule = (CapsuleShape) shapes[BodyPart.BODYPART_RIGHT_LOWER_ARM
          .ordinal()];
      radius = capsule.getRadius();
      halfHeight = capsule.getHalfHeight();
      myTransform = bodies[BodyPart.BODYPART_RIGHT_LOWER_ARM.ordinal()]
          .getMotionState().getWorldTransform(myTransform);
      applyMatrix(myTransform, g);
      functions.cylinder(radius, radius * .5f, halfHeight * 2,
          SETTINGS.cylinder_res, g);
      g.translate(0, halfHeight, 0);
      g.sphere(radius * 0.7f); //jaw
      g.translate(0, -halfHeight * 2, 0);
      g.sphere(radius * 1.1f);
      g.popMatrix();

      //LOWER RIGHT LEG
      g.pushMatrix();
      capsule = (CapsuleShape) shapes[BodyPart.BODYPART_LEFT_LOWER_ARM
          .ordinal()];
      radius = capsule.getRadius();
      halfHeight = capsule.getHalfHeight();
      myTransform = bodies[BodyPart.BODYPART_LEFT_LOWER_ARM.ordinal()]
          .getMotionState().getWorldTransform(myTransform);
      applyMatrix(myTransform, g);
      functions.cylinder(radius, radius * .5f, halfHeight * 2,
          SETTINGS.cylinder_res, g);
View Full Code Here

    int partNum = 0;
    this.buildProportions();

    // Setup some damping on the m_bodies
    for (int i = 0; i < BodyPart.BODYPART_COUNT.ordinal(); ++i) {
      shapes[i] = new CapsuleShape(limbWidths[i], limbLengths[i]);
    }

    // Setup all the rigid bodies
    Transform offset = new Transform();
    offset.setIdentity();
View Full Code Here

   
    //shapes[BodyPart.BODYPART_HEAD.ordinal()].
    //HEAD//_________________________________________________________________________
    ratio = 0.9f;
    g.pushMatrix();
    CapsuleShape capsule = (CapsuleShape) shapes[BodyPart.BODYPART_HEAD
        .ordinal()];
    float radius = capsule.getRadius();
    float halfHeight = capsule.getHalfHeight();
   
   
    if (GLOBAL.performanceMode)
      halfHeight = halfHeight * 1.75f;

    myTransform = bodies[BodyPart.BODYPART_HEAD.ordinal()].getMotionState()
        .getWorldTransform(myTransform);
    //g.fill(0);
    applyMatrix(myTransform, g);

    if (this.scaling) {
      g.pushMatrix();
      g.scale(GLOBAL.jBullet.getScale());
      g.fill(SETTINGS.person_height_text_fill_colour);
      g.text((int) (this.scale * 177f) + " cm", -50, (-radius - 2)
          * (1 / GLOBAL.jBullet.getScale()));
      g.fill(SETTINGS.ERGODOLL_FILL_COLOUR);
      g.popMatrix();

    }
   
   
    /*
    functions.cylinder(radius, radius * ratio, halfHeight * 2,
        SETTINGS.cylinder_res, g);

    g.translate(0, halfHeight, 0);

    if (!GLOBAL.performanceMode)
      g.sphere(radius * ratio); //jaw

    g.translate(0, -halfHeight * 2, 0);

    if (!GLOBAL.performanceMode)
      g.sphere(radius);

    this.renderFace(g);
   
    */


    functions.flatCylinder(radius, radius * ratio, halfHeight * 2, myTransform,g);
    g.popMatrix();

    //gl.drawCylinder(radius, halfHeight, upAxis);

    //SPINE_______________________________________________________________________
    ratio = 0.80f;
    g.pushMatrix();
    capsule = (CapsuleShape) shapes[BodyPart.BODYPART_SPINE.ordinal()];
    radius = capsule.getRadius();
    halfHeight = capsule.getHalfHeight();
    if (GLOBAL.performanceMode)
      halfHeight = halfHeight * 1.75f;

    myTransform = bodies[BodyPart.BODYPART_SPINE.ordinal()]
        .getMotionState().getWorldTransform(myTransform);
    applyMatrix(myTransform, g);
   
   
    g.pushMatrix();
    functions.flatCylinder(radius, radius * ratio, halfHeight * 2, myTransform,g);
    g.popMatrix();
    //functions.cylinder(radius, radius * ratio, halfHeight * 2,
    //    SETTINGS.cylinder_res, g);
    //functions.flatCylinder(radius, radius * ratio, halfHeight * 2, myTransform,g);

    g.translate(0, halfHeight, 0);
    //if (!GLOBAL.performanceMode)
    //  g.sphere(radius * ratio);
    g.translate(0, -halfHeight * 2, 0);
    //if (!GLOBAL.performanceMode)
    //  g.sphere(radius); // top
    g.popMatrix();

    //Pelvis_________________________________________________________________________
    ratio = 1.0f;
    g.pushMatrix();
    capsule = (CapsuleShape) shapes[BodyPart.BODYPART_PELVIS.ordinal()];
    radius = capsule.getRadius();
    halfHeight = capsule.getHalfHeight();
    if (GLOBAL.performanceMode)
      halfHeight = halfHeight * 1.75f;

    myTransform = bodies[BodyPart.BODYPART_PELVIS.ordinal()]
        .getMotionState().getWorldTransform(myTransform);
    applyMatrix(myTransform, g);
    functions.cylinder(radius * ratio, radius, halfHeight * 2,
        SETTINGS.cylinder_res, g);
    functions.flatCylinder(radius, radius * ratio, halfHeight * 2, myTransform,g);

    g.translate(0, halfHeight, 0);
    //if (!GLOBAL.performanceMode)
    //  g.sphere(radius);
    g.translate(0, -halfHeight * 2, 0);
    //if (!GLOBAL.performanceMode)
    //  g.sphere(radius * ratio); // top
    g.popMatrix();

    if (hasArms) {

      //RIGHT_UPPER_ARM_________________________________________________________________________
      g.pushMatrix();
      capsule = (CapsuleShape) shapes[BodyPart.BODYPART_RIGHT_UPPER_ARM
          .ordinal()];
      radius = capsule.getRadius();
      halfHeight = capsule.getHalfHeight();
      if (GLOBAL.performanceMode)
        halfHeight = halfHeight * 1.75f;

      myTransform = bodies[BodyPart.BODYPART_RIGHT_UPPER_ARM.ordinal()]
          .getMotionState().getWorldTransform(myTransform);
      applyMatrix(myTransform, g);
      functions.cylinder(radius, radius * .5f, halfHeight * 2,
          SETTINGS.cylinder_res, g);
      functions.flatCylinder(radius, radius * ratio, halfHeight * 2, myTransform,g);

      g.translate(0, halfHeight, 0);
      //if (!GLOBAL.performanceMode)
      //  g.sphere(radius * 0.7f); //jaw
      g.translate(0, -halfHeight * 2, 0);
      //if (!GLOBAL.performanceMode)
      //  g.sphere(radius * 1.1f);
      g.popMatrix();

      //LEFT_UPPER_ARM_________________________________________________________________________
      g.pushMatrix();
      capsule = (CapsuleShape) shapes[BodyPart.BODYPART_LEFT_UPPER_ARM
          .ordinal()];
      radius = capsule.getRadius();
      halfHeight = capsule.getHalfHeight();
      if (GLOBAL.performanceMode)
        halfHeight = halfHeight * 1.75f;

      myTransform = bodies[BodyPart.BODYPART_LEFT_UPPER_ARM.ordinal()]
          .getMotionState().getWorldTransform(myTransform);
      applyMatrix(myTransform, g);
      functions.cylinder(radius, radius * .5f, halfHeight * 2,
          SETTINGS.cylinder_res, g);
      functions.flatCylinder(radius, radius * ratio, halfHeight * 2, myTransform,g);

      g.translate(0, halfHeight, 0);
      //if (!GLOBAL.performanceMode)
      //  g.sphere(radius * 0.7f); //jaw
      g.translate(0, -halfHeight * 2, 0);
      //if (!GLOBAL.performanceMode)
      //  g.sphere(radius * 1.1f);
      g.popMatrix();

      //RIGHT_LOWER_ARM_________________________________________________________________________
      g.pushMatrix();
      capsule = (CapsuleShape) shapes[BodyPart.BODYPART_RIGHT_LOWER_ARM
          .ordinal()];
      radius = capsule.getRadius();
      halfHeight = capsule.getHalfHeight();
      if (GLOBAL.performanceMode)
        halfHeight = halfHeight * 1.75f;

      myTransform = bodies[BodyPart.BODYPART_RIGHT_LOWER_ARM.ordinal()]
          .getMotionState().getWorldTransform(myTransform);
      applyMatrix(myTransform, g);
      functions.cylinder(radius, radius * .5f, halfHeight * 2,
          SETTINGS.cylinder_res, g);
      functions.flatCylinder(radius, radius * ratio, halfHeight * 2, myTransform,g);

      g.translate(0, halfHeight, 0);
      //if (!GLOBAL.performanceMode)
      //  g.sphere(radius * 0.7f); //jaw
      g.translate(0, -halfHeight * 2, 0);
      //if (!GLOBAL.performanceMode)
      //  g.sphere(radius * 1.1f);
      g.popMatrix();

      //LEFT_LOWER_ARM_________________________________________________________________________
      g.pushMatrix();
      capsule = (CapsuleShape) shapes[BodyPart.BODYPART_LEFT_LOWER_ARM
          .ordinal()];
      radius = capsule.getRadius();
      halfHeight = capsule.getHalfHeight();
      if (GLOBAL.performanceMode)
        halfHeight = halfHeight * 1.75f;

      myTransform = bodies[BodyPart.BODYPART_LEFT_LOWER_ARM.ordinal()]
          .getMotionState().getWorldTransform(myTransform);
      applyMatrix(myTransform, g);
      functions.cylinder(radius, radius * .5f, halfHeight * 2,
          SETTINGS.cylinder_res, g);
      functions.flatCylinder(radius, radius * ratio, halfHeight * 2, myTransform,g);

      g.translate(0, halfHeight, 0);
      //if (!GLOBAL.performanceMode)
      //  g.sphere(radius * 0.7f); //jaw
      g.translate(0, -halfHeight * 2, 0);
      //if (!GLOBAL.performanceMode)
      //  g.sphere(radius * 1.1f);
      g.popMatrix();

      //LEFT HAND_________________________________________________________________________
      g.pushMatrix();
      capsule = (CapsuleShape) shapes[BodyPart.BODYPART_LEFT_HAND
          .ordinal()];
      radius = capsule.getRadius();
      halfHeight = capsule.getHalfHeight();
      if (GLOBAL.performanceMode)
        halfHeight = halfHeight * 1.75f;

      myTransform = bodies[BodyPart.BODYPART_LEFT_HAND.ordinal()]
          .getMotionState().getWorldTransform(myTransform);
      applyMatrix(myTransform, g);
      functions.cylinder(radius, radius * .5f, halfHeight * 2,
          SETTINGS.cylinder_res, g);
      functions.flatCylinder(radius, radius * ratio, halfHeight * 2, myTransform,g);

      g.translate(0, halfHeight, 0);
      //if (!GLOBAL.performanceMode)
      //  g.sphere(radius * 0.7f); //jaw
      g.translate(0, -halfHeight * 2, 0);
      //if (!GLOBAL.performanceMode)
      //  g.sphere(radius * 1.1f);
      g.popMatrix();

      //RIGHT HAND_________________________________________________________________________
      g.pushMatrix();
      capsule = (CapsuleShape) shapes[BodyPart.BODYPART_RIGHT_HAND
          .ordinal()];
      radius = capsule.getRadius();
      halfHeight = capsule.getHalfHeight();
      if (GLOBAL.performanceMode)
        halfHeight = halfHeight * 1.75f;

      myTransform = bodies[BodyPart.BODYPART_RIGHT_HAND.ordinal()]
          .getMotionState().getWorldTransform(myTransform);
      applyMatrix(myTransform, g);
      functions.cylinder(radius, radius * .5f, halfHeight * 2,
          SETTINGS.cylinder_res, g);
      functions.flatCylinder(radius, radius * ratio, halfHeight * 2, myTransform,g);

      g.translate(0, halfHeight, 0);
      //if (!GLOBAL.performanceMode)
      //  g.sphere(radius * 0.7f); //jaw
      g.translate(0, -halfHeight * 2, 0);
      //if (!GLOBAL.performanceMode)
      //  g.sphere(radius * 1.1f);
      g.popMatrix();

    }

    //LEFT Upper Leg_________________________________________________________________________
    //ratio = .7f;
    ratio = 0.9f;

    g.pushMatrix();
    capsule = (CapsuleShape) shapes[BodyPart.BODYPART_LEFT_UPPER_LEG
        .ordinal()];
    radius = capsule.getRadius();
    halfHeight = capsule.getHalfHeight();
   
    if (GLOBAL.performanceMode)
      halfHeight = halfHeight * 1.75f;

    myTransform = bodies[BodyPart.BODYPART_LEFT_UPPER_LEG.ordinal()]
        .getMotionState().getWorldTransform(myTransform);
    applyMatrix(myTransform, g);

    functions.cylinder(radius, radius * ratio, halfHeight * 2,
        SETTINGS.cylinder_res, g);
    functions.flatCylinder(radius, radius * ratio, halfHeight * 2, myTransform,g);

    g.translate(0, halfHeight, 0);
    //if (!GLOBAL.performanceMode)
    //  g.sphere(radius * 0.7f); //jaw
    g.translate(0, -halfHeight * 2, 0);
    //if (!GLOBAL.performanceMode)
    //  g.sphere(radius);
    g.popMatrix();

   
   
    //Right Upper Leg_________________________________________________________________________
    ratio = 0.9f;

    g.pushMatrix();
    capsule = (CapsuleShape) shapes[BodyPart.BODYPART_RIGHT_UPPER_LEG
        .ordinal()];
    radius = capsule.getRadius();
    halfHeight = capsule.getHalfHeight();
    if (GLOBAL.performanceMode)
      halfHeight = halfHeight * 1.75f;

    myTransform = bodies[BodyPart.BODYPART_RIGHT_UPPER_LEG.ordinal()]
        .getMotionState().getWorldTransform(myTransform);
    applyMatrix(myTransform, g);
    functions.cylinder(radius, radius * ratio, halfHeight * 2,
        SETTINGS.cylinder_res, g);
    functions.flatCylinder(radius, radius * ratio, halfHeight * 2, myTransform,g);

    g.translate(0, halfHeight, 0);
    //if (!GLOBAL.performanceMode)
    //  g.sphere(radius * 0.7f); //jaw
    g.translate(0, -halfHeight * 2, 0);
    //if (!GLOBAL.performanceMode)
    //  g.sphere(radius);
    g.popMatrix();

    //LOWER LEFT LEG_________________________________________________________________________
    ratio = 0.9f;
    g.pushMatrix();
    capsule = (CapsuleShape) shapes[BodyPart.BODYPART_LEFT_LOWER_LEG
        .ordinal()];
    radius = capsule.getRadius();
    halfHeight = capsule.getHalfHeight();
    if (GLOBAL.performanceMode)
      halfHeight = halfHeight * 1.75f;

    myTransform = bodies[BodyPart.BODYPART_LEFT_LOWER_LEG.ordinal()]
        .getMotionState().getWorldTransform(myTransform);
    applyMatrix(myTransform, g);
    functions.cylinder(radius, radius * .5f, halfHeight * 2,
        SETTINGS.cylinder_res, g);
    functions.flatCylinder(radius, radius * ratio, halfHeight * 2, myTransform,g);

    g.translate(0, halfHeight, 0);
    //if (!GLOBAL.performanceMode)
    //  g.sphere(radius * 0.7f); //jaw

    g.translate(0, -halfHeight * 2, 0);
    //if (!GLOBAL.performanceMode)
    //  g.sphere(radius * 1.1f);
    g.popMatrix();

    //LOWER RIGHT LEG_________________________________________________________________________
    ratio = 0.9f;

    g.pushMatrix();
    capsule = (CapsuleShape) shapes[BodyPart.BODYPART_RIGHT_LOWER_LEG
        .ordinal()];
    radius = capsule.getRadius();
    halfHeight = capsule.getHalfHeight();
    if (GLOBAL.performanceMode)
      halfHeight = halfHeight * 1.75f;

    myTransform = bodies[BodyPart.BODYPART_RIGHT_LOWER_LEG.ordinal()]
        .getMotionState().getWorldTransform(myTransform);
    applyMatrix(myTransform, g);
    functions.cylinder(radius, radius * .5f, halfHeight * 2,
        SETTINGS.cylinder_res, g);
    functions.flatCylinder(radius, radius * ratio, halfHeight * 2, myTransform,g);

    g.translate(0, halfHeight, 0);
    //if (!GLOBAL.performanceMode)
    //  g.sphere(radius * 0.7f); //jaw
    g.translate(0, -halfHeight * 2, 0);
    //if (!GLOBAL.performanceMode)
    //  g.sphere(radius * 1.1f);
    g.popMatrix();

    // RIGHT Foot_________________________________________________________________________
    g.pushMatrix();
    capsule = (CapsuleShape) shapes[BodyPart.BODYPART_RIGHT_FOOT.ordinal()];
    radius = capsule.getRadius();
    halfHeight = capsule.getHalfHeight();
    if (GLOBAL.performanceMode)
      halfHeight = halfHeight * 1.75f;

    myTransform = bodies[BodyPart.BODYPART_RIGHT_FOOT.ordinal()]
        .getMotionState().getWorldTransform(myTransform);
    applyMatrix(myTransform, g);
    functions.cylinder(radius, radius * .5f, halfHeight * 2,
        SETTINGS.cylinder_res, g);
    functions.flatCylinder(radius, radius * ratio, halfHeight * 2, myTransform,g);

    g.translate(0, halfHeight, 0);
    //if (!GLOBAL.performanceMode)
    //  g.sphere(radius * 0.7f); //jaw
    g.translate(0, -halfHeight * 2, 0);
    //if (!GLOBAL.performanceMode)
    //  g.sphere(radius * 1.1f);
    g.popMatrix();

    //LEFT Foot_________________________________________________________________________
    g.pushMatrix();
    capsule = (CapsuleShape) shapes[BodyPart.BODYPART_LEFT_FOOT.ordinal()];
    radius = capsule.getRadius();
    halfHeight = capsule.getHalfHeight();
    if (GLOBAL.performanceMode)
      halfHeight = halfHeight * 1.75f;

    myTransform = bodies[BodyPart.BODYPART_LEFT_FOOT.ordinal()]
        .getMotionState().getWorldTransform(myTransform);
View Full Code Here

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

    // Setup geometry
    //
    float bodySize  = 0.25f;
    float legLength = 0.45f;
    float foreLegLength = 0.75f;
    shapes[0] = new CapsuleShape(bodySize, 0.10f);
    int i;
    for ( i=0; i<NUM_LEGS; i++)
    {
      shapes[1 + 2*i] = new CapsuleShape(0.10f, legLength);
      shapes[2 + 2*i] = new CapsuleShape(0.08f, foreLegLength);
    }

    //
    // Setup rigid bodies
    //
View Full Code Here

    ghostObject = new PairCachingGhostObject();
    ghostObject.setWorldTransform(startTransform);
    sweepBP.getOverlappingPairCache().setInternalGhostPairCallback(new GhostPairCallback());
    float characterHeight = 1.75f * characterScale;
    float characterWidth = 1.75f * characterScale;
    ConvexShape capsule = new CapsuleShape(characterWidth, characterHeight);
    ghostObject.setCollisionShape(capsule);
    ghostObject.setCollisionFlags(CollisionFlags.CHARACTER_OBJECT);

    float stepHeight = 0.35f * characterScale;
    character = new KinematicCharacterController(ghostObject, capsule, stepHeight);
View Full Code Here

        }
        Vector3f pos = locComp.getWorldPosition();
        final float worldScale = locComp.getWorldScale();
        final float height = (movementComp.height - 2 * movementComp.radius) * worldScale;
        final float width = movementComp.radius * worldScale;
        ConvexShape shape = new CapsuleShape(width, height);
        shape.setMargin(0.1f);
        return createCustomCollider(pos, shape, movementComp.collisionGroup.getFlag(), combineGroups(movementComp.collidesWith),
                CollisionFlags.CHARACTER_OBJECT, owner);
    }
View Full Code Here

        if (sphere != null) {
            return new SphereShape(sphere.radius);
        }
        CapsuleShapeComponent capsule = entity.getComponent(CapsuleShapeComponent.class);
        if (capsule != null) {
            return new CapsuleShape(capsule.radius, capsule.height);
        }
        CylinderShapeComponent cylinder = entity.getComponent(CylinderShapeComponent.class);
        if (cylinder != null) {
            return new CylinderShape(new Vector3f(cylinder.radius, 0.5f * cylinder.height, cylinder.radius));
        }
        HullShapeComponent hull = entity.getComponent(HullShapeComponent.class);
        if (hull != null) {
            ObjectArrayList<Vector3f> verts = new ObjectArrayList<Vector3f>();
            TFloatIterator iterator = hull.sourceMesh.getVertices().iterator();
            while (iterator.hasNext()) {
                Vector3f newVert = new Vector3f();
                newVert.x = iterator.next();
                newVert.y = iterator.next();
                newVert.z = iterator.next();
                verts.add(newVert);
            }
            return new ConvexHullShape(verts);
        }
        CharacterMovementComponent characterMovementComponent = entity.getComponent(CharacterMovementComponent.class);
        if (characterMovementComponent != null) {
            return new CapsuleShape(characterMovementComponent.radius, characterMovementComponent.height);
        }
        logger.error("Creating physics object that requires a ShapeComponent or CharacterMovementComponent, but has neither. Entity: {}", entity);
        throw new IllegalArgumentException("Creating physics object that requires a ShapeComponent or CharacterMovementComponent, but has neither. Entity: " + entity);
    }
View Full Code Here

TOP

Related Classes of com.bulletphysics.collision.shapes.CapsuleShape

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.