Jump to content
• Advertisement

# Isometric 2:1 projection in OpenGL

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

Hi there, I am having problems getting my projection just right. I want a orthographic projection of my world such that it looks just like SimCity 2000, Transport tycoon etc. E.g. I want tiles with a 2:1 ratio on screen.
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-400, +400, -300, +300, -1000, +1000);
glRotated(-orthoAngle, 1, 0, 0);
glRotated(45, 0, 0, 1);


With the angle I calculated having to be arctangens of 2.
double PI = std::acos(-1);
double orthoAngle = (std::atan(2) * 180) / PI;


Now this is nearly correct, it the orthoAngle variable is set to about 63.43 degrees. Now this gives some artifacts in my world, such as the tiles that are being drawn are not exactly in the 2:1 ratio. An orthoAngle of about ~62.09 seems to do a better job. Obviously I don't want to have to fill in a random constant like that and I would like to get the theory right. Could anyone help me out?? The result of the original projection is as follows: CLICK! Kind regards, Mark

#### Share this post

##### Share on other sites
Advertisement
Your orthoAngle should be exactly 60 degrees, calculcated by acos(0.5).

That should fix your first problem of the lines not being drawn at exactly 1/2 slope.

After that, you will probably have to scale the projection in such a way, that the vertices in 3D coordinates end up being projected into the very center of every pixel, as opposed to a varying location.

#### Share this post

##### Share on other sites

• Advertisement
• Advertisement

• ### Popular Contributors

1. 1
Rutin
67
2. 2
3. 3
4. 4
5. 5
• Advertisement

• 21
• 10
• 33
• 20
• 9
• ### Forum Statistics

• Total Topics
633420
• Total Posts
3011792
• ### Who's Online (See full list)

There are no registered users currently online

×

## 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!