Jump to content
  • Advertisement
Sign in to follow this  
zi_jaz

OpenGL Design a building?

This topic is 4837 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! Im new in OpenGL with C++.. just started to learn yet have to do a game. I need some help on how to design a building out of GL_QUADS with a front view. The front face of building is removed, and there will be 12 floors in the building. I am doing this game project which is to improve on a game and I have chosen Elevator Action Game to be modified.(if u ever heard of this arcade game) Basically this is a simple code that I have develop to make a long rectangular QUAD: //Using this 'drawn' QUAD, how to loop them to make 12 floors apart from each other from top to below with a gap between the floors at least 20.0 y-axis apart. void CDice::DrawSelf() { glPushMatrix(); glTranslatef(-100,y,z); glRotatef(yaw, 0.0f, 5.0f, 0.0f); glRotatef(pitch, 1.0f, 0.0f, 0.0f); glRotatef(roll, 0.0f, 0.0f, 1.0f); glBegin(GL_QUADS); //////////////////////// //Front face glColor3f(255,0,0); glVertex3f(-90.5,-10.5,10.5); glVertex3f(280.5,-10.5,10.5); glVertex3f(280.5,0,10.5); glVertex3f(-90.5,0,10.5); //////////////////////// //Right face glColor3f(0,255,0); glVertex3f(280.5,-10.5,10.5); glVertex3f(280.5,-10.5,-10.5); glVertex3f(280.5,0,-10.5); glVertex3f(280.5,0,10.5); //////////////////////// //Back face glColor3f(0,0,255); glVertex3f(280.5,-10.5,-10.5); glVertex3f(-90.5,-10.5,-10.5); glVertex3f(-90.5,0,-10.5); glVertex3f(280.5,0,-10.5); //////////////////////// //Left face glColor3f(255,255,0); glVertex3f(-90.5,-10.5,-10.5); glVertex3f(-90.5,-10.5,10.5); glVertex3f(-90.5,0,10.5); glVertex3f(-90.5,0,-10.5); //////////////////////// //Top face glColor3f(255,255,255); glVertex3f(-90.5,0.5,10.5); glVertex3f(280.5,0,10.5); glVertex3f(280.5,0,-10.5); glVertex3f(-90.5,0,-10.5); //////////////////////// //Bottom face glColor3f(255,0,255); glVertex3f(-90.5,-10.5,-10.5); glVertex3f(280.5,-10.5,-10.5); glVertex3f(280.5,-10.5,10.5); glVertex3f(-90.5,-10.5,10.5); glEnd(); glPopMatrix(); ///////////////////////////////////////////////////////////////////////// //while below is the SetupRC() void SetupRC() { glEnable(GL_DEPTH_TEST); // Hidden surface removal //glEnable(GL_CULL_FACE); // Do not calculate inside of jet glFrontFace(GL_CW); // Counter clock-wise polygons face out SetupLights(); // Nice light blue glClearColor(0.0f, 0.1f, 0.5f,0.4f); //create our camera; glMatrixMode(GL_MODELVIEW); glLoadIdentity(); gluLookAt(0,0,100, 0,0,-10, 0,1,0); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(130,1,0.3,1000); glMatrixMode(GL_MODELVIEW); }

Share this post


Link to post
Share on other sites
Advertisement
First of all, great game choice!

Now I havn't play the game in a while, but you should be able to do this pretty easily. I'd say do it floor by floor, so have a DrawFloor(...) function that, as you might think, draws a floor then translates down a floor. If you havn't used glTranslatef(...) or glTranslated(...) don't panic! All it does is move where things are drawn(in this caes, on floor lower).

So the first thing you want to choose is how many 'units' equals a floor. Since it's based off a nintendo game you might go by sprites or pixels, but also having an entire floor being one measurement units has it's own advantages.

From their you can make a 'floor' structure and it all get's fun from their :)

if you AIM me I can walk you through it IsMakeFire

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

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!