Jump to content
  • Advertisement
Sign in to follow this  
godsenddeath

Problem with View Rotation[SOLVED]

This topic is 3664 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I built a camera class, but when I rotate my camera, the world doesn't turn, only the direction in which the camera travels changes here's the code

void Camera::Move(float x, float y, float z)
{

	if((z != 0) && (yAng != 0))
	{
		int tempz = cos(D3DXToRadian(yAng)) * z;
		int tempx = sin(D3DXToRadian(yAng)) * z;

		X += tempx;
		Z += tempz;
	}

	else
	{

		if(x)
		{
			X += x;
		}

		if(z)
		{
			Z += z;
		}
	}

	if(y)
	{
		Y += y;
	}



}

void Camera::Rotate(int x, int y, int z)
{

	if(x)
	{
		xAng += x;
	}

	if(y)
	{
		yAng += y;
	}

	if(z)
	{
		zAng += z;
	}

}


void Camera::Transform(LPDIRECT3DDEVICE9 device)
{

	D3DXMatrixIdentity(&Trans);
	D3DXMatrixTranslation(&Trans,X,Y,Z);

	D3DXMatrixIdentity(&xRot);
	D3DXMatrixIdentity(&yRot);
	D3DXMatrixIdentity(&zRot);

	if(X)
	{
		//D3DXMatrixRotationX(&xRot,D3DXToRadian(X));
	}

	//if(Y)
	//{
		D3DXMatrixRotationY(&yRot,D3DXToRadian(Y));
	//}

	if(Z)
	{
		//D3DXMatrixRotationZ(&zRot,D3DXToRadian(Z));
	}


	D3DXMATRIX FinalRot,Final;

	FinalRot = (xRot * yRot * zRot);
	Final = FinalRot * Trans;

	device->SetTransform(D3DTS_VIEW,&Final);

}



is there any noticeable problem?

Share this post


Link to post
Share on other sites
Advertisement
oh i'm an idiot, sorry, i accidently used my position values instead of rotation values in the rotations

thanks though, that is a really helpful link

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!