# Problem with mouse roll when using arcball.

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

## 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.

1. 1
2. 2
3. 3
Rutin
15
4. 4
khawk
14
5. 5
frob
12

• 9
• 11
• 11
• 23
• 12
• ### Forum Statistics

• Total Topics
633660
• Total Posts
3013221
×

## Important Information

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!