Пример #1
0
 protected abstract void OnGetCameraTransform(out Vec3 position, out Vec3 forward, out Vec3 up,
                                              ref Degree cameraFov);
Пример #2
0
        protected override void OnGetCameraTransform(out Vec3 position, out Vec3 forward, out Vec3 up, ref Degree cameraFov)
        {
            //To use data about orientation the camera if the cut scene is switched on
            if (IsCutSceneEnabled())
            {
                if (CutSceneManager.Instance.GetCamera(out position, out forward, out up, out cameraFov))
                {
                    return;
                }
            }

            Vec3 offset;
            {
                Quat rot = new Angles(0, 0, MathFunctions.RadToDeg(cameraDirection.Horizontal)).ToQuat();
                rot    *= new Angles(0, MathFunctions.RadToDeg(cameraDirection.Vertical), 0).ToQuat();
                offset  = rot * new Vec3(1, 0, 0);
                offset *= cameraDistance;
            }

            Vec3 lookAt = new Vec3(cameraPosition.X, cameraPosition.Y, 0);

            forward   = -offset;
            position  = lookAt + offset;
            up        = new Vec3(0, 0, 1);
            cameraFov = 80f;
        }
Пример #3
0
        protected override void OnRender()
        {
            base.OnRender();

            //update camera orientation
            {
                Vec3   position, forward, up;
                Degree cameraFov = (fov != 0) ? fov : Map.Instance.Fov;

                if (!FreeCameraEnabled)
                {
                    OnGetCameraTransform(out position, out forward, out up, ref cameraFov);
                }
                else
                {
                    position = freeCameraPosition;
                    forward  = freeCameraDirection.GetVector();
                    up       = Vec3.ZAxis;
                }

                if (cameraFov == 0)
                {
                    cameraFov = (fov != 0) ? fov : Map.Instance.Fov;
                }

                Camera camera = RendererWorld.Instance.DefaultCamera;
                camera.NearClipDistance = Map.Instance.NearFarClipDistance.Minimum;
                camera.FarClipDistance  = Map.Instance.NearFarClipDistance.Maximum;

                camera.FixedUp   = up;
                camera.Fov       = cameraFov;
                camera.Position  = position;
                camera.Direction = forward;
            }

            //update game specific options
            {
                //water reflection level
                foreach (WaterPlane waterPlane in WaterPlane.Instances)
                {
                    waterPlane.ReflectionLevel = GameEngineApp.WaterReflectionLevel;
                }

                //decorative objects
                if (DecorativeObjectManager.Instance != null)
                {
                    DecorativeObjectManager.Instance.Visible = GameEngineApp.ShowDecorativeObjects;
                }

                //HeightmapTerrain
                //enable simple rendering for Low material scheme.
                foreach (HeightmapTerrain terrain in HeightmapTerrain.Instances)
                {
                    terrain.SimpleRendering = GameEngineApp.MaterialScheme == MaterialSchemes.Low;
                }
            }

            //update sound listener
            if (SoundWorld.Instance != null)
            {
                Vec3 position, velocity, forward, up;
                OnGetSoundListenerTransform(out position, out velocity, out forward, out up);
                SoundWorld.Instance.SetListener(position, velocity, forward, up);
            }
        }