• Create Account

# Camera Movement dependet from mouse movement

Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

2 replies to this topic

### #1cg_neuling  Members   -  Reputation: 106

Like
0Likes
Like

Posted 22 August 2012 - 04:49 AM

Hi!
I have the following question. I have programmed the rotation of the object dependent from the mouse movement. This works. But know I want to make the "object movement" by rotating the camera instead of rotating the object because I need this for a new program code because it would make this program code simplier.

The problem is how to make the rotation of the camera movement? When I have a movement in x-direction and a movement in y-direction of the mouse then I have written the following code:
m_Camera->setRotation(mouseRX, mouseRY, status);
temp_rot  = m_Camera->getRotation();
rot1 = m_Camera->getLength() * cos(temp_rot.y) * cos(temp_rot.x);
rot2 = m_Camera->getLength() * cos(temp_rot.y) * sin(temp_rot.x);
rot3 = m_Camera->getLength()* sin(temp_rot.y);

m_Camera->SetPosition(rot1,  rot2, rot3);
m_Camera->SetLookVector(nullvector - m_Camera->GetPosition());


So I calcuate the kartesian coordinates (rot1, rot2, rot3 ) which are the x,y,z coordinates and set the position and look vector. This works when one of the angles is zero, but if both of them aren't zero then it does not work. Can anyone help me with this problem?
Thanks a lot.
Regards

### #2BCullis  Crossbones+   -  Reputation: 1700

Like
0Likes
Like

Posted 22 August 2012 - 08:48 AM

I'm assuming since you posted this in the DirectX forum, that you have access to the Matrix class. Why not use the Matrix method from your API that creates a rotation matrix from a yaw, pitch, and roll value? (Not sure which version of DirectX you're using)
Hazard Pay :: FPS/RTS in SharpDX
DeviantArt :: Because right-brain needs love too

### #3cg_neuling  Members   -  Reputation: 106

Like
0Likes
Like

Posted 22 August 2012 - 08:57 AM

I am using DirectX 11 but I am not using the Matrix class in my engine.

Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

PARTNERS