Update() public method

public Update ( float _dt ) : void
_dt float
return void
コード例 #1
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            m_spriteBatch = new SpriteBatch(GraphicsDevice);

            m_camera = new OrbitCamera(this);
            m_camera.Update(0);

            m_World = Matrix.Identity;

            CurPrimitive = null;
        }
コード例 #2
0
ファイル: Game1.cs プロジェクト: LoveDuckie/MGShaderEditor
    /// <summary>
    /// LoadContent will be called once per game and is the place to load
    /// all of your content.
    /// </summary>
    protected override void LoadContent()
    {
      // Create a new SpriteBatch, which can be used to draw textures.
      m_spriteBatch = new SpriteBatch(GraphicsDevice);

      m_camera = new OrbitCamera(this);
      m_camera.Update(0);

      m_World = Matrix.Identity;

      CurPrimitive = null;


    }
コード例 #3
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            //Inputs
            var ms = Mouse.GetState();
            var ks = Keyboard.GetState();

            //Control Mouse pos under Game Window
            bool bUnderWindows = false;

            if (Window.ClientBounds.Contains(ms.Position))
            {
                bUnderWindows = true;
            }

            //Process mouse events
            if (bUnderWindows)
            {
                //LMouse Down
                if (ms.LeftButton == ButtonState.Pressed && m_prevMouseState.LeftButton == ButtonState.Released)
                {
                    m_nStartDragX = ms.X;
                    m_nStartDragY = ms.Y;

                    if (ks.IsKeyDown(Keys.LeftControl) == true)
                    {
                        m_bZoomingCamera = true;
                    }
                    else
                    {
                        m_bDraggingCamera = true;
                    }
                }

                //LMouse Up
                if (ms.LeftButton == ButtonState.Released && m_prevMouseState.LeftButton == ButtonState.Pressed)
                {
                    m_bDraggingCamera = false;
                    m_bZoomingCamera  = false;
                }

                //Mouse Move and camera dragging
                if (m_bDraggingCamera == true)
                {
                    float turnSpeed = 8f;

                    float offsetX = ((ms.X - m_nStartDragX) * turnSpeed * 0.001f); // pitch degree
                    float offsetY = ((ms.Y - m_nStartDragY) * turnSpeed * 0.001f); // yaw degree

                    var a = m_camera.AngleRad;
                    a.X -= offsetY;
                    a.Y -= offsetX;

                    a.Y = MathHelper.Clamp(a.Y, 0, MathHelper.Pi * 2);
                    a.X = MathHelper.Clamp(a.X, -(MathHelper.PiOver2 - 0.1f), (MathHelper.PiOver2 - 0.1f));

                    m_camera.AngleRad = a;

                    m_nStartDragX = ms.X;
                    m_nStartDragY = ms.Y;
                }

                //Mouse Move and camera zooming
                if (m_bZoomingCamera == true)
                {
                    float speed   = 8f;
                    float offsetY = ((ms.Y - m_nStartDragY) * speed * 0.001f);

                    m_camera.TargetDistance += offsetY;
                    m_camera.TargetDistance  = MathHelper.Clamp(m_camera.TargetDistance, 1.0f, 10);

                    m_nStartDragY = ms.Y;
                }

                //Mouse Wheel
                var wheelDelta = m_prevMouseState.ScrollWheelValue - ms.ScrollWheelValue;
                if (wheelDelta != 0)
                {
                    m_camera.TargetDistance += (wheelDelta / 100.0f);
                    m_camera.TargetDistance  = MathHelper.Clamp(m_camera.TargetDistance, 1.0f, 10);
                }

                m_prevMouseState = ms;
            }

            //Update Camera Matrices
            m_camera.Update(0);

            //Update Model World Matrice
            if (m_bDraggingCamera == false)
            {
                m_fmodelRotation += (float)gameTime.ElapsedGameTime.TotalMilliseconds / 1000.0f;
            }

            m_World = Matrix.CreateRotationX(m_fmodelRotation) * Matrix.CreateRotationY(m_fmodelRotation) * Matrix.CreateRotationZ(m_fmodelRotation);


            base.Update(gameTime);
        }