Jump to content
  • Advertisement
Sign in to follow this  
gowron67

projection matrix

This topic is 5405 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!