編集
あ、それともう一つ、ロングティチュートはいいけど、ラティチュートが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;
}
}