Sign in to follow this  

Direct X: D3DXMatrixRotationAxis?

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

Hi Im a begginer, and am wanting, just to start with, to roll a ball around the screen. Im using direct X (i recently did some online tutorials on it). Should I use D3DXMatrixRotationAxis? If so, how? What would I put in the D3DXVECTOR3 to make it work? Or should I be using D3DXMatrixRotationQuaternion? Or something else? Thanks in advice Andy

Share this post


Link to post
Share on other sites
Quaternions and matrices are, as far as i know, pretty different.

Are you trying to move a 3D ball? or a 2D ball. If 3D maybe this is a bit ambitious for your first project.

But more to the point, i personaly would play around with matrices for the X,Y and Z axis all at once then concatenating tehm for teh transformation to teh ball.

ace

Share this post


Link to post
Share on other sites
Thanks Ace

Ive tried using D3DXMatrixRotationZ & D3DXMatrixRotationX. At first, it seemed like it worked, but as I messed around with my ball a bit more, sometimes the ball wasn't rotating in the right direction. It especially seemed so when I moved the ball left and right (meaning the ball would be ROTATING on the Z axis, and MOVING left and right ALONG the X axis). Here is my code.
Here is the relevant bits of code for rotating the ball assuming this is the bit where my problem lies). Any ideas for what ive done wrong?




//Work out how to roll the ball over the X and Z axis
D3DXMatrixRotationZ(&matRotateZ, D3DXToRadian(m_rAngleZ));
D3DXMatrixRotationX(&matRotateX, D3DXToRadian(m_rAngleX));

//Multiply the rotation matrices, and then the matrix that physically moves the ball
D3DXMatrixMultiply(&matBallRoll, &matRotateZ, &matRotateX);
D3DXMatrixMultiply(&matBall, &matBallRoll, &matBallMove);

//Render the ball
m_pD3DDevice->SetTransform(D3DTS_WORLD, &matBall);
m_dwTotalPolygons += m_pSphere->Render();

Share this post


Link to post
Share on other sites

This topic is 4691 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.

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

Sign in to follow this