public void SceneOrbit(FScene scene, fCamera cam, float deltaAzimuth, float deltaAltitude, bool bSet = false) { //Vector3f sceneOrigin = scene.RootGameObject.transform.position; Vector3f rotTarget = cam.GetTarget(); // [RMS] Orbiting around the Target point is kind of a weird concept when // you are moving the scene and not the camera. Basically we want to rotate // the scene around the target, but not incrementally - based on a pair of // spherical angles. So, we have to return to a 'reference' state each update. // Simplest way to do that is to "un-rotate" by the angles before the delta... // (???) Vector3f up = Vector3f.AxisY; Vector3f right = cam.Right(); scene.RootGameObject.RotateAroundD(rotTarget, right, -turntableAltitudeD); scene.RootGameObject.RotateAroundD(rotTarget, up, -turntableAzimuthD); if (bSet) { turntableAzimuthD = deltaAzimuth; turntableAltitudeD = deltaAltitude; } else { turntableAzimuthD -= deltaAzimuth; turntableAltitudeD += deltaAltitude; } turntableAzimuthD = (float)MathUtil.ClampAngleDeg(Convert.ToDouble(turntableAzimuthD), -360d, 360d); turntableAltitudeD = Mathf.Clamp(turntableAltitudeD, -89.9f, 89.9f); scene.RootGameObject.RotateAroundD(rotTarget, up, turntableAzimuthD); scene.RootGameObject.RotateAroundD(rotTarget, right, turntableAltitudeD); }
public void ResetSceneOrbit(FScene scene, bool bAzimuth, bool bAltitude, bool bApply = true) { Vector3f up = Vector3f.AxisY; Vector3f right = Camera.Right(); Vector3f rotTarget = Camera.GetTarget(); if (bApply) { scene.RootGameObject.RotateAroundD(rotTarget, right, -turntableAltitudeD); scene.RootGameObject.RotateAroundD(rotTarget, up, -turntableAzimuthD); } if (bAzimuth == true) { turntableAzimuthD = 0.0f; } if (bAltitude == true) { turntableAltitudeD = 0.0f; } if (bApply) { scene.RootGameObject.RotateAroundD(rotTarget, up, turntableAzimuthD); scene.RootGameObject.RotateAroundD(rotTarget, right, turntableAltitudeD); } }
public void SceneTumble(FScene scene, fCamera cam, float dx, float dy) { Vector3f up = cam.Up(); Vector3f right = cam.Right(); //Vector3 curOrigin = scene.RootGameObject.transform.position; Vector3f curOrigin = cam.GetTarget(); scene.RootGameObject.RotateAroundD(curOrigin, up, dx); scene.RootGameObject.RotateAroundD(curOrigin, right, dy); }