dinvog
26-12-2007 18:13:43
Hi,
I am using the inherited class method for my contact reporter. One group has an actor of triangleMesh type while the other is compound shape as given below:
Compound Mesh
Triangle Mesh
ContactReporter Class
Setting up the GroupCallBack
The callback to onstarttouch and ontouch seem to work fine. However the onEndTouch does not seem to work. Is there something wrong with my code.
I also tried to change the NX_NOTIFY_ALL flag to NX_NOTIFY_ON_END_TOUCH but that did not help.
I had used similar code in NxOgre0.4 by declaring contactpairs and it had worked. I had a few more questions about using ActorGroups; If a collision is detected for an actor of group, will code in the callback function affect all actors in the group or just the one for which the collision occurred?
If trianglemesh is what is causing the problem than is there anyway I can convert it into a convexmesh?
I am using the inherited class method for my contact reporter. One group has an actor of triangleMesh type while the other is compound shape as given below:
Compound Mesh
gCar = mScene->createActorGroup("Car");
nxcar = mScene->createBody
(
"final_car.mesh",
new CapsuleShape(..),
...
"mass: 400, Group: Car");
nxcar->addShape(
new CapsuleShape(..)
);
nxcar->addShape(
new CapsuleShape(..)
);
Triangle Mesh
gTunnel= mScene->createActorGroup("Tunnel");
tunnel = mScene->createBody
(
"tuneel_final.mesh",
new TriangleMeshShape("tuneel_final.mesh"),
...
"Static: Yes, Group: Tunnel"
);ContactReporter Class
class myCallback : public GroupCallback::InheritedCallback
{
public :
bool air_borne;
myCallback()
{
air_borne = false;
}
void onStartTouch(Actor *a, Actor *b)
{
Body * bd = static_cast<Body*>(b);
bd->getEntity()->setMaterialName("arrow");
air_borne = false;
}
void onEndTouch(Actor *a, Actor *b)
{
Body * bd = static_cast<Body*>(b);
bd->getEntity()->setMaterialName("ball_mesh_material");
air_borne = true;
}
void onTouch(Actor *a, Actor *b)
{
Body * bd = static_cast<Body*>(b);
bd->getEntity()->setMaterialName("arrow");
air_borne = false;
}
};
Setting up the GroupCallBack
mCar_Tun = new myCallback();
gTunnel->setCallback<myCallback>(mCar_Tun,&myCallback::onStartTouch,&myCallback::onEndTouch,&myCallback::onTouch);
gTunnel->setCollisionCallback(gCar,NX_NOTIFY_ALL,true);
The callback to onstarttouch and ontouch seem to work fine. However the onEndTouch does not seem to work. Is there something wrong with my code.
I also tried to change the NX_NOTIFY_ALL flag to NX_NOTIFY_ON_END_TOUCH but that did not help.
I had used similar code in NxOgre0.4 by declaring contactpairs and it had worked. I had a few more questions about using ActorGroups; If a collision is detected for an actor of group, will code in the callback function affect all actors in the group or just the one for which the collision occurred?
If trianglemesh is what is causing the problem than is there anyway I can convert it into a convexmesh?