Sign in to follow this  

[opengl] Isometric Ortho

This topic is 4590 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 all, I'm looking for a way to create an Isometric view in opengl. After some googling the only thing I came acros is to create your own matrix to do so, but no instructions whatsoever on how. I was hoping someone here can tell me how to do this. Tnx in advance

Share this post


Link to post
Share on other sites
Unless you modify the projection matrix, it defaults to an orthographical view from -1 to +1 on all 3 axiis. The way you change it is like this:

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(left,right,bottom,top,near,far);//default = -1.0,+1.0,-1.0,+1.0,-1.0,+1.0


After you do that, you simply switch back to the modelview matrix, load the identity matrix, and start drawing. One thing to take note of is the fact that the 'near' value doesn't actually mean that which is closest to the screen, it's really the negative Z range, which is the furtherest from the screen.

Share this post


Link to post
Share on other sites
ok... so how does that relate to isometric views? I have what you described, but it results in a "normal" 2D view, from the top down. I'd like to view my 3d world from under a certain angle, without the depth stuff, like C&C ra2 or something, but using real 3d, not sprites/voxels

Share this post


Link to post
Share on other sites
If you want a 3D view, you're going to want to use some perspective function like gluPerspective(). Once you've got that working, you'll need to use something like gluLookAt() in order to translate and rotate the scene into position.

Share this post


Link to post
Share on other sites
set up the orthographic view, and then rotate the axes before you render anything. you want to rotate 45 degrees around the Y axis, and then 35.264ish degrees around the Z axis (i tend to use 45 degrees here too, i think it looks nicer even though it is not technically "isometric" then).
for example, this is the projection setup code for a demo/testing-of-ideas of mine that sounds similar to what you mean:

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-100.0f, 100.0f, -100.0f, 100.0f, -500.0f, 500.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glRotatef(35.264f, 1.0f, 0.0f, 0.0f);
glRotatef(-45.0f, 0.0f, 1.0f, 0.0f);
glScalef(1.0f, 1.0f, -1.0f);

one warning though: with ortho projection, 3D things sometimes look a bit odd, i guess it depends on your models and such.

Share this post


Link to post
Share on other sites
Can you explain to me why I can't get my models to lgiht up decently when rendering like this?

I created a function for rendering like this, cuz it's confusing me like hell


GL_RenderIsometric(400, 300, model);


void GL_RenderIsometric(float x, float y, C3dsLoader &model)
{
POINT WindowSize = myApp->GetWindowSize();

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0.0f, WindowSize.x, 0.0f, WindowSize.y, -1000.0f, 1000.0f);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glRotatef(35.264f, 1.0f, 0.0f, 0.0f);
glTranslatef(x, y, 0.0f);
glRotatef(-45.0f, 0.0f, 1.0f, 0.0f);
glRotatef(-90.0f, 1.0f, 0.0f, 0.0f);
glScalef(50.0f, 50.0f, 50.0f);

model.Render_3ds();
}



Share this post


Link to post
Share on other sites
Well the thing is that if I don't use that code but render it the "normal" way (normal perspective) the lighting is fine, just like in the nehe tutorials.

Share this post


Link to post
Share on other sites

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this