Пример #1
0
 /**
  * <summary>
  * This constructor takes a TuioPoint argument and sets its coordinate attributes
  * to the coordinates of the provided TuioPoint and its time stamp to the current session time.</summary>
  *
  * <param name="tpoint">the TuioPoint to assign</param>
  */
 public TuioPoint(TuioPoint tpoint)
 {
     xpos        = tpoint.X;
     ypos        = tpoint.Y;
     currentTime = TuioTime.SessionTime;
     startTime   = new TuioTime(currentTime);
 }
Пример #2
0
        /**
         * Takes a TuioTime argument and assigns it along with the provided
         * X and Y coordinate to the private TuioContainer attributes.
         * The speed and accleration values are calculated accordingly.
         *
         * @param	ttime	the TuioTime to assign
         * @param	xp	the X coordinate to assign
         * @param	yp	the Y coordinate to assign
         */
        public new void update(TuioTime ttime, float xp, float yp)
        {
            TuioPoint lastPoint = path[path.Count - 1];

            base.update(ttime, xp, yp);

            TuioTime diffTime          = currentTime - lastPoint.getTuioTime();
            float    dt                = diffTime.getTotalMilliseconds() / 1000.0f;
            float    dx                = this.xpos - lastPoint.getX();
            float    dy                = this.ypos - lastPoint.getY();
            float    dist              = (float)Math.Sqrt(dx * dx + dy * dy);
            float    last_motion_speed = this.motion_speed;

            this.x_speed      = dx / dt;
            this.y_speed      = dy / dt;
            this.motion_speed = dist / dt;
            this.motion_accel = (motion_speed - last_motion_speed) / dt;

            path.Add(new TuioPoint(currentTime, xpos, ypos));
            if (motion_accel > 0)
            {
                state = TUIO_ACCELERATING;
            }
            else if (motion_accel < 0)
            {
                state = TUIO_DECELERATING;
            }
            else
            {
                state = TUIO_STOPPED;
            }
        }
Пример #3
0
        /**
         * <summary>
         * Takes a TuioTime argument and assigns it along with the provided
         * X and Y coordinate and angle to the private TuioBlob attributes.
         * The speed and accleration values are calculated accordingly.</summary>
         *
         * <param name="ttime">the TuioTime to assign</param>
         * <param name="xp">the X coordinate to assign</param>
         * <param name="yp">the Y coordinate to assign</param>
         * <param name="a">the angle coordinate to assign</param>
         * <param name="w">the width to assign</param>
         * <param name="h">the height to assign</param>
         * <param name="f">the area to assign</param>
         */
        public void update(TuioTime ttime, float xp, float yp, float a, float w, float h, float f)
        {
            TuioPoint lastPoint = path[path.Count - 1];

            base.update(ttime, xp, yp);

            width  = w;
            height = h;
            area   = f;

            TuioTime diffTime            = currentTime - lastPoint.TuioTime;
            float    dt                  = diffTime.TotalMilliseconds / 1000.0f;
            float    last_angle          = angle;
            float    last_rotation_speed = rotation_speed;

            angle = a;

            float da = (angle - last_angle) / (2.0f * (float)Math.PI);

            if (da > 0.75f)
            {
                da -= 1.0f;
            }
            else if (da < -0.75f)
            {
                da += 1.0f;
            }

            rotation_speed = da / dt;
            rotation_accel = (rotation_speed - last_rotation_speed) / dt;
            if ((rotation_accel != 0) && (state != TUIO_STOPPED))
            {
                state = TUIO_ROTATING;
            }
        }
Пример #4
0
        public float getAngle(TuioPoint tuioPoint)
        {
            float side = tuioPoint.getX()-xpos;
            float height = tuioPoint.getY()-ypos;
            float distance = tuioPoint.getDistance(xpos,ypos);

            float angle = (float)(Math.Asin(side/distance)+Math.PI/2);
            if (height<0) angle = 2.0f*(float)Math.PI-angle;

            return angle;
        }
