コード例 #1
0
 /// <summary>
 /// 次のシーンフレームに進みます。
 /// </summary>
 public void Update()
 {
     if (camera.NeedUpdate)
     {
         camera.Update();
         Transform_View = camera.ViewMatrix;
     }
     if (motion_enabled)
     {
         int frame_len = figures.GetMaxFrameLength();
         if (frame_len > 0)
         {
             long dt = DateTime.Now.Ticks - start_ticks;
             int  new_frame_index = (int)((start_frame_index + dt / wait) % frame_len);
             Debug.Assert(new_frame_index >= 0);
             Debug.Assert(new_frame_index < frame_len);
             frame_index = new_frame_index;
         }
         figures.SetFrameIndex(frame_index);
         figures.UpdateBoneMatrices(true);
     }
 }
コード例 #2
0
        /// <summary>
        /// 次のシーンフレームに進みます。
        /// </summary>
        public void FrameMove()
        {
            if (motion_enabled)
            {
                int frame_len = figures.GetMaxFrameLength();
                if (frame_len > 0)
                {
                    long dt = DateTime.Now.Ticks - start_ticks;
                    int  new_frame_index = (int)((start_frame_index + dt / wait) % frame_len);
                    Debug.Assert(new_frame_index >= 0);
                    Debug.Assert(new_frame_index < frame_len);
                    this.frame_index = new_frame_index;
                }
                figures.SetFrameIndex(this.frame_index);
                figures.UpdateBoneMatrices(true);
            }

            KeyboardState currentKeyboardState = keyboard.GetCurrentState();

            if (!keyboardState.IsPressed(Key.LeftControl) && currentKeyboardState.IsPressed(Key.LeftControl))
            {
                sneaked = !sneaked;
            }
            if (!keyboardState.IsPressed(Key.RightControl) && currentKeyboardState.IsPressed(Key.RightControl))
            {
                sneaked = !sneaked;
            }

            if (currentKeyboardState.IsPressed(Key.Left))
            {
                main_camera.RotY(+ocu_config.Angle);
            }
            if (currentKeyboardState.IsPressed(Key.Right))
            {
                main_camera.RotY(-ocu_config.Angle);
            }

            {
                float speed = sneaked ? ocu_config.Sneak.Speed : ocu_config.Speed;

                if (currentKeyboardState.IsPressed(Key.W))
                {
                    main_camera.Move(0, 0, -speed);
                }
                if (currentKeyboardState.IsPressed(Key.S))
                {
                    main_camera.Move(0, 0, +speed);
                }
                if (currentKeyboardState.IsPressed(Key.A))
                {
                    main_camera.Move(-speed, 0, 0);
                }
                if (currentKeyboardState.IsPressed(Key.D))
                {
                    main_camera.Move(+speed, 0, 0);
                }
            }

            {
                float y = sneaked ? ocu_config.Sneak.Y : ocu_config.Position.Y;

                main_camera.Position.Y = hmd.GetFloat(OculusWrap.OVR.OVR_KEY_EYE_HEIGHT, 0) + y;
            }

            keyboardState = currentKeyboardState;
        }