コード例 #1
0
ファイル: MouseDragEvent.cs プロジェクト: zeta1999/Vrmac
        void iMouseMoveHandler.mouseMove(CPoint point, eMouseButtonsState bs)
        {
            if (!prevPoint.HasValue)
            {
                return;
            }
            if (!bs.HasFlag(buttonBit))
            {
                prevPoint = null;
                return;
            }

            // Detected the event
            int dx = point.x - prevPoint.Value.x;
            int dy = point.y - prevPoint.Value.y;

            prevPoint = point;
            if (dx == 0 && dy == 0)
            {
                return;
            }

            Vector2 delta = new Vector2(dx, dy);

            delta *= m_scaling;
            onDragDelta?.Invoke(delta);
        }
コード例 #2
0
ファイル: TeapotMotion.cs プロジェクト: zeta1999/Vrmac
        void iMouseMoveHandler.mouseMove(CPoint pos, eMouseButtonsState bs)
        {
            if (bs.HasFlag(eMouseButtonsState.Left) && prevMouse.HasValue)
            {
                float dx = pos.x - prevMouse.Value.x;
                float dy = pos.y - prevMouse.Value.y;
                prevMouse = pos;
                dx       /= content.swapChainSize.cx;
                dy       /= content.swapChainSize.cy;
                dx       *= mouseSpeedMul;
                dy       *= mouseSpeedMul;

                Quaternion q = Quaternion.CreateFromYawPitchRoll(0, -dy, -dx);
                rotation = Quaternion.Multiply(q, rotation);
                Dispatcher.currentDispatcher.nativeDispatcher.renderFrame(content.renderContext, true);
                mouseVelocity.add(pos, timeSource.messageTime);
            }
        }