Tanque
#include
#include
#include
#include
#include
int Ancho, Alto;
float tx=0.0;
float ty=0.0;
float tz=0.0;
float a=355.0;
float b=0.0;
void ejes (){
glBegin(GL_LINES);glLoadIdentity();
glColor3f(1,0,0);
glVertex3f(0,0,0);
glVertex3f(100,0,0);
glColor3f(0,1,0);
glVertex3f(0,0,0);
glVertex3f(0,100,0);
glColor3f(0,0,1);
glVertex3f(0,0,0);glVertex3f(0,0,100);
glColor3f(1,1,1);
glEnd();
}
void base (){
glNewList(1,GL_COMPILE);
glPushMatrix();
glutWireCube(4.0);
glPopMatrix();
glEndList();
}
void tubo (){glNewList(2,GL_COMPILE);
glPushMatrix();
GLUquadricObj *qobj;
qobj = gluNewQuadric();
gluQuadricDrawStyle(qobj, GLU_LINE);
gluCylinder(qobj, 0.5, 0.5, 2.0, 20, 1);glTranslatef(0.0,0.0,2.0);
GLUquadricObj *qobj2;
qobj2 = gluNewQuadric();
gluQuadricDrawStyle(qobj2, GLU_LINE);
gluCylinder(qobj2, 0.7, 0.7, 0.2, 20, 1);
glPopMatrix();
glEndList();
}void torre (){
glNewList(3,GL_COMPILE);
glPushMatrix();
glutWireCube(2.0);
glPopMatrix();
glEndList();
}
void mover_tubo( float a, float tx, float ty, float tz ){glNewList(4,GL_COMPILE);
glPushMatrix();
glCallList(3);
glTranslatef(tx,ty,tz);
glRotatef(a,1.0,0.0,0.0);
glCallList(2);
glPopMatrix();
glEndList();
}
void mover_torre( float a, float tx,float ty, float tz ){
glNewList(5,GL_COMPILE);
glPushMatrix();
glCallList(1);
glTranslatef(tx,ty,tz);
glRotatef(a,0.0,1.0,0.0);
glCallList(4);
glPopMatrix();
glEndList();
}static void Init( void )
{
glClearIndex( 0.0 );
glShadeModel( GL_FLAT );
}
static void Reshape( int width, int height )
{
Ancho=width;
Alto=height;glClearColor(0.0,0.3,0.5,0.0);
glClear( GL_COLOR_BUFFER_BIT );
//Perspectiva
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glViewport(0+Alto/2, 0, (GLint)width/2, (GLint)height/2);...
Regístrate para leer el documento completo.