Skip to main content
GameDev.net gamedev.net
🔒 Locked

[opengl] Isometric Ortho

Started by Ruudje May 14, 2005 at 3:57 AM 8 replies 14.5k views
Original Post
Ruudje
Ruudje
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
Gorax
Gorax
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.
Ruudje
Ruudje
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
Gorax
Gorax
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.
Ruudje
Ruudje
I know I know, but thats the normal 3d stuff, with objects getting smaller in the background etc etc.
krez
krez
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])
Ruudje
Ruudje
Tnx. This should be helpful indeed
Ruudje
Ruudje
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();}

Ruudje
Ruudje
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.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.