编辑
哦,还有一件事,longtitute 效果很好,但是当 lattitute 达到大约 1.57 时,它翻转了......
编辑作品!
哦,只有转动一圈才开始增加转速。猜测必须在每次旋转后重置 tempMouse。
private void mouseWheel(object sender, MouseWheelEventArgs e)
{
if (e.Delta < 0) { distance = distance - 0.5; } else { distance = distance + 0.5; }
Point3D position = new Point3D
(
Math.Cos(longitude) * Math.Cos(latitude) * distance,
Math.Sin(latitude) * distance,
Math.Sin(longitude) * Math.Cos(latitude) * distance
);
_perspectiveCamera.Position = position;
}
private void mouseMove(object sender, MouseEventArgs e)
{
if ( e.LeftButton == MouseButtonState.Pressed )
{
if (isLeftDown == false)
{
isLeftDown = true;
tempMouseX = this.PointToScreen(Mouse.GetPosition(this)).X;
tempMouseY = this.PointToScreen(Mouse.GetPosition(this)).Y;
}
else
{
double currentDelataX = tempMouseX - this.PointToScreen(Mouse.GetPosition(this)).X;
double currentDelataY = tempMouseY - this.PointToScreen(Mouse.GetPosition(this)).Y;
longitude = longitude - currentDelataX / 5000;
latitude = latitude - currentDelataY / 5000;
Point3D objectPosition = new Point3D(0, 0, 0);
Point3D position = new Point3D
(
Math.Cos(longitude) * Math.Cos(latitude) * distance,
Math.Sin(latitude) * distance,
Math.Sin(longitude) * Math.Cos(latitude) * distance
);
_perspectiveCamera.Position = position;
Vector3D lookDirection = objectPosition - position;
_perspectiveCamera.LookDirection = lookDirection;
}
}
/////////////////////////////////////////
if (e.LeftButton == MouseButtonState.Released)
{
isLeftDown = false;
}
}