Sign in to follow this  
lucky6969b

This setup leads to a blank screen

Recommended Posts

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

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
[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;
[/code]
[code]
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[i][j] = 0; continue; }
if (i == 3 && j == 3) { NewMat[i][j] = 1; continue; }
NewMat[i][j] = tm[i][j];
}
}
for (int i = 0; i < 4; i++)
{
for (int j = 0 ; j < 4; j++)
{
if (j == 3 && i != 3) { NewTargetMat[i][j] = 0; continue; }
if (i == 3 && j == 3) { NewTargetMat[i][j] = 1; continue; }
NewTargetMat[i][j] = target[i][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[i][j] = 0; continue; }
if (i == 3 && j == 3) { NewMat[i][j] = 1; continue; }
NewMat[i][j] = tm[i][j];
}
}
fwrite((const void *) NewMat, sizeof(float), 16, fpc);
fclose(fpc);

}
[/code]

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

[code]
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;

[/code]
Any ideas how I can do it better?
Thanks
Jack

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