Пример #5
0
        /**
         * <summary>
         * Takes a TuioTime argument and assigns it along with the provided
         * X and Y coordinate to the private TuioContainer attributes.
         * The speed and accleration values are calculated accordingly.</summary>
         * <param name="ttime">the TuioTime to assign</param>
         * <param name="xp">the X coordinate to assign</param>
         * <param name="yp">the Y coordinate to assign</param>
         */
        public new void update(TuioTime ttime, float xp, float yp)
        {
            TuioPoint lastPoint = path.Last.Value;

            base.update(ttime, xp, yp);

            TuioTime diffTime          = currentTime - lastPoint.TuioTime;
            float    dt                = diffTime.TotalMilliseconds / 1000.0f;
            float    dx                = this.xpos - lastPoint.X;
            float    dy                = this.ypos - lastPoint.Y;
            float    dist              = (float)Math.Sqrt(dx * dx + dy * dy);
            float    last_motion_speed = this.motion_speed;

            this.x_speed      = dx / dt;
            this.y_speed      = dy / dt;
            this.motion_speed = dist / dt;
            this.motion_accel = (motion_speed - last_motion_speed) / dt;

            if (motion_accel > 0)
            {
                state = TUIO_ACCELERATING;
            }
            else if (motion_accel < 0)
            {
                state = TUIO_DECELERATING;
            }
            else
            {
                state = TUIO_STOPPED;
            }

            lock (path) {
                path.AddLast(new TuioPoint(currentTime, xpos, ypos));
                if (path.Count > 128)
                {
                    path.RemoveFirst();
                }
            }
        }
Пример #6
0
 /**
  * <summary>
  * Takes a TuioPoint argument and updates its coordinate attributes
  * to the coordinates of the provided TuioPoint and leaves its time stamp unchanged.</summary>
  *
  * <param name="tpoint">the TuioPoint to assign</param>
  */
 public void update(TuioPoint tpoint)
 {
     xpos = tpoint.X;
     ypos = tpoint.Y;
 }
        /**
         * Takes a TuioTime argument and assigns it along with the provided
         * X and Y coordinate to the private TuioContainer attributes.
         * The speed and accleration values are calculated accordingly.
         *
         * @param	ttime	the TuioTime to assign
         * @param	xp	the X coordinate to assign
         * @param	yp	the Y coordinate to assign
         */
        public new void update(TuioTime ttime, float xp, float yp)
        {
            lastPoint = path[path.Count - 1];
            if (path.Count > 1)
                lastLastPoint = path[path.Count - 2];

            base.update(ttime, xp, yp);

            TuioTime diffTime = currentTime - lastPoint.getTuioTime();
            float dt = diffTime.getTotalMilliseconds() / 1000.0f;
            float dx = this.xpos - lastPoint.getX();
            float dy = this.ypos - lastPoint.getY();
            float dist = (float)Math.Sqrt(dx * dx + dy * dy);
            float last_motion_speed = this.motion_speed;

            this.x_speed = dx / dt;
            this.y_speed = dy / dt;
            this.motion_speed = dist / dt;
            this.motion_accel = (motion_speed - last_motion_speed) / dt;

            lock (pathSync)
            {
                path.Add(new TuioPoint(currentTime, xpos, ypos));
            }
            if (motion_accel > 0) state = TUIO_ACCELERATING;
            else if (motion_accel < 0) state = TUIO_DECELERATING;
            else state = TUIO_STOPPED;
            this.trimPath();
        }
Пример #8
0
 /**
  * This constructor takes a TuioPoint argument and sets its coordinate attributes
  * to the coordinates of the provided TuioPoint and its time stamp to the current session time.
  *
  * @param	tpoint	the TuioPoint to assign
  */
 public TuioPoint(TuioPoint tpoint)
 {
     xpos = tpoint.getX();
     ypos = tpoint.getY();
     currentTime = TuioTime.getSessionTime();
 }
Пример #9
0
 public TuioPoint(TuioPoint p)
 {
     this.xpos = p.getX();
     this.ypos = p.getY();
     timestamp = TUIO_UNDEFINED;
 }
        /**
         * Assigns the provided X and Y coordinate, X and Y velocity and acceleration
         * to the private TuioContainer attributes. The TuioTime time stamp remains unchanged.
         *
         * @param	xp	the X coordinate to assign
         * @param	yp	the Y coordinate to assign
         * @param	xs	the X velocity to assign
         * @param	ys	the Y velocity to assign
         * @param	ma	the acceleration to assign
         */
        public void update(float xp, float yp, float xs, float ys, float ma)
        {
            lastPoint = path[path.Count - 1];
            if (path.Count > 1)
                lastLastPoint = path[path.Count - 2];

            base.update(xp, yp);
            x_speed = xs;
            y_speed = ys;
            motion_speed = (float)Math.Sqrt(x_speed * x_speed + y_speed * y_speed);
            motion_accel = ma;
            lock (pathSync)
            {
                path.Add(new TuioPoint(currentTime, xpos, ypos));
            }
            if (motion_accel > 0) state = TUIO_ACCELERATING;
            else if (motion_accel < 0) state = TUIO_DECELERATING;
            else state = TUIO_STOPPED;
            this.trimPath();
        }
