detect when collision has happened

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
Requiem
Posts: 20
Joined: Fri Mar 02, 2007 10:01 am

detect when collision has happened

Post by Requiem »

hi.I have already applied collision to an .irr scene and it's working fine,the camera collides with all the objects etc.Now i want to display something when the camera collides with any of the objects. getCollsionPoint(line3d<f32>, selector, ..,..) which can return true but i dnt knw how to use the "line3d". I don't knw if there is any other method to knw if collision has occured. :oops:
Requiem
Posts: 20
Joined: Fri Mar 02, 2007 10:01 am

Post by Requiem »

Is this question too easy to be answered? :cry:
Phant0m51
Posts: 106
Joined: Mon Jan 15, 2007 6:07 am

Post by Phant0m51 »

Irrlicht's primative collision detection by itself cannot tell the difference between objects it bumps into.

Casting ray's is a possible solution, but you would have to be casting a ray in the direction that the model hits the other object to know that it hit the object, so depending on the size of objects you're 'bumping' into, you may or may not be able to do this.

If your objects are large, you may be able to get away with casting 8 rays out from the center of the camera, and you could even have some of the rays go up and down. It might look something like this (top down view)

Code: Select all

....|
..\.../
---...---
../...\
....|
Don't mind the '.'s they're just to space out the 'drawing'. The lines represent the Rays cast out of your camera, just imagine those going around the center of your camera, and you could adjust the Y coordinates on them to make them point up and down, so you can find other stuff you bump into. The problem is that really small objects, or corners, might not get picked up with the rays because they may fit between the rays. This problem may be eliminated by using more rays, but you'll probably start to see a performance hit if you're casting too many rays (although it will depend on the system your program is running on).

You should probably look into using a Physics library like Newton, Bullet, ODE, or even PhysX. I believe they have the ability to know what has collided with what.
Requiem
Posts: 20
Joined: Fri Mar 02, 2007 10:01 am

Post by Requiem »

how can i cast the rays in different direction?
Post Reply