Sign in to follow this  
Medo Mex

Detect collision only with a shape (No physics)

Recommended Posts

I am loading a mesh, this mesh will be invisible, so I want to only detect collision with it, other meshes should be able to intersect with it, the only purpose is to detect collision.

I'm able to detect collision but the mesh is treated as physical mesh and other meshes can't intersect with it.

How do I make the mesh intersectable? I want to ONLY detect collision

Here is the code I'm using:[CODE]
btConvexHullShape* invisibleShape = new btConvexHullShape((btScalar*)btVertices, numVertices, sizeof(btVector3));
btAlignedObjectArray<btCollisionShape*> collisionShapes;
btTransform groundTransform;
btScalar mass(.0);
//rigidbody is dynamic if and only if mass is non zero, otherwise static
bool isDynamic = (mass != 0.f);
btVector3 localInertia(0,0,0);

if (isDynamic)
btDefaultMotionState* myMotionState = new btDefaultMotionState(groundTransform);
btRigidBody::btRigidBodyConstructionInfo rbInfo(mass,myMotionState,invisibleShape,localInertia);
btRigidBody* body = new btRigidBody(rbInfo);


Share this post

Link to post
Share on other sites
I know that, but usually I initialize btRigidBody by giving information about the mesh, such as the radius if it's a sphere, how can I make the following sphere btGhostOjbect?
[CODE]btSphereShape *sphere = new btSphereShape(500.0f);[/CODE]

Share this post

Link to post
Share on other sites
as both btGhostObject and btRigidBody derive from btCollisionObject you can just do :

btSphereShape *sphere = new btSphereShape(500.0f);
btGhostObject* ghost = new btGhostObject();

(which you could also do on the rigid body rather than setting the collision shape in the btRigidBodyConstructionInfo and passing that to the btRigidBody ctor.

make sure you do all this before adding it to the collisionWorld though.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this