# Directx Camera

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

## Recommended Posts

I've written this camera code, and it kinda works okay. but i wanna make some changes to the way it works. Mainly when i move the mouse i just want the camera to rotate.
Currently the camera rotates with the mouse, but it seems to be rotating from (0,0,0). Hopefully somebody can offer a hand with this issue.

 dim m_previousposition2d as point dim m_cameraposition as new Vector3(0,1,-75) dim m_cameratarget as new Vector3(0,0,0) public sub OnMouseMove() If e.Button = MouseButtons.Right Then leftrightrot += Calculate_Angle(e.x - m_previousposition2d) updownrot += Calculate_Angle(x.y - m_previousposition2d) m_previosuposition2d = e.location End Sub public function Calculate_Angle(byval opposite as single) as single return Math.Atan(opposite / Math.Abs(m_cameraposition.z)) end function public readonly property Transform() as Matrix Get dim camerarotation as matrix = matrix.rotationx(updownrot) * matrix.rotationy(leftrightrot) dim camerafinalposition as vector3 = vector3.transformcoordinate(m_cameraposition, camerarotation) dim camerafinaltarget as vector3 = vector3.transformcoordinate(m_cameratarget, camerarotation) dim camerafinalupvector as vector3 = vector3.transformcoordinate(new vector3(0,1,0), camerarotation) return matrix.LookAtLH(camerafinalposition, camerafinaltarget,camerafinalupvector) End Get 

Thanks
Gary
[attachment=2254:BaseCamera.txt][attachment=2255:FirstPersonCamera.txt]

1. 1
2. 2
3. 3
Rutin
12
4. 4
5. 5

• 26
• 10
• 9
• 9
• 11
• ### Forum Statistics

• Total Topics
633695
• Total Posts
3013382
×