How to get the collided mesh ?

You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers.
No questions about C++ programming or topics which are answered in the tutorials!
Post Reply
maitrelame2
Posts: 26
Joined: Sun Jan 21, 2007 9:11 pm

How to get the collided mesh ?

Post by maitrelame2 »

Hi !

I am trying to create a FPS but when my bullet collide a mesh I would like to know which mesh it was so I can decrease his health !

How could I know which mesh has been collide.
I use ITriangleSelector.

Maybe It's not a good thing?

Thanks
Irrlicht 4ever.
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

What is your method of collision detection other than using a triangle selector? Presumably you have multiple nodes that the bullet can collide with.

One thing you could do is for each bullet iterate through all the players checking the bullet against the player's triangle selector, then you'll know which one has been hit.
Image Image Image
vitek
Bug Slayer
Posts: 3919
Joined: Mon Jan 16, 2006 10:52 am
Location: Corvallis, OR

Post by vitek »

It isn't really good enough to test the position of the bullet against the player triangle selector. Remember that the simulation runs at discrete intervals depending on the frame rate. At 60fps, the physics run every 0.0167 seconds. A bullet travelling at 600 ft/sec will go 10 feet in that time.

If you just do discrete collision detection every frame, the bullet may have passed through the model since the last time you did collision detection.

Ideally you would take the previous position of the bullet and the new position of the bullet and create a line segment. Then you'd do collision testing on that line segment. For efficiency you would want to check the nodes bounding box against the ray [possibly using getSceneNodeFromRayBB()] and if that succeeds, you would want to do the more expensive mesh to ray collision test [with getCollisionPoint()].

Travis
maitrelame2
Posts: 26
Joined: Sun Jan 21, 2007 9:11 pm

Post by maitrelame2 »

Thanks.

Actually I guess It's gonna be hard to use this method because the collision are calculating inside the server so that nobody can hack.

Which method would be better?

I guess getCollisionPoint would be efficient but I never used it so I don't know how it does work.

maitrelame2
Irrlicht 4ever.
Post Reply