Is it possible to do a top down RTS in OpenGL?

Started by
8 comments, last by MARS_999 22 years ago
Is it possible to do a top down view like TA in OpenGL? I think it is but not sure how one would go about it? Would I use glOrtho() or gluPerspective()? I am not sure, but from what I see TA''s tilesets are 2D textures? So if that is the case then the only 3D part of the game is the units. Which you would have to use 3DS for right? Now if you use those units you will have to use gluPerspective() so you have all three axis''s. Because if you use glOrtho() and you have an airplane fly by and do a roll its not going to show up when its rolling. So if I use a tile based engine with 512x512 textures for the map, wouldn''t I need to load each 512x512 texture with a heightmap and somehow determine the height at any given textel on the screen? Any help would be great thanks!! Bill Gates is my Pool Boy!! Nothing is to good for me!!
Advertisement
newer 3d rts games use 3D maps with variable hieght terran (empire earth, warcraft 3). Just do the whole thing in 3D. Storing a hieghtfield is cheap anyways (just 8 bits more per tile, plus they compress well). Use a perspective projection and keep the camera at some fixed distance from the ground plane looking down at a fixed angle (most games let you scroll down to horizontal with the mouse wheel, but for gameplay, thats worthless). If you have seen war3, they basically still use tiles for textures instead of the more tranditional large texture / detail texture used in most terrain renderers.
How about using a Iso Metric view in OpenGL? Where could I find info on that? I looked around on the gamedev and looks like all tutorials are on DirectX? I would prefer to do the game as a Iso Metric view since I like the way those kind of games play. Thanks!

Bill Gates is my Pool Boy!!
Nothing is to good for me!!
>>How about using a Iso Metric view in OpenGL? Where could I find info on that? I looked around on the gamedev and looks like all tutorials are on DirectX? I would prefer to do the game as a Iso Metric view since I like the way those kind of games play. Thanks! <<

yes its possible look atsetting up a orthogonal viewport +
setup the camera like so

gluLookAt(-10,sqrt(200),10,0,0,0,0,1,0) as an example

http://uk.geocities.com/sloppyturds/gotterdammerung.html
quote:Original post by zedzeek
>>How about using a Iso Metric view in OpenGL? Where could I find info on that? I looked around on the gamedev and looks like all tutorials are on DirectX? I would prefer to do the game as a Iso Metric view since I like the way those kind of games play. Thanks! <<

yes its possible look atsetting up a orthogonal viewport +
setup the camera like so

gluLookAt(-10,sqrt(200),10,0,0,0,0,1,0) as an example

http://uk.geocities.com/sloppyturds/gotterdammerung.html


Ok here is what I got setup and am seeing nothing? My code compiles fine but not sure why I don''t see a simple quad?


  void Draw(void){    glLoadIdentity();	gluLookAt(-10, sqrt(200), 10, 0, 0, 0, 0, 1, 0);          glBegin(GL_QUADS);	glColor3f(1.0f, 0.0f, 0.0f);    glVertex2f(-10.0f, -10.0f);    glVertex2f(10.0f, -10.0f);	    glVertex2f(10.0f, 10.0f);	    glVertex2f(-10.0f, 10.0f);	    glEnd();}bool InitOpenGL(int width, int height){	float ratio = float(width) / float(height);    glViewport(0, 0, width, height);    	glClearColor(0.0f, 0.0f, 0.0f, 0.0f);	glShadeModel(GL_SMOOTH);	glClearDepth(1.0f);  	glDepthFunc(GL_LEQUAL);    	glMatrixMode(GL_PROJECTION);    glLoadIdentity();    glOrtho(0.0f, float(width), 0.0f, float(height), -1.0f, 100.0f);	glMatrixMode(GL_MODELVIEW);	return true;}  


I think I got everyting setup right? Thanks for the help in advance. =)

