Original Post
Hello, my camera class sucks, here is my code. I hope you can help me make a better one, because for some reason, clip planes arent computed easily.
[cpp]
void CRTCamera::SetupCamera(float eyeX, float eyeY, float eyeZ, float targetX, float targetY, float targetZ)
{
rtCamera.vEye = Vec3(eyeX, eyeY, eyeZ);
rtCamera.vLookAt = Vec3(targetX, targetY, targetZ);
rtCamera.fAspect = 1.0f;
D3DXMatrixPerspectiveFovLH(&rtCamera.matProj, rtCamera.fFov, rtCamera.fAspect, rtCamera.fNear, rtCamera.fFar);
D3DXMatrixLookAtLH(&rtCamera.matView, &rtCamera.vEye, &rtCamera.vLookAt, &rtCamera.vUp);
}
/* Method/Function name: SetPosition
---------------------------------
DESC: Updates the camera eye position.
---------------------------------
*/
void CRTCamera::SetPosition(float x, float y, float z)
{
rtCamera.vEye = Vec3(x,y,z);
D3DXMatrixLookAtLH(&rtCamera.matView, &rtCamera.vEye, &rtCamera.vLookAt, &rtCamera.vUp);
}
/* Method/Function name: SetLookAt
-------------------------------
DESC: Updates the camera looking at vector.
-------------------------------
*/
void CRTCamera::SetLookAt(float x, float y, float z)
{
rtCamera.vLookAt = Vec3(x,y,z);
D3DXMatrixLookAtLH(&rtCamera.matView, &rtCamera.vEye, &rtCamera.vLookAt, &rtCamera.vUp);
}
[/cpp]
then, I set the view and projection matrices for that camera in the start of my loop. But this doesnt work well. What is your camera code, or maybe you can point me to some nice camera tutorial for d3d?
Thanks!