• Create Account

### #ActualGuardianX

Posted 21 February 2013 - 09:21 AM

Are you sure about what do you want to do in this code:

void TransformMatrix::Rotate( float x, float y, float z, float ang )
{
if ( x * ang != 0.0f ) rotate *= XMMatrixRotationX( x * ang );
if ( y * ang != 0.0f ) rotate *= XMMatrixRotationY( y * ang );
if ( z * ang != 0.0f ) rotate *= XMMatrixRotationZ( z * ang );
}


Don't you want to rotate around vector with x, y, z coordinates actually? Because if so, rotating around each orthogonal axis for angle ang is not the same as rotating around specified vector for angle ang and you should use XMMatrixRotationAxis instead.

Also, I couldn't find any code, responsible for view and projection matrix creation.

To jump back an idea for a second, another suspicion was that I maybe shouldn't be transposing the matrices before sending them to the vertex shader.  The reason I am is because every example I have came across on msdn and some other places have always sent the matrices to the vertex shader after a XMMatrixTranspose().

You must use XMMatrixTranspose(), because matrices in shaders are transposed version of XNA SSE matrices by default.

Also make sure that you constant buffer structure has the same member's order as your shader constant buffer:

cbuffer ProjectionBuffer : register(b0)
{
matrix p;
matrix m;
matrix v;
}; 

### #2GuardianX

Posted 21 February 2013 - 09:21 AM

Are you sure about what do you want to do in this code:

void TransformMatrix::Rotate( float x, float y, float z, float ang )
{
if ( x * ang != 0.0f ) rotate *= XMMatrixRotationX( x * ang );
if ( y * ang != 0.0f ) rotate *= XMMatrixRotationY( y * ang );
if ( z * ang != 0.0f ) rotate *= XMMatrixRotationZ( z * ang );
}


Don't you want to rotate around vector with x, y, z coordinates actually? Because if so, rotating around each orthogonal axis for angle ang is not the same as rotating around specified vector for angle ang and you should use XMMatrixRotationAxis instead.

Also, I couldn't find any code, responsible for view and projection matrix creation.

To jump back an idea for a second, another suspicion was that I maybe shouldn't be transposing the matrices before sending them to the vertex shader.  The reason I am is because every example I have came across on msdn and some other places have always sent the matrices to the vertex shader after a XMMatrixTranspose().

You must use XMMatrixTranspose(), because matrices in shaders are transposed version of XNA SSE matrices by default.

Also make sure that you constant buffer structure has the same member's order as your shader constant buffer:

cbuffer ProjectionBuffer : register(b0)
{
matrix p;
matrix m;
matrix v;
}; 

### #1GuardianX

Posted 21 February 2013 - 09:21 AM

Are you sure about what do you want to do in this code:

void TransformMatrix::Rotate( float x, float y, float z, float ang )
{
if ( x * ang != 0.0f ) rotate *= XMMatrixRotationX( x * ang );
if ( y * ang != 0.0f ) rotate *= XMMatrixRotationY( y * ang );
if ( z * ang != 0.0f ) rotate *= XMMatrixRotationZ( z * ang );
}


Don't you want to rotate around vector with x, y, z coordinates actually? Because if so, rotating around each orthogonal axis for angle ang is not the same as rotating around specified vector for angle ang and you should use XMMatrixRotationAxis instead.

Also, I couldn't find any code, responsible for view and projection matrix creation.

To jump back an idea for a second, another suspicion was that I maybe shouldn't be transposing the matrices before sending them to the vertex shader.  The reason I am is because every example I have came across on msdn and some other places have always sent the matrices to the vertex shader after a XMMatrixTranspose().

You must use XMMatrixTranspose(), because matrices in shaders are transposed version of XNA SSE matrices by default.

Also make sure that you constant buffer structure has the same member's order as your shader constant buffer:

cbuffer ProjectionBuffer : register(b0)
{
matrix p;
matrix m;
matrix v;
};


PARTNERS