Jump to content
  • Advertisement
Sign in to follow this  
lucky6969b

Rotating around y-axis for 1.57radian

This topic is 845 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

I've got an object with +ve x facing front in local space.
when I rotate the object by D3DXVECTOR3(1.57,0,0),
it is lying on the ground sideways,
So I think it should rotate around the y-axis instead to get it facing south
because y-up axis is facing up in DirectX.
I think it must be correct. But indeed it has no effect.
The object is still facing East, not facing South.
Why is this happening?

I debug the transformation at the final stage of setting world transformation.

the rotation vector is D3DXVECTOR3(0,1.57,0)

and the matrix code is

void Mover::Transform(float time, float& localTime, D3DXMATRIX& matWorld,
                      const D3DXVECTOR3& scale, const boost::shared_ptr<cPoint> pos,
                      const D3DXVECTOR3& rot,
                      LPD3DXANIMATIONCONTROLLER pAnimCtrl,
                      const D3DXMATRIX* combinedMatrix,
                      const D3DXVECTOR3& scaleCenter,
                      const D3DXVECTOR3& rotCenter) {
    localTime += time;

    D3DXQUATERNION quatRot;

    if (rot.x != 0.0f || rot.y != 0.0f || rot.z != 0.0f)
    {
        D3DXQuaternionRotationYawPitchRoll(&quatRot, rot.x, rot.y, rot.z);
        D3DXMatrixTransformation(&matWorld, &scaleCenter, NULL, &scale,
            &rotCenter, &quatRot, &pos->m_vec3);
    }
    else {
        D3DXMatrixTransformation(&matWorld, &scaleCenter, NULL, &scale,
            NULL, NULL, &pos->m_vec3);
    }

    // check if current object is attach to other object
    // check if m_matWorld = *m_pCombineFrameMatrix works
    if (combinedMatrix != NULL)
        matWorld *= *combinedMatrix;

    if (pAnimCtrl != NULL) {
        pAnimCtrl->AdvanceTime(time, NULL);
    }

    


}

Update:

Sorry, found the bug, no problem with D3DXVECTOR3(1.57,0,0)

but since I've got some impurities in the rotation of the physics subsystem.

The object was tilted and fell over to the ground

 

Thanks

Jack


 
 

Edited by lucky6969b

Share this post


Link to post
Share on other sites
Advertisement
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!