PDA

View Full Version : calculating the way



06-12-2004, 07:00 AM
hi, i am coding a 2d game where i click on the screen and the unit moves there.
but how can i check if theres a nonwalkable area beetween the starting and ending point ? i mean, how can i check if the line from starting to ending point crosses the polygon which marks my non walkable terrain.
i read a lot about selection but glupickmatrix only lets me define a cube not a line
how can this be done

thanks

ZbuffeR
06-12-2004, 10:56 AM
This is not an opengl question, this is an algorithm problem.
Google for pathfinding.

06-12-2004, 12:31 PM
read it. its an opengl question. i dont want an algorythm that calculates a way around objects. i want to know how to check if an object is in my way , in opengl.

06-12-2004, 01:03 PM
No its not, OpenGL does rendering only.

OpenGL has no knowledge about your "non walkable" areas.

Zbuffer already pointed you in the correct direction "pathfinding". Another thing that comes to mind are simple line->triangle intersection tests.

But none of this has anything to do with OpenGL though. Just using OpenGL for rendering doesnt mean all your questions are OpenGL related.

06-12-2004, 06:59 PM
i read a lot about selection but glupickmatrix only lets me define a cube not a line how can this be doneactually, selection could be used for collision detection, but would require a great deal of thought and effort to make it practical (if at all possible). having never attempted it myself, i can't say for sure, but most anything is possible. if you find a way, please post your results! :)