Unkown problem! HELP!

Started by
2 comments, last by AfroMogli 20 years, 1 month ago
I''ve run into a rather small but very heavy problem. It all begun when I changed the camera settings. From the beginning I had the camera setup at the location: 0.0, 0.0, -98. And when I rendered a field, which consists of two rectangles I could see the field. But then I realized that my coordinate-system was uppside down because of the camera position. So I changed the camera to: 0.0, 0.0, 98. Then the whole field disappeared! Everything just went black! So after some experimentation I succeded in making one of the rects visible. But the other one is not working and I do not know how the first is working. And I can only speculate what the problem is. Is OpenGL thining that the negative Z vector is the frontside of all objects or what? Here is the Draw() in main.cpp:

int DrawGLScene(GLvoid)									// Here''s Where We Do All The Drawing

{
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT);	 // Clear Screen, Depth And Stencil Buffer.

	glLoadIdentity();									// Reset The Current Modelview Matrix


	float elapsedSeconds = timer->getElapsedSeconds();	// Get elapsed seconds.

	
	if(g_angle >= 360.0)
		g_angle = 0.0;
	g_angle +=1.5;

	input.Update();										// Update the inputsystem.

	
	timer->LockFPS(60);									// The app runs at maximum 60 fps.


	gluLookAt(0.0, 0.0, 92.0,  0.0, 0.0, -1.0,   0.0, 1.0, 0.0);

	//gameField->Animate(elapsedSeconds);

	backPaddel1->Move(input, elapsedSeconds);
	backPaddel2->Move(input, elapsedSeconds);
	frontPaddel1->Move(input, elapsedSeconds);
	frontPaddel2->Move(input, elapsedSeconds);
	//fireball->Animate(elapsedSeconds);

	//mainball->Animate(elapsedSeconds);

	
	gameField->Draw();
	fireball->Draw2(g_angle);
	mainball->Draw2(g_angle);
	backPaddel1->Draw();
	backPaddel2->Draw();
	frontPaddel1->Draw();
	frontPaddel2->Draw();	

	glFlush();

	return TRUE;										// Everything Went OK

}
And the CField::Draw():

void CField::Draw()
{	
	glPushMatrix();
		glTranslatef(pos.x, pos.y, pos.z);			// Moves the origo of the coordinatesystem to the fields position.

		
		glColor3f(1.0, 1.0, 1.0);				// Sets the color and transparacy. 													

		
		// This rect does not work

		glBegin(GL_QUADS);
			glNormal3f(0.0, 0.0, 1.0);
			glVertex3f(-50.0, 25.0, Z);
			glVertex3f(0.0, 25.0, Z);
			glVertex3f(0.0, -25.0, Z);
			glVertex3f(-50.0, -25.0, Z);
		glEnd();
		
		// This rect is working!

		glBegin(GL_QUADS);
			glNormal3f(0.0, 0.0, 1.0);
			glVertex3f(50.0, 25.0, Z);
			glVertex3f(0.0, 25.0, Z);
			glVertex3f(0.0, -25.0, Z);
			glVertex3f(50, -25.0, Z);	
		glEnd();

		glPopMatrix();			
}
Please help!
Does: C++ combined with OpenGL games and other visuals. Dream: To become a REAL gameprogrammer. Yeah!
Advertisement
You system wasnt backwards, what you need to realise is that for OpenGL as a Z coord becomes more negative it moves into the screen and as it becomes positive it moves out of the screen.
(also, the camera doesnt move, all you''ve done is move the local coordinate system 98 units back out of the screen)
But that isn't my problem. The problem is that I'm trying to display two rects and I cannot see the ONE of them.
WHY isn't the second one shown? THAT is my question.
You got the source code above, PLEASE help me with this one guys!

[edited by - AfroMogli on March 20, 2004 4:29:12 AM]

[edited by - AfroMogli on March 20, 2004 4:29:49 AM]
Does: C++ combined with OpenGL games and other visuals. Dream: To become a REAL gameprogrammer. Yeah!
quote:Original post by AfroMogli
But that isn''t my problem. The problem is that I''m trying to display two rects and I cannot see the ONE of them.
WHY isn''t the second one shown? THAT is my question.
You got the source code above, PLEASE help me with this one guys!

[edited by - AfroMogli on March 20, 2004 4:29:12 AM]

[edited by - AfroMogli on March 20, 2004 4:29:49 AM]


You don''t see them because you are drawing and moving them back "through" the screen, they are behind the camera. you are moving the objects 98 units "into" the screen. To see them you need to move them -x units away from the screen.


"C lets you shoot yourself in the foot rather easily. C++ allows you to reuse the bullet!"
"C lets you shoot yourself in the foot rather easily. C++ allows you to reuse the bullet!"

This topic is closed to new replies.

Advertisement