コード例 #1
0
ファイル: Kinect.cs プロジェクト: adambatson/gbtis
        private Kinect()
        {
            sensor = KinectSensor.GetDefault();
            sensor.Open();

            // Prepare sensor feed
            frameReader = sensor.OpenMultiSourceFrameReader(FrameSourceTypes.Color | FrameSourceTypes.Depth);
            frameReader.MultiSourceFrameArrived += frameReader_frameArrived;

            numBodies      = this.sensor.BodyFrameSource.BodyCount;
            gestureSources = new VisualGestureBuilderFrameSource[numBodies];
            gestureReaders = new VisualGestureBuilderFrameReader[numBodies];
            OpenBodyReader();
            OpenGestureReader();
            bodies = new Body[numBodies];

            //Coordinate Mapping
            coordinateMapper = sensor.CoordinateMapper;

            sensor.IsAvailableChanged += OnIsAvailableChanged;
            smoother = new Smoother();

            setHand(true);
            NextMode      = CursorModes.Idle;
            ModeFrameSkip = 0;
        }
コード例 #2
0
 void Start()
 {
     poopHealth                  = startingPoopHealth;
     cursor                      = WorldMethods.GetCursor();
     startScale                  = transform.localScale;
     politicsManager             = WorldMethods.GetPoliticsManager();
     politicsManager.numOfPoops += 1;
 }
コード例 #3
0
 void Start()
 {
     gameController  = WorldMethods.GetGameController();
     characterSpeech = gameObject.GetComponent <CharacterSpeech>();
     cursor          = WorldMethods.GetCursor();
     politicsManager = WorldMethods.GetPoliticsManager();
     rb = gameObject.GetComponent <Rigidbody>();
     interactionSounds = GameObject.Find("Main Camera").GetComponent <InteractionSounds>();
 }
コード例 #4
0
        /// <summary>
        /// Cursor released
        /// </summary>
        /// <param name="cursor">Position</param>
        /// <param name="mode">State</param>
        private void cursorUp(CursorModes m)
        {
            // Revert to standby cursor
            if (cursor.Mode == CursorModes.Idle)
            {
                canvas.EditingMode = InkCanvasEditingMode.Select;
            }

            // Recognize input and clear set of points
            Dispatcher.Invoke(new Action(() => recognize()));
            stylusPoints = null;
        }
コード例 #5
0
ファイル: Cursor.xaml.cs プロジェクト: adambatson/gbtis
        public Cursor()
        {
            InitializeComponent();
            toggleIdle(true);
            Kinect kinect = Kinect.getInstance();

            parentBounds = new Size(0, 0);

            Loaded += (source, args) => {
                parentWindow = Window.GetWindow(this);

                // Kinect controls
                kinect.FingerPositionChanged += (p) => {
                    Position = kinect.ColorToInterface(p, parentBounds);
                    Mode     = kinect.CursorMode;
                };
                kinect.ModeStart += (m) => {
                    Position = kinect.ColorToInterface(kinect.FingerPosition, parentBounds);
                    Mode     = m;

                    ModeStart?.Invoke(m);
                };
                kinect.ModeEnd += (m) => {
                    Position = kinect.ColorToInterface(kinect.FingerPosition, parentBounds);
                    Mode     = m;

                    ModeEnd?.Invoke(m);
                };

                /* Mouse controls
                 * parentWindow.MouseMove += (s, e) => {
                 *  Position = Mouse.GetPosition(parentWindow);
                 *  Mode = mouseMode();
                 *
                 *  Moved?.Invoke(Position);
                 * };
                 * parentWindow.PreviewMouseDown += (s, e) => {
                 *  Position = Mouse.GetPosition(parentWindow);
                 *  Mode = mouseMode();
                 *
                 *  ModeStart?.Invoke(Mode);
                 * };
                 * parentWindow.PreviewMouseUp += (s, e) => {
                 *  Position = Mouse.GetPosition(parentWindow);
                 *  Mode = mouseMode();
                 *
                 *  ModeEnd?.Invoke(Mode);
                 * }; */
            };
        }
コード例 #6
0
ファイル: PlayerCursor.cs プロジェクト: Smcmax/RealityBleed
    private void SetCursorState(CursorModes p_mode)
    {
        Cursor.visible = !m_hideHardwarePointer;

        if (p_mode == CursorModes.LINE && m_usingController)
        {
            Cursor.lockState = CursorLockMode.Locked;
        }
        else
        {
            Cursor.lockState = CursorLockMode.Confined;

                        #if UNITY_EDITOR
            Cursor.lockState = CursorLockMode.None;
                        #endif
        }
    }
コード例 #7
0
	public void ChangeModes(CursorModes p_mode) {
		m_mode = p_mode;
		m_image.type = Image.Type.Simple;

		if(p_mode == CursorModes.LINE) {
			GetComponent<RectTransform>().sizeDelta = new Vector2(8, 640);

			m_image.sprite = m_lineSprite;
			m_image.preserveAspect = true;
			m_image.color = new Color(1, 1, 1, 0.5f);
		} else {
			transform.rotation = Quaternion.Euler(0, 0, 0);
			GetComponent<RectTransform>().sizeDelta = new Vector2(100, 100);
			m_image.sprite = m_cursorSprite;
			m_image.preserveAspect = false;
			m_image.color = new Color(1, 1, 1, 1);
		}
	}
