Examples of BvhTriangleMeshShape


Examples of com.bulletphysics.collision.shapes.BvhTriangleMeshShape

        gIndices,
        indexStride,
        totalVerts, vertices, vertStride);

    boolean useQuantizedAabbCompression = true;
    groundShape = new BvhTriangleMeshShape(indexVertexArrays, useQuantizedAabbCompression);

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

    //#else
//    //testing btHeightfieldTerrainShape
View Full Code Here

Examples of com.bulletphysics.collision.shapes.BvhTriangleMeshShape

    boolean useQuantizedAabbCompression = true;

    if (TEST_SERIALIZATION) {
      if (SERIALIZE_TO_DISK) {
        trimeshShape = new BvhTriangleMeshShape(indexVertexArrays, useQuantizedAabbCompression);
        collisionShapes.add(trimeshShape);

        // we can serialize the BVH data
        try {
          ObjectOutputStream out = new ObjectOutputStream(new GZIPOutputStream(new FileOutputStream(new File("bvh.bin"))));
          out.writeObject(trimeshShape.getOptimizedBvh());
          out.close();
        }
        catch (IOException e) {
          e.printStackTrace();
        }
      }
      else {
        trimeshShape = new BvhTriangleMeshShape(indexVertexArrays, useQuantizedAabbCompression, false);

        OptimizedBvh bvh = null;
        try {
          ObjectInputStream in = new ObjectInputStream(new GZIPInputStream(new FileInputStream(new File("bvh.bin"))));
          bvh = (OptimizedBvh)in.readObject();
          in.close();
        }
        catch (Exception e) {
          e.printStackTrace();
        }

        trimeshShape.setOptimizedBvh(bvh);
        trimeshShape.recalcLocalAabb();
      }
    }
    else {
      trimeshShape = new BvhTriangleMeshShape(indexVertexArrays, useQuantizedAabbCompression);
      collisionShapes.add(trimeshShape);
    }

    CollisionShape groundShape = trimeshShape;
View Full Code Here

Examples of com.bulletphysics.collision.shapes.BvhTriangleMeshShape

    boolean useQuantizedAabbCompression = true;

    //comment out the next line to read the BVH from disk (first run the demo once to create the BVH)
    //#define SERIALIZE_TO_DISK 1
    //#ifdef SERIALIZE_TO_DISK
    trimeshShape = new BvhTriangleMeshShape(indexVertexArrays, useQuantizedAabbCompression);
    collisionShapes.add(trimeshShape);

    CollisionShape groundShape = trimeshShape;

    collisionConfiguration = new DefaultCollisionConfiguration();
View Full Code Here

Examples of com.bulletphysics.collision.shapes.BvhTriangleMeshShape

      gIndices,
      indexStride,
      totalVerts,vertices,vertStride);

    boolean useQuantizedAabbCompression = true;
    groundShape = new BvhTriangleMeshShape(indexVertexArrays,useQuantizedAabbCompression);

    tr.origin.set(0,-4.5f,0);
    //#else
    ////testing btHeightfieldTerrainShape
    //int width=128;
View Full Code Here

