public void InitGImpactCollision() { /// Create Torus Shape { m_indexVertexArrays = new TriangleIndexVertexArray(DemoMeshes.TORUS_NUM_TRIANGLES, DemoMeshes.gTorusIndices, 3, DemoMeshes.TORUS_NUM_VERTICES, DemoMeshes.gTorusVertices, 3); #if BULLET_GIMPACT_CONVEX_DECOMPOSITION btGImpactConvexDecompositionShape *trimesh = new btGImpactConvexDecompositionShape( m_indexVertexArrays, IndexedVector3(1.f, 1.f, 1.f), btScalar(0.01)); trimesh->setMargin(0.07); trimesh->updateBound(); #else //GImpactMeshShape trimesh = new GImpactMeshShape(m_indexVertexArrays); //IndexedVector3 scaling = IndexedVector3.One; //trimesh.SetLocalScaling(ref scaling); //trimesh.SetMargin(0.07f); ///????? //trimesh.UpdateBound(); #endif //m_trimeshShape = trimesh; } /// Create Bunny Shape { m_indexVertexArrays2 = new TriangleIndexVertexArray(DemoMeshes.BUNNY_NUM_TRIANGLES, DemoMeshes.gBunnyIndices, 3, DemoMeshes.BUNNY_NUM_VERTICES, DemoMeshes.gBunnyVertices, 3); #if BULLET_GIMPACT_CONVEX_DECOMPOSITION btGImpactConvexDecompositionShape *trimesh2 = new btGImpactConvexDecompositionShape( m_indexVertexArrays2, IndexedVector3(4.f, 4.f, 4.f), btScalar(0.01)); trimesh2->setMargin(0.07); trimesh2->updateBound(); #else GImpactMeshShape trimesh2 = new GImpactMeshShape(m_indexVertexArrays2); IndexedVector3 scaling = new IndexedVector3(4.0f, 4.0f, 4.0f); trimesh2.SetLocalScaling(ref scaling); //trimesh2.SetMargin(0.07f); ///????? trimesh2.UpdateBound(); #endif m_trimeshShape2 = trimesh2; } ///register GIMPACT algorithm CollisionDispatcher dispatcher = m_dynamicsWorld.GetDispatcher() as CollisionDispatcher; GImpactCollisionAlgorithm.RegisterAlgorithm(dispatcher); }
public void InitGImpactCollision() { /// Create Torus Shape { m_indexVertexArrays = new TriangleIndexVertexArray(DemoMeshes.TORUS_NUM_TRIANGLES, DemoMeshes.gTorusIndices, 3, DemoMeshes.TORUS_NUM_VERTICES, DemoMeshes.gTorusVertices, 3); #if BULLET_GIMPACT_CONVEX_DECOMPOSITION btGImpactConvexDecompositionShape * trimesh = new btGImpactConvexDecompositionShape( m_indexVertexArrays, IndexedVector3(1.f,1.f,1.f),btScalar(0.01)); trimesh->setMargin(0.07); trimesh->updateBound(); #else //GImpactMeshShape trimesh = new GImpactMeshShape(m_indexVertexArrays); //IndexedVector3 scaling = IndexedVector3.One; //trimesh.SetLocalScaling(ref scaling); //trimesh.SetMargin(0.07f); ///????? //trimesh.UpdateBound(); #endif //m_trimeshShape = trimesh; } /// Create Bunny Shape { m_indexVertexArrays2 = new TriangleIndexVertexArray(DemoMeshes.BUNNY_NUM_TRIANGLES, DemoMeshes.gBunnyIndices, 3, DemoMeshes.BUNNY_NUM_VERTICES, DemoMeshes.gBunnyVertices, 3); #if BULLET_GIMPACT_CONVEX_DECOMPOSITION btGImpactConvexDecompositionShape * trimesh2 = new btGImpactConvexDecompositionShape( m_indexVertexArrays2, IndexedVector3(4.f,4.f,4.f),btScalar(0.01)); trimesh2->setMargin(0.07); trimesh2->updateBound(); #else GImpactMeshShape trimesh2 = new GImpactMeshShape(m_indexVertexArrays2); IndexedVector3 scaling = new IndexedVector3(4.0f, 4.0f, 4.0f); trimesh2.SetLocalScaling(ref scaling); //trimesh2.SetMargin(0.07f); ///????? trimesh2.UpdateBound(); #endif m_trimeshShape2 = trimesh2; } ///register GIMPACT algorithm CollisionDispatcher dispatcher = m_dynamicsWorld.GetDispatcher() as CollisionDispatcher; GImpactCollisionAlgorithm.RegisterAlgorithm(dispatcher); }