[opengl] Isometric Ortho

Started by
8 comments, last by Ruudje 18 years, 11 months ago
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
Advertisement
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.
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
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.
I know I know, but thats the normal 3d stuff, with objects getting smaller in the background etc etc.
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.
--- krez ([email="krez_AT_optonline_DOT_net"]krez_AT_optonline_DOT_net[/email])
Tnx. This should be helpful indeed
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();}

There is nothing in that posted code even remotely connected to lighting. Post some code that is relevant, and maybe someone can answer your question.
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.

This topic is closed to new replies.

Advertisement