checking for collision?

grizzley90

28-10-2006 15:02:24

How can I check to see if two objects are colliding or just collided? Sorry if it seems like a general question...

grizzley90

29-10-2006 02:57:00

Would contact callback be the right thing to use ?

Game_Ender

29-10-2006 03:56:25

Not trying to troll here, but did you actually try it? You could probably try it/read Newton documentation faster than get an answer on the forums.

grizzley90

29-10-2006 14:28:55

Yeah i read the newton documentation and i saw the virtual contact callback class but i dont know how to use it and im not even sure if its the right thing to use??

P.S. We need to all write a manual as a community effort. :)

nikhil

29-10-2006 22:44:23

How can I check to see if two objects are colliding or just collided? Sorry if it seems like a general question...

Yep.. I asked the same thing.. but got better response..

You've to do something like this:-

I've something called a ball and a track and doing the following:-


//This is the object which will help in trackking collisions between the ball and track
BallTrackCollideCallback* _ballTrackCollideCallback;

OgreNewt::MaterialID* ballMatId;
ballMatId = new OgreNewt::MaterialID(m_World);

OgreNewt::MaterialID* trackMatId;
trackMatId = new OgreNewt::MaterialID(m_World);

_ballBody->setMaterialGroupID(ballMatId);
trackBody->setMaterialGroupID(trackMatId);

//Creating the Material Pair
OgreNewt::MaterialPair* ballTrackMatPair;
ballTrackMatPair = new OgreNewt::MaterialPair(m_World, ballMatId, trackMatId);
ballTrackMatPair->setContactCallback(_ballTrackCollideCallback);


and in the class:-

class BallTrackCollideCallback: public OgreNewt::ContactCallback
{
public:
//This captures the collision event. Put code here to trigger actions on collision
int userProcess()
{
return 1;
}
}


Hope this helps

regards
nik

walaber

29-10-2006 23:13:30

there is a demo that comes with OgreNewt (the conveyor belt demo) that shows how to use the contactCallback classes.

grizzley90

30-10-2006 20:09:01

All right that is exactly what I am looking for ... I guess now im gonna have to do it in mogrenewt :D