Skip to main content
GameDev.net gamedev.net
🔒 Locked

Picking ray (using gluLookAt)

Started by VanKurt Sep 26, 2005 at 2:53 AM 0 replies 600+ views
Original Post
VanKurt
VanKurt
Hi there! I thought that this topic was rather well documented but after half an hour of googlin' I ended up here ;-) The problem: I'm working on some kind of editor. The view is done rthe following way: there's one point for the camera's pos, and one for it's focus. Then I use "gluLookAt(pos, focus)" to render the scene. So the camera is simpley positioned at POS and looks straight to FOCUS. Now when the user clicks on the screen (giving me coords fom (0,0) to (1024,768)) I want to calculate the corresponding ray (from the cam's pos through my scene). The next thing I need is simply the intersection point between the ray and the "normal" plane (y=0, just extending along the X/Z axis). But this is rather easy once I got the ry (I guess) ;-) So what troubles me right now is how to get the ray. It's starting point is the camera's position, right? But how do I get it's direction? I guess I'll somehow have to take the viewing matrices (how do I get those?) and do some crazy math with them... Can you help me out? Thanks!!!
timw
timw
there was a thread about generating rays form perspective camera

http://www.gamedev.net/community/forums/topic.asp?topic_id=340401

If I recal I posted an entire psudo code for doing this.

Tim

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.