Jump to content

  • Log In with Google      Sign In   
  • Create Account

Ray / Polygon Collision from DigiBen


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
1 reply to this topic

#1 BytePtr   Members   -  Reputation: 106

Like
0Likes
Like

Posted 14 January 2012 - 07:56 AM

I have a DidgiBen programming Lessons source of simple line -> polygon collision code:

http://pastebin.com/XEjwQfst

The source contains lines like this:


  • // This is our line that we will be checking against the polygon's plane for collision.

  • // We position the line going directly through the polygon at first.

  • CVector3 vLine[2] = { {0, 0.5f, -0.5f}, {0, 0.5f, 0.5f} };



vLine is used like ray, to shoot through polygon / triangle / quad.
It works fine.

Now, my question is: is it possible and how to make this code to use ray from gluUnproject?
Instead of hardcoded vLine?

Will this be very hard? What modifications i must make?

Sponsor:

#2 dpadam450   Members   -  Reputation: 946

Like
0Likes
Like

Posted 17 January 2012 - 02:02 AM

you have to call glGetDouble to grab the current projection matrix, gluUnproject asks for a few other things. Take a point such as mousex, mousey, far plane (the parameter for far in gluPerspective), and that gives you the 3D point really far away from your 3D camera. Subtract that point, from your camera position and you have a 3d ray.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS