Jump to content
  • Advertisement
Sign in to follow this  
icethelog

Problem with mouse roll when using arcball.

This topic is 3640 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. I am passing in a y and x movement from the mouse into a function, along with a 3D point in space. It then alters the camera x,y and z co-ordinate so you can move it around this 3D point in a sphere shape. My problem is that the camera rolls on its look axis, which I don't want it to do. I basically have no way of figuring out how to fix this. Would it involve altering my initial function, or taking the right, up and look vectors for the camera and then altering them so the camera has not rolled? Here is my code: void CCamera::RotateAround(D3DXVECTOR3 vCentre, float x, float y) { //Calculate the radius D3DXVECTOR3 vD = vPosition - vCentre; float fDistance = sqrt(vD.x*vD.x + vD.y*vD.y + vD.z*vD.z); //Calculate look at vector vLookAt = vCentre; //Work out movement phi += x*0.01; theta -= y*0.01; //Calculate the rotation vPosition.x = fDistance * cosf(phi) * cosf(theta); vPosition.z = fDistance * sinf(phi) * cosf(theta); vPosition.y = fDistance * sinf(theta); //Prevent camera from flippping upside down. if(cosf(theta) < 0){ vUp = D3DXVECTOR3(0.0f,1.0f,0.0f); //Set up to 0,1,0 } else { vUp = D3DXVECTOR3(0.0f,-1.0f,0.0f); //Set up to 0,1,0 } } If it involves changing the right, up and look vector of the view matrix, how would I change them? I am terrible with the math involved for this. Thanks for any help.

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!