Sign in to follow this  
Sokol

Directx 10 camera rotation problem

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this