character detecting a body

alejandro

31-05-2007 22:25:17

i want to know ,with what body is my character controler colliding

so i add the body actor to a group

i im using the variable hit , from the class character controler , when it call the function NxControllerAction character::onShapeHit(const NxControllerShapeHit& hit)

i save the hit value in hitt , so it is public

so i my app, i used and i did this :

if (mPlayer->mColision()){

if ( mPlayer->hitt.shape->getActor().getGroup() == 10)
{

// code here
}

}

// in the setup of the scene
NxActorGroup grupo = 10 ;
bodyArbolTrepar->mActor->setGroup( grupo );

the weird thing , is when i add this to the body

bodyArbolTrepar->freezeAll(); , it do not enter to the "if" ,
"(// code here ) "

so , i dont know

the "bodyArbolTrepar" is just a body with a cubeshape

when i delete my terrain and replace with the body, bodyArbolTrepar and chage the dimension , like cubeShape(Vector3(1000,1,1000)); and used frezee it WORKS !!,

but when the character is touching the terrain and also touch the body (tree) , it doesnt work .


any comments will be helpful

i just need know with what is colling my character controller
i am using 0.4 RC3

Pottej

01-06-2007 14:20:45

Sorry not really sure what is going on but want to see if you fix your problems since I will need character collision detection soon :)

Why are you freezing it exactly? Maybe frozen bodies are not meant to trigger the onShapeHit command?

If you want bodies for terrain why not use static bodies, instead of frozen dynamic ones?

Also it would be good to know: what is your tree? What is your terrain? (e.g. is it static, frozen, what shape is it? etc.).

alejandro

01-06-2007 23:03:15

thanks for you reply .

i have frezee because it was non static, but even , if i put static like this
body* bodyArbolTrepar = m_Scene->createStaticBody("bodyArbolTrepar", "arbol.mesh" ,arbolesTrepar_shape,
pose (Vector3(30,5,30) ));

it do not work , the character is detectin the colision , but i dont know how to get the body , the body with he is colliding.

the terrain is static and with a mesh Shape
the tree is a body , with a cubeshape and static

Toby

08-06-2007 08:46:16

If I do not use character controller class. Can I make collision detection with a simple body??

I try to do it for my rocket and bullet but I always get the same collision respond. Maybe because my terrain is static body and because I test if mt is in colliding with other bounding box. And terrain bounding box is very large.
Any idea how to do it?

Thx

alejandro

13-06-2007 22:54:51

yes, of couse , with , 0.4 just use contact reporters, is a very simple class
and you can use group , for detecting with who is colliding

Toby

16-06-2007 12:19:36

Yep, I know this class, i take a look on ageia documentation. But I understand that you must set a contact reporter for only 2 entities. An entities can be a group. To collide with track and object, ok.

But if I have 10 single entities and I want to know if I collide with 1 or 2 or number 8. I must set contact reporter for 1 to 2, 1 to 3, 1 to 4 ... 1 to 10 ....

??

Thanks.

I tried by getting each actors and test with each bounding box colision.

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++;

if(actor->getName() != "NxB")
{

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);
mWeapons[i]->setParticle(false);

std::cout<<"explode by touching "<<actor->getName()<<std::endl;
}
}
}


Return always same name. Maybe because bind my track bounding box??

<~Creatine~>

16-06-2007 13:57:00

Can I make collision detection with a simple body??
Thx

I show this in 0.9 topic. 0.4 directly can it.

Look at AGEIA doc for contact reporter events:
First, subclass NxUserContactReport:

class MyContactReport : public NxUserContactReport
{
void onContactNotify(NxContactPair& pair, NxU32 events)
{
}
} myReport;


Then register this object with the SDK as before:

scene->setUserContactReport(&myReport);

Toby

16-06-2007 14:16:39

Yep, I already look into this class, then it is taht I said, we must register all combinatio of pair contact that we want to notify.

I will do it.

Thanks for your answers...