nikhil
04-12-2006 13:45:43
I've my ContactCallback class defined for two materialID's.
The problem is when the userBegin is first called m_body1 is the Ball body and when it is called the second time it's the track body!!!!!
I don't understand this behaviour..First of all isn't the body0 / body1 suppposedly dependent on the order in which we pass the MaterialID's.
I can, by checking for which OgreNode is the body attached to, deal with this problem. But according to me this shouldn't be happening in the first place. Unless ofcourse my assumption of m_body0 being the first body passed in the MaterialPair is wrong..
regards
Nikhil
OgreNewt::MaterialID* motorBallMatID = new OgreNewt::MaterialID(newtWorld);
OgreNewt::MaterialID* trackMatId= new OgreNewt::MaterialID(newtWorld);
trackBody->setMaterialGroupID(trackMatId);
motorBallBody->setMaterialGroupID(motorBallMatID );
ballTrackMatPair = new OgreNewt::MaterialPair(newtWorld, motorBallMatID, trackMatId);
ballTrackMatPair->setContactCallback(_ballTrackCollideCallback);
class BallTrackCollideCallback: public OgreNewt::ContactCallback
{
bool isTouchingTrack;
public:
BallTrackCollideCallback () : isTouchingTrack(false)
{}
int userBegin()
{
Ball* ball = (Ball *) m_body1->getUserData();
//check only if it's actually touching the track.. we check for whether it got off the ground or not..
if (isTouchingTrack)
isTouchingTrack = ball->checkBallTouchTrack();
return 1;
}
};
The problem is when the userBegin is first called m_body1 is the Ball body and when it is called the second time it's the track body!!!!!
I don't understand this behaviour..First of all isn't the body0 / body1 suppposedly dependent on the order in which we pass the MaterialID's.
I can, by checking for which OgreNode is the body attached to, deal with this problem. But according to me this shouldn't be happening in the first place. Unless ofcourse my assumption of m_body0 being the first body passed in the MaterialPair is wrong..
regards
Nikhil