Click here to Skip to main content
15,881,380 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm trying to make multiple separate objects using openGL and freeGLUT.

I have a 3d cube that represents my player that I can move with user inputs.
And I have a very large 100x100 quad (of quads) representing the ground.
I also have a light and I track the position of the camera using a third, unmovable, cube.


Now, here's the issue:

The quad is obviously much larger than the tiny cube at 1f scale, so I scale this huge quad to 0.03f using the glScalef() function.

When I draw my player cube, I draw it after I have drawn the ground, and my player cube inherits the scale (becoming tiny AND appears at the origin of the ground quad, rather than the real origin.

How can I fix this? so that my player appears at the correct origin, NOT the origin of the ground, and that it DOESN'T inherit the scale of the ground?

void Scene::DrawCameraCube(float x, float y, float z)
{
	glTranslatef(x, y, z);
	glScalef(1, 1, 1);
	glRotatef(0, 1, 0, 0);
	
	glBegin(GL_QUADS);

        > <snip> drawing cube

        glEnd();
}



void Scene::DrawGround()
{
	glTranslatef(-3, -3, 0);
	glScalef(0.03, 0.03, 0.03);

	glBegin(GL_QUADS);

	> <snip> drawing quad ground. 

	glEnd();
}


What I have tried:

a bunch of stuff, changing around the variable values, switching the orders of the transforms and rotates.

No idea what else to do.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900