コード例 #8
0
ファイル: Cursor.xaml.cs プロジェクト: adambatson/gbtis
        /// <summary>
        /// Change the cursor display mode
        /// </summary>
        /// <param name="mode">Cursor mode to use</param>
        private void setMode(CursorModes mode)
        {
            switch (mode)
            {
            case CursorModes.Idle:
                toggleIdle(true);
                toggleErase(false);
                break;

            case CursorModes.Draw:
                toggleErase(false);
                toggleIdle(false);
                break;

            case CursorModes.Erase:
                toggleErase(true);
                toggleIdle(false);
                break;
            }
        }
コード例 #9
0
        /// <summary>
        /// Cursor pressed
        /// </summary>
        /// <param name="cursor">Position</param>
        /// <param name="mode">State</param>
        private void cursorDown(CursorModes m)
        {
            // Start input capture
            if (stylusPoints == null)
            {
                stylusPoints = new StylusPointCollection();
            }

            // Add current point
            stylusPoints.Add(toStylusPoint(relativeTransform(cursor.Position)));

            // Draw points if need be
            if (cursor.Mode == CursorModes.Draw)
            {
                draw();
            }
            if (cursor.Mode == CursorModes.Erase)
            {
                erase();
            }
        }
コード例 #10
0
ファイル: PlayerCursor.cs プロジェクト: Smcmax/RealityBleed
    public void ChangeMode(CursorModes p_mode, bool p_force)
    {
        if (!p_force && p_mode == m_currentMode)
        {
            return;
        }

        string axisUsed = "Aim";

        if (p_mode == CursorModes.CURSOR)
        {
            axisUsed = "UI" + axisUsed;
        }

        m_mouse.xAxis.actionName = axisUsed + "X";
        m_mouse.yAxis.actionName = axisUsed + "Y";

        m_currentMode = p_mode;

        // ui cursor doesn't know the real cursor mode, only player cursor does
        if (p_mode == CursorModes.LINE)
        {
            if (m_usingController)
            {
                m_uiCursor.ChangeModes(p_mode);
                m_mouse.screenPosition = new Vector2(Screen.width / 2, Screen.height / 2 + 1);
            }
        }
        else
        {
            m_uiCursor.ChangeModes(p_mode);
        }

        SetCursorState(p_mode);
        OnScreenPositionChanged(m_mouse.screenPosition);
    }
コード例 #11
0
 private void resetTimeoutTimer(CursorModes mode)
 {
     timeoutTimer.Stop();
     timeoutTimerInit();
 }
コード例 #12
0
ファイル: WorldMethods.cs プロジェクト: PetterV/Tamagotcha
    public static CursorModes GetCursor()
    {
        CursorModes cursor = GameObject.Find("CursorManager").GetComponent <CursorModes>();

        return(cursor);
    }
コード例 #13
0
ファイル: Kinect.cs プロジェクト: adambatson/gbtis
        /// <summary>
        /// Generates an ImageSource based on the latest MultiSourceFrame
        /// and triggers a BitMapReady event
        /// </summary>
        /// <param name="sender">The Sender of the frame (Kinect.sensor)</param>
        /// <param name="e">The MultiSourceFrameEventArgs</param>
        private void frameReader_frameArrived(Object sender, MultiSourceFrameArrivedEventArgs e)
        {
            var reference = e.FrameReference.AcquireFrame();

            using (var frame = reference.ColorFrameReference.AcquireFrame()) {
                if (frame != null)
                {
                    BitMapReadyHandler handler = BitMapReady;
                    ImageSource        img     = ToBitmap(frame);
                    //Allow the image to be accessible outside this thread
                    img.Freeze();
                    Application.Current.Dispatcher.Invoke(new Action(() => handler?.Invoke(img)));
                }
            }

            if (activeBody != null && activeBody.IsTracked)
            {
                HandState handState = (rightHand) ? activeBody.HandRightState :
                                      activeBody.HandLeftState;

                var colorPoint = coordinateMapper.MapCameraPointToColorSpace(
                    activeBody.Joints[handTip].Position);

                Point point = smoother.Next(new System.Drawing.PointF(colorPoint.X, colorPoint.Y));
                if (!point.Equals(prevPoint))
                {
                    FingerPosition = point;
                    prevPoint      = point;
                    Application.Current.Dispatcher.Invoke(new Action(() => FingerPositionChanged?.Invoke(point)));
                }

                CursorModes mode;
                switch (handState)
                {
                case HandState.Lasso:
                    mode = CursorModes.Draw;
                    break;

                case HandState.Open:
                    mode = CursorModes.Erase;
                    break;

                case HandState.Closed:
                case HandState.NotTracked:
                    mode = CursorModes.Idle;
                    break;

                default:
                    return;
                }

                if (mode != CursorMode)
                {
                    if (mode == CursorModes.Idle)
                    {
                        //Compare the tip of the hand to the hand blob
                        //Attempt to see if a finger is extended
                        if (Math.Abs(activeBody.Joints[hand].Position.Z - activeBody.Joints[handTip].Position.Z) > 0.05)
                        {
                            mode = CursorModes.Draw;
                            return;
                        }
                    }

                    if (mode == NextMode)
                    {
                        if (++ModeFrameSkip == FRAME_SKIP_HAND_STATUS)
                        {
                            Application.Current.Dispatcher.Invoke(new Action(() => ModeEnd?.Invoke(CursorMode)));
                            Application.Current.Dispatcher.Invoke(new Action(() => ModeStart?.Invoke(mode)));
                            CursorMode    = mode;
                            ModeFrameSkip = 0;
                        }
                    }
                    else
                    {
                        NextMode = mode;
                    }
                }
            }
        }