Jump to content
  • Advertisement
Sign in to follow this  
Sokol

Directx 10 camera rotation problem

This topic is 4063 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

Hi I can't say I am expert on shaders, But Some time ago I wrote really easy class for camera and It was working(i was writing in Dx9 without shaders). Now I am trying to write something similar In Dx10 but the effect is bad. i have problem with rotation. The camera isn't rotating. Object on the screen appears to be blurred or something like that(Instead of rotating). Anyone? Shader // Taken nearly exactly from tutorial 5
matrix World;
matrix View;
matrix Projection;
struct VS_INPUT
{
    float4 Pos : POSITION;
};
struct PS_INPUT
{
    float4 Pos : SV_POSITION;
};

PS_INPUT VS( VS_INPUT input )
{
    PS_INPUT output = (PS_INPUT)0;
    output.Pos = mul( input.Pos, World );
    output.Pos = mul( output.Pos, View );
    output.Pos = mul( output.Pos, Projection );
    
    return output;
}

float4 PS1( PS_INPUT input) : SV_Target
{
    return float4(1.0f, 0.0f, 0.0f, 1.0f);
}
float4 PS2(PS_INPUT input) : SV_Target
{
	return float4(0.0f, 1.0f, 0.0f, 1.0f);
}
technique10 Render
{
   ///Technique Cut not to make this thread too long
}


CCamera class
void CCamera::Rotation(bool X, bool Y,	 //Rotation around particular axis for a test only rotation about Right vector		
	bool Z, int rad)
	{
	D3DXMATRIX Rot;
	D3DXMatrixRotationAxis(&Rot, &vRight, rad);
	D3DXVec3TransformCoord(&vLookAt, &vLookAt, &Rot);
	D3DXVec3TransformCoord(&vUp, &vUp, &Rot);
LookAtLH();
/*Rotation aobut Y it also isn't working
		D3DXMatrixRotationY(&Rot, rad);
		D3DXVec3TransformCoord(&vRight, &vRight, &Rot);		
		D3DXVec3TransformCoord(&vLookAt, &vLookAt, &Rot);
		LookAtLH();*/
	}
void CCamera::LookAtLH()
{
D3DXMatrixLookAtLH(&matView, &vEye, &vUp, &vLookAt);
}


Main cpp
void Render()
{
//....
	camera1.Rotation(1,1,1,10.0f);

	g_pWorldVariable->SetMatrix((float*)&g_World);
	g_pViewVariable->SetMatrix((float*)&camera1.GetViewMatrix());
	g_pProjectionVariable->SetMatrix((float*)&camera1.GetProjMatrix());

	D3D10_TECHNIQUE_DESC techDesc;
	g_pTechnique->GetDesc(&techDesc);
	for(UINT p=0; p<1; ++p)
	{
		g_pTechnique->GetPassByIndex(p)->Apply(0);
		g_pd3dDevice->DrawIndexed(36, 0, 0);
	}
//......

}

camera1.Rotation(1,1,1,10.0f); - As You can see instead of changing variable I put 10.0f But it doesn't matter if I give here t(time variable) or 10.0f the effect is still the same)

Share this post


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

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!