Jump to content
  • Advertisement
Sign in to follow this  

Graphics matrices give odd render results

This topic is 1665 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

Hello all,

 

I've been fiddling around with matrices. I think I have everything it working, however, the results seem kind of strange.

 

No rotation:

KjDRt8q.jpg

 

45 degrees rotation around the z-axis.

Z1rjnak.jpg

 

It seems like the proportions after rotations are incorrect, is this just me or what?

I've set the FOV to 90 degrees and the aspect ratio to 1024/768 for a 1024x768 window.

 

Thanks in advance for any help.

Share this post


Link to post
Share on other sites
Advertisement

By far the most common error would be the way you calculate the aspect ratio. If both the dividend and the divisor are integers, then, depending on the language, you are likely getting an integer division so the aspect ratio is an integer. Solution is to cast either the dividend or the divisor, or both, to a floating point value to force a floating point division.

Share this post


Link to post
Share on other sites

Are WINDOW_WIDTH and WINDOW_HEIGHT floating point values? If not, you are doing integer division when calculating the aspect ratio.

Edited by Brother Bob

Share this post


Link to post
Share on other sites

Camera c(1, 100, .25*TAU, WINDOW_WIDTH / WINDOW_HEIGHT);

 

are WINDOW_WIDTH and WINDOW_HEIGHT integers? Try this

 

Camera c(1, 100, .25*TAU, (float)WINDOW_WIDTH / WINDOW_HEIGHT);

 

EDIT: Ninja'd

Edited by Paradigm Shifter

Share this post


Link to post
Share on other sites

void setLookat(const Vector3f& target, const Vector3f& up)

{
       n = target.normalized();
       u = up.normalized().cross(n);
       v = n.cross(u);
 
       computeView();
}
 
If n and u aren't orthogonal you need to normalise v after the cross product, try that...

Share this post


Link to post
Share on other sites

As far as I know n and u are orthogonal for target=(0,0,1) and up=(0,1,0) but I've changed

v = n.cross(u)

to

v = n.cross(u).normalized()

but still the same image.

 

Maybe I should have mentioned this earlier, but the quad is a square, the vertex coordinates are:

{

{-0.5f,  0.5f, 1},
{ 0.5f,  0.5f, 1},
{-0.5f, -0.5f, 1},
{ 0.5f, -0.5f, 1}

}

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!