Jump to content
  • Advertisement

Archived

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

Aprosenf

Perspective Question

This topic is 6125 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''m doing a 3-D wireframe game using a 2-D API (for a contest), and I can''t quite get the perspective to work right. What''s the formula for creating a projection matrix that translates a 3-D point to a 2-D point? I already have matrix and vector classes, and the trasnformations seem to work fine, as does the line drawing function, but the perspective makes it look awkward. Also, although not as important, I''m just curious as to what the formula for rotating about a general axis is (i.e. how the function glRotate*() works). Thanks in advance.

Share this post


Link to post
Share on other sites
Advertisement
I am not very good in projective math, but I think it should work as follows:
a 0 0 0
0 b 0 0
0 0 0 1
0 0 1 0
Where a and b control the FOV. (something like a = b = sin(a/2) * screenWidth... I dunno)
Most graphics apis do not use 1, as they control the near and far clipping plane with the projection matrix, but I am too lazy now to figure out how it works...
You only need to consider the following things:
1) The projection must be the last operation.
2) After the projection, you must divide your whole vector by the homogenous coordinate. That is, if your result is (a, b, c, d) after transformation, your final result will be (a/d, b/d, c/d, 1).

There is an exercise about general axis rotation in Computer Graphics: Principles and Practice.
Foley does it the following way: He calculates M as the rotation matrix, that rotates your axis into the z axis, and then he calculates (M^-1)*R*M where R is a rotation around the z axis and M^-1 is the inverse of M. So the whole thing first rotates your object so that the rotation axis is the z axis, does the rotation around z and then rotates it back to the original orientation. Again I am too lazy to calculate it for you, but it should be possible to do it by hand. There is also the result in "Computer Graphics" but I do not have it right here. Hope this helped...

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!