What is the best way to do CD between two meshes?
How would I do it with DirectX?
So far I can get the hello world example to work. But instead of outputing in a cmd box I made a mesh update its Y. It works but I don't know how to use a DirectX mesh with Bullet CD.
Bullet Collision Detection
Re: Bullet Collision Detection
To use a directX mesh in bullet, you would need to convert the mesh to a triangle mesh with vertices, and indices that make triangles.
You can then use a btTriangleMesh, or a btTriangleIndexVertexArray to create a btGImpactShape, which can be used in bullet for collision detection.
You can then use a btTriangleMesh, or a btTriangleIndexVertexArray to create a btGImpactShape, which can be used in bullet for collision detection.
Re: Bullet Collision Detection
so is this how I would do it?
I couldn't find a btGImpactShape but the closest I could come is the btGImpactMeshShape.
So would that work?
How would I do collisions between btGImpactMeshShapes?
Code: Select all
LPD3DXMESH pMesh;
DWORD numFaces = pMesh->GetNumFaces();
DWORD numVertices = pMesh->GetNumVertices();
int *indices = new int[numFaces * 3];
for (int i=0;i < numFaces; i++)
{
pData->indices[i*3+0] = ind[i*3+0];
pData->indices[i*3+1] = ind[i*3+1];
pData->indices[i*3+2] = ind[i*3+2];
}
btScalar *vertices;
vertices = new btScalar[numVertices * 3];
for(UINT i = 0; i < numVertices; i++)
{
pData->vertices[i*3+0] = v[i].position.x;
pData->vertices[i*3+1] = v[i].position.y;
pData->vertices[i*3+2] = v[i].position.z;
}
btTriangleIndexVertexArray *indexVertexArrays = new btTriangleIndexVertexArray(numFaces, indices, 3 * sizeof(int), numVertices, (btScalar*) &vertices[0], sizeof(btScalar) * 3);
btGImpactMeshShape *impact_shape = new btGImpactMeshShape( indexVertexArrays );
So would that work?
How would I do collisions between btGImpactMeshShapes?
Re: Bullet Collision Detection
How would I do collisions between btGImpactMeshShapes?
If I end up using really complex meshes that would make this method slow wouldn't it? I would have to use a simple shape like btBoxShape or a simpler mesh used for collision only riight?
I'm going to look this up but how do I do collisions between btBoxShape?
As for making the real meshes move I just update their cords based on the bullet meshes right?
If I end up using really complex meshes that would make this method slow wouldn't it? I would have to use a simple shape like btBoxShape or a simpler mesh used for collision only riight?
I'm going to look this up but how do I do collisions between btBoxShape?
As for making the real meshes move I just update their cords based on the bullet meshes right?
Re: Bullet Collision Detection
?) How would I do collisions between btGImpactMeshShapes?
?) If I end up using really complex meshes that would make this method slow wouldn't it? I would have to use a simple shape like btBoxShape or a simpler mesh used for collision only right?
?) This code works for a normal like player mesh right?
?) Pretty much the same could be used except
for terrains right?
?) How would I do collisions between btBvhTriangleMeshShape and btGImpactMeshShape?
?) How does Bullet do collisions?
I saw that you just do some loop and it automatically does the physics and collision detection... There isn't any if(box.collideswith(wall)) type thing?
?) If I end up using really complex meshes that would make this method slow wouldn't it? I would have to use a simple shape like btBoxShape or a simpler mesh used for collision only right?
?) This code works for a normal like player mesh right?
Code: Select all
LPD3DXMESH pMesh;
DWORD numFaces = pMesh->GetNumFaces();
DWORD numVertices = pMesh->GetNumVertices();
int *indices = new int[numFaces * 3];
for (int i=0;i < numFaces; i++)
{
pData->indices[i*3+0] = ind[i*3+0];
pData->indices[i*3+1] = ind[i*3+1];
pData->indices[i*3+2] = ind[i*3+2];
}
btScalar *vertices;
vertices = new btScalar[numVertices * 3];
for(UINT i = 0; i < numVertices; i++)
{
pData->vertices[i*3+0] = v[i].position.x;
pData->vertices[i*3+1] = v[i].position.y;
pData->vertices[i*3+2] = v[i].position.z;
}
btTriangleIndexVertexArray *indexVertexArrays = new btTriangleIndexVertexArray(numFaces, indices, 3 * sizeof(int), numVertices, (btScalar*) &vertices[0], sizeof(btScalar) * 3);
btGImpactMeshShape *impact_shape = new btGImpactMeshShape( indexVertexArrays );
Code: Select all
btBvhTriangleMeshShape* trimeshShape;
trimeshShape = new btBvhTriangleMeshShape(indexVertexArrays, useQuantizedAabbCompression, aabbMin, aabbMax);
?) How would I do collisions between btBvhTriangleMeshShape and btGImpactMeshShape?
?) How does Bullet do collisions?
I saw that you just do some loop and it automatically does the physics and collision detection... There isn't any if(box.collideswith(wall)) type thing?
Re: Bullet Collision Detection
BUMP!
Too many questions at once maybe?
How about one at a time.
First. I want to understand how Bullet works. When I tried the hello world code with my meshes I noticed something. I didn't need to check if they hit each other to make them stop. Like I am used to with 2d CD. So does this mean that all of the checking is done for you?
If so then how would I do events like for example if( bullet hits badguy) {badguydies();)?
Please help me.
Too many questions at once maybe?
How about one at a time.
First. I want to understand how Bullet works. When I tried the hello world code with my meshes I noticed something. I didn't need to check if they hit each other to make them stop. Like I am used to with 2d CD. So does this mean that all of the checking is done for you?
If so then how would I do events like for example if( bullet hits badguy) {badguydies();)?
Please help me.