Ogre particles emission on collision contact position

toglia

31-12-2009 15:18:14

I looked for this on the forums for quite a bit and was surprised I didn't find much, or I wasn't looking with the right words...

Anyway, its almost a must in any game to emit some particle sparks when two metals (or whatever) collide. And although I have perfect control over the actors that are touching, I was just curious if there was a specific way on knowing the position of the contact surface? that would be the perfect place for emitting the sparks.

Thanks for any help.

This was some great programming year, I really appreciated beatajaen's helpfulness over the year so I wanted to wish him and every Nxogre and Ogre user a Happy New Year and all those kind of nice stuff one must say :D.

toglia

01-02-2010 15:54:33

Anyone?
:P Do I have to implement some kind of custom ray-casting?

LucaMoller

01-02-2010 20:39:25

I dont know Bloody Mess, but in Bleeding I think I knew how to do it:

In the callback method:
onStartTouch(NxOgre::Actor*a, NxOgre::Actor* b, NxOgre::ContactStream* c);

c has a function called getPoint() that return an Ogre::Vector3 with the position of the contact point. So if you call c->getPoint() inside the callback method you will get the position you want for that collision. (I guess you can get the forces involved in the collision with a method in c too, you know when you want to break things if some force is reached during a collison...)
Maybe you should take a look at the NxContactPairFlag that you can set when you call the actor_group->setCollisionCallback() method, depending on it the ContactStream will be able to provide you with more or less information about the collision I think. In you case, I think it is ok to use the NX_NOTIFY_ALL flag.

Hope this helps! :wink:

toglia

02-02-2010 04:14:12

Thanks Luca, I was starting to think this forum had dropped its popularity.

Anyway, the funny part is that I'm using nxogre 0.9 :P, and that ContactStream parameter wasn't available on the callbacks by that time (as I have just found out). :D I haven't switched cause new versions are always cataloged as unstable, and sometimes incomplete, instead with the 0.9 I have had everything I needed, and it has proven me to be very robust. The other thing is that new version are not cross-platform, right? This project is linux based.

Maybe for my next project, I think this one won't have sparks... :( Nevertheless its good to know!