Artic_Ice83
24-02-2008 13:33:30
i have created 6 bodies: 3 cubes and 3 spheres that belongs respectively to mCubeGroup and mSphereGroup.
If i set a collision callback with the class->method pointer, all works well except for the onEndTouch, that should restore the default material of the body.
these are the callback class and the code that sets the callback:
setting the callback...
i have also another question: if i have three groups and set the collision callback between the first and second, and between the second and third group, why do the first and third group collide?should the body of the first group pass through the body that belongs to third group(like in the physX tutorial collision groups)?
If i set a collision callback with the class->method pointer, all works well except for the onEndTouch, that should restore the default material of the body.
these are the callback class and the code that sets the callback:
class myCallback {
public:
void onStartTouch(Actor* a , Actor* b) {
Body* bd = static_cast<Body*>(b);
bd->getEntity()->setMaterialName("nx.capsule");
Body* ad = static_cast<Body*>(a);
ad->getEntity()->setMaterialName("nx.sphere");
}
void onEndTouch(Actor* a, Actor* b) {
Body* bd = static_cast<Body*>(b);
bd->getEntity()->setMaterialName("nx.sphere");
Body* ad = static_cast<Body*>(a);
ad->getEntity()->setMaterialName("nx.cube");
}
void Jiggle(Actor* a, Actor* b) {
b->addForce(Vector3(NxMath::rand(-10,10), NxMath::rand(-10,10), NxMath::rand(-10,10)) * b->getMass());
}
};
setting the callback...
mCubeGroup->setCallback<myCallback>(mCallback,&myCallback::onStartTouch,&myCallback::onEndTouch, &myCallback::Jiggle);
mCubeGroup->setCollisionCallback(mSphereGroup,NX_NOTIFY_ALL, true);
i have also another question: if i have three groups and set the collision callback between the first and second, and between the second and third group, why do the first and third group collide?should the body of the first group pass through the body that belongs to third group(like in the physX tutorial collision groups)?