Package com.bulletphysics.collision.shapes

Examples of com.bulletphysics.collision.shapes.CollisionShape


        startTransform.basis.rotX((float) -Math.PI / 2f);
        startTransform.origin.set(0, -10, 0);
        //startTransform.origin.set(0, 0, -10f);
       
        // this create an internal copy of the vertices
        CollisionShape shape = new ConvexHullShape(vertices);
        collisionShapes.add(shape);

        //btRigidBody* body = m_demoApp->localCreateRigidBody(mass, startTransform,shape);
        localCreateRigidBody(mass, startTransform, shape);
      }
View Full Code Here


    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

    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
      CollisionShape tmpShape = colObj.getCollisionShape();
      colObj.internalSetTemporaryCollisionShape(childShape);
      childCollisionAlgorithms.getQuick(i).processCollision(colObj, otherObj, dispatchInfo, resultOut);
      // revert back
      colObj.internalSetTemporaryCollisionShape(tmpShape);
      colObj.setWorldTransform(orgTrans);
View Full Code Here

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

      CollisionShape tmpShape = colObj.getCollisionShape();
      colObj.internalSetTemporaryCollisionShape(childShape);
      float frac = childCollisionAlgorithms.getQuick(i).calculateTimeOfImpact(colObj, otherObj, dispatchInfo, resultOut);
      if (frac < hitFraction) {
        hitFraction = frac;
      }
View Full Code Here

    triBody.getWorldTransform(convexInTriangleSpace);
    convexInTriangleSpace.inverse();
    convexInTriangleSpace.mul(convexBody.getWorldTransform(Stack.alloc(Transform.class)));

    CollisionShape convexShape = (CollisionShape)convexBody.getCollisionShape();
    //CollisionShape* triangleShape = static_cast<btCollisionShape*>(triBody->m_collisionShape);
    convexShape.getAabb(convexInTriangleSpace, aabbMin, aabbMax);
    float extraMargin = collisionMarginTriangle;
    Vector3f extra = Stack.alloc(Vector3f.class);
    extra.set(extraMargin, extraMargin, extraMargin);

    aabbMax.add(extra);
View Full Code Here

    if (convexBody.getCollisionShape().isConvex()) {
      tm.init(triangle[0], triangle[1], triangle[2]);
      tm.setMargin(collisionMarginTriangle);

      CollisionShape tmpShape = ob.getCollisionShape();
      ob.internalSetTemporaryCollisionShape(tm);

      CollisionAlgorithm colAlgo = ci.dispatcher1.findAlgorithm(convexBody, triBody, manifoldPtr);
      // this should use the btDispatcher, so the actual registered algorithm is used
      //    btConvexConvexAlgorithm cvxcvxalgo(m_manifoldPtr,ci,m_convexBody,m_triBody);
View Full Code Here

          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);
            rayTestSingle(rayFromTrans, rayToTrans,
                collisionObject,
                childCollisionShape,
                childWorldTrans,
View Full Code Here

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

        collisionConfiguration);

    dynamicsWorld.setGravity(new Vector3f(0, -10, 0));

    // create a few basic rigid bodies
    CollisionShape groundShape = new BoxShape(new Vector3f(50.f, 50.f, 50.f));

    // keep track of the shapes, we release memory at exit.
    // make sure to re-use collision shapes among rigid bodies whenever
    // possible!
    ObjectArrayList<CollisionShape> collisionShapes = new ObjectArrayList<CollisionShape>();

    collisionShapes.add(groundShape);

    Transform groundTransform = new Transform();
    groundTransform.setIdentity();
    groundTransform.origin.set(new Vector3f(0.f, -56.f, 0.f));

    {
      float mass = 0f;

      // rigidbody is dynamic if and only if mass is non zero,
      // otherwise static
      boolean isDynamic = (mass != 0f);

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

      // using motionstate is recommended, it provides interpolation
      // capabilities, and only synchronizes 'active' objects
      DefaultMotionState myMotionState = new DefaultMotionState(groundTransform);
      RigidBodyConstructionInfo rbInfo = new RigidBodyConstructionInfo(
          mass, myMotionState, groundShape, localInertia);
      RigidBody body = new RigidBody(rbInfo);

      // add the body to the dynamics world
      dynamicsWorld.addRigidBody(body);
    }

    {
      // create a dynamic rigidbody

      // btCollisionShape* colShape = new
      // btBoxShape(btVector3(1,1,1));
      CollisionShape colShape = new SphereShape(1.f);
      collisionShapes.add(colShape);

      // Create Dynamic Objects
      Transform startTransform = new Transform();
      startTransform.setIdentity();

      float mass = 1f;

      // rigidbody is dynamic if and only if mass is non zero,
      // otherwise static
      boolean isDynamic = (mass != 0f);

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

      startTransform.origin.set(new Vector3f(2, 10, 0));

      // using motionstate is recommended, it provides
View Full Code Here

    dynamicsWorld = new DiscreteDynamicsWorld(dispatcher, broadphase, solver, collisionConfiguration);

    dynamicsWorld.setGravity(new Vector3f(0f, -10f, 0f));

    // create a few basic rigid bodies
    CollisionShape groundShape = new BoxShape(new Vector3f(50f, 50f, 50f));
    //CollisionShape groundShape = new StaticPlaneShape(new Vector3f(0, 1, 0), 50);

    collisionShapes.add(groundShape);

    Transform groundTransform = new Transform();
    groundTransform.setIdentity();
    groundTransform.origin.set(0, -56, 0);

    // We can also use DemoApplication::localCreateRigidBody, but for clarity it is provided here:
    {
      float mass = 0f;

      // rigidbody is dynamic if and only if mass is non zero, otherwise static
      boolean isDynamic = (mass != 0f);

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

      // using motionstate is recommended, it provides interpolation capabilities, and only synchronizes 'active' objects
      DefaultMotionState myMotionState = new DefaultMotionState(groundTransform);
      RigidBodyConstructionInfo rbInfo = new RigidBodyConstructionInfo(mass, myMotionState, groundShape, localInertia);
      RigidBody body = new RigidBody(rbInfo);

      // add the body to the dynamics world
      dynamicsWorld.addRigidBody(body);
    }

    {
      // create a few dynamic rigidbodies
      // Re-using the same collision is better for memory usage and performance

      CollisionShape colShape = new BoxShape(new Vector3f(1, 1, 1));
      //CollisionShape colShape = new SphereShape(1f);
      collisionShapes.add(colShape);

      // Create Dynamic Objects
      Transform startTransform = new Transform();
      startTransform.setIdentity();

      float mass = 1f;

      // rigidbody is dynamic if and only if mass is non zero, otherwise static
      boolean isDynamic = (mass != 0f);

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

      float start_x = START_POS_X - ARRAY_SIZE_X / 2;
      float start_y = START_POS_Y;
      float start_z = START_POS_Z - ARRAY_SIZE_Z / 2;
View Full Code Here

TOP

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

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.