Advertisement

sky sphere

Started by May 10, 2003 06:58 PM
0 comments, last by noRulez43 21 years, 9 months ago
How can I get my sky sphere to move with my player. I need to be able to look left and right and have it not move though...does that make sense? I found where to put it to have it completely move with the player, but this looks weird because it looks like you''re always staring in the same spot...so I need it to not move when I turn left or right. This is my code for my display routine:
  


void display(void)

{
    
	int i,j,k;



	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

	glEnable(GL_TEXTURE_2D);   
   glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);


	if(smooth)

		glShadeModel(GL_SMOOTH);

	else

		glShadeModel(GL_FLAT);



	glMatrixMode(GL_MODELVIEW);
    
	glLoadIdentity();
 

	cam->applyView();

	if(player1.get_movingFrwd()){
		if(player1.fSpeed>=-.2){
			player1.fSpeed-=.002;
		}
		cam1->slide(0,0,player1.fSpeed); //move forward

	}
	else{
		if(player1.fSpeed<0){
			cout << "decreasing speed" << endl;
			player1.fSpeed+=.002;
			cam1->slide(0,0,player1.fSpeed);
		}
	}

	if(player1.get_rollLeft()){
		cam1->roll(1.0);
	}
	if(player1.get_rollRight()){
		cam1->roll(-1.0);
	}
	if(player1.get_turnLeft()){
		cam1->yaw(.5);
	}
	if(player1.get_turnRight()){
		cam1->yaw(-.5);
	}


    //SKY HERE

	for(i=0;i<nrows;i++)

		for(j=0;j<ncols;j++)

			for(k=0;k<nlevels;k++)

				cube[i][j][k]->draw();

    glPushMatrix();
    glRotatef ( 90.0, 1.0, 0.0, 0.0 );
   
    GLUquadricObj*  q = gluNewQuadric ( );
    gluQuadricDrawStyle ( q, GLU_FILL );
    gluQuadricNormals ( q, GLU_SMOOTH );
    gluQuadricTexture ( q, GL_TRUE    );
    gluSphere ( q, 1000.0, 20, 20 );
    gluDeleteQuadric ( q );
    glPopMatrix ( );

	glutSwapBuffers();
}
  
-----Just a quick idea------
you could simply call on glLoadIdentity so that the sphere
always moves with the camera and then rotate it opposite of the camera's rotation....

camera.update()
glPushMatrix()
glLoadIdentity()
glRotatef(-cam.rotx,...
glRotatef(-cam.roty...
etc
DrawSkySphere()
glPopMatrix()
DrawWorld()...

your done.

If this works, let me know

~yodaman

[edited by - yodaman on May 11, 2003 1:02:12 PM]
www.jinx.com www.thebroken.org www.suprnova.org www.mozilla.org

This topic is closed to new replies.

Advertisement