Jump to content
  • Advertisement
Sign in to follow this  
lucky6969b

Getting the look vector of a Matrix when the current rotation is 1.57(x-axis)

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

How come I would get 1.00000, 0, 0

 

void CCB::CreateMoveBack()
{
 
    D3DXMATRIX newWorld = m_matWorld;
    TurnObjectAround(newWorld);
    D3DXVECTOR3 moveBackDir = GetLookVector(newWorld);    
    CreateMoveBackAnimation(-moveBackDir);

}
 
 
void TurnObjectAround(D3DXMATRIX& matWorld) // Rotate an object by D3DX_PI / 2 or 180.0f degrees.
{
    D3DXMATRIX RY;
    D3DXMatrixRotationY(&RY, D3DXToRadian(180.0f));
    matWorld *= RY;
}
 
 
D3DXVECTOR3 GetLookVector(const D3DXMATRIX& matWorld) // Also called Forward vector or Direction vector, this is the vector from the object's world matrix
{
    return D3DXVECTOR3(matWorld._13, matWorld._23, matWorld._33);
}

 

The result is of the vMoveBackDir is -1.0000, 0.0000, 0.0000

when the world matrix is collapsed and when the rotation is 1.57, 0, 0, scale of 1,1,1 and no other transformations added?

Why? I am expecting to get something like 0, 0, 1

Share this post


Link to post
Share on other sites
Advertisement

"D3DXVECTOR3(matWorld._13, matWorld._23, matWorld._33);"

 

You're grabbing the third column from the matrix there, not the third row.

 

So the identity matrix transformed by a 1.57 rad rotation around the Y-axis results in:

0 0 [-1]

0 1 [0]

1 0 [0]

Share this post


Link to post
Share on other sites

Even though the math is corrected now,

I still need to get the right vector instead of the lookat vector without negating it?

Why??? it seems very strange to me...

 

[0] 0 -1

[0] 1 0

[1] 0 0

Thanks

Jack

Edited by lucky6969b

Share this post


Link to post
Share on other sites

That's the first row:

 

[0, 0, -1]

0 1 0

1 0 0

Edited by eppo

Share this post


Link to post
Share on other sites

So the first row, is the left vector right (in directx sense),
but why not the third row, which represents the look vector?
I still need to get the left vector though.
Thanks
Jack

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!