Sign in to follow this  
sipickles

inverting matrix errors with REF device

Recommended Posts

Hi, My app runs great on HAL, but when I switch to REF device, I get errors like this, and it crashes! Direct3D9: (INFO) :Cannot invert world-view matrix, assuming identity Direct3D9: (INFO) :Cannot invert view matrix, assuming identity Does anyone have any idea what causes this? I expected more to work on REF than HAL, not the other way round! :) Thanks Simon (MSVC2003, DXSDK dec05)

Share this post


Link to post
Share on other sites
Graphics hardware tends to be more forgiving of certain types of abuse than software - it doesn't have much of a way to complain anyway!

From the info messages, I'm assuming you're using the fixed function pipeline here. The FFP maintains a concatenation of your D3DTS_WORLD and D3DTS_VIEW matrices: world-view (to transform from object space to camera space).

If the REF device ever needed to transform from camera space to object space, it would use the inverse of the world-view matrix (which it probably computes when it concatenates the world and view matrices - it's been a while since I looked at the refrast source, can't remember why).


Unless you're trying to do some particularly funky transformation, then it's likely the values you've supplied for D3DTS_WORLD and/or D3DTS_VIEW are either mathematically non invertible (such as a row of the matrix which contained all 0's), garbage, or filled in incorrectly (e.g. rows where columns were meant to be).


Useful link: http://www.easycalculation.com/matrix/matrix-inverse.php

Share this post


Link to post
Share on other sites
Thanks for that advice,

I am just surprised it renders correctly, with this stream of error messages:

Here's how I am building my view... perhaps this is a poor method?

void cProxyMobile::LookAt(D3DXVECTOR3& pos, D3DXVECTOR3& target, D3DXVECTOR3& up)
{
D3DXVECTOR3 L = target - pos;
D3DXVec3Normalize(&L, &L);

D3DXVECTOR3 R;
D3DXVec3Cross(&R, &up, &L);
// Since 'up' and 'L' are unit vectors, 'R' will be a
// unit vector also.

D3DXVECTOR3 U;
D3DXVec3Cross(&U, &L, &R);
// Since 'L' and 'right' are unit vectors, 'U' will be a
// unit vector also.


m_right = R;
m_up = U;
m_forward = L;


// Keep camera's axes orthogonal to each other and of unit length.
// D3DXVec3Normalize(&L, &L);

// D3DXVec3Cross(&U, &L, &R);
// D3DXVec3Normalize(&U, &U);

// D3DXVec3Cross(&R, &U, &L);
// D3DXVec3Normalize(&R, &R);

float x = -D3DXVec3Dot(&m_translation, &m_right);
float y = -D3DXVec3Dot(&m_translation, &m_up);
float z = -D3DXVec3Dot(&m_translation, &m_forward);

m_viewMatrix(0,0) = m_right.x;
m_viewMatrix(1,0) = m_right.y;
m_viewMatrix(2,0) = m_right.z;
m_viewMatrix(3,0) = x;

m_viewMatrix(0,1) = m_up.x;
m_viewMatrix(1,1) = m_up.y;
m_viewMatrix(2,1) = m_up.z;
m_viewMatrix(3,1) = y;

m_viewMatrix(0,2) = m_forward.x;
m_viewMatrix(1,2) = m_forward.y;
m_viewMatrix(2,2) = m_forward.z;
m_viewMatrix(3,2) = z;

m_viewMatrix(0,3) = 0.0f;
m_viewMatrix(1,3) = 0.0f;
m_viewMatrix(2,3) = 0.0f;
m_viewMatrix(3,3) = 1.0f;

g_device->SetTransform( D3DTS_VIEW, &m_viewMatrix );
}





Thanks for help!

Simon

Share this post


Link to post
Share on other sites
Hi Sirob,

You know what? I can't remember!

I wrote the class so long ago! Just goes to show, always review the code you are using from time to time.

Thanks for the good idea!

Simon

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