Sairon
16-05-2007 15:10:50
Hi, I have projectiles which acts as physx objects within the world. The collision works fine with CCD, however, I can't seem to get any contact reports on collisions with static geometry. This is needed since I need to remove bullets once they hit walls. I'm starting to belive that perhaps it's one of the limitations with static geometry, however, is there another way to do it in that case?
Any help appreciated.
[EDIT] Oh, and btw, I'm currently not using NxOgre.
Hi, I have same problems.
I launch projectiles and I want to know when they hit wall or other player.
Then my code is:
void WeaponMgr::checkCollision()
{
if(!mScene)
return;
for(unsigned int i=0; i<10; i++)
{
if(mWeapons[i]->getState() == Weapon::USE)
{
if(!static_cast<WRocket*>(mWeapons[i])->mBody)
return;
NxShape* const* shapes = static_cast<WRocket*>(mWeapons[i])->mBody->mActor->getShapes();
NxShape* shape = *shapes++;
unsigned int nbActors = mScene->getNbActors();
NxActor** actors = mScene->mScene->getActors();
while (nbActors--)
{
NxActor* actor = *actors++;
// Get our object back
nxOgre::body* Object = (nxOgre::body*)actor->userData;
if(!Object) continue;
NxShape* const* objShapes = Object->mActor->getShapes();
NxShape* objShape = *objShapes++;
NxBounds3 dest;
objShape->getWorldBounds(dest);
if(shape->checkOverlapAABB(dest))
{
static_cast<WRocket*>(mWeapons[i])->setState(Weapon::EXPLODE); static_cast<WRocket*>(mWeapons[i])->mBody->freezeAll();
std::cout<<"explode by touching "<<actor->getName()<<std::endl;
}
}
}
}
}
This does not work well. Rocket stop since I launch it and actor is always NxB.
For info I construct my racing track as a static body and other vehicle as dynamic body. Then problem come because I checkOverlapAABB with bounding box of track?
If anybody have any suggestion?
Thx.