Package com.bulletphysics.collision.shapes

Examples of com.bulletphysics.collision.shapes.CompoundShape


      return;
    }
    //#endif

    if (shape1.isCompound()) {
      CompoundShape compoundshape = (CompoundShape) shape1;
      gimpact_vs_compoundshape(body0, body1, shape0, compoundshape, swapped);
      return;
    }
    else if (shape1.isConcave()) {
      ConcaveShape concaveshape = (ConcaveShape) shape1;
View Full Code Here


    //localTrans.setOrigin(btVector3(0,0,1));
    //#else
    CollisionShape chassisShape = new BoxShape(new Vector3f(1.0f, 0.5f, 2.0f));
    collisionShapes.add(chassisShape);

    CompoundShape compound = new CompoundShape();
    collisionShapes.add(compound);
    Transform localTrans = new Transform();
    localTrans.setIdentity();
    // localTrans effectively shifts the center of mass with respect to the chassis
    localTrans.origin.set(0, 1, 0);
    //#endif

    compound.addChildShape(localTrans, chassisShape);

    tr.origin.set(0, 0, 0);

    carChassis = localCreateRigidBody(800, tr, compound); //chassisShape);
    //m_carChassis->setDamping(0.2,0.2);
View Full Code Here

    if (USE_BOX_SHAPE) {
      colShape = new BoxShape(new Vector3f(1f, 1f, 1f));
    }
    else {
      colShape = new CompoundShape();
      CollisionShape cylinderShape = new CylinderShapeX(new Vector3f(4, 1, 1));
      CollisionShape boxShape = new BoxShape(new Vector3f(4f, 1f, 1f));
      Transform localTransform = new Transform();
      localTransform.setIdentity();
      ((CompoundShape)colShape).addChildShape(localTransform, boxShape);
View Full Code Here

    CollisionShape staticboxShape2 = new BoxShape(new Vector3f(1f, 50f, 200f)); // left wall
    CollisionShape staticboxShape3 = new BoxShape(new Vector3f(1f, 50f, 200f)); // right wall
    CollisionShape staticboxShape4 = new BoxShape(new Vector3f(200f, 50f, 1f)); // front wall
    CollisionShape staticboxShape5 = new BoxShape(new Vector3f(200f, 50f, 1f)); // back wall

    CompoundShape staticScenario = new CompoundShape(); // static scenario

    startTransform.origin.set(0f, 0f, 0f);
    staticScenario.addChildShape(startTransform, staticboxShape1);
    startTransform.origin.set(-200f, 25f, 0f);
    staticScenario.addChildShape(startTransform, staticboxShape2);
    startTransform.origin.set(200f, 25f, 0f);
    staticScenario.addChildShape(startTransform, staticboxShape3);
    startTransform.origin.set(0f, 25f, 200f);
    staticScenario.addChildShape(startTransform, staticboxShape4);
    startTransform.origin.set(0f, 25f, -200f);
    staticScenario.addChildShape(startTransform, staticboxShape5);

    startTransform.origin.set(0f, 0f, 0f);

    RigidBody staticBody = localCreateRigidBody(mass, startTransform, staticScenario);
View Full Code Here

//      glPopMatrix();
//      return;
//    }

    if (shape.getShapeType() == BroadphaseNativeType.COMPOUND_SHAPE_PROXYTYPE) {
      CompoundShape compoundShape = (CompoundShape) shape;
      Transform childTrans = transformsPool.get();
      for (int i = compoundShape.getNumChildShapes() - 1; i >= 0; i--) {
        compoundShape.getChildTransform(i, childTrans);
        CollisionShape colShape = compoundShape.getChildShape(i);
        drawOpenGL(gl, childTrans, colShape, color, debugMode);
      }
      transformsPool.release(childTrans);
    }
    else {
View Full Code Here

    //localTrans.setOrigin(btVector3(0,0,1));
    //#else
    CollisionShape chassisShape = new BoxShape(new Vector3f(1.f,0.5f,2.f));
    collisionShapes.add(chassisShape);

    CompoundShape compound = new CompoundShape();
    collisionShapes.add(compound);
    Transform localTrans = new Transform();
    localTrans.setIdentity();
    // localTrans effectively shifts the center of mass with respect to the chassis
    localTrans.origin.set(0,1,0);
    //#endif

    compound.addChildShape(localTrans,chassisShape);

    {
      CollisionShape suppShape = new BoxShape(new Vector3f(0.5f,0.1f,0.5f));
      collisionShapes.add(chassisShape);
      Transform suppLocalTrans = new Transform();
      suppLocalTrans.setIdentity();
      // localTrans effectively shifts the center of mass with respect to the chassis
      suppLocalTrans.origin.set(0f,1.0f,2.5f);
      compound.addChildShape(suppLocalTrans, suppShape);
    }

    tr.origin.set(0,0.f,0);

    carChassis = localCreateRigidBody(800,tr,compound);//chassisShape);
    //m_carChassis->setDamping(0.2,0.2);


    {
      CollisionShape liftShape = new BoxShape(new Vector3f(0.5f,2.0f,0.05f));
      collisionShapes.add(liftShape);
      Transform liftTrans = new Transform();
      liftStartPos.set(0.0f, 2.5f, 3.05f);
      liftTrans.setIdentity();
      liftTrans.origin.set(liftStartPos);
      liftBody = localCreateRigidBody(10,liftTrans, liftShape);

      Transform localA = new Transform(), localB = new Transform();
      localA.setIdentity();
      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);
      CompoundShape forkCompound = new CompoundShape();
      collisionShapes.add(forkCompound);
      Transform forkLocalTrans = new Transform();
      forkLocalTrans.setIdentity();
      forkCompound.addChildShape(forkLocalTrans, forkShapeA);

      CollisionShape forkShapeB = new BoxShape(new Vector3f(0.1f,0.02f,0.6f));
      collisionShapes.add(forkShapeB);
      forkLocalTrans.setIdentity();
      forkLocalTrans.origin.set(-0.9f, -0.08f, 0.7f);
      forkCompound.addChildShape(forkLocalTrans, forkShapeB);

      CollisionShape forkShapeC = new BoxShape(new Vector3f(0.1f,0.02f,0.6f));
      collisionShapes.add(forkShapeC);
      forkLocalTrans.setIdentity();
      forkLocalTrans.origin.set(0.9f, -0.08f, 0.7f);
      forkCompound.addChildShape(forkLocalTrans, forkShapeC);

      Transform forkTrans = new Transform();
      forkStartPos.set(0.0f, 0.6f, 3.2f);
      forkTrans.setIdentity();
      forkTrans.origin.set(forkStartPos);
      forkBody = localCreateRigidBody(5, forkTrans, forkCompound);

      localA.setIdentity();
      localB.setIdentity();
      MatrixUtil.setEulerZYX(localA.basis, 0, 0, PI_2);
      localA.origin.set(0.0f, -1.9f, 0.05f);
      MatrixUtil.setEulerZYX(localB.basis, 0, 0, PI_2);
      localB.origin.set(0.0f, 0.0f, -0.1f);
      forkSlider = new SliderConstraint(liftBody, forkBody, localA, localB, true);
      forkSlider.setLowerLinLimit(0.1f);
      forkSlider.setUpperLinLimit(0.1f);
      forkSlider.setLowerAngLimit(-LIFT_EPS);
      forkSlider.setUpperAngLimit(LIFT_EPS);
      dynamicsWorld.addConstraint(forkSlider, true);
     
      CompoundShape loadCompound = new CompoundShape();
      collisionShapes.add(loadCompound);
      CollisionShape loadShapeA = new BoxShape(new Vector3f(2.0f,0.5f,0.5f));
      collisionShapes.add(loadShapeA);
      Transform loadTrans = new Transform();
      loadTrans.setIdentity();
      loadCompound.addChildShape(loadTrans, loadShapeA);
      CollisionShape loadShapeB = new BoxShape(new Vector3f(0.1f,1.0f,1.0f));
      collisionShapes.add(loadShapeB);
      loadTrans.setIdentity();
      loadTrans.origin.set(2.1f, 0.0f, 0.0f);
      loadCompound.addChildShape(loadTrans, loadShapeB);
      CollisionShape loadShapeC = new BoxShape(new Vector3f(0.1f,1.0f,1.0f));
      collisionShapes.add(loadShapeC);
      loadTrans.setIdentity();
      loadTrans.origin.set(-2.1f, 0.0f, 0.0f);
      loadCompound.addChildShape(loadTrans, loadShapeC);
      loadTrans.setIdentity();
      loadStartPos.set(0.0f, -3.5f, 7.0f);
      loadTrans.origin.set(loadStartPos);
      loadBody  = localCreateRigidBody(4, loadTrans, loadCompound);
    }
View Full Code Here

    CollisionObject colObj = isSwapped ? body1 : body0;
    CollisionObject otherObj = isSwapped ? body0 : body1;
    assert (colObj.getCollisionShape().isCompound());

    CompoundShape compoundShape = (CompoundShape) colObj.getCollisionShape();
    int numChildren = compoundShape.getNumChildShapes();
    int i;

    //childCollisionAlgorithms.resize(numChildren);
    for (i = 0; i < numChildren; i++) {
      CollisionShape tmpShape = colObj.getCollisionShape();
      CollisionShape childShape = compoundShape.getChildShape(i);
      colObj.internalSetTemporaryCollisionShape(childShape);
      childCollisionAlgorithms.add(ci.dispatcher1.findAlgorithm(colObj, otherObj));
      colObj.internalSetTemporaryCollisionShape(tmpShape);
    }
  }
View Full Code Here

  public void processCollision(CollisionObject body0, CollisionObject body1, DispatcherInfo dispatchInfo, ManifoldResult resultOut) {
    CollisionObject colObj = isSwapped ? body1 : body0;
    CollisionObject otherObj = isSwapped ? body0 : body1;

    assert (colObj.getCollisionShape().isCompound());
    CompoundShape compoundShape = (CompoundShape) colObj.getCollisionShape();

    // We will use the OptimizedBVH, AABB tree to cull potential child-overlaps
    // If both proxies are Compound, we will deal with that directly, by performing sequential/parallel tree traversals
    // given Proxy0 and Proxy1, if both have a tree, Tree0 and Tree1, this means:
    // determine overlapping nodes of Proxy1 using Proxy0 AABB against Tree1
    // then use each overlapping node AABB against Tree0
    // and vise versa.

    Transform tmpTrans = Stack.alloc(Transform.class);
    Transform orgTrans = Stack.alloc(Transform.class);
    Transform childTrans = Stack.alloc(Transform.class);
    Transform orgInterpolationTrans = Stack.alloc(Transform.class);
    Transform newChildWorldTrans = Stack.alloc(Transform.class);

    int numChildren = childCollisionAlgorithms.size();
    int i;
    for (i = 0; i < numChildren; i++) {
      // temporarily exchange parent btCollisionShape with childShape, and recurse
      CollisionShape childShape = compoundShape.getChildShape(i);

      // backup
      colObj.getWorldTransform(orgTrans);
      colObj.getInterpolationWorldTransform(orgInterpolationTrans);

      compoundShape.getChildTransform(i, childTrans);
      newChildWorldTrans.mul(orgTrans, childTrans);
      colObj.setWorldTransform(newChildWorldTrans);
      colObj.setInterpolationWorldTransform(newChildWorldTrans);
     
      // the contactpoint is still projected back using the original inverted worldtrans
View Full Code Here

    CollisionObject colObj = isSwapped ? body1 : body0;
    CollisionObject otherObj = isSwapped ? body0 : body1;

    assert (colObj.getCollisionShape().isCompound());

    CompoundShape compoundShape = (CompoundShape) colObj.getCollisionShape();

    // We will use the OptimizedBVH, AABB tree to cull potential child-overlaps
    // If both proxies are Compound, we will deal with that directly, by performing sequential/parallel tree traversals
    // given Proxy0 and Proxy1, if both have a tree, Tree0 and Tree1, this means:
    // determine overlapping nodes of Proxy1 using Proxy0 AABB against Tree1
    // then use each overlapping node AABB against Tree0
    // and vise versa.

    Transform tmpTrans = Stack.alloc(Transform.class);
    Transform orgTrans = Stack.alloc(Transform.class);
    Transform childTrans = Stack.alloc(Transform.class);
    float hitFraction = 1f;

    int numChildren = childCollisionAlgorithms.size();
    int i;
    for (i = 0; i < numChildren; i++) {
      // temporarily exchange parent btCollisionShape with childShape, and recurse
      CollisionShape childShape = compoundShape.getChildShape(i);

      // backup
      colObj.getWorldTransform(orgTrans);

      compoundShape.getChildTransform(i, childTrans);
      //btTransform  newChildWorldTrans = orgTrans*childTrans ;
      tmpTrans.set(orgTrans);
      tmpTrans.mul(childTrans);
      colObj.setWorldTransform(tmpTrans);

View Full Code Here

        }
      }
      else {
        // todo: use AABB tree or other BVH acceleration structure!
        if (collisionShape.isCompound()) {
          CompoundShape compoundShape = (CompoundShape) collisionShape;
          int i = 0;
          Transform childTrans = Stack.alloc(Transform.class);
          for (i = 0; i < compoundShape.getNumChildShapes(); i++) {
            compoundShape.getChildTransform(i, childTrans);
            CollisionShape childCollisionShape = compoundShape.getChildShape(i);
            Transform childWorldTrans = Stack.alloc(colObjWorldTransform);
            childWorldTrans.mul(childTrans);
            // replace collision shape so that callback can determine the triangle
            CollisionShape saveCollisionShape = collisionObject.getCollisionShape();
            collisionObject.internalSetTemporaryCollisionShape(childCollisionShape);
View Full Code Here

TOP

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

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.