Bill Gates is my Pool Boy!!
Nothing is to good for me!!
your screen is say 1024x768 pixels large, though that quad is only 20x20 pixels large thus it might be a bit small

use 3d vertices (x,y,z) y is going up
eg

glVertex3f(-10.0f, 0, -10.0f);
glVertex3f(10.0f,0, -10.0f);
glVertex3f(10.0f, 0, 10.0f);
glVertex3f(-10.0f, 0, 10.0f);

turn off backface culling, texturing/alphatest/lighting etc

http://uk.geocities.com/sloppyturds/gotterdammerung.html
quote:Original post by zedzeek
your screen is say 1024x768 pixels large, though that quad is only 20x20 pixels large thus it might be a bit small

use 3d vertices (x,y,z) y is going up
eg

glVertex3f(-10.0f, 0, -10.0f);
glVertex3f(10.0f,0, -10.0f);
glVertex3f(10.0f, 0, 10.0f);
glVertex3f(-10.0f, 0, 10.0f);

turn off backface culling, texturing/alphatest/lighting etc

http://uk.geocities.com/sloppyturds/gotterdammerung.html


Great its showing up now. I am a little consfused on how I should move the screen around now? I must have to make a bi-axis move now to move on what would have been one axis before? The image is showing up on the far left and would like to move it to the center of the screen so I can get a better look at it. The quad don''t look right but like I said I can''t see the whole quad. I have to admit I have only worked with glOrtho() as a x,y axis map and glPerspective as x,y,z using glTranslatef() and glRotatef() so this is all new to me. =) Thanks

Bill Gates is my Pool Boy!!
Nothing is to good for me!!
if it''s just 2d you can use glOrtho2d and 2d coordinates
There is nothing prohibiting you from using ortho to make a top-down RTS, even one with 3D units. Ortho just means that there is no perspective correction, where things get smaller with distance or lean a certain way near the edges of the screen.

Check the screenshots at my website (below) for an example of me starting out with ortho and switching to perspective. While I''m not using 3D units, you can still see the difference.

Speaking of TA, I believe it used 3D terrain AND 3D units, same as TA:K. The terrain utilized height-mapped sections with 2D textures mapped onto them.

And where do you get the idea that you can''t see a rolling plane in ortho projection? Ortho is just a method of projecting things onto the screen. There is no perspective in ortho, so there is no reduction/enlargement based on distance. I.e., that plane right at your nose and 50 units into the screen will still look the same size unless you scale it or your viewport.


Care,
Chris Rasmus

Florida, USA
RTS Engine in Development
http://www.knology.net/~heaven
Jesus is LORD!
Florida, USA
Current Project
Jesus is LORD!
quote:Original post by Heaven
There is nothing prohibiting you from using ortho to make a top-down RTS, even one with 3D units. Ortho just means that there is no perspective correction, where things get smaller with distance or lean a certain way near the edges of the screen.

Check the screenshots at my website (below) for an example of me starting out with ortho and switching to perspective. While I''m not using 3D units, you can still see the difference.

Speaking of TA, I believe it used 3D terrain AND 3D units, same as TA:K. The terrain utilized height-mapped sections with 2D textures mapped onto them.

And where do you get the idea that you can''t see a rolling plane in ortho projection? Ortho is just a method of projecting things onto the screen. There is no perspective in ortho, so there is no reduction/enlargement based on distance. I.e., that plane right at your nose and 50 units into the screen will still look the same size unless you scale it or your viewport.


Care,
Chris Rasmus

Florida, USA
RTS Engine in Development
http://www.knology.net/~heaven
Jesus is LORD!


Wow it works!! glOrtho() will do 3D. =) Oops my bad. Now I can do a game in glOrtho() top down and use 3D units. I am not worried about perspective since I can enlarge or shrink my units to make them look in proportion. Thanks a million. Now off to work on code to load .3ds models.

Bill Gates is my Pool Boy!!
Nothing is to good for me!!

This topic is closed to new replies.

Advertisement