Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <windows.h>
- #include <stdlib.h>
- #include <stdio.h>
- #include <math.h>
- #include <GL/glut.h>
- //--------------------------------- Definir cores
- #define BLUE 0.0, 0.0, 1.0, 1.0
- #define RED 1.0, 0.0, 0.0, 1.0
- #define YELLOW 1.0, 1.0, 0.0, 1.0
- #define GREEN 0.0, 1.0, 0.0, 1.0
- #define WHITE 1.0, 1.0, 1.0, 1.0
- #define BLACK 0.0, 0.0, 0.0, 1.0
- #define PI 3.14159
- #define SIZE 156
- #define SIZEMINI 96
- //================================================================================
- //===========================================================Variaveis e constantes
- //------------------------------------------------------------ Sistema Coordenadas + objectos
- GLint wScreen=1000, hScreen=800; //.. janela (pixeis)
- GLfloat xC=1000.0, yC=1000.0, zC=1000.0; //.. Mundo (unidades mundo)
- //------------------------------------------------------------ Observador
- GLfloat rVisao=-300, aVisao=1*PI, incVisao=0.05;
- GLfloat obsP[] ={rVisao*cos(aVisao), 50, rVisao*sin(aVisao)};
- GLfloat angZoom=90;
- GLfloat incZoom=3;
- GLdouble tx=0;
- GLdouble ty=0;
- GLdouble tz=0;
- GLdouble Upx=0;
- GLdouble Upy=1;
- GLdouble Upz=0;
- //auxiliar de camera
- float movementSpeed = 0.05;
- GLfloat forwardVector[3] = {tx - obsP[0],ty - obsP[1], tz - obsP[2]};
- //forwardVector.normalise(); //lol
- //=========================================================== FACES DA MESA
- GLboolean frenteVisivel=1;
- static GLuint **ordem = new GLuint*[SIZE/4]();
- static GLuint **ordemMini = new GLuint*[SIZEMINI/4]();
- GLfloat tam=2.0;
- static GLfloat vertices[]={
- -30.000000, -0.000000, 96.000000, 30.000000, -0.000000, 96.000000, 30.000000, 0.000000, 0.000000, -30.000000, 0.000000, 0.000000, -30.000000, 0.000000, 96.000000, 30.000000, 0.000000, 96.000000, 30.000000, 16.000000, 96.000000, -30.000000, 16.000000, 96.000000, -30.000000, 16.000000, 128.000000, 30.000000, 16.000000, 128.000000, 30.000000, 16.000000, 96.000000, -30.000000, 16.000000, 96.000000, -30.000000, 16.000000, 128.000000, 30.000000, 16.000000, 128.000000, 30.000000, 32.000000, 128.000000, -30.000000, 32.000000, 128.000000, -30.000000, 32.000000, 160.000000, 30.000000, 32.000000, 160.000000, 30.000000, 32.000000, 128.000000, -30.000000, 32.000000, 128.000000, -30.000000, 32.000000, 160.000000, 30.000000, 32.000000, 160.000000, 30.000000, 48.000000, 160.000000, -30.000000, 48.000000, 160.000000, -30.000000, 48.000000, 192.000000, 30.000000, 48.000000, 192.000000, 30.000000, 48.000000, 160.000000, -30.000000, 48.000000, 160.000000, -30.000000, 48.000000, 192.000000, 30.000000, 48.000000, 192.000000, 30.000000, 64.000000, 192.000000, -30.000000, 64.000000, 192.000000, -30.000000, 64.000000, 224.000000, 30.000000, 64.000000, 224.000000, 30.000000, 64.000000, 192.000000, -30.000000, 64.000000, 192.000000, -30.000000, 64.000000, 224.000000, 30.000000, 64.000000, 224.000000, 30.000000, 80.000000, 224.000000, -30.000000, 80.000000, 224.000000, -30.000000, 80.000000, 256.000000, 30.000000, 80.000000, 256.000000, 30.000000, 80.000000, 224.000000, -30.000000, 80.000000, 224.000000, -30.000000, 80.000000, 256.000000, 30.000000, 80.000000, 256.000000, 30.000000, 96.000000, 256.000000, -30.000000, 96.000000, 256.000000, -30.000000, 96.000000, 352.000000, 30.000000, 96.000000, 352.000000, 30.000000, 96.000000, 256.000000, -30.000000, 96.000000, 256.000000
- };
- static GLfloat normais[] = {
- 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000
- };
- //------------------------------------------------------------ Cores
- static GLfloat cores[]={
- 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000
- };
- static GLfloat verticesMini[]={
- -30.000000, 0.000000, 0.000000, 30.000000, 0.000000, 0.000000, 30.000000, 16.000000, 0.000000, -30.000000, 16.000000, 0.000000, -30.000000, 16.000000, 32.000000, 30.000000, 16.000000, 32.000000, 30.000000, 16.000000, 0.000000, -30.000000, 16.000000, 0.000000, -30.000000, 16.000000, 32.000000, 30.000000, 16.000000, 32.000000, 30.000000, 32.000000, 32.000000, -30.000000, 32.000000, 32.000000, -30.000000, 32.000000, 64.000000, 30.000000, 32.000000, 64.000000, 30.000000, 32.000000, 32.000000, -30.000000, 32.000000, 32.000000, -30.000000, 32.000000, 64.000000, 30.000000, 32.000000, 64.000000, 30.000000, 48.000000, 64.000000, -30.000000, 48.000000, 64.000000, -30.000000, 48.000000, 96.000000, 30.000000, 48.000000, 96.000000, 30.000000, 48.000000, 64.000000, -30.000000, 48.000000, 64.000000, -30.000000, 48.000000, 96.000000, 30.000000, 48.000000, 96.000000, 30.000000, 64.000000, 96.000000, -30.000000, 64.000000, 96.000000, -30.000000, 64.000000, 192.000000, 30.000000, 64.000000, 192.000000, 30.000000, 64.000000, 96.000000, -30.000000, 64.000000, 96.000000
- };
- static GLfloat normaisMini[] = {
- 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000
- };
- static GLfloat coresMini[]={
- 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000, 0.000000, 0.000000, 1.000000
- };
- //================================================================================
- //=========================================================================== INIT
- void inicializa(int escada)
- {
- glClearColor(BLACK); //………………………………………………………………………………Apagar
- glEnable(GL_DEPTH_TEST); //………………………………………………………………………………Profundidade
- glShadeModel(GL_SMOOTH); //………………………………………………………………………………Interpolacao de cores
- if(escada==1){
- glVertexPointer(3, GL_FLOAT, 0, vertices); //………………………………………Vertex arrays
- glEnableClientState(GL_VERTEX_ARRAY);
- glNormalPointer(GL_FLOAT, 0, normais);// normais
- glEnableClientState(GL_NORMAL_ARRAY);
- glColorPointer(3, GL_FLOAT, 0, cores);
- glEnableClientState(GL_COLOR_ARRAY);
- } if(escada==0) {
- glVertexPointer(3, GL_FLOAT, 0, verticesMini); //………………………………………Vertex arrays
- glEnableClientState(GL_VERTEX_ARRAY);
- glNormalPointer(GL_FLOAT, 0, normaisMini);// normais
- glEnableClientState(GL_NORMAL_ARRAY);
- glColorPointer(3, GL_FLOAT, 0, coresMini);
- glEnableClientState(GL_COLOR_ARRAY);
- } if(escada == 2) { //paredes em volta
- }
- }
- void drawEixos()
- {
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Eixo X
- glColor4f(RED);
- glBegin(GL_LINES);
- glVertex3i( 0, 0, 0);
- glVertex3i(200, 0, 0);
- glEnd();
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Eixo Y
- glColor4f(GREEN);
- glBegin(GL_LINES);
- glVertex3i(0, 0, 0);
- glVertex3i(0, 200, 0);
- glEnd();
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Eixo Z
- glColor4f(BLUE);
- glBegin(GL_LINES);
- glVertex3i( 0, 0, 0);
- glVertex3i( 0, 0, 200);
- glEnd();
- }
- void tubos(){
- glClearColor(BLACK); //………………………………………………………………………………Apagar
- glEnable(GL_DEPTH_TEST); //………………………………………………………………………………Profundidade
- glShadeModel(GL_SMOOTH); //………………………………………………………………………………Interpolacao de cores
- int acum = 0, temp;
- //PARTE FRENTE
- glPushMatrix();
- glColor4f(WHITE);
- while(acum<=352){
- glBegin(GL_POLYGON);
- glVertex3f( -30, 0, acum );
- temp = rand() %10 + 5;
- acum += temp;
- glVertex3f( -30, 0, acum );
- glVertex3f( -30, 325, acum);
- glVertex3f( -30, 325, acum-temp );
- glEnd();
- //printf("%d\t", temp);
- acum += temp;
- //printf("%d\t", temp);
- }
- glPopMatrix();
- //PARTE TRAS
- glPushMatrix();
- glColor4f(WHITE);
- acum = -30;
- while(acum<=220 + 30){
- glBegin(GL_POLYGON);
- glVertex3f( acum, 0, 352 );
- temp = rand() %10 + 8;
- acum += temp;
- glVertex3f( acum, 0, 352 );
- glVertex3f( acum, 325, 352);
- glVertex3f( acum-temp, 325, 352 );
- glEnd();
- //printf("%d\t", temp);
- acum += temp;
- //printf("%d\t", temp);
- }
- glPopMatrix();
- //PARTE TRAS2
- glPushMatrix();
- glColor4f(WHITE);
- acum = 0;
- while(acum<=352){
- glBegin(GL_POLYGON);
- glVertex3f( 250, 0, acum );
- temp = rand() %10 + 8;
- acum += temp;
- glVertex3f( 250, 0, acum );
- glVertex3f( 250, 325, acum);
- glVertex3f( 250, 325, acum-temp );
- glEnd();
- //printf("%d\t", temp);
- acum += temp;
- //printf("%d\t", temp);
- }
- glPopMatrix();
- //PARTE FRENTE2 LOL
- glPushMatrix();
- glColor4f(WHITE);
- acum = -30;
- while(acum<=220 + 30){
- glBegin(GL_POLYGON);
- glVertex3f( acum, 0, 0 );
- temp = rand() %10 + 8;
- acum += temp;
- glVertex3f( acum, 0, 0 );
- glVertex3f( acum, 325, 0);
- glVertex3f( acum-temp, 325, 0 );
- glEnd();
- //printf("%d\t", temp);
- acum += temp;
- //printf("%d\t", temp);
- }
- glPopMatrix();
- }
- void cenario(){
- glClearColor(BLACK); //………………………………………………………………………………Apagar
- glEnable(GL_DEPTH_TEST); //………………………………………………………………………………Profundidade
- glShadeModel(GL_SMOOTH); //………………………………………………………………………………Interpolacao de cores
- glPushMatrix();
- glTranslatef(0,162.5,100); //nivelar
- glScalef( 650.0, 650.0/2, 650.0 );
- glBegin(GL_POLYGON);
- glColor3f( 1.0, 0.0, 0.0 ); glVertex3f( 0.5, -0.5, -0.5 );
- glColor3f( 0.0, 1.0, 0.0 ); glVertex3f( 0.5, 0.5, -0.5 );
- glColor3f( 0.0, 0.0, 1.0 ); glVertex3f( -0.5, 0.5, -0.5 );
- glColor3f( 1.0, 0.0, 1.0 ); glVertex3f( -0.5, -0.5, -0.5 );
- glEnd();
- glBegin(GL_POLYGON);
- glColor3f( 1.0, 1.0, 1.0 );
- glVertex3f( 0.5, -0.5, 0.5 );
- glVertex3f( 0.5, 0.5, 0.5 );
- glVertex3f( -0.5, 0.5, 0.5 );
- glVertex3f( -0.5, -0.5, 0.5 );
- glEnd();
- glBegin(GL_POLYGON);
- glColor3f( 1.0, 0.0, 1.0 );
- glVertex3f( 0.5, -0.5, -0.5 );
- glVertex3f( 0.5, 0.5, -0.5 );
- glVertex3f( 0.5, 0.5, 0.5 );
- glVertex3f( 0.5, -0.5, 0.5 );
- glEnd();
- glBegin(GL_POLYGON);
- glColor3f( 0.0, 1.0, 0.0 );
- glVertex3f( -0.5, -0.5, 0.5 );
- glVertex3f( -0.5, 0.5, 0.5 );
- glVertex3f( -0.5, 0.5, -0.5 );
- glVertex3f( -0.5, -0.5, -0.5 );
- glEnd();
- // TOPO
- glBegin(GL_POLYGON);
- glColor3f( 0.0, 0.0, 1.0 );
- glVertex3f( 0.5, 0.5, 0.5 );
- glVertex3f( 0.5, 0.5, -0.5 );
- glVertex3f( -0.5, 0.5, -0.5 );
- glVertex3f( -0.5, 0.5, 0.5 );
- glEnd();
- glBegin(GL_POLYGON);
- glColor3f( 1.0, 0.0, 0.0 );
- glVertex3f( 0.5, -0.5, -0.5 );
- glVertex3f( 0.5, -0.5, 0.5 );
- glVertex3f( -0.5, -0.5, 0.5 );
- glVertex3f( -0.5, -0.5, -0.5 );
- glEnd();
- glPopMatrix();
- //tubos
- tubos();
- }
- void drawScene(){
- //cenario
- cenario();
- inicializa(1);
- //em frente
- glPushMatrix();
- //glTranslatef(40, 0, 0);
- for(int i=0; i<SIZE/4; i++) {
- glDrawElements(GL_POLYGON, 4, GL_UNSIGNED_INT, ordem[i]);
- }
- glPopMatrix();
- //para tras
- glPushMatrix();
- glTranslatef(222, 160, 351);
- glRotatef(180,0,1,0);
- for(int i=0; i<SIZE/4; i++) {
- glDrawElements(GL_POLYGON, 4, GL_UNSIGNED_INT, ordem[i]);
- }
- glPopMatrix();
- //para o lado
- inicializa(0);
- glPushMatrix();
- glTranslatef(30, 96, 322);
- glRotatef(90,0,1,0);
- for(int i=0; i<SIZEMINI/4; i++) {
- glDrawElements(GL_POLYGON, 4, GL_UNSIGNED_INT, ordemMini[i]);
- }
- glPopMatrix();
- }
- void display(void){
- //================================================================= APaga ecran/profundidade
- glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
- //3D
- glViewport (0, 0, wScreen, hScreen); // ESQUECER PoR AGORA
- glMatrixMode(GL_PROJECTION); // ESQUECER PoR AGORA
- glLoadIdentity(); // ESQUECER PoR AGORA
- //glOrtho( -20, 20, -20, 20, -20, 20);
- gluPerspective(angZoom, (float)wScreen/hScreen, 0.1, 3*zC); // ESQUECER PoR AGORA
- glMatrixMode(GL_MODELVIEW); // ESQUECER PoR AGORA
- glLoadIdentity();
- //-------------------------------------------------------------- observador
- gluLookAt(obsP[0], obsP[1], obsP[2], tx,ty,tz, Upx, Upy, Upz);
- drawEixos();
- drawScene();
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~Actualizacao
- glutSwapBuffers();
- }
- void keyboard(unsigned char key, int x, int y){
- forwardVector[0] = tx - obsP[0];
- forwardVector[1] = ty - obsP[1];
- forwardVector[2] = tz - obsP[2];
- switch (key) {
- case 'W':
- case 'w':
- //moving forward :
- obsP[0] += forwardVector[0] * movementSpeed;
- obsP[1] += forwardVector[1] * movementSpeed;
- obsP[2] += forwardVector[2] * movementSpeed;
- tx += forwardVector[0] * movementSpeed;
- ty += forwardVector[1] * movementSpeed;
- tz += forwardVector[2] * movementSpeed;
- glutPostRedisplay();
- break;
- case 'S':
- case 's':
- //moving backward :
- obsP[0] -= forwardVector[0] * movementSpeed;
- obsP[1] -= forwardVector[1] * movementSpeed;
- obsP[2] -= forwardVector[2] * movementSpeed;
- tx -= forwardVector[0] * movementSpeed;
- ty -= forwardVector[1] * movementSpeed;
- tz -= forwardVector[2] * movementSpeed;
- glutPostRedisplay();
- break;
- //--------------------------- Escape
- case 27:
- exit(0);
- break;
- }
- }
- void teclasNotAscii(int key, int x, int y){
- if(key == GLUT_KEY_UP){
- //aVisaoAux = (aVisaoAux + 0.1) ;
- //printf("antes -> %d\n", ty);
- ty = ty + rVisao*sin(-0.1);
- //printf("depois -> %d\n", ty);
- }
- if(key == GLUT_KEY_DOWN){
- //aVisaoAux = (aVisaoAux - 0.1) ;
- ty = ty + rVisao*sin(0.1);
- }
- if(key == GLUT_KEY_LEFT)
- aVisao = (aVisao - 0.1) ;
- tx =obsP[0] + rVisao*cos(aVisao);
- tz =obsP[2] + rVisao*sin(aVisao);
- if(key == GLUT_KEY_RIGHT){
- aVisao = (aVisao + 0.1) ;
- tx =obsP[0] + rVisao*cos(aVisao);
- tz =obsP[2] + rVisao*sin(aVisao);
- }
- glutPostRedisplay();
- }
- //======================================================= MAIN
- //======================================================= MAIN
- int main(int argc, char** argv){
- glutInit(&argc, argv);
- glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH );
- glutInitWindowSize (wScreen, hScreen);
- glutInitWindowPosition (300, 100);
- glutCreateWindow ("{jh,pjmm}@dei.uc.pt| |FaceVisivel:'f'| |Observador:'SETAS'| |Andar-'a/s'| |Rodar -'e/d'| ");
- //escadas grandes
- int acum = 0;
- for(int i = 0; i < SIZE/4; i++){
- ordem[i] = new GLuint[4];
- }
- for(int i = 0; i<SIZE/4; i++) {
- for(int j=0; j<4; j++){
- ordem[i][j] = acum;
- acum++;
- }
- }
- //escadas pequenas
- acum = 0;
- for(int i = 0; i < SIZEMINI/4; i++){
- ordemMini[i] = new GLuint[4];
- }
- for(int i = 0; i<SIZEMINI/4; i++) {
- for(int j=0; j<4; j++){
- ordemMini[i][j] = acum;
- acum++;
- }
- }
- glutSpecialFunc(teclasNotAscii);
- glutDisplayFunc(display);
- glutKeyboardFunc(keyboard);
- glutMainLoop();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement