Example #1
0
        /// <summary>
        /// sets to current camera.
        /// </summary>
        /// <param name="key">key name</param>
        public bool SetCurrentCamera(string key)
        {
            //  Set a current camera
            currentViewCamera = GetViewCamera(key);

            if (currentViewCamera == null)
            {
                return(false);
            }

            return(true);
        }
Example #2
0
        /// <summary>
        /// update cameras.
        /// </summary>
        public void Update(GameTime gameTime)
        {
            // Update the current camera
            ViewCamera viewCamera = CurrentCamera;

            for (int i = 0; i < viewCamera.Count; i++)
            {
                CameraBase camera = viewCamera.GetCamera(i);
                camera.Update(gameTime);
            }

            // Update scene models in the render context
            renderContext.Update(gameTime);
        }
Example #3
0
        /// <summary>
        /// initialize members and creates default camera.
        /// </summary>
        public void Initialize()
        {
            //  initialize the RenderContext
            renderContext.Initialize();

            this.defaultViewport = FrameworkCore.Game.GraphicsDevice.Viewport;

            // creates default camera
            {
                defaultViewCamera = new ViewCamera(new CameraBase(), null);

                //  default camera setting
                defaultViewCamera.FirstCamera.SetView(Vector3.Zero, Vector3.Forward,
                                                      Vector3.Up);

                defaultViewCamera.FirstCamera.SetPespective(MathHelper.PiOver4,
                                                            (float)ViewWidth,
                                                            (float)ViewHeight, 1.0f, 1000.0f);

                currentViewCamera = defaultViewCamera;
            }
        }
Example #4
0
        /// <summary>
        /// creates a third person view camera which follows the player.
        /// </summary>
        public void InitCamera()
        {
            //  Follow Camera
            FollowCamera followCamera = new FollowCamera();

            followCamera.SetPespective(MathHelper.ToRadians(this.GameLevel.Info.FOV),
                                (float)GraphicsDevice.Viewport.Width,
                                (float)GraphicsDevice.Viewport.Height,
                                1.0f, 10000.0f);

            // Follow camera offset position setting
            followCamera.TargetOffset = 
                            GameLevel.SinglePlayer.SpecData.CameraTargetOffset;

            followCamera.PositionOffset = 
                            GameLevel.SinglePlayer.SpecData.CameraPositionOffset;

            ViewCamera followViewCamera = new ViewCamera(followCamera, 
                new Rectangle(0, 0, FrameworkCore.ViewWidth, FrameworkCore.ViewHeight));

            Viewer.AddCamera("Follow", followViewCamera);

            Viewer.SetCurrentCamera("Follow");
        }
Example #5
0
        /// <summary>
        /// sets to current camera.
        /// </summary>
        /// <param name="key">key name</param>
        public bool SetCurrentCamera(string key)
        {
            //  Set a current camera
            currentViewCamera = GetViewCamera(key);

            if (currentViewCamera == null)
                return false;

            return true;
        }
Example #6
0
 /// <summary>
 /// adds a camera.
 /// </summary>
 /// <param name="key">key name</param>
 /// <param name="viewCamera">view camera</param>
 public void AddCamera(string key, ViewCamera viewCamera)
 {
     //  New camera add
     viewCamera.FirstCamera.Name = key;
     viewCameraList.Add(key, viewCamera);
 }
Example #7
0
        /// <summary>
        /// initialize members and creates default camera.
        /// </summary>
        public void Initialize()
        {
            //  initialize the RenderContext
            renderContext.Initialize();

            this.defaultViewport = FrameworkCore.Game.GraphicsDevice.Viewport;

            // creates default camera
            {
                defaultViewCamera = new ViewCamera(new CameraBase(), null);

                //  default camera setting
                defaultViewCamera.FirstCamera.SetView(Vector3.Zero, Vector3.Forward, 
                    Vector3.Up);

                defaultViewCamera.FirstCamera.SetPespective(MathHelper.PiOver4,
                                            (float)ViewWidth,
                                            (float)ViewHeight, 1.0f, 1000.0f);

                currentViewCamera = defaultViewCamera;
            }
        }
Example #8
0
 /// <summary>
 /// adds a camera.
 /// </summary>
 /// <param name="key">key name</param>
 /// <param name="viewCamera">view camera</param>
 public void AddCamera(string key, ViewCamera viewCamera)
 {
     //  New camera add
     viewCamera.FirstCamera.Name = key;
     viewCameraList.Add(key, viewCamera);
 }
Example #9
0
        /// <summary>
        /// initializes this screen. 
        /// </summary>
        public override void InitializeScreen()
        {
            this.refScene3DRoot.RemoveAllChild(true);

            this.refScene3DRoot.AddChild(this.GameLevel.SceneWorldRoot);
            this.refScene3DRoot.AddChild(this.GameLevel.SceneMechRoot);
            this.refScene3DRoot.AddChild(this.GameLevel.SceneParticleRoot);
            this.refScene3DRoot.AddChild(this.GameLevel.SceneCollisionRoot);

            RobotGameGame.CurrentStage = this;

            //  Free Camera
            FreeCamera freeCamera = new FreeCamera();

            freeCamera.SetView(new Vector3(0.0f, 0.0f, 10.0f),
                                Vector3.Forward, Vector3.Up);

            freeCamera.SetPespective(MathHelper.PiOver4,
                                (float)Viewer.ViewWidth,
                                (float)Viewer.ViewHeight,
                                1.0f, 10000.0f);

            ViewCamera freeViewCamera = new ViewCamera(freeCamera, null);
            Viewer.AddCamera("Free", freeViewCamera);

            //  PostScreen effect
            {
                paramCenterX = boosterEffect.Parameters["xCenter"];
                paramCenterY = boosterEffect.Parameters["yCenter"];
                paramTexWidth = boosterEffect.Parameters["texWidth"];
                paramTexHeight = boosterEffect.Parameters["texHeight"];
                paramWaveWidth = boosterEffect.Parameters["width"];
                paramWaveMag = boosterEffect.Parameters["mag"];

                paramBloomThreshold = postScreenEffect.Parameters["BloomThreshold"];
                paramBloomIntensity = postScreenEffect.Parameters["BloomIntensity"];
                paramBloomSaturation = postScreenEffect.Parameters["BloomSaturation"];
                paramBaseIntensity = postScreenEffect.Parameters["BaseIntensity"];
                paramBaseSaturation = postScreenEffect.Parameters["BaseSaturation"];

                //  Entry the post screen processing function
                FrameworkCore.RenderContext.RenderingPostDraw3D += OnPostDraw3DScreen;
            }

            //  Tracer bullets
            {
                tracerBulletManager = new TracerBulletManager();
                tracerBulletManager.AddBulletInstance(0, 32,
                    "Particles/Spark_Horizontal01",
                    RobotGameGame.CurrentGameLevel.SceneParticleRoot);
            }

            this.refScene3DRoot.Initialize();

            //  Create 2D Scene layer for Hud
            this.refRenderContext.CreateScene2DLayer(2);
            this.refSceneHudRoot = FrameworkCore.Scene2DLayers[0];
            this.refSceneMissionRoot = FrameworkCore.Scene2DLayers[1];

#if DEBUG
            Vector2 pos = new Vector2(0, 20);
            pos = FrameworkCore.ClampSafeArea(pos);

            camPosition = FrameworkCore.TextManager.AddText(FrameworkCore.DebugFont,
                    "CAM :", (int)pos.X, (int)pos.Y, Color.White);

            camPosition.Visible = true;
#endif

            FrameworkCore.GameEventManager.Enable = true;
        }
Example #10
0
        /// <summary>
        /// draws every scene node which is attached to the scene node.
        /// Draws in order of 3D scene node, 2D scene node, and overlay text.
        /// When there are more than one view cameras that have registered
        /// to the 3D scene, Viewport is applied to the 3D scene node,
        /// which is drawn as many as the number of the view camera.
        /// When render event handler has been registered, it is called
        /// before or after drawing.
        /// </summary>
        public override void Draw(GameTime gameTime)
        {
            //  Set to render information
            renderTracer.Device      = FrameworkCore.Game.GraphicsDevice;
            renderTracer.GameTime    = gameTime;
            renderTracer.SpriteBatch = SpriteBatch;
            renderTracer.Fog         = FrameworkCore.Viewer.BasicFog;
            renderTracer.Lighting    = FrameworkCore.Viewer.BasicLighting;

            ClearBackBuffer();

            if (RenderingPreDrawScene != null)
            {
                RenderingPreDrawScene(this, EventArgs.Empty);
            }

            //  3D Render
            {
                if (RenderingPreDraw3D != null)
                {
                    RenderingPreDraw3D(this, EventArgs.Empty);
                }

                //  process multiple camera
                for (int i = 0; i < FrameworkCore.CurrentCamera.Count; i++)
                {
                    ViewCamera viewCamera = FrameworkCore.Viewer.CurrentCamera;
                    CameraBase camera     = viewCamera.GetCamera(i);

                    renderTracer.View       = camera.ViewMatrix;
                    renderTracer.ViewInvert = Matrix.Invert(camera.ViewMatrix);
                    renderTracer.Projection = camera.ProjectionMatrix;

                    // Update frustum
                    UpdateFrustum(camera.ViewMatrix, camera.ProjectionMatrix);
                    renderTracer.Frustum = this.Frustum;

                    //  Set to each viewport
                    ApplyViewport(viewCamera.GetViewport(i));

                    //  Render the 3D scene
                    Draw3D(renderTracer);
                }

                //  restore to default viewport
                ApplyViewport(FrameworkCore.DefaultViewport);

                if (RenderingPostDraw3D != null)
                {
                    RenderingPostDraw3D(this, EventArgs.Empty);
                }
            }

            //  2D Render
            {
                if (RenderingPreDraw2D != null)
                {
                    RenderingPreDraw2D(this, EventArgs.Empty);
                }

                //  Render the 2D scene
                Draw2D(renderTracer);

                if (RenderingPostDraw2D != null)
                {
                    RenderingPostDraw2D(this, EventArgs.Empty);
                }
            }

            if (RenderingPostDrawScene != null)
            {
                RenderingPostDrawScene(this, EventArgs.Empty);
            }

            // Display overlaped texts or others
            DrawOverlayText(gameTime);

            // Draw other components
            base.Draw(gameTime);
        }