There are some disprepancies between my max camera and direct3d cameras
I followed this thread
http://mcrogames.wordpress.com/2011/11/23/transforming-your-position-and-rotation-matrix-from-z-up-to-y-up/
Matrix3 atm = node->GetNodeTM(ip->GetTime(), 0);// 4x3 matrix
Matrix3 targetTM;
node->GetTargetTM(ip->GetTime(), targetTM);
MRow *row1 = atm.GetAddr();
Point3 position;
position.x = row1[3][0];
position.y = row1[3][2];
position.z = row1[3][1];
Matrix3 rotation(atm);
MRow *row2 = rotation.GetAddr();
// row 2
Point3 temp2(row2[1][0], row2[1][1], row2[1][2]);
// put row 3 to row 2
row2[1][0] = row2[2][0]; // 1,0
row2[1][1] = row2[2][1]; // 1,1
row2[1][2] = row2[2][2]; // 1,2
// put row 2 to row 3
row2[2][0] = temp2.x; //2,0
row2[2][1] = temp2.y; //2,1
row2[2][2] = temp2.z; //2,2
// column vector 2
Point3 temp(row2[0][1], row2[1][1], row2[2][1]);
// put column 3 into column 2
Point3 col2;
col2.x = rotation.GetRow(0)[2]; // 0,1
col2.y = rotation.GetRow(1)[2];
col2.z = rotation.GetRow(2)[2];
rotation.SetColumn(1, col2);
// put column 2 into column 3
Point3 col3;
col3.x = temp.x; // 0,2
col3.y = temp.y;
col3.z = temp.z;
rotation.SetColumn(2, col3);
int ki, kj;
for (ki = 0; ki < 4; ki++) {
for (kj = 0; kj < 3; kj++) {
d3dViewXform.m[ki][kj] = row2[ki][kj];
}
}
// Assign the fourth column (perspective terms)
d3dViewXform.m[0][3] = d3dViewXform.m[1][3] = d3dViewXform.m[2][3] = 0.0f;
d3dViewXform.m[3][0] = position.x;
d3dViewXform.m[3][1] = position.y;
d3dViewXform.m[3][2] = position.z;
d3dViewXform.m[3][3] = 1.0f;
float fov_rh = cam->GetFOV(ip->GetTime(), FOREVER);
float aspectRatio = ip->GetRendImageAspect();
float fov_lh = aspectRatio / fov_rh;
// Change it to vertical 3d mathematic book
float e = 1 / tanf( fov_lh / 2 );
// vertical fov
float fov_vert = 2 * atanf(aspectRatio/e);
float nearClip = cam->GetClipDist(ip->GetTime(), CAM_HITHER_CLIP, FOREVER);
float farClip = cam->GetClipDist(ip->GetTime(), CAM_YON_CLIP, FOREVER);
D3DXMATRIX d3dProjXform;
D3DXMatrixPerspectiveFovLH(&d3dProjXform, fov_vert, aspectRatio, nearClip, farClip);
I tried to swap row2 and row3 and followed by swapping column2 and column3, what beneath it is the projection matrix calculation method.
Image compared
[max]
[attachment=14396:rendered camera1.jpg]
[actual]
[attachment=14397:direct3d camera.jpg]
Any ideas?
Thanks