Archived

This topic is now archived and is closed to further replies.

lekki

camera

Recommended Posts

Hey I write my own raytracer and i think how to calculate ray direction vector from calcuted projection matrix i model view matrix. i use opengl to calculate these matrix. P = [x, y, z, 1]T P’ = [x’, y’, z’, 1]T = Mmodelview*P. P” = [x”, y”, 1]T = Mprojection*P’. i use glGet() to obtain these matrix. Give me a hint how to find a ray direction for given point (x, y). lekki

Share this post


Link to post
Share on other sites
Look into the gluUnproject(...) function. If you give it a viewport coordinate, such as [0,0] it will return the location of that point in the scene. From there you can calculate the direction of the ray by making it travel along the vector formed by subtracting the eye point from the newly unprojected point.

Share this post


Link to post
Share on other sites