コード例 #1
0
        /// <summary>
        /// This callback function will be called once at the beginning of every frame. This is the
        /// best location for your application to handle updates to the scene, but is not
        /// intended to contain actual rendering calls, which should instead be placed in the
        /// OnFrameRender callback.
        /// </summary>
        public void OnFrameMove(Device device, double appTime, float elapsedTime)
        {
            // Update the camera's position based on user input
            camera.FrameMove(elapsedTime);

            // Set device transforms
            device.Transform.World = camera.WorldMatrix;
            device.Transform.View  = camera.ViewMatrix;
        }
コード例 #2
0
        /// <summary>
        /// This callback function will be called once at the beginning of every frame. This is the
        /// best location for your application to handle updates to the scene, but is not
        /// intended to contain actual rendering calls, which should instead be placed in the
        /// OnFrameRender callback.
        /// </summary>
        public void OnFrameMove(Device device, double appTime, float elapsedTime)
        {
            // Update the camera's position based on user input
            camera.FrameMove(elapsedTime);

            Matrix m = Matrix.RotationY((float)Math.PI * elapsedTime / 40.0f);

            viewMatrix = m * viewMatrix;
        }
コード例 #3
0
        /// <summary>
        /// This callback function will be called once at the beginning of every frame. This is the
        /// best location for your application to handle updates to the scene, but is not
        /// intended to contain actual rendering calls, which should instead be placed in the
        /// OnFrameRender callback.
        /// </summary>
        public void OnFrameMove(Device device, double appTime, float elapsedTime)
        {
            // Update the camera's position based on user input
            camera.FrameMove(elapsedTime);

            // Get the world matrix
            Matrix worldMatrix = worldCenter * camera.WorldMatrix;

            // Update the effect's variables
            effect.SetValue(worldViewHandle, worldMatrix * camera.ViewMatrix * camera.ProjectionMatrix);
            effect.SetValue(worldHandle, worldMatrix);
            effect.SetValue(timeHandle, (float)appTime);
        }
コード例 #4
0
        /// <summary>
        /// This callback function will be called once at the beginning of every frame. This is the
        /// best location for your application to handle updates to the scene, but is not
        /// intended to contain actual rendering calls, which should instead be placed in the
        /// OnFrameRender callback.
        /// </summary>
        public void OnFrameMove(Device device, double appTime, float elapsedTime)
        {
            // Update the camera's position based on user input
            camera.FrameMove(elapsedTime);

            // Setup vertex shader constants
            Matrix worldViewProj, world, view, proj;

            world         = camera.WorldMatrix;
            view          = camera.ViewMatrix;
            proj          = camera.ProjectionMatrix;
            worldViewProj = world * view * proj;

            constantTable.SetValue(device, worldViewHandle, worldViewProj);
            constantTable.SetValue(device, timeHandle, (float)appTime);
        }
コード例 #5
0
ファイル: Simple2D.cs プロジェクト: d3x0r/xperdex
        /// <summary>
        /// This callback function will be called once at the beginning of every frame. This is the
        /// best location for your application to handle updates to the scene, but is not
        /// intended to contain actual rendering calls, which should instead be placed in the
        /// OnFrameRender callback.
        /// </summary>
        public void OnFrameMove(Device device, double appTime, float elapsedTime)
        {
            // Update the camera's position based on user input
            camera.FrameMove(elapsedTime);



            if (movingSpriteEnabled)
            {
                movingSprite.Move(elapsedTime);
            }

            //This technique is called "throttling" and limits events  to a
            //specific framerate.  This technique works well for "whole number" advancement
            //such as advancing a frame of animation.
            timeToAdvance -= elapsedTime;
            if (timeToAdvance < 0)
            {
                //The Particle effect was far more efficient using an integer
                //implementation, so we are using throttled rendering
                if (canvasEnabled)
                {
                    if (particleIsUsingUnsafeMethods)
                    {
                        effect.UpdateUnsafe();
                    }
                    else
                    {
                        effect.Update();
                    }
                }


                if (animatedSpriteEnabled)
                {
                    animatedSprite.AdvanceFrame();
                }

                //throttling is simple, but can cause jittery animation and
                //perceived slowdown under certain conditions (such as low framerate)
                timeToAdvance += 1 / fps;
            }
        }
コード例 #6
0
 /// <summary>
 /// This callback function will be called once at the beginning of every frame. This is the
 /// best location for your application to handle updates to the scene, but is not
 /// intended to contain actual rendering calls, which should instead be placed in the
 /// OnFrameRender callback.
 /// </summary>
 public void OnFrameMove(Device device, double appTime, float elapsedTime)
 {
     // Update the camera's position based on user input
     camera.FrameMove(elapsedTime);
 }