예제 #1
0
 /// <summary>
 /// Called at the end of a rendering frame.
 /// </summary>
 /// <param name="timesincelastframe"></param>
 /// <param name="timesincelastevent"></param>
 /// <returns></returns>
 protected virtual bool FrameEnded(FrameEvent e)
 {
     return(true);
 }
예제 #2
0
        /// <summary>
        /// Called at the start of a rendering frame.
        /// </summary>
        /// <param name="timesincelastframe"></param>
        /// <param name="timesincelastevent"></param>
        /// <returns></returns>
        protected virtual bool FrameStarted(FrameEvent e)
        {
            if (mRenderWindow.Closed || mDone)
            {
                return(false);
            }

            mDeltaTime = e.TimeSinceLastFrame;

            UpdateDebugOverlay();


            if ((mRoll & 1) > 0)
            {
                mCamera.Roll(new Radian(mRotateScale * 1.0f * e.TimeSinceLastFrame));
            }
            if ((mRoll & 2) > 0)
            {
                mCamera.Roll(new Radian(mRotateScale * -1.0f * e.TimeSinceLastFrame));
            }
            if ((mPitch & 1) > 0)
            {
                mCamera.Pitch(new Radian(mRotateScale * 1.0f * e.TimeSinceLastFrame));
            }
            if ((mPitch & 2) > 0)
            {
                mCamera.Pitch(new Radian(mRotateScale * -1.0f * e.TimeSinceLastFrame));
            }
            if ((mYaw & 1) > 0)
            {
                mCamera.Yaw(new Radian(mRotateScale * 1.0f * e.TimeSinceLastFrame));
            }
            if ((mYaw & 2) > 0)
            {
                mCamera.Yaw(new Radian(mRotateScale * -1.0f * e.TimeSinceLastFrame));
            }

            if (mMoveCam > 0)
            {//mMoveCam bits: 1=forward, 2=backward, 4=left, 8=right, 16=up, 32=down
                Vector3 vCamMove = Vector3.Zero;
                float   mvscale  = mMoveScale * e.TimeSinceLastFrame;

                if ((mMoveCam & 1) > 0)
                {
                    vCamMove += Vector3.NegativeUnitZ;
                }
                if ((mMoveCam & 2) > 0)
                {
                    vCamMove += Vector3.UnitZ;
                }
                if ((mMoveCam & 4) > 0)
                {
                    vCamMove += Vector3.NegativeUnitX;
                }
                if ((mMoveCam & 8) > 0)
                {
                    vCamMove += Vector3.UnitX;
                }
                if ((mMoveCam & 16) > 0)
                {
                    vCamMove += Vector3.UnitY;
                }
                if ((mMoveCam & 32) > 0)
                {
                    vCamMove += Vector3.NegativeUnitY;
                }

                vCamMove *= mvscale;
                mCamera.MoveRelative(vCamMove);
            }

            return(true);
        }