# World Inverse Transpose

This topic is 3521 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Is this the proper way to set the world inverse transpose matrix? Do I need to normalize anything? I never know when to normalize things. Sometimes it's done to account for floating point error and sometimes its done because it actually makes sense.
//----------------------------------------------------------------------------
void Effect::SetWorldMatrix(const D3DXMATRIX & worldMatrix)
{
BaseException exception("Not Set",
"void Effect::SetWorldMatrix(const D3DXMATRIX & worldMatrix)",
"Effect.cpp");

// Check for a valid world matrix
if ( !m_worldMatrix ||
!m_worldMatrix->IsValid() )
{
exception.m_msg = "World matrix effect variable is NULL or invalid. Check that the effect contains a matrix variable named 'world'",
throw exception;
}

// Check for a valid world inverse transpose matrix
if( !m_worldInverseTransposeMatrix ||
!m_worldInverseTransposeMatrix->IsValid() )
{
exception.m_msg = "World inverse transpose matrix effect variable is NULL or invalid. Check that the effect contains a matrix variable named 'worldInverseTranspose'",
throw exception;
}

// Set the world matrix effect variable
m_worldMatrix->SetMatrix((float *)&worldMatrix);

// Set the world inverse transpose matrix effect variable
D3DXMATRIX inverseTranspose;
float determinant = D3DXMatrixDeterminant(&worldMatrix);
D3DXMatrixInverse(&inverseTranspose, &determinant, &worldMatrix);
D3DXMatrixTranspose(&inverseTranspose, &inverseTranspose);

m_worldInverseTransposeMatrix->SetMatrix((float *)&inverseTranspose);
}



##### Share on other sites
Make sure that your only using the 3x3 portion of the matrix that has the rotation and scale. If the world matrix included translation, then the results will not be what you want.

##### Share on other sites
So, when my application sets the world inverse transpose matrix, I should do it like this?

   // Set the world inverse transpose matrix effect variable   D3DXMATRIX inverseTranspose(worldMatrix);   inverseTranspose._14 = inverseTranspose._24 = inverseTranspose._34 = 0.0f;   inverseTranspose._41 = inverseTranspose._42 = inverseTranspose._43 = 0.0f;   inverseTranspose._44 = 1.0f;   float determinant = D3DXMatrixDeterminant(&inverseTranspose);   D3DXMatrixInverse(&inverseTranspose, &determinant, &inverseTranspose);   D3DXMatrixTranspose(&inverseTranspose, &inverseTranspose);   m_worldInverseTransposeMatrix->SetMatrix((float *)&inverseTranspose);

1. 1
2. 2
Rutin
20
3. 3
khawk
17
4. 4
A4L
14
5. 5

• 12
• 16
• 26
• 10
• 44
• ### Forum Statistics

• Total Topics
633759
• Total Posts
3013715
×