Jump to content
  • Advertisement
Sign in to follow this  
NDIR

OpenGL matrix question

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

Hey, maybe this is an easy question, but i do not have much experience in equation to matrix transformations :) Here's the deal: i'm trying to create an opengl projection (dimetric) matrix. I have this 2 equations: x' = x·cos(7°) + ½ z·cos(42°) y' = y + ½ z·sin(42°) - x·sin(7°) So how does this translate to opengl matrix? So i could do this: ... glMatrixMode(GL.GL_PROJECTION); glLoadIdentity(); glOrtho(.....); double matrix[] = { // here come things from equations }; glMultMatrixd(matrix); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); ...

Share this post


Link to post
Share on other sites
Advertisement
If you understand how a matrix is multiplied, you will see what values goes where in the matrix. For example, the resulting X-component weights the original vector's X and Z component by cos(7) and 0.5*cos(42), respectively, so stick those factors into the matrix's top row. Same for the second row for the Y-component.

double matrix[] =
{
cos(7), -sin(7), 0, 0,
0, 1, 0, 0,
0.5*cos(42), 0.5*sin(42), 0, 0,
0, 0, 0, 0,
};

Just make sure you get the angles in radians, not degrees.

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.

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!