Example #1
0
void Inicializa(){
   
   //importarBlenderWrl("nave_pronta3.wrl",&faces,&points);
   printf("inicializando\n");
   sprintf(textpontos,"%s","Pontos: 0");
   printf("gerando lista do aviao\n");
   aviao=glGenLists(1);
   glNewList(aviao,GL_COMPILE);
   importarBlenderWrl("nave_pronta3.wrl",&faces,&points);
   glEndList();

   DestroiRegFaces(&faces);
   DestroiRegPoints(&points);

   //importarBlenderWrl("missel.wrl",&faces,&points);
   printf("gerando lista de misseis\n");
   missel=glGenLists(2);
   glNewList(missel,GL_COMPILE);
    importarBlenderWrl("missel.wrl",&faces,&points);
   glEndList();

   DestroiRegFaces(&faces);
   DestroiRegPoints(&points);
   
   printf("define iluminacao\n");
   iluminacao();
   printf("inicializa esferas\n");
   InitEsferas(esfera);
 
   
   
}
Example #2
0
void Inicializa(){
	char str[40+1];
	
	OB_ovni.ponto.x = 0.0;
	OB_ovni.ponto.y = 0.0;
	OB_ovni.ponto.z = 0.0;
	
	OB_nave.ponto.x = 0.0;
	OB_nave.ponto.y = -17.5;
	OB_nave.ponto.z = 3.0;
	
	for(i=0;i<QTD_MISSEL_NAVE;i++){
		OB_missel1[i].ponto.x = OB_nave.ponto.x;
		OB_missel1[i].ponto.y = OB_nave.ponto.y + trans_missel_nave;
		OB_missel1[i].ponto.z = 0;
		OB_missel1[i].habilitado = false;
		OB_missel1[i].dispara_missel_esfera = false;
	}
	
	for(i=0;i<QTD_MISSEL_OVNI;i++){
		OB_missel2[i].ponto.x = 0.0;
		OB_missel2[i].ponto.y = 0.0;
		OB_missel2[i].ponto.z = 0.0;
		OB_missel2[i].habilitado = false;
		OB_missel2[i].dispara_missel_esfera = false;
	}
	
	//imagem = CarregaJPG("490020730_5d1ef91b20_o.jpg");

	//importarBlenderWrl("nave_pronta3.wrl",&SA_faces,&points);
	sprintf(textpontos,"%s","Pontos: 0");
	//printf("Inicializa 1\n");



	/*aviao = CarregaObjeto("nave_pronta_gabriel2.obj", true);
	if(aviao == NULL){
		printf("ERRO teste.obj\n");
	}else{
		printf("Nave Importado\n");
	}*/
	
	GLM_background = glmReadOBJ("fundo.obj");
	GLM_background_list = glGenLists(1);
	glNewList(GLM_background_list, GL_COMPILE);
	glmDraw(GLM_background, GLM_NONE|GLM_SMOOTH|GLM_TEXTURE|GLM_COLOR);
	glEndList();
	
	GLM_aviao = glmReadOBJ("nave_pronta_gabriel2.obj");
	GLM_aviao_list = glGenLists(1);
	glNewList(GLM_aviao_list, GL_COMPILE);
	glmDraw(GLM_aviao, GLM_SMOOTH|GLM_TEXTURE|GLM_COLOR);
	glEndList();
	
	GLM_aviao2 = glmReadOBJ("nave_pronta_gabriel2.obj");
	GLM_aviao_list2 = glGenLists(1);
	glNewList(GLM_aviao_list2, GL_COMPILE);
	glmDraw(GLM_aviao2, GLM_SMOOTH);
	glEndList();
	
	
	GLM_missel = glmReadOBJ("missel.obj");
	GLM_missel_list = glGenLists(1);
	glNewList(GLM_missel_list, GL_COMPILE);
	glmDraw(GLM_missel, GLM_NONE|GLM_SMOOTH|GLM_TEXTURE|GLM_COLOR);
	glEndList();
	
	GLM_missel2 = glmReadOBJ("missel2.obj");
	GLM_missel_list2 = glGenLists(1);
	glNewList(GLM_missel_list2, GL_COMPILE);
	glmDraw(GLM_missel2, GLM_NONE|GLM_SMOOTH|GLM_TEXTURE|GLM_COLOR);
	glEndList();
	
	/*missel=glGenLists(1);
	glNewList(missel,GL_COMPILE);
	importarBlenderWrl("missel.wrl",&SA_faces,&points);
	glEndList();

	DestroiRegFaces(&SA_faces);
	DestroiRegPoints(&points);*/


	/*ovni = CarregaObjeto("ovni.obj", true);
	if(ovni == NULL){
		printf("ERRO ovni.obj\n");
	}else{
		printf("Ovni Importado\n");
	}*/
	
	GLM_ovni = glmReadOBJ("ovni.obj");
	GLM_ovni_list = glGenLists(1);
	glNewList(GLM_ovni_list, GL_COMPILE);
	glmDraw(GLM_ovni, GLM_NONE|GLM_SMOOTH|GLM_TEXTURE|GLM_MATERIAL);
	glEndList();
	
	/*background = CarregaObjeto("background.obj", false);
	if(background == NULL){
		printf("ERRO background.obj\n");
	}else{
		printf("background Importado\n");
	}*/
	
	CriaDisplayList(NULL);

	iluminacao();
	InitEsferas(esfera);



}
Example #3
0
File: main.cpp Project: JoaoS/CG
void display(void)
{
	if (noite)
		glClearColor(GRAY1);
	else
		glClearColor(GRAY2);
	
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
    if(end_game == 0)
	{
        //================================================================= Viewport1
        glViewport (0, hScreen/4, wScreen/4, hScreen/4);
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        glOrtho (-xC,xC, -xC,xC, -zC,zC);
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();	
        gluLookAt( 0, 10,0, 0,0,0, 0, 0, -1);
	   //--------------------- Informacao
        sprintf(texto,"Nivel : %d",level+1);
        desenhaTexto(texto,-8,1,0,18);
        if(clock_active ==1)
        {    
            t2 = clock() - t1;
            sprintf(texto,"Tempo : %.2f",((float)t2)/CLOCKS_PER_SEC);
            desenhaTexto(texto,-8,1,4,12);
        }
        if(noite)
            strcpy(texto, "Noite : Activo\n");
        else
            strcpy(texto, "Noite : Inactivo\n");
        desenhaTexto(texto,-8,1,8,12);
        if(ligaLuz)
            strcpy(texto, "Luz tecto : Activo\n");
        else
            strcpy(texto, "Luz tecto : Inactivo\n");
        desenhaTexto(texto,-8,1,12,12);
        if(ligaFoco)
            strcpy(texto, "Luz foco : Activo\n");
        else
            strcpy(texto, "Luz foco : Inactivo\n");
        desenhaTexto(texto,-8,1,16,12);

	   //================================================================= Viewport2
	   glEnable(GL_LIGHTING);  
	   glViewport (wScreen/4, hScreen/4, 0.75*wScreen, 0.75*hScreen);
	   glMatrixMode(GL_PROJECTION);
	   glLoadIdentity();
	   gluPerspective(99.0, wScreen/hScreen, 0.1, 100.0);
	   glMatrixMode(GL_MODELVIEW);
	   glLoadIdentity();
	   gluLookAt(obsPini[0], obsPini[1], obsPini[2], obsPfin[0], obsPfin[1], obsPfin[2], 0, 1, 0);
	   /* desenha objectos */
	   iluminacao();
	   drawScene();
       glutSwapBuffers();
    }
    else
    {   
        glViewport (0, 0, wScreen, hScreen);
        glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
        glOrtho (-xC,xC, -xC,xC, -zC,zC);
        glMatrixMode(GL_MODELVIEW);
        glLoadIdentity();   
        gluLookAt( 0, 10,0, 0,0,0, 0, 0, -1);
        strcpy(texto,"FIM");
        desenhaTexto(texto,0,0,-8,24);
        sprintf(texto,"Tempo Nivel 1 : %.2f",((float)level_time[0])/CLOCKS_PER_SEC);
        desenhaTexto(texto,-8,0,-4,24);
        sprintf(texto,"Tempo Nivel 2 : %.2f",((float)level_time[1])/CLOCKS_PER_SEC);
        desenhaTexto(texto,-8,0,0,24);
        sprintf(texto,"Tempo Nivel 3 : %.2f",((float)level_time[2])/CLOCKS_PER_SEC);
        desenhaTexto(texto,-8,0,4,24);
        strcpy(texto,"Pressione ESC para sair");
        desenhaTexto(texto,-4,0,8,24);
        glutSwapBuffers();
    }
}