lixiaojun
2025-03-28 bc99451a0ab10dbba6ac1fe4cea020d68bbbad2b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
//正交缩放操作可通过投影矩阵的参数配置进行调整
 
//旋转除了旋转模型外,也可以改变相机位置和相机观察方向进行
//在MouseMove事件中计算旋转四元数
//float dx = e.X - _lastMousePos.X;
//float dy = e.Y - _lastMousePos.Y;
// 根据鼠标移动量计算旋转角度
//var roation_dx = dy / _radius;
//var rotaion_dy = dx / _radius;
//_rotationX += roation_dx;
//_rotationY += rotaion_dy;
//Quaternion rotationX = Quaternion.FromAxisAngle(Vector3.UnitX, dy / _radius);
//Quaternion rotationY = Quaternion.FromAxisAngle(Vector3.UnitY, dx / _radius);
// 更新四元数
//_rotation = rotationY * rotationX * _rotation;
//_rotation = Quaternion.Normalize(_rotation);
//var eye = new Vector3(_mc.X, _mc.Y, _mc.Z + _radius * 2);
//var target = _mc;
//var up = Vector3.UnitY;
//_rotation = Quaternion.Identity;
//var rotationX = Quaternion.FromAxisAngle(Vector3.UnitX, _rotationX);
//var rotationY = Quaternion.FromAxisAngle(Vector3.UnitY, _rotationY);
//_rotation = rotationY * rotationX * _rotation;
//_rotation.Normalize();
//var matrix = Matrix4.CreateFromQuaternion(_rotation);
//matrix.Invert();
//eye = Vector3.TransformPosition(eye, matrix);
//up = Vector3.TransformPosition(up, matrix);
//_viewMatrix = Matrix4.LookAt(eye, target, up);
//_forward = target - eye;
//_forward.Normalize();