Ejemplo n.º 1
0
        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);
        }