本文整理汇总了Java中com.bulletphysics.collision.shapes.TriangleIndexVertexArray类的典型用法代码示例。如果您正苦于以下问题:Java TriangleIndexVertexArray类的具体用法?Java TriangleIndexVertexArray怎么用?Java TriangleIndexVertexArray使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TriangleIndexVertexArray类属于com.bulletphysics.collision.shapes包,在下文中一共展示了TriangleIndexVertexArray类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: verticesToPhysicsMesh
import com.bulletphysics.collision.shapes.TriangleIndexVertexArray; //导入依赖的package包/类
public static TriangleIndexVertexArray verticesToPhysicsMesh(float[] vts, int[] ids){
IndexedMesh indexedMesh=new IndexedMesh();
indexedMesh.numTriangles=ids.length/3;
indexedMesh.triangleIndexBase=ByteBuffer.allocateDirect(ids.length*4).order(ByteOrder.nativeOrder());
indexedMesh.triangleIndexBase.asIntBuffer().put(ids);
indexedMesh.triangleIndexStride=3*4;
indexedMesh.numVertices=vts.length;
indexedMesh.vertexBase=ByteBuffer.allocateDirect(vts.length*4).order(ByteOrder.nativeOrder());
indexedMesh.vertexBase.asFloatBuffer().put(vts);
indexedMesh.vertexStride=3*4;
TriangleIndexVertexArray vertArray=new TriangleIndexVertexArray();
vertArray.addIndexedMesh(indexedMesh);
return vertArray;
}
示例2: createShape
import com.bulletphysics.collision.shapes.TriangleIndexVertexArray; //导入依赖的package包/类
protected void createShape() {
bulletMesh = new IndexedMesh();
bulletMesh.numVertices = numVertices;
bulletMesh.numTriangles = numTriangles;
bulletMesh.vertexStride = vertexStride;
bulletMesh.triangleIndexStride = triangleIndexStride;
bulletMesh.triangleIndexBase = triangleIndexBase;
bulletMesh.vertexBase = vertexBase;
bulletMesh.triangleIndexBase = triangleIndexBase;
TriangleIndexVertexArray tiv = new TriangleIndexVertexArray(numTriangles, triangleIndexBase, triangleIndexStride, numVertices, vertexBase, vertexStride);
cShape = new GImpactMeshShape(tiv);
cShape.setLocalScaling(Converter.convert(worldScale));
((GImpactMeshShape)cShape).updateBound();
cShape.setLocalScaling(Converter.convert(getScale()));
cShape.setMargin(margin);
}
示例3: initPhysics
import com.bulletphysics.collision.shapes.TriangleIndexVertexArray; //导入依赖的package包/类
/**
*
*/
@Override
public void initPhysics() {
DefaultMotionState groundMotionState = new DefaultMotionState(new Transform(new Matrix4f(new Quat4f(0, 0, 0, 1), new Vector3f(0, -1, 0), 1.0f)));
//TODO: Un uglify this code.
TriangleIndexVertexArray vertArray = new TriangleIndexVertexArray();
for (Mesh mesh : this.getMeshes()) {
// Construct collision shape based on the mesh vertices in the Mesh.
float[] positions = mesh.getPositions();
int[] indices = mesh.getIndices();
IndexedMesh indexedMesh = new IndexedMesh();
indexedMesh.numTriangles = indices.length / 3;
indexedMesh.triangleIndexBase = ByteBuffer.allocateDirect(indices.length*4).order(ByteOrder.nativeOrder());
indexedMesh.triangleIndexBase.asIntBuffer().put(indices);
indexedMesh.triangleIndexStride = 3 * 4;
indexedMesh.numVertices = positions.length / 3;
indexedMesh.vertexBase = ByteBuffer.allocateDirect(positions.length*4).order(ByteOrder.nativeOrder());
indexedMesh.vertexBase.asFloatBuffer().put(positions);
indexedMesh.vertexStride = 3 * 4;
vertArray.addIndexedMesh(indexedMesh);
}
BvhTriangleMeshShape collShape = new BvhTriangleMeshShape(vertArray, false);
System.out.println("SCALE: " + this.getScale());
//collisionShape = new ScaledBvhTriangleMeshShape(collShape, new Vector3f(this.getcale(), this.getScale(), this.getScale()));
collisionShape = collShape;
collisionShape.setLocalScaling(new Vector3f(this.getScale(), this.getScale(), this.getScale()));
RigidBodyConstructionInfo groundRigidBodyCI = new RigidBodyConstructionInfo(0, groundMotionState, collisionShape, new Vector3f(0,0,0));
rigidBody = new RigidBody(groundRigidBodyCI);
this.rigidBody.activate();
}
示例4: createShape
import com.bulletphysics.collision.shapes.TriangleIndexVertexArray; //导入依赖的package包/类
protected void createShape() {
bulletMesh = new IndexedMesh();
bulletMesh.numVertices = numVertices;
bulletMesh.numTriangles = numTriangles;
bulletMesh.vertexStride = vertexStride;
bulletMesh.triangleIndexStride = triangleIndexStride;
bulletMesh.triangleIndexBase = triangleIndexBase;
bulletMesh.vertexBase = vertexBase;
bulletMesh.triangleIndexBase = triangleIndexBase;
TriangleIndexVertexArray tiv = new TriangleIndexVertexArray(numTriangles, triangleIndexBase, triangleIndexStride, numVertices, vertexBase, vertexStride);
cShape = new BvhTriangleMeshShape(tiv, true);
cShape.setLocalScaling(Converter.convert(getScale()));
cShape.setMargin(margin);
}
示例5: initGImpactCollision
import com.bulletphysics.collision.shapes.TriangleIndexVertexArray; //导入依赖的package包/类
public void initGImpactCollision() {
// create trimesh
TriangleIndexVertexArray indexVertexArrays = new TriangleIndexVertexArray(
Bunny.NUM_TRIANGLES, Bunny.getIndexBuffer(), 4 * 3,
Bunny.NUM_VERTICES, Bunny.getVertexBuffer(), 4 * 3);
GImpactMeshShape trimesh = new GImpactMeshShape(indexVertexArrays);
trimesh.setLocalScaling(new Vector3f(4f, 4f, 4f));
trimesh.updateBound();
trimeshShape = trimesh;
// register algorithm
GImpactCollisionAlgorithm.registerAlgorithm(dispatcher);
}
示例6: PhysicsBody
import com.bulletphysics.collision.shapes.TriangleIndexVertexArray; //导入依赖的package包/类
/**
* Creates a new body from the specified {@link de.fabmax.lightgl.scene.Mesh} and
* {@link com.bulletphysics.collision.shapes.CollisionShape} with the specified mass.
*
* @param gfxMesh {@link de.fabmax.lightgl.scene.Mesh} used to render this body
* @param collisionMesh Triangle mesh that will be used to build the collision shape for this
* body
* @param mass Mass of the body
*/
public PhysicsBody(Mesh gfxMesh, TriangleIndexVertexArray collisionMesh, float mass) {
if (gfxMesh != null) {
mGfxMesh = gfxMesh;
addChild(mGfxMesh);
}
mCollisionMesh = collisionMesh;
mMass = mass;
mBufferedTransform.setIdentity();
mPhysicsTransform.setIdentity();
}