detecting collision 2 actors

gugus

01-12-2007 14:22:51

Hello.
How can i have collisions beetween two trianglemeshshape?(it's not for me but for somebody who doesn't speak english very well).
And has fluid been implemented in NxOgre yet?

EDIT:I do not want to make another topic,so i change th title.

alienskull

01-12-2007 17:33:05

Short answer, you can't. Triangle meshes should only be used for static ( not moving ) meshes. Use convex meshes for your dynamic ( moving ) actors/bodies.

I do believe that there has been some work done on fluids but I'm not sure to what extent they are done. I haven't used them yet.

gugus

01-12-2007 17:40:19

Thanks for answering.
Are you sure you can't?He have a concave mesh so it doesn"t work well...

gugus

01-12-2007 18:07:36

I am back but this time with a question for myself.I am trying to use the GroupCallback but it doesn't work.Could somebody send a minimal code to use it like this one?

class my myContactReporter
{
...
}

main()
{

World = new World
Scene=new Scene
bodie1=...
...}

alienskull

01-12-2007 18:18:01

Well thats why I said short answer. The long answer is yes you can use concave triangle meshes for dynamic bodies but there may be many problems with collisions and such. :wink:

If you need to you can break your concave model into several convex models. That would probably be the easiest way.

[Edit] Betajaen beat me to it while I was editing my post :roll:

betajaen

01-12-2007 18:19:35

A group of convexes making up a concave is much easier and probably faster and can be used in dynamic actors.

gugus

01-12-2007 19:47:00

Ok thanks guys.But can I attach several shape to a unique Actore?

and for my question about callback,can you give me a piece of code?

betajaen

01-12-2007 19:54:11

Use a CompoundShape.

As for ShapeGroups do a search, there are a few examples in one of the bigger posts.

gugus

02-12-2007 11:02:59

ok thanks.
GroupShape,if i understood well tell if one group collide with another or not.But that's not what i exactly want.I want to know when 2 actors collides and then call a function.I tried actorsGroup but for i reson i do not understand,it doesn't work(i must have miss something)and then finction onTouch is never called :cry: .That's why i would be very glad if somebody give me a piece of code to show how to use it!

betajaen

02-12-2007 11:37:29

It took me seven seconds to search:

http://www.ogre3d.org/phpBB2addons/view ... 7130#27130

gugus

03-12-2007 15:08:45

No one know why I it doesn't detect when my actors are colliding?

Edit:will trimesh / trimesh collision be implemented with dynamic object implemented on day?

betajaen

03-12-2007 15:30:31

Have you tried the other method of using callbacks; the function pointer route?


Trimesh to Trimesh will be implemented on Tuesday, Tuesday of never.

gugus

03-12-2007 15:41:23

No.I will try it today.
Trimesh to Trimesh will be implemented on Tuesday, Tuesday of never.I do not understand the end..(excuse my poor english level).Do you mean that NxOgre 0.9.39 will be out thuesday with trimesh to trimesh implemented or that it will never be in NxOgre?

Edit:Do you live un Europe?Beceause if you don't,you never sleep!(or at least you do not sleep at night^^)...

betajaen

03-12-2007 16:08:08

I do not work for Ageia, nor do I have access the source code or the knowledge to implement such a thing. Ageia have the finest minds in the World that could implement trimesh to trimesh collisions and they've always said it would be slow and horrid.

So you have to use alternatives like the rest of us, and stop bugging me about it.

gugus

03-12-2007 16:46:32

I don't know why,I was thinking that Aegia had it implemented :oops: :oops:

gugus

03-12-2007 17:11:45

Ok.I tried and it doesn't work.I update my NxOgre version,but it still doesn't work.
I am sure that both object colides because they are starting with their mesh colliding(and the actors go away).
And i am sure it is not colling my functions because i am doing something totaly illegal in them:
delete a;
a->_destroyActor();
a->addLocalForce(Ogre::Vector3(0,10000000,0));
b->addLocalForce(Ogre::Vector3(0,10000000,0));


And i used this for the 2nd way:
mGroup->setCallback<myContactReporter>(mReporter, &myContactReporter::onTouch, &myContactReporter::onStartTouch, &myContactReporter::onEndTouch);
mGroup->setCollisionCallback(mGroup2, NX_NOTIFY_ALL, true);


what can i do?

gugus

04-12-2007 18:26:13

It's working now...I just compiled against old NxOgre lib that i forgot to delete...

Thanks again for having helping me!

ClementM

26-01-2009 10:12:05

Hello,

I try to implements the collision between 2 objects, but it don't work
I think the problem is with the instruction "setCallback".

Please help me !
Thanks a lot ;)


class myContactReporter : public NxOgre::GroupCallback::InheritedCallback
{
public:
void onTouch(NxOgre::Actor* a, NxOgre::Actor* bc);
void onStartTouch(NxOgre::Actor* a, NxOgre::Actor* b);
void onEndTouch(NxOgre::Actor* a, NxOgre::Actor* b);
NxOgre::Scene* mScene;
};
void myContactReporter::onStartTouch(NxOgre::Actor* a, NxOgre::Actor* b)
{
a->_destroyActor();
b->_destroyActor();
}

void myContactReporter::onTouch(NxOgre::Actor *a, NxOgre::Actor *b)
{
a->_destroyActor();
b->_destroyActor();
}
void myContactReporter::onEndTouch(Actor* a, Actor* b)
{

}




Entity *ent;
char na[1024],nb[1024];
Cube * c = new Cube(1);
NodeRenderableParams nrp;
nrp.setToDefault();
nrp.mIdentifierUsage = NxOgre::NodeRenderableParams::IU_Use;
nrp.mIdentifier = mCurrentObject->getName();
NxOgre::Body *body = mScene->createBody(Ogre::String(na)+"_body",c,pos,nrp,"mass:100,Group:1);
NxOgre::Body *body = mScene->createBody(Ogre::String(nb)+"_body",c,pos2,nrp,"mass:100,Group:1);



NxOgre::ActorGroup* mGroup = mScene->createActorGroup("1");
NxOgre::ActorGroup* mGroup2 = mScene->createActorGroup("2");
mReporter->mScene = mScene;
bool ownCallback = true;

mGroup->setCallback<myContactReporter>(mReporter,
myContactReporter::onStartTouch,
myContactReporter::onEndTouch,
myContactReporter::onTouch,
ownCallback);
mGroup->setCollisionCallback(mGroup2, NX_NOTIFY_ALL, true);