math & physics
Hello Guys...i will try to explain my problem (sorry the bad english ok)..??
I´m making a shooter in DevC++ with OpenGl...and i am new in collisions....but i made a "bounding box" collision..ok it works...but i want to do that collision like the professional games do, that when the user collides, it slides for the side...but i want the code in opengl, because my friend try to explain the "mathematics" , hehe but i cant understand...
hehe i hope you understand my problems...
That is not OpenGL code, just mathematics, so listen to your friend.
Trying to be a bit more helpfull: Exactly in wich situations to you need sliding? If you only have axis aligned bounding boxes, there won't be any sliding.
This is a maths topic .
its because my friend tell only the mathematic, but i dont know how do this in opengl code...I want the sliding when the user collides with one box, and if he is turned to the left, he slides to the left, if he is turned to right, he slides to the right...
baldurk: This is nos a math topic, because i want to know if someone know how to this in opengl ...
erkokite: Im trying to see the pages you send, but says im not authorized...
but thank you for the answers!
OpenGL is an API to draw 3d geometry. What you want to achieve has nothing to do with drawing, so OpenGL is out of the question. It's pure math, there is no OpenGL code that does this.
heres a way to implement wall sliding for a fps type map.
i had code for it but i cant find it on my computer... sorry, anyway
ill try to explain it.
for starters you need a ray-triangle intersect.
then for each wall in your map, hopefully only the ones that are close
to the object, if you code it right, you cast a ray out from the object pointing
at the inverse of the walls normal (a vector that fires out from the wall the way the walls "pointing") so you want the inverse of this, it sorta points backwards from the wall instead of forwards.
if the ray intersects with the wall at distance less than the radius of the
object then you have found a collision, so to
implement sliding you push back the walls normal the the radius of the object minus the distance of the intersection.
if your a quick one, you should work out that this system lets you pass through the edges of the walls cause the ray firer misses to the side, this
algorythm only works if your map is all enclosed... anyway, hope you understand. this is a good way to get started though.
[EDIT] you could probably fix that by extending the walls planes length to the objects radius each edge somehow... [EDIT]