changing modelview matirx on the fly

i want to be able to make my ‘guy’ to walk arbitrarily instead of just forward backward.

I know to translate the whole ‘person’ forward and backward thinggy. I just wanna make it move like gaming thing. Of course, i dont need to make both button usable at the same time. just basic simple move.

TIA

Originally posted by <noobie>:
[b]i want to be able to make my ‘guy’ to walk arbitrarily instead of just forward backward.

I know to translate the whole ‘person’ forward and backward thinggy. I just wanna make it move like gaming thing. Of course, i dont need to make both button usable at the same time. just basic simple move.

TIA[/b]
http://www.gametutorials.com/Tutorials/opengl/opengl_pg1.htm#Camera

Use the following code this may help u in arbitary rotaions


struct CAMERA
{
float position[3];
float orientation[3];
};

CAMERA cameraData;

init func()
{
cameraData.position[0] = 0.0f;
cameraData.position[1] = 0.0f;
cameraData.position[2] = -500.0f;

cameraData.orientation[0] = 0.0f;
cameraData.orientation[1] = 0.0f;
cameraData.orientation[2] = 0.0f;

}

DisplayFunc()
{

	glRotatef(cameraData.orientation[0], 1.0f, 0.0f, 0.0f);
	glRotatef(cameraData.orientation[1], 0.0f, 1.0f, 0.0f);
	glRotatef(cameraData.orientation[2], 0.0f, 0.0f, 1.0f);
	glTranslatef(-cameraData.position[0],cameraData.position[1],cameraData.position[2]);

}

keyDown func()
{

case LEFT :
cameraData.orientation[1]–; break;
case RIGHT : cameraData.orientation[1]++; break;

case UP : fLinearVelocity += 20.0;
// Update linear position
fTime = fTime * fLinearVelocity;
fXDelta = fTime * (float)(sin(DEGTORAD(cameraData.orientation[1])));
fXDelta += cameraData.position[0]; fZDelta = fTime * (float)(cos(DEGTORAD(cameraData.orientation[1])));
fZDelta += cameraData.position[2]; cameraData.position[0] = fXDelta; cameraData.position[2] = fZDelta;
break;

case DOWN :
fLinearVelocity -= 20.0;
// Update linear position
fTime = fTime * fLinearVelocity;
fXDelta = fTime * (float)(sin(DEGTORAD(cameraData.orientation[1])));
fXDelta += cameraData.position[0];
fZDelta = fTime * (float)(cos(DEGTORAD(cameraData.orientation[1])));
fZDelta += cameraData.position[2];

						cameraData.position[0] = fXDelta;
						cameraData.position[2] = fZDelta;
	
					break;

}

}