PDA

View Full Version : gluProject doubt



ccouto
09-08-2011, 04:07 AM
Hello

I need to detect the colision between a line and a rectangle.

The procedure i am using is something like this:
1. Convert the line world coordinates into window coordinates using gluProject.
2. Check the colision between the line and the rectangle (the rectangle is in window coordinates).

Although this procedure works fine i am having problems if the line isn't totally onscreen.

For example, if one line starts at the left of the window screen i was expecting that gluProject returned a negative X coordinate, but it doesn't...

What i am missing here? Thank you for your help.

xiphos
09-08-2011, 05:18 AM
for collision why are you projecting into windows coordinates? can't you check collision in world coordinates?

ccouto
09-08-2011, 05:51 AM
i guess i could do that... but i didn't know how to handle the Z coordinate so i took this approach...

By the way this is working now using the procedure i mention, maybe i was doing something wrong anywhere else in the code...