Пример #11
0
 /**
  * <summary>
  * Returns the distance to the provided TuioPoint</summary>
  *
  * <param name="tpoint">the distant TuioPoint</param>
  * <returns>the distance to the provided TuioPoint</returns>
  */
 public float getDistance(TuioPoint tpoint)
 {
     return getDistance(tpoint.X, tpoint.Y);
 }
        /// <summary>
        /// Checks all current TuioCursors for button presses, and invokes actions if needed.
        /// </summary>
        private void CheckTuioCursors()
        {
            foreach (TuioCursor tcur in tuioCursors.Values)
            {
                int pathCount = tcur.getPath().Count();
                // Ignore abnormally long paths
                if (pathCount < 100)
                {
                    List<TuioPoint> path;
                    path = tcur.getPath();
                    //Debug.WriteLine("Path count: " + path.Count());

                    // Check to see if cursor has been around long enough, if it started on a button, and is currently on a button
                    TuioPoint firstPoint = path.First();
                    TuioPoint lastPoint = path.Last();
                    long firstTime = firstPoint.getTuioTime().getTotalMilliseconds();
                    long lastTime;

                    //// Use  the last point in the path as the time of the last point
                    //lastTime = lastPoint.getTuioTime().getTotalMilliseconds();

                    //// If tuio cursor is about to be removed, use the current time as the time of the last point
                    //if (tuioCursorRemoveQueue.Contains(tcur))
                    //{
                    //    lastTime = TuioTime.getSystemTime().getTotalMilliseconds();
                    //}

                    // Use the current time as the time of the last point
                    lastTime = TuioTime.getSystemTime().getTotalMilliseconds();

                    //Debug.WriteLine("Tuio cursor path count: " + path.Count());

                    ZoomCircle firstButtonZoomCircle, lastButtonZoomCircle;
                    string firstButtonName, lastButtonName;
                    WouldPushButton(firstPoint, out firstButtonZoomCircle, out firstButtonName);
                    WouldPushButton(lastPoint, out lastButtonZoomCircle, out lastButtonName);

                    // Calculate average of all path points
                    float averageX = 0, averageY = 0;
                    TuioPoint[] pathArray = new TuioPoint[pathCount];
                    path.CopyTo(0, pathArray, 0, pathCount); // Copy to a new array before enumerating to avoid concurrency issues
                    foreach (TuioPoint tpoint in pathArray)
                    {
                        averageX += tpoint.getScreenX(Settings.RESOLUTION_X);
                        averageY += tpoint.getScreenY(Settings.RESOLUTION_Y);
                    }
                    averageX /= path.Count;
                    averageY /= path.Count;

                    // Check to see if touch starts and ends on a button and lasted long enough
                    if (firstButtonZoomCircle == lastButtonZoomCircle && firstButtonName == lastButtonName && lastTime - firstTime > Settings.INPUT_TOUCH_TIME)
                    {
                        switch (firstButtonName)
                        {
                            case "tab1":
                                firstButtonZoomCircle.AttachedGuide.
                                    Tab1ButtonPressed();
                                break;
                            case "tab2":
                                firstButtonZoomCircle.AttachedGuide.Tab2ButtonPressed();
                                break;
                            case "tab3":
                                firstButtonZoomCircle.AttachedGuide.Tab3ButtonPressed();
                                break;
                            case "tab4":
                                firstButtonZoomCircle.AttachedGuide.Tab4ButtonPressed();
                                break;
                            case "close":
                                if (!Settings.INPUT_SWIPES_ONLY)
                                    firstButtonZoomCircle.AttachedGuide.CloseButtonPressed();
                                break;
                            case "open":
                                if (!Settings.INPUT_SWIPES_ONLY)
                                    firstButtonZoomCircle.AttachedGuide.OpenButtonPressed(IsUpsideDown(tcur));
                                break;
                        }
                    }
                    // Check if touch started on a swipable button, and was swiped in the appropriate direction
                    else if (firstButtonName == "close" || firstButtonName == "open")
                    {
                        // Pass average of path to ZoomCircle for it to check
                        firstButtonZoomCircle.AttachedGuide.CheckButtonSwipe(firstButtonName, averageX, averageY, IsUpsideDown(tcur));
                    }
                }
            }
        }
