This setup leads to a blank screen

Started by
1 comment, last by lucky6969b 12 years, 10 months ago
Projection Matrix
[source]
2.4142134 0 0 0
0 2.4142134 0 0
0 0 1.00200 1
0 0 -1.00250 0
[/source]


View Matrix
[source]
0.6726143 -0.54732075 -0.49802950 0
0 0.67301720 -0.73962673 0
0.73999518 0.45748194 0.45267957 0
-269.02557 -21.353961 758.17938 1
[/source]



World Matrix
[source]
1 0 0 0
0 1 0 0
0 0 1 0
189.40488 13.586655 151.57556 1
[/source]


Anyone sees what might have gone wrong?
My apologies because I don't know which tag to use....
Thanks
Jack
Advertisement
Can you post the code you use to create the matrices?

Are you using DirectX 9 or DirectX 11? Are you sure the problem isnt in the shaders?

P.S. You should use [.code] [./code]


CameraObject *cam = (CameraObject*) aNode->EvalWorldState(ip->GetTime()).obj;
CameraState cs;
cam->EvalCameraState(ip->GetTime(), FOREVER, &cs);
// cs.fov/aspect;
Matrix3 atm = aNode->GetObjectTM(ip->GetTime(), 0);//>GetObjectTM(ip->GetTime()); // 4x3 matrix
//cam->EvalCameraState(ip->GetTime(), &cs);
Matrix3 targetTM;
aNode->GetTargetTM(ip->GetTime(), targetTM);
float fov = cs.fov;
WriteCam_File(atm, targetTM, fov);
continue;


void WriteCam_File(const Matrix3& tm, const Matrix3& target, float fov)
{
FILE* fpc;
float zero = 0;
float one = 1;
fpc = fopen("Demo.cam", "wb");
float NewMat[4][4];
float NewTargetMat[4][4];
for (int i = 0; i < 4; i++)
{
for (int j = 0 ; j < 4; j++)
{
if (j == 3 && i != 3) { NewMat[j] = 0; continue; }
if (i == 3 && j == 3) { NewMat[j] = 1; continue; }
NewMat[j] = tm[j];
}
}
for (int i = 0; i < 4; i++)
{
for (int j = 0 ; j < 4; j++)
{
if (j == 3 && i != 3) { NewTargetMat[j] = 0; continue; }
if (i == 3 && j == 3) { NewTargetMat[j] = 1; continue; }
NewTargetMat[j] = target[j];
}
}
fwrite((const void *) NewMat, sizeof(float), 16, fpc); // View
fwrite((const void *) NewTargetMat, sizeof(float),16, fpc); // Projection
//float fov = 0.8f;
fwrite((const void*)&fov, sizeof(float), 1, fpc);
fclose(fpc);

}

void WriteOrigin_File(const Matrix3& tm)
{
FILE *fpc;
// we need to group or collapse the scene
fpc = fopen("Demo.ori", "wb");
float NewMat[4][4];
for (int i = 0; i < 4; i++)
{
for (int j = 0 ; j < 4; j++)
{
if (j == 3 && i != 3) { NewMat[j] = 0; continue; }
if (i == 3 && j == 3) { NewMat[j] = 1; continue; }
NewMat[j] = tm[j];
}
}
fwrite((const void *) NewMat, sizeof(float), 16, fpc);
fclose(fpc);

}


I use the above code to export the view and projection matrices to a file.
Then I read it back into direct3d by


bool CPerfectSimDoc::LoadCamera(TCHAR *szFilename, u32 Width, u32 Height)
{
D3DXMATRIX matView;
D3DXMATRIX matLookAt;
float *fov;
TCHAR aDir[MAX_PATH];
ifstream f;
float buf[16];
float bufb[16];
float buf2;
/// FILE *fp = NULL;

//char *temp = "Data\\Demo.cam";

//fp = fopen (temp, "rb");






f.open(szFilename, ifstream::in|ifstream::binary);
if (f == NULL)
return false;


f.read(reinterpret_cast<char*>(&buf), 16*sizeof(float));

matView._41 = buf[12];
matView._42 = buf[13];
matView._43 = buf[14];

f.read(reinterpret_cast<char*>(&bufb), 16*sizeof(float));
matLookAt._41 = bufb[12];
matLookAt._42 = bufb[13];
matLookAt._43 = bufb[14];

f.read(reinterpret_cast<char*>(&buf2), 1*sizeof(float));

fov = (float*) &buf2;



// Camera adjusted for warehouse object temp solution
D3DXVECTOR3 vecLoc (matView._41, matView._43, matView._42);
D3DXVECTOR3 vecLookAt(matLookAt._41, matLookAt._43, matLookAt._42);

m_Cam.SetPos(vecLoc);
m_Cam.SetLookAt(vecLookAt);
m_Cam.SetFOV(*fov);

m_Cam.Create((float)Width/(float)Height, 40000.0f);
f.close();

return true;


Any ideas how I can do it better?
Thanks
Jack

This topic is closed to new replies.

Advertisement