예제 #1
0
void desenharVenus(GLuint texture, GLUquadric *  Q)
{
	glPushMatrix();
	glRotatef(orbitalTiltVenus,0.0,0.0,1.0);
	angVenus += ((2*PI)/velVenus)*timeFactor;

	posicoes[2][0]=distFactor*distSolVenus*sin(angVenus);
	posicoes[2][1]=distFactor*distSolVenus*sin(angVenus) * sin(orbitalTiltVenus*(PI/180)) ;
	posicoes[2][2]=distFactor*distSolVenus*cos(angVenus);
	raios[2]=raioVenus*scale;

	//colisao planeta -> nave
	if((cameraMode==0 && haColisao(camZ,camX,camY,2)) || (cameraMode == 1 && haColisaoNave2(camZ,camX,camY,camlookZ,camlookX,camlookY,2)) )
		afastaCamara(2);

	glTranslatef(distFactor*distSolVenus*sin(angVenus), 0, distFactor*distSolVenus*cos(angVenus));

	//glColor3f(0.6,0.5,0.1);//castanho
	angRotVenus += (360/velRVenus)*timeFactor;
	rotacao(angRotVenus,axisTiltVenus);
	glRotatef(90,1,0,0);
	glEnable (GL_TEXTURE_2D);
    glBindTexture(GL_TEXTURE_2D, texture);
	
	if(sphereInFrustum(posicoes[2],raios[2]))
		gluSphere (Q,scale*raioVenus,calcularFatias(2),32);
	
	glDisable(GL_TEXTURE_2D);
	glPopMatrix();
	if(orbitas)draw_orbita(distFactor*distSolVenus,90,0.0,orbitalTiltVenus);
}
예제 #2
0
void desenharNeptuno(GLuint texture, GLUquadric *  Q)
{
	glPushMatrix();
	glRotatef(orbitalTiltNeptuno,0.0,0.0,1.0);
	angNeptuno += ((2*PI)/velNeptuno)*timeFactor;
	
	posicoes[18][0]=distFactor*distSolNeptuno*sin(angNeptuno);
	posicoes[18][1]=distFactor*distSolNeptuno*sin(angNeptuno) * sin(orbitalTiltNeptuno*(PI/180)) ;
	posicoes[18][2]=distFactor*distSolNeptuno*cos(angNeptuno);
	raios[18]=raioNeptuno*scale;

	//colisao planeta -> nave
	if((cameraMode==0 && haColisao(camZ,camX,camY,18)) || (cameraMode == 1 && haColisaoNave2(camZ,camX,camY,camlookZ,camlookX,camlookY,18)) )
		afastaCamara(18);

	glTranslatef(distFactor*distSolNeptuno*sin(angNeptuno), 0, distFactor*distSolNeptuno*cos(angNeptuno));

	//glColor3f(0.12,0.432,0.123);//verde
	angRotNeptuno += (360/velRNeptuno)*timeFactor;
	rotacao(angRotNeptuno,axisTiltNeptuno);
	glEnable (GL_TEXTURE_2D);
    glBindTexture(GL_TEXTURE_2D, texture);
	glRotatef(-90,1,0,0);
	
	if(sphereInFrustum(posicoes[18],raios[18]))
		gluSphere (Q,scale*raioNeptuno,calcularFatias(18),32);
	
	glDisable(GL_TEXTURE_2D);
	glPopMatrix();
	
	if(orbitas)draw_orbita(distFactor*distSolNeptuno,90,0.0,orbitalTiltNeptuno);
}
예제 #3
0
void display(void)
{
	// clear the screen
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	
	mat4 total, modelView, camMatrix;
	
	printError("pre display");
	
	glUseProgram(program);

	// Build matrix
	lookAtPoint = VectorAdd(cam, camDir);
	camMatrix = lookAt(cam.x, cam.y, cam.z,
                       lookAtPoint.x, lookAtPoint.y, lookAtPoint.z,
                       0.0, 1.0, 0.0);

    calculateCullingFrustum(camMatrix);
    
	modelView = IdentityMatrix();
	total = Mult(camMatrix, modelView);
	glUniformMatrix4fv(glGetUniformLocation(program, "model"), 1, GL_TRUE, total.m);

    glUniform3f(glGetUniformLocation(program, "camPos"), cam.x, cam.y, cam.z);

	glBindTexture(GL_TEXTURE_2D, tex1);		// Bind Our Texture tex1
	DrawModel(tm, program, "inPosition", "inNormal", "inTexCoord");

    /*

    mat4 foobar = Mult(modelView, camMatrix);
    */
    GLfloat ballY = GetMapHeight(tm,ttex.width, ttex.height, ballX, ballZ);
    if (sphereInFrustum((vec3) {ballX, ballY, ballZ}, 10.0f)) {
        modelView = T(ballX, ballY, ballZ);
        total = Mult(camMatrix, modelView);
        glUniformMatrix4fv(glGetUniformLocation(program, "model"), 1, GL_TRUE, total.m);
        DrawModel(m2, program, "inPosition", "inNormal", "inTexCoord");
        printf("foo\n");
    }
	printError("display 2");
	glutSwapBuffers();
}
예제 #4
0
void desenharJupiter(GLuint texture, GLUquadric *  Q, GLuint texture2, GLUquadric *  Q2)
{
	glPushMatrix();
	glRotatef(orbitalTiltJupiter,0.0,0.0,1.0);
	angJupiter += ((2*PI)/velJupiter)*timeFactor;
	
	posicoes[12][0]=distFactor*distSolJupiter*sin(angJupiter);
	posicoes[12][1]=distFactor*distSolJupiter*sin(angJupiter) * sin(orbitalTiltJupiter*(PI/180)) ;
	posicoes[12][2]=distFactor*distSolJupiter*cos(angJupiter);
	raios[12]=raioJupiter*scale;

	//colisao planeta -> nave
	if((cameraMode==0 && haColisao(camZ,camX,camY,12)) || (cameraMode == 1 && haColisaoNave2(camZ,camX,camY,camlookZ,camlookX,camlookY,12)) )
		afastaCamara(12);

	glTranslatef(distFactor*distSolJupiter*sin(angJupiter), 0, distFactor*distSolJupiter*cos(angJupiter));
	//glColor3f(1,1,0);//amarelo

	angRotJupiter += (360/velRJupiter)*timeFactor;
	rotacao(angRotJupiter,axisTiltJupiter);
	glEnable (GL_TEXTURE_2D);
    glBindTexture(GL_TEXTURE_2D, texture);
	glRotatef(-90,1,0,0);

	double vec[3];
	vec[0]= posicoes[12][0];
	vec[1]= posicoes[12][1];	
	vec[2]= posicoes[12][2];
	if(sphereInFrustum(posicoes[12],raios[12])){
		gluSphere (Q,scale*raioJupiter,calcularFatias(12),32);
	}
	glDisable(GL_TEXTURE_2D);
	glRotatef(90,1,0,0);
	desenharIO(texture2, Q2);
	desenharEuropa(texture2, Q2);
	desenharGanimedes(texture2, Q2);
	desenharCalisto(texture2, Q2);

	glPopMatrix();
	
	if(orbitas)draw_orbita(distFactor*distSolJupiter,90,0.0,orbitalTiltJupiter);
}
예제 #5
0
void display(void)
{
    // clear the screen
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    mat4 total, modelView, camMatrix;

    printError("pre display");

    glUseProgram(program);

    // Build matrix
    lookAtPoint = VectorAdd(cam, camDir);
    camMatrix = lookAt(cam.x, cam.y, cam.z,
                       lookAtPoint.x, lookAtPoint.y, lookAtPoint.z,
                       0.0, 1.0, 0.0);
    modelView = IdentityMatrix();
    total = Mult(camMatrix, modelView);
    glUniformMatrix4fv(glGetUniformLocation(program, "model"), 1, GL_TRUE, total.m);

    glUniform3f(glGetUniformLocation(program, "camPos"), cam.x, cam.y, cam.z);

    glBindTexture(GL_TEXTURE_2D, tex1);         // Bind Our Texture tex1



    DrawModel(tm, program, "inPosition", "inNormal", "inTexCoord");

    /*modelView = T(10.f, 30.f, 10.f);
    glUniformMatrix4fv(glGetUniformLocation(program, "model"), 1, GL_TRUE, modelView.m);
    DrawModel(m, program, "inPosition", "inNormal", "inTexCoord");*/

    if (sphereInFrustum((vec3) {-10.f, 30.f, 10.f}, 10.f)) {
        modelView = T(-10.f, 30.f, 10.f);
        glUniformMatrix4fv(glGetUniformLocation(program, "model"), 1, GL_TRUE, modelView.m);
        DrawModel(m2, program, "inPosition", "inNormal", "inTexCoord");
        printf("foo\n");
    }

    printError("display 2");
    glutSwapBuffers();
}
예제 #6
0
void desenharSaturno(GLuint texture, GLUquadric *  Q, GLuint texture2, GLUquadric *  Q2)
{
	glPushMatrix();
	glRotatef(orbitalTiltSaturno,0.0,0.0,1.0);
	angSaturno+= ((2*PI)/velSaturno)*timeFactor;
	
	posicoes[16][0]=distFactor*distSolSaturno*sin(angSaturno);
	posicoes[16][1]=distFactor*distSolSaturno*sin(angSaturno) * sin(orbitalTiltSaturno*(PI/180)) ;
	posicoes[16][2]=distFactor*distSolSaturno*cos(angSaturno);
	raios[16]=raioSaturno*scale;

	//colisao planeta -> nave
	if((cameraMode==0 && haColisao(camZ,camX,camY,16)) || (cameraMode == 1 && haColisaoNave2(camZ,camX,camY,camlookZ,camlookX,camlookY,16)) )
		afastaCamara(16);

	glTranslatef(distFactor*distSolSaturno*sin(angSaturno), 0, distFactor*distSolSaturno*cos(angSaturno));

	//glColor3f(1,0,1);//rosa
	angRotSaturno += (360/velRSaturno)*timeFactor;
	rotacao(angRotSaturno,axisTiltSaturno);
	glEnable (GL_TEXTURE_2D);
    glBindTexture(GL_TEXTURE_2D, texture);
	glRotatef(-90,1,0,0);
	
	if(sphereInFrustum(posicoes[16],raios[16]))
		gluSphere(Q,scale*raioSaturno,calcularFatias(16),32);
	
	glDisable(GL_TEXTURE_2D);

	glRotatef(90,1,0,0);
	
	desenhaAnel();

	desenharRhea(texture2, Q2);
	desenharTitan(texture2, Q2);
	desenharIapetus(texture2, Q2);

	glPopMatrix();
	//glColor3f(1,0,1);//rosa
	if(orbitas)draw_orbita(distFactor*distSolSaturno,90,0.0,orbitalTiltSaturno);
}
예제 #7
0
void desenharSol(GLuint texture, GLUquadric *  Q)
{
	glPushMatrix();
	//posSOl
	posicoes[0][0]=0.0;
	posicoes[0][1]=0.0;
	posicoes[0][2]=0.0;
	raios[0]=raioSol;

	angRotSol += (360/velRSol)*timeFactor;
	rotacao(angRotSol,0.0);

	//desenhar cintura de asteroides aqui, so mesmo para ter um efeito de rotaçao
	if(drawCintura)	glCallList(cintura);

	glEnable(GL_LIGHT0);
	glLightfv(GL_LIGHT1, GL_POSITION, lightPos);

	glEnable (GL_TEXTURE_2D);
    glBindTexture(GL_TEXTURE_2D, texture);
	
	glRotatef(-90,1,0,0);
	double vec[3];
	vec[0]= posicoes[0][0];
	vec[1]= posicoes[0][1];	
	vec[2]= posicoes[0][2];
	
	if(sphereInFrustum(posicoes[0],raios[00])){
		gluSphere (Q,raioSol,calcularFatias(0),32);
	}
	
	glDisable(GL_LIGHT0);
	glEnable(GL_LIGHT1);

	glMaterialfv(GL_FRONT, GL_SPECULAR, nullv);
	glMaterialfv(GL_FRONT, GL_EMISSION, nullv);
	glDisable(GL_TEXTURE_2D);
		
	glPopMatrix();
}
예제 #8
0
파일: Octree.cpp 프로젝트: burner/q3rt
void Octree::render(float frustum[6][4]) {
	//render all childs first because only leaves have ObjIns
	if(!this->childs.empty()) {
		std::vector<Octree*>::iterator it;
		for(it = this->childs.begin(); it != this->childs.end(); it++) {
			(*it)->render(frustum);
		}
		return;
	}

	//if no childs exists render all objIns in node
	std::list<ObjIns*>::iterator it;
	for(it = this->objIns->begin(); it != this->objIns->end(); it++) {
		if(sphereInFrustum(frustum, (*it)->pos, (*it)->radius)) {
			if(typeid(*(*it)->object) == typeid(Quad) && (*it)->object->isFacing()) {
				Renderer::appendObjInsToRender((*it));
			} else if(typeid(*(*it)->object) != typeid(Quad)) {
				Renderer::appendObjInsToRender((*it));
			}
		}
	}
}
예제 #9
0
void desenharTerra(GLuint texture, GLUquadric *  Q, GLuint texture2, GLUquadric *  Q2)
{
	glPushMatrix();
	glRotatef(orbitalTiltTerra,0.0,0.0,1.0);
	angTerra += ((2*PI)/velTerra)*timeFactor;
	

	posicoes[4][0]=distFactor*distSolTerra*sin(angTerra+((2*PI)/velTerra)*timeFactor);
	posicoes[4][1]=distFactor*distSolTerra*sin(angTerra) * sin(orbitalTiltTerra*(PI/180)) ;
	posicoes[4][2]=distFactor*distSolTerra*cos(angTerra+((2*PI)/velTerra)*timeFactor);
	raios[4]=raioTerra*scale;

	//colisao planeta -> nave
	if((cameraMode==0 && haColisao(camZ,camX,camY,4)) || (cameraMode == 1 && haColisaoNave2(camZ,camX,camY,camlookZ,camlookX,camlookY,4)) )
		afastaCamara(4);

	glTranslatef(distFactor*distSolTerra*sin(angTerra), 0, distFactor*distSolTerra*cos(angTerra));

	//glColor3f(0,0,1);//azul
	//angRotTerra += ((0.25*360)/velRTerra)*timeFactor;
	angRotTerra += (360/velRTerra)*timeFactor;

	rotacao(angRotTerra,axisTiltTerra);
	glEnable (GL_TEXTURE_2D);
    glBindTexture(GL_TEXTURE_2D, texture);
	glRotatef(-90,1,0,0);
	
	if(sphereInFrustum(posicoes[4],raios[4]))
		gluSphere (Q,scale*raioTerra,calcularFatias(4),32);
	
	glDisable(GL_TEXTURE_2D);
	glRotatef(90,1,0,0);
	desenharLua(texture2, Q2);
	glPopMatrix();
	//glColor3f(0,0,1);//azul
	
	if(orbitas)draw_orbita(distFactor*distSolTerra,90,0.0,orbitalTiltTerra);
}
예제 #10
0
void desenharMarte(GLuint texture, GLUquadric *  Q, GLuint texture2, GLUquadric *  Q2)
{
	glPushMatrix();
	glRotatef(orbitalTiltMarte,0.0,0.0,1.0);
	angMarte+= ((2*PI)/velMarte)*timeFactor;
	
	posicoes[7][0]=distFactor*distSolMarte*sin(angMarte);
	posicoes[7][1]=distFactor*distSolMarte*sin(angMarte) * sin(orbitalTiltMarte*(PI/180)) ;
	posicoes[7][2]=distFactor*distSolMarte*cos(angMarte);
	raios[7]=raioMarte*scale;

	//colisao planeta -> nave
	if((cameraMode==0 && haColisao(camZ,camX,camY,7)) || (cameraMode == 1 && haColisaoNave2(camZ,camX,camY,camlookZ,camlookX,camlookY,7)) )
		afastaCamara(7);

	glTranslatef(distFactor*distSolMarte*sin(angMarte), 0, distFactor*distSolMarte*cos(angMarte));

	desenharDeimos(texture2, Q2);
	desenharFobos(texture2, Q2);

	//glColor3f(1,0,0);//vermelho
	angRotMarte += (360/velRMarte)*timeFactor;
	rotacao(angRotMarte,axisTiltMarte);
	glEnable (GL_TEXTURE_2D);
    glBindTexture(GL_TEXTURE_2D, texture);
	glRotatef(-90,1,0,0);
	
	if(sphereInFrustum(posicoes[7],raios[7]))
		gluSphere (Q,scale*raioMarte,calcularFatias(7),32);
	
	glDisable(GL_TEXTURE_2D);
	
	glPopMatrix();
	
	if(orbitas)draw_orbita(distFactor*distSolMarte,90,0.0,orbitalTiltMarte);
}
예제 #11
0
int sphere(vec3 p, float ratio)
{
   return sphereInFrustum(Vec3(p.x,p.y,p.z),ratio);
}