projection matrix

Started by
0 comments, last by JohnBolton 19 years, 6 months ago
I understand the model -> world and world -> camera transformation matricies but after those two transforms I want to know how that camera space coordinate actually ends up as a 2D coordinate in the viewport window.... I also am ok with actually calculating a projection matrix... So my problem is.... Am I right in thinking that the projection matrix transforms space from the camera viewing frustum to a cube ? If so, assuming I have a correct projection matrix, I should just be able to transform a 3d vector( point ), by the projection matrix and that would give me the coordinates of the 3d point in the projection cube... So if I then divide the x and y coords of of the transformed point by the w value of the transformed point, that should give me the coordinates of the point in my actual viewport ranging from -1.0f to 1.0f ? Then, if I multiply that number by the viewport width and height, I get the actual windows screen coordinates ? Is all of this correct ? Can anyone tell me where I've gone wrong. All this is with a view to doing some sort mouse clicking on objects in my world, but I'm a bit stuck on the maths needed.
Advertisement
Almost. After transforming by the projection matrix, the ranges of x and y are already [-1,1] (in most renderers). To get the location of the point relative to the center of the viewport, you multiply x and y by the viewport's w/2 and h/2 (which must be in screen space).
John BoltonLocomotive Games (THQ)Current Project: Destroy All Humans (Wii). IN STORES NOW!

This topic is closed to new replies.

Advertisement