Jump to content
  • Advertisement
bowerbirdcn

how to understand dxut CDXUTDirectionWidget class

Recommended Posts

hi, guys, how to understand the math used in CDXUTDirectionWidget ::UpdateLightDir 

the  following code snippet is taken from MS DXTU source code

 

  D3DXMATRIX mInvView;
    D3DXMatrixInverse( &mInvView, NULL, &m_mView );
    mInvView._41 = mInvView._42 = mInvView._43 = 0;

    D3DXMATRIX mLastRotInv;
    D3DXMatrixInverse( &mLastRotInv, NULL, &m_mRotSnapshot );

    D3DXMATRIX mRot = *m_ArcBall.GetRotationMatrix();
    m_mRotSnapshot = mRot;

    // Accumulate the delta of the arcball's rotation in view space.
    // Note that per-frame delta rotations could be problematic over long periods of time.
    m_mRot *= m_mView * mLastRotInv * mRot * mInvView;

    // Since we're accumulating delta rotations, we need to orthonormalize 
    // the matrix to prevent eventual matrix skew
    D3DXVECTOR3* pXBasis = ( D3DXVECTOR3* )&m_mRot._11;
    D3DXVECTOR3* pYBasis = ( D3DXVECTOR3* )&m_mRot._21;
    D3DXVECTOR3* pZBasis = ( D3DXVECTOR3* )&m_mRot._31;
    D3DXVec3Normalize( pXBasis, pXBasis );
    D3DXVec3Cross( pYBasis, pZBasis, pXBasis );
    D3DXVec3Normalize( pYBasis, pYBasis );
    D3DXVec3Cross( pZBasis, pXBasis, pYBasis );
 

 

https://github.com/Microsoft/DXUT/blob/master/Optional/DXUTcamera.cpp

Share this post


Link to post
Share on other sites
Advertisement

Probably easier to ask what you don't understand about it.

Do you understand what the basis vectors are?  Do you understand what the cross product operations do? What about the function is confusing to you?

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

  • 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!