Examples of com.bulletphysics.collision.shapes.BvhTriangleMeshShape

    }
    else {
      if (collisionShape.isConcave()) {
        if (collisionShape.getShapeType() == BroadphaseNativeType.TRIANGLE_MESH_SHAPE_PROXYTYPE) {
          // optimized version for BvhTriangleMeshShape
          BvhTriangleMeshShape triangleMesh = (BvhTriangleMeshShape)collisionShape;
          Transform worldTocollisionObject = Stack.alloc(Transform.class);
          worldTocollisionObject.inverse(colObjWorldTransform);
          Vector3f rayFromLocal = Stack.alloc(rayFromTrans.origin);
          worldTocollisionObject.transform(rayFromLocal);
          Vector3f rayToLocal = Stack.alloc(rayToTrans.origin);
          worldTocollisionObject.transform(rayToLocal);

          BridgeTriangleRaycastCallback rcb = new BridgeTriangleRaycastCallback(rayFromLocal, rayToLocal, resultCallback, collisionObject, triangleMesh);
          rcb.hitFraction = resultCallback.closestHitFraction;
          triangleMesh.performRaycast(rcb, rayFromLocal, rayToLocal);
        }
        else {
          ConcaveShape triangleMesh = (ConcaveShape)collisionShape;

          Transform worldTocollisionObject = Stack.alloc(Transform.class);
          worldTocollisionObject.inverse(colObjWorldTransform);

          Vector3f rayFromLocal = Stack.alloc(rayFromTrans.origin);
          worldTocollisionObject.transform(rayFromLocal);
          Vector3f rayToLocal = Stack.alloc(rayToTrans.origin);
          worldTocollisionObject.transform(rayToLocal);

          BridgeTriangleRaycastCallback rcb = new BridgeTriangleRaycastCallback(rayFromLocal, rayToLocal, resultCallback, collisionObject, triangleMesh);
          rcb.hitFraction = resultCallback.closestHitFraction;

          Vector3f rayAabbMinLocal = Stack.alloc(rayFromLocal);
          VectorUtil.setMin(rayAabbMinLocal, rayToLocal);
          Vector3f rayAabbMaxLocal = Stack.alloc(rayFromLocal);
          VectorUtil.setMax(rayAabbMaxLocal, rayToLocal);

          triangleMesh.processAllTriangles(rcb, rayAabbMinLocal, rayAabbMaxLocal);
        }
      }
      else {
        // todo: use AABB tree or other BVH acceleration structure!
        if (collisionShape.isCompound()) {
View Full Code Here

Examples of com.bulletphysics.collision.shapes.BvhTriangleMeshShape

      }
    }
    else {
      if (collisionShape.isConcave()) {
        if (collisionShape.getShapeType() == BroadphaseNativeType.TRIANGLE_MESH_SHAPE_PROXYTYPE) {
          BvhTriangleMeshShape triangleMesh = (BvhTriangleMeshShape)collisionShape;
          Transform worldTocollisionObject = Stack.alloc(Transform.class);
          worldTocollisionObject.inverse(colObjWorldTransform);

          Vector3f convexFromLocal = Stack.alloc(Vector3f.class);
          convexFromLocal.set(convexFromTrans.origin);
          worldTocollisionObject.transform(convexFromLocal);

          Vector3f convexToLocal = Stack.alloc(Vector3f.class);
          convexToLocal.set(convexToTrans.origin);
          worldTocollisionObject.transform(convexToLocal);

          // rotation of box in local mesh space = MeshRotation^-1 * ConvexToRotation
          Transform rotationXform = Stack.alloc(Transform.class);
          Matrix3f tmpMat = Stack.alloc(Matrix3f.class);
          tmpMat.mul(worldTocollisionObject.basis, convexToTrans.basis);
          rotationXform.set(tmpMat);

          BridgeTriangleConvexcastCallback tccb = new BridgeTriangleConvexcastCallback(castShape, convexFromTrans, convexToTrans, resultCallback, collisionObject, triangleMesh, colObjWorldTransform);
          tccb.hitFraction = resultCallback.closestHitFraction;
          tccb.normalInWorldSpace = true;
         
          Vector3f boxMinLocal = Stack.alloc(Vector3f.class);
          Vector3f boxMaxLocal = Stack.alloc(Vector3f.class);
          castShape.getAabb(rotationXform, boxMinLocal, boxMaxLocal);
          triangleMesh.performConvexcast(tccb, convexFromLocal, convexToLocal, boxMinLocal, boxMaxLocal);
        }
        else {
          ConcaveShape triangleMesh = (ConcaveShape)collisionShape;
          Transform worldTocollisionObject = Stack.alloc(Transform.class);
          worldTocollisionObject.inverse(colObjWorldTransform);

          Vector3f convexFromLocal = Stack.alloc(Vector3f.class);
          convexFromLocal.set(convexFromTrans.origin);
          worldTocollisionObject.transform(convexFromLocal);

          Vector3f convexToLocal = Stack.alloc(Vector3f.class);
          convexToLocal.set(convexToTrans.origin);
          worldTocollisionObject.transform(convexToLocal);

          // rotation of box in local mesh space = MeshRotation^-1 * ConvexToRotation
          Transform rotationXform = Stack.alloc(Transform.class);
          Matrix3f tmpMat = Stack.alloc(Matrix3f.class);
          tmpMat.mul(worldTocollisionObject.basis, convexToTrans.basis);
          rotationXform.set(tmpMat);

          BridgeTriangleConvexcastCallback tccb = new BridgeTriangleConvexcastCallback(castShape, convexFromTrans, convexToTrans, resultCallback, collisionObject, triangleMesh, colObjWorldTransform);
          tccb.hitFraction = resultCallback.closestHitFraction;
          tccb.normalInWorldSpace = false;
          Vector3f boxMinLocal = Stack.alloc(Vector3f.class);
          Vector3f boxMaxLocal = Stack.alloc(Vector3f.class);
          castShape.getAabb(rotationXform, boxMinLocal, boxMaxLocal);

          Vector3f rayAabbMinLocal = Stack.alloc(convexFromLocal);
          VectorUtil.setMin(rayAabbMinLocal, convexToLocal);
          Vector3f rayAabbMaxLocal = Stack.alloc(convexFromLocal);
          VectorUtil.setMax(rayAabbMaxLocal, convexToLocal);
          rayAabbMinLocal.add(boxMinLocal);
          rayAabbMaxLocal.add(boxMaxLocal);
          triangleMesh.processAllTriangles(tccb, rayAabbMinLocal, rayAabbMaxLocal);
        }
      }
      else {
        // todo: use AABB tree or other BVH acceleration structure!
        if (collisionShape.isCompound()) {
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.