Пример #13
0
 /**
  * <summary>
  * This constructor takes a TuioPoint argument and sets its coordinate attributes
  * to the coordinates of the provided TuioPoint and its time stamp to the current session time.</summary>
  *
  * <param name="tpoint">the TuioPoint to assign</param>
  */
 public TuioPoint(TuioPoint tpoint)
 {
     xpos = tpoint.X;
     ypos = tpoint.Y;
     currentTime = TuioTime.SessionTime;
     startTime = new TuioTime(currentTime);
 }
Пример #14
0
 /**
  * <summary>
  * Returns the angle to the provided TuioPoint</summary>
  *
  * <param name="tpoint">the distant TuioPoint</param>
  * <returns>the angle to the provided TuioPoint</returns>
  */
 public float getAngle(TuioPoint tpoint)
 {
     return getAngle(tpoint.X, tpoint.Y);
 }
Пример #15
0
 public TuioPoint(TuioPoint p)
 {
     this.xpos = p.getX();
     this.ypos = p.getY();
 }
Пример #16
0
 public void update(TuioPoint p)
 {
     this.xpos = p.getX();
     this.ypos = p.getY();
 }
Пример #17
0
 /**
  * This constructor takes a TuioPoint argument and sets its coordinate attributes
  * to the coordinates of the provided TuioPoint and its time stamp to the current session time.
  *
  * @param	tpoint	the TuioPoint to assign
  */
 public TuioPoint(TuioPoint tpoint)
 {
     xpos        = tpoint.getX();
     ypos        = tpoint.getY();
     currentTime = TuioTime.getSessionTime();
 }
Пример #18
0
 /**
  * <summary>
  * Returns the distance to the provided TuioPoint</summary>
  *
  * <param name="tpoint">the distant TuioPoint</param>
  * <returns>the distance to the provided TuioPoint</returns>
  */
 public float getDistance(TuioPoint tpoint)
 {
     return(getDistance(tpoint.X, tpoint.Y));
 }
Пример #19
0
 public float getAngleDegrees(TuioPoint tuioPoint)
 {
     return (getAngle(tuioPoint)/(float)Math.PI)*180.0f;
 }
Пример #20
0
 /**
  * <summary>
  * Returns the angle to the provided TuioPoint</summary>
  *
  * <param name="tpoint">the distant TuioPoint</param>
  * <returns>the angle to the provided TuioPoint</returns>
  */
 public float getAngle(TuioPoint tpoint)
 {
     return(getAngle(tpoint.X, tpoint.Y));
 }
Пример #21
0
 /**
  * Takes a TuioPoint argument and updates its coordinate attributes
  * to the coordinates of the provided TuioPoint and leaves its time stamp unchanged.
  *
  * @param	tpoint	the TuioPoint to assign
  */
 public void update(TuioPoint tpoint)
 {
     xpos = tpoint.getX();
     ypos = tpoint.getY();
 }
 // Check each ZoomedCircle to see if cursor pressed a button
 /// <summary>
 /// Check all ZoomCircles to see if cursor pressed a button
 /// </summary>
 /// <param name="tcur">The cursor to check against all ZoomCircles and their buttons</param>
 /// <returns>Returns a tuple consisting of a ZoomCircle, and a text description of which button on that ZoomCircle the cursor would press. Otherwise, null and emptry string.</returns>
 public void WouldPushButton(TuioPoint tPoint, out ZoomCircle outZoomCircle, out string outButtonName)
 {
     // Check each ZoomedCircle to see if cursor pressed a button
     Vector2 cursorPosition = new Vector2(tPoint.getScreenX(Settings.RESOLUTION_X), tPoint.getScreenY(Settings.RESOLUTION_Y));
     foreach (ZoomCircle zoomedCircle in zoomedCircles.Values)
     {
         Vector2 openButtonPosition, closeButtonPosition, tab1, tab2, tab3, tab4;
         if (zoomedCircle.AttachedGuide.IsLeftward)
         {
             openButtonPosition = Settings.CALLOUT_OPEN_BUTTON_LEFT;
             closeButtonPosition = Settings.CALLOUT_CLOSE_BUTTON_LEFT;
             if (zoomedCircle.AttachedGuide.IsUpsideDown)
             {
                 tab1 = -Settings.CALLOUT_TAB1_BUTTON;
                 tab2 = -Settings.CALLOUT_TAB2_BUTTON;
                 tab3 = -Settings.CALLOUT_TAB3_BUTTON;
                 tab4 = -Settings.CALLOUT_TAB4_BUTTON;
             }
             else
             {
                 tab1 = Settings.CALLOUT_TAB1_BUTTON_LEFT;
                 tab2 = Settings.CALLOUT_TAB2_BUTTON_LEFT;
                 tab3 = Settings.CALLOUT_TAB3_BUTTON_LEFT;
                 tab4 = Settings.CALLOUT_TAB4_BUTTON_LEFT;
             }
         }
         else
         {
             openButtonPosition = Settings.CALLOUT_OPEN_BUTTON;
             closeButtonPosition = Settings.CALLOUT_CLOSE_BUTTON;
             if (zoomedCircle.AttachedGuide.IsUpsideDown)
             {
                 tab1 = -Settings.CALLOUT_TAB1_BUTTON_LEFT;
                 tab2 = -Settings.CALLOUT_TAB2_BUTTON_LEFT;
                 tab3 = -Settings.CALLOUT_TAB3_BUTTON_LEFT;
                 tab4 = -Settings.CALLOUT_TAB4_BUTTON_LEFT;
             }
             else
             {
                 tab1 = Settings.CALLOUT_TAB1_BUTTON;
                 tab2 = Settings.CALLOUT_TAB2_BUTTON;
                 tab3 = Settings.CALLOUT_TAB3_BUTTON;
                 tab4 = Settings.CALLOUT_TAB4_BUTTON;
             }
         }
         if (zoomedCircle.AttachedGuide.CurrentState == Guide.GuideState.CLOSED)
         {
             Vector2 differenceVector = cursorPosition - zoomedCircle.position - openButtonPosition;
             // If within a certain radius, trigger callout opening for the matched circle
             if ((int)differenceVector.Length() <= Settings.CALLOUT_DETECTION_RADIUS)
             {
                 outZoomCircle = zoomedCircle;
                 outButtonName = "open";
                 return;
             }
             //Debug.WriteLine(differenceVector.Length());
         }
         else if (zoomedCircle.AttachedGuide.CurrentState == Guide.GuideState.OPEN)
         {
             Vector2 differenceVector = cursorPosition - zoomedCircle.position - closeButtonPosition;
             if ((int)differenceVector.Length() <= Settings.CALLOUT_DETECTION_RADIUS)
             {
                 outZoomCircle = zoomedCircle;
                 outButtonName = "close";
                 return;
             }
             differenceVector = cursorPosition - zoomedCircle.position - tab1;
             if ((Math.Abs(differenceVector.X) <= (Settings.CALLOUT_TAB_WIDTH / 2)) && (Math.Abs(differenceVector.Y) <= (Settings.CALLOUT_TAB_HEIGHT / 2)))
             {
                 outZoomCircle = zoomedCircle;
                 outButtonName = "tab1";
                 return;
             }
             differenceVector = cursorPosition - zoomedCircle.position - tab2;
             if ((Math.Abs(differenceVector.X) <= (Settings.CALLOUT_TAB_WIDTH / 2)) && (Math.Abs(differenceVector.Y) <= (Settings.CALLOUT_TAB_HEIGHT / 2)))
             {
                 outZoomCircle = zoomedCircle;
                 outButtonName = "tab2";
                 return;
             }
             differenceVector = cursorPosition - zoomedCircle.position - tab3;
             if ((Math.Abs(differenceVector.X) <= (Settings.CALLOUT_TAB_WIDTH / 2)) && (Math.Abs(differenceVector.Y) <= (Settings.CALLOUT_TAB_HEIGHT / 2)))
             {
                 outZoomCircle = zoomedCircle;
                 outButtonName = "tab3";
                 return;
             }
             differenceVector = cursorPosition - zoomedCircle.position - tab4;
             if ((Math.Abs(differenceVector.X) <= (Settings.CALLOUT_TAB_WIDTH / 2)) && (Math.Abs(differenceVector.Y) <= (Settings.CALLOUT_TAB_HEIGHT / 2)))
             {
                 outZoomCircle = zoomedCircle;
                 outButtonName = "tab4";
                 return;
             }
         }
     }
     outZoomCircle = null;
     outButtonName = "";
 }
Пример #23
0
 /**
  * Returns the angle to the provided TuioPoint
  *
  * @param	tpoint	the distant TuioPoint
  * @return	the angle to the provided TuioPoint
  */
 public float getAngle(TuioPoint tpoint)
 {
     return(getAngle(tpoint.getX(), tpoint.getY()));
 }
Пример #24
0
 /**
  * <summary>
  * Takes a TuioPoint argument and updates its coordinate attributes
  * to the coordinates of the provided TuioPoint and leaves its time stamp unchanged.</summary>
  *
  * <param name="tpoint">the TuioPoint to assign</param>
  */
 public void update(TuioPoint tpoint)
 {
     xpos = tpoint.X;
     ypos = tpoint.Y;
 }
        /**
         * Takes the atttibutes of the provided TuioContainer
         * and assigs these values to this TuioContainer.
         * The TuioTime time stamp of this TuioContainer remains unchanged.
         *
         * @param	tcon	the TuioContainer to assign
         */
        public void update(TuioContainer tcon)
        {
            lastPoint = path[path.Count - 1];
            if (path.Count > 1)
                lastLastPoint = path[path.Count - 2];

            base.update(tcon.getX(), tcon.getY());

            x_speed = tcon.getXSpeed();
            y_speed = tcon.getYSpeed();
            motion_speed = (float)Math.Sqrt(x_speed * x_speed + y_speed * y_speed);
            motion_accel = tcon.getMotionAccel();
            lock (pathSync)
            {
                path.Add(new TuioPoint(currentTime, xpos, ypos));
            }
            if (motion_accel > 0) state = TUIO_ACCELERATING;
            else if (motion_accel < 0) state = TUIO_DECELERATING;
            else state = TUIO_STOPPED;
            this.trimPath();
        }
Пример #26
0
 public float getDistance(TuioPoint pt)
 {
     float dx = xpos-pt.getX();
     float dy = ypos-pt.getY();
     return (float)Math.Sqrt(dx*dx+dy*dy);
 }
Пример #27
0
 /**
  * Returns the angle to the provided TuioPoint
  *
  * @param	tpoint	the distant TuioPoint
  * @return	the angle to the provided TuioPoint
  */
 public float getAngle(TuioPoint tpoint)
 {
     return getAngle(tpoint.getX(),tpoint.getY());
 }
Пример #28
0
 /**
  * Returns the distance to the provided TuioPoint
  *
  * @param	tpoint	the distant TuioPoint
  * @return	the distance to the provided TuioPoint
  */
 public float getDistance(TuioPoint tpoint)
 {
     return(getDistance(tpoint.getX(), tpoint.getY()));
 }
Пример #29
0
 /**
  * Returns the distance to the provided TuioPoint
  *
  * @param	tpoint	the distant TuioPoint
  * @return	the distance to the provided TuioPoint
  */
 public float getDistance(TuioPoint tpoint)
 {
     return getDistance(tpoint.getX(),tpoint.getY());
 }
Пример #30
0
 /**
  * Returns the angle in degrees to the provided TuioPoint
  *
  * @param	tpoint	the distant TuioPoint
  * @return	the angle in degrees to the provided TuioPoint
  */
 public float getAngleDegrees(TuioPoint tpoint)
 {
     return((getAngle(tpoint) / (float)Math.PI) * 180.0f);
 }
Пример #31
0
 /**
  * Takes a TuioPoint argument and updates its coordinate attributes
  * to the coordinates of the provided TuioPoint and leaves its time stamp unchanged.
  *
  * @param	tpoint	the TuioPoint to assign
  */
 public void update(TuioPoint tpoint)
 {
     xpos = tpoint.getX();
     ypos = tpoint.getY();
 }