Hi,
i want to test, if a vector has a collision with my level.
How can I test this case?
Bye,
Christ/off
Collision detection between vector and Mesh
irr::scene::ISceneCollisionManager::getCollisionPoint
look it up in the manual
BTW Irrlicht's collision code is slow. It isn't that slow, it can be used for a few tests per frame, but beware of it when you're into anything more than, say, 10 tests a frame.
colDet is much better when it comes to collisions. And then a physics engine might also do the job.
look it up in the manual
BTW Irrlicht's collision code is slow. It isn't that slow, it can be used for a few tests per frame, but beware of it when you're into anything more than, say, 10 tests a frame.
colDet is much better when it comes to collisions. And then a physics engine might also do the job.
colDet is what you think it is, a collision library.
It's pretty simple to use with Irrlicht. You just do this:
and then you can do mesh-mesh collision, sphere-mesh collisions, ray-mesh collisions, and so forth.
Just google for colDet, it'll come up.
EDIT: Oh, and here's how I build the mesh in my current engine:
It's pretty simple to use with Irrlicht. You just do this:
Code: Select all
CollisionModel *model = newCollisionModel();
model->addTriangle(....);
model->addTriangle(....);
model->addTriangle(....);
...
model->finalize();
Just google for colDet, it'll come up.
EDIT: Oh, and here's how I build the mesh in my current engine:
Code: Select all
void CLevelManager::createCollisionModel(IMesh *mesh)
{
if(m_collision_model)
{
delete m_collision_model;
m_collision_model = NULL;
}
m_collision_model = newCollisionModel3D(true);
for(int i = 0; i < mesh->getMeshBufferCount(); ++i)
{
IMeshBuffer *mesh_buffer = mesh->getMeshBuffer(i);
if(mesh_buffer->getVertexType() == EVT_STANDARD)
{
S3DVertex *vertices = (S3DVertex *)mesh_buffer->getVertices();
u16 *indices = mesh_buffer->getIndices();
for(int i = 0; i < mesh_buffer->getIndexCount(); i += 3)
{
m_collision_model->addTriangle(
vertices[i].Pos.X, vertices[i].Pos.Y, vertices[i].Pos.Z,
vertices[i + 1].Pos.X, vertices[i + 1].Pos.Y, vertices[i + 1].Pos.Z,
vertices[i + 2].Pos.X, vertices[i + 2].Pos.Y, vertices[i + 2].Pos.Z
);
}
}
else
{
S3DVertex2TCoords *vertices = (S3DVertex2TCoords *)mesh_buffer->getVertices();
u16 *indices = mesh_buffer->getIndices();
for(int i = 0; i < mesh_buffer->getIndexCount(); i += 3)
{
m_collision_model->addTriangle(
vertices[i].Pos.X, vertices[i].Pos.Y, vertices[i].Pos.Z,
vertices[i + 1].Pos.X, vertices[i + 1].Pos.Y, vertices[i + 1].Pos.Z,
vertices[i + 2].Pos.X, vertices[i + 2].Pos.Y, vertices[i + 2].Pos.Z
);
}
}
}
m_collision_model->finalize();
}
It would be possible to modify the OctTreeTriangleSelector so that it gave accurate detection using the octree to avoid testign uneccesary areas. Currently the OctTreeTriangleSelector function for getting triangles from a ray returns all triangles that intersect with the ray's aabb -- not very useful.
You do a lot of programming? Really? I try to get some in, but the debugging keeps me pretty busy.
Crucible of Stars
Crucible of Stars