Hi
I noticed that when fovy is 90 then the below issue is observed when I rotate camera around right camera vector.
D3DXMatrixPerspectiveFovLH(&d3d::MatProj, D3DXToRadian(45), 1.6f, 0.1f, 1000);
The issue dissapear when I use fovy = 45. Could anybody check and comment that really my code for making rotation is OK and the issue is really connected with fovy=90?
Before rotation:
[attachment=31076:before.JPG]
After pitch rotation (rotation around right camera vector):
[attachment=31077:afterPitchRotation.JPG]
We see that post ends at the ground are narrowed down to inside whereas post ends at crossbarr are expanded to outside. This is distortion.
My code which recalculates view matrix after rotation about some angle is made.
void Camera::Pitch(float angle)
{
D3DXMATRIX T;
D3DXMatrixRotationAxis(&T, &right[curCamView], angle);
// rotate up and look around right vector
D3DXVec3TransformCoord(&up[curCamView],&up[curCamView], &T); //up=up*T i tak by up(x,y,z,w) w = 1
D3DXVec3TransformCoord(&look[curCamView],&look[curCamView], &T);
}
void Camera::SetViewMatrix(CameraView cam)
{
if(cam >= MaxCams) return;
// Keep camera's axes orthogonal to each other:
D3DXVec3Normalize(&look[cam], &look[cam]);
D3DXVec3Cross(&up[cam], &look[cam], &right[cam]);
D3DXVec3Normalize(&up[cam], &up[cam]);
D3DXVec3Cross(&right[cam], &up[cam], &look[cam]);
D3DXVec3Normalize(&right[cam], &right[cam]);
// Build the view matrix:
float x = -D3DXVec3Dot(&right[cam], &pos[cam]);
float y = -D3DXVec3Dot(&up[cam], &pos[cam]);
float z = -D3DXVec3Dot(&look[cam], &pos[cam]);
MatView[cam](0, 0) = right[cam].x;
MatView[cam](0, 1) = up[cam].x;
MatView[cam](0, 2) = look[cam].x;
MatView[cam](0, 3) = 0.0f;
MatView[cam](1, 0) = right[cam].y;
MatView[cam](1, 1) = up[cam].y;
MatView[cam](1, 2) = look[cam].y;
MatView[cam](1, 3) = 0.0f;
MatView[cam](2, 0) = right[cam].z;
MatView[cam](2, 1) = up[cam].z;
MatView[cam](2, 2) = look[cam].z;
MatView[cam](2, 3) = 0.0f;
MatView[cam](3, 0) = x;
MatView[cam](3, 1) = y;
MatView[cam](3, 2) = z;
MatView[cam](3, 3) = 1.0f;
}