Jump to content
  • Advertisement
Sign in to follow this  
NDIR

OpenGL matrix question

This topic is 3379 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.

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!