Example #1
0
    // Cursor down is for new touch events. we take the TUIO cursor object and convert it
    // into a touch event, and add it to our active list of events
    public virtual void cursorDown(TuioCursor cursor)
    {
        // first, make a new BBTouchEvent, tag it with the unique touch id
        BBTouchEvent newEvent = new BBTouchEvent(cursor.getSessionID());

        // set the initial information
        newEvent.screenPosition = new Vector3(cursor.getX() * cameraPixelWidth, (1.0f - cursor.getY()) * cameraPixelHeight, 0.3f);
        newEvent.eventState     = BBTouchEventState.Began;
        newEvent.didChange      = true;
        // set all the rest of the info
        updateEvent(newEvent, cursor);

        // add it to our active event dictionary so we can retireve it based on it's unique ID
        // some times badness happens and we get an error adding one here for some reason
        // it should not ever be the case that the ID is already there.
        // if it is, then we need to behave
        if (activeEvents.ContainsKey(cursor.getSessionID()))
        {
            // then something is not right.. remove the old one and add a new one
            activeEvents.Remove(cursor.getSessionID());
        }
        activeEvents.Add(cursor.getSessionID(), newEvent);
        // queue it up for processing
        lock (eventQueueLock) eventQueue.Add(newEvent);
    }
Example #2
0
 public void removeTuioCursor(TuioCursor tcur)
 {
     lock (cursorSync)
     {
         cursorList.Remove(tcur.getSessionID());
     }
     Console.WriteLine("del cur " + tcur.getCursorID() + " (" + tcur.getSessionID() + ")");
 }
Example #3
0
        public void addTuioCursor(TuioCursor tcur)
        {
            lock (cursorSync)
            {
                cursorList.Add(tcur.getSessionID(), tcur);
            }

            Console.WriteLine("add cur " + tcur.getCursorID() + " (" + tcur.getSessionID() + ") " + tcur.getX() + " " + tcur.getY());
            //  VisualFeedback.InvalidateVisual();
        }
Example #4
0
    public virtual void cursorUp(TuioCursor cursor)
    {
        // find the matching event object, set the state to 'ended'
        // and remove it from our actives
        if (!activeEvents.ContainsKey(cursor.getSessionID()))
        {
            return;
        }
        BBTouchEvent anEvent = activeEvents[cursor.getSessionID()];

        anEvent.eventState = BBTouchEventState.Ended;
        lock (eventQueueLock) eventQueue.Add(anEvent);
        activeEvents.Remove(cursor.getSessionID());
    }
Example #5
0
    public virtual void cursorMove(TuioCursor cursor)
    {
        // find the matching event object, set th state to 'moved'
        // and update it with the new position info
        if (!activeEvents.ContainsKey(cursor.getSessionID()))
        {
            return;
        }
        BBTouchEvent anEvent = activeEvents[cursor.getSessionID()];

        updateEvent(anEvent, cursor);
        anEvent.eventState = BBTouchEventState.Moved;
        lock (eventQueueLock) eventQueue.Add(anEvent);
    }
Example #6
0
 public void removeTuioCursor(TuioCursor tcur)
 {
     if (GestureManager != null)
     {
         TouchGroup tg = GestureManager.GetTouchGroup(tcur.getSessionID());
         if (tg != null)
         {
             TouchPoint tp = tg.Get(tcur.getSessionID());
             tp.Mode = TouchPoint.TouchMode.UP;
             this.UpdateTouchPoint(tp, tcur);
             OnTouchUp(tp);
         }
     }
 }
Example #7
0
    public void updateCursor(TuioCursor cursor)
    {
        if (!activeEvents.ContainsKey(cursor.getSessionID()))
        {
            return;
        }
        mtCntrEvent anEvent = activeEvents[cursor.getSessionID()];

        anEvent.eventState = mtEventState.Moved;

        if (cursor.getContour() != null)
        {
            List <TuioPoint> contr      = cursor.getContour();
            List <Vector3>   cntrPoints = new List <Vector3>();
            foreach (TuioPoint pnt in contr)
            {
                float xC = pnt.getX();
                float yC = pnt.getY();
                cntrPoints.Add(new Vector3(xC * cameraPixelWidth, 0, (1.0f - yC) * cameraPixelHeight));
            }
            anEvent.contour = cntrPoints.ToArray();

            //calibrate and CoM (center of mass)
            float  xCoM = 0.0F;
            float  yCoM = 0.0F;
            Matrix mat  = Matrix.Translate(xTCalib, yTCalib, 0.0F);
            for (int i = 0; i < anEvent.contour.Length; i++)
            {
                anEvent.contour[i] = mat.TransformVector(anEvent.contour[i]);
                xCoM += anEvent.contour[i].x;
                yCoM += anEvent.contour[i].y;
            }
            xCoM /= anEvent.contour.Length;
            yCoM /= anEvent.contour.Length;

            //translate to 0
            for (int i = 0; i < anEvent.contour.Length; i++)
            {
                anEvent.contour[i].x -= xCoM;
                anEvent.contour[i].y -= yCoM;
            }

            anEvent.lastScreenPosition = anEvent.screenPosition;
            anEvent.screenPosition     = new Vector3(xCoM, 0, yCoM);
        }

        lock (eventQueueLock) eventQueue.Add(anEvent);
        didChange = true;
    }
Example #8
0
    public void removeCursor(TuioCursor cursor)
    {
        if (!activeEvents.ContainsKey(cursor.getSessionID()))
        {
            return;
        }
        mtCntrEvent anEvent = activeEvents[cursor.getSessionID()];

        anEvent.eventState = mtEventState.Ended;
        lock (eventQueueLock) {
            eventQueue.Add(anEvent);
        }
        activeEvents.Remove(cursor.getSessionID());
        didChange = true;
    }
Example #9
0
    public void updateCursor(TuioCursor cursor)
    {
        if (!activeEvents.ContainsKey(cursor.getSessionID()))
        {
            return;
        }
        mtEvent anEvent = activeEvents[cursor.getSessionID()];

        anEvent.lastScreenPosition = anEvent.screenPosition;

        anEvent.screenPosition = new Vector3(cursor.getX() * cameraPixelWidth, 0, (1.0f - cursor.getY()) * cameraPixelHeight);
        anEvent.tuioPosition   = new Vector2(cursor.getX(), (1.0f - cursor.getY()));
        anEvent.eventState     = mtEventState.Moved;

        lock (eventQueueLock) eventQueue.Add(anEvent);
        didChange = true;
    }
Example #10
0
 public void removeTuioCursor(TuioCursor tuioCursor)
 {
     this.Dispatcher.Invoke(
         DispatcherPriority.Normal,
         (Action)(() =>
     {
         BSQSim.RemoveTouchDevice((int)tuioCursor.getSessionID());
     }));
 }
Example #11
0
 public void updateTuioCursor(TuioCursor tuioCursor)
 {
     this.Dispatcher.Invoke(
         DispatcherPriority.Normal,
         (Action)(() =>
     {
         BSQSim.UpdateTouchDevice((int)tuioCursor.getSessionID(),
                                  new Point(tuioCursor.getScreenX(Convert.ToInt32(DISPLAY_W)), tuioCursor.getScreenY(Convert.ToInt32(DISPLAY_H))));
     }));
 }
Example #12
0
    public void newCursor(TuioCursor cursor)
    {
        mtCntrEvent newEvent = new mtCntrEvent(cursor.getSessionID());

        newEvent.tuioPosition = new Vector2(cursor.getX(), (1.0f - cursor.getY()));
        //switching y and z (y is up axis by default in unity)
        newEvent.screenPosition     = new Vector3(cursor.getX() * cameraPixelWidth, 0, (1.0f - cursor.getY()) * cameraPixelHeight);
        newEvent.lastScreenPosition = newEvent.screenPosition;
        newEvent.eventState         = mtEventState.Began;

        if (activeEvents.ContainsKey(cursor.getSessionID()))
        {
            //Already on list, remove old - add new
            activeEvents.Remove(cursor.getSessionID());
        }
        activeEvents.Add(cursor.getSessionID(), newEvent);
        // queue it up for processing
        lock (eventQueueLock) eventQueue.Add(newEvent);
        didChange = true;
    }
Example #13
0
        private TouchPoint CreateTouchPoint(TuioCursor cursor)
        {
            TouchPoint tp = new TouchPoint
            {
                StartPoint   = cursor.getPath().First().ToPoint(GestureManager),
                StartTimeMS  = cursor.getStartTime().getTotalMilliseconds(),
                CurrentPoint = cursor.getPath().First().ToPoint(GestureManager),
                SessionID    = cursor.getSessionID()
            };

            return(UpdateTouchPoint(tp, cursor));
        }
Example #14
0
    public void newCursor(TuioCursor cursor)
    {
        ibheTuioEvent newEvent = new ibheTuioEvent(cursor.getSessionID());

        newEvent.tuioPosition = new Vector2(cursor.getX(), (1.0f - cursor.getY()));
        //switching y and z (y is up axis by default in unity)
        newEvent.screenPosition     = new Vector3(cursor.getX() * cameraPixelWidth, 0, (1.0f - cursor.getY()) * cameraPixelHeight);
        newEvent.lastScreenPosition = newEvent.screenPosition;
        newEvent.eventState         = mtEventState.Began;
        newEvent.xPos   = cursor.getHXpos() * cameraPixelWidth;
        newEvent.yPos   = (1.0f - cursor.getHYpos()) * cameraPixelHeight;
        newEvent.width  = cursor.getWidth();
        newEvent.height = cursor.getHeight();
        if (cursor.getHeightPoints() != null)
        {
            newEvent.heights = cursor.getHeightPoints().ToArray();
        }

        float min = 250.0F;

        for (int i = 0; i < newEvent.heights.Length; i++)
        {
            if (((newEvent.heights[i] / 255.0F) * -4.0F) < min)
            {
                min = (newEvent.heights[i] / 255.0F) * -4.0F;
            }
        }
        newEvent.minHeight = min;

        if (activeEvents.ContainsKey(cursor.getSessionID()))
        {
            //Already on list, remove old - add new
            activeEvents.Remove(cursor.getSessionID());
        }
        activeEvents.Add(cursor.getSessionID(), newEvent);
        // queue it up for processing
        lock (eventQueueLock) eventQueue.Add(newEvent);
        didChange = true;
    }
Example #15
0
    public void updateCursor(TuioCursor cursor)
    {
        if (!activeEvents.ContainsKey(cursor.getSessionID()))
        {
            return;
        }
        ibheTuioEvent anEvent = activeEvents[cursor.getSessionID()];

        anEvent.lastScreenPosition = anEvent.screenPosition;
        anEvent.screenPosition     = new Vector3(cursor.getX() * cameraPixelWidth, 0, (1.0f - cursor.getY()) * cameraPixelHeight);
        anEvent.tuioPosition       = new Vector2(cursor.getX(), (1.0f - cursor.getY()));
        anEvent.eventState         = mtEventState.Moved;
        anEvent.xPos   = cursor.getHXpos() * cameraPixelWidth;
        anEvent.yPos   = (1.0f - cursor.getHYpos()) * cameraPixelHeight;
        anEvent.width  = cursor.getWidth();
        anEvent.height = cursor.getHeight();
        if (cursor.getHeightPoints() != null)
        {
            anEvent.heights = cursor.getHeightPoints().ToArray();
        }

        float min = 250.0F;

        for (int i = 0; i < anEvent.heights.Length; i++)
        {
            if (((anEvent.heights[i] / 255.0F) * -4.0F) < min)
            {
                min = (anEvent.heights[i] / 255.0F) * -4.0F;
            }
        }
        anEvent.minHeight = min;
        //calibrate
        //Matrix mat = Matrix.Translate(xTCalib, yTCalib, 0.0F);
        //anEvent.xPos = mat.TransformVector( anEvent.xPos );

        lock (eventQueueLock) eventQueue.Add(anEvent);
        didChange = true;
    }
        public void RemoveTuioCursor(TuioCursor tuioCursor)
        {
            _refreshTimer.Stop();

            int pid = tuioCursor.getCursorID();

            int i = _pointerTouchInfos.FindIndex(pti => pti.PointerInfo.PointerId == pid);

            if (i != -1)
            {
                PointerTouchInfo pointerTouchInfo = _pointerTouchInfos[i];
                pointerTouchInfo.PointerInfo.PointerFlags = PointerFlags.UP;
                _pointerTouchInfos[i] = pointerTouchInfo;

                Trace.WriteLine(string.Format("del cur {0} ({1})", pid, tuioCursor.getSessionID()), "TUIO");
            }
        }
        public void AddTuioCursor(TuioCursor tuioCursor)
        {
            _refreshTimer.Stop();

            int pid = tuioCursor.getCursorID();

            int i = _pointerTouchInfos.FindIndex(pti => pti.PointerInfo.PointerId == pid);

            if (i != -1)
            {
                _pointerTouchInfos.RemoveAt(i);
            }

            int x = (int)((tuioCursor.getX() * (_screenRect.Width + _calibrationBuffer.Width)) + _calibrationBuffer.Left + _screenRect.Left);
            int y = (int)((tuioCursor.getY() * (_screenRect.Height + _calibrationBuffer.Height)) + _calibrationBuffer.Top + _screenRect.Top);

            _pointerTouchInfos.Add
            (
                new PointerTouchInfo()
            {
                TouchFlags  = TouchFlags.NONE,
                Orientation = TOUCH_ORIENTATION,
                Pressure    = TOUCH_PRESSURE,
                TouchMasks  = TouchMask.CONTACTAREA | TouchMask.ORIENTATION | TouchMask.PRESSURE,
                PointerInfo = new PointerInfo
                {
                    PointerInputType = PointerInputType.TOUCH,
                    PointerFlags     = PointerFlags.DOWN | PointerFlags.INRANGE | ((this.IsContactEnabled) ? PointerFlags.INCONTACT : PointerFlags.NONE),
                    PtPixelLocation  = new PointerTouchPoint {
                        X = x, Y = y
                    },
                    PointerId = (uint)pid
                },
                ContactArea = new ContactArea
                {
                    Left   = x - CONTACT_AREA_RADIUS,
                    Right  = x + CONTACT_AREA_RADIUS,
                    Top    = y - CONTACT_AREA_RADIUS,
                    Bottom = y + CONTACT_AREA_RADIUS
                }
            }
            );

            Trace.WriteLine(string.Format("add cur {0} ({1}) {2} {3}", pid, tuioCursor.getSessionID(), x, y), "TUIO");
        }
Example #18
0
    public void updateCursor(TuioCursor cursor)
    {
        if (!activeEvents.ContainsKey(cursor.getSessionID()))
        {
            return;
        }
        mtCntrEvent anEvent = activeEvents[cursor.getSessionID()];

        anEvent.eventState = mtEventState.Moved;

        if (cursor.getContour() != null)
        {
            List <TuioPoint> contr      = cursor.getContour();
            List <Vector3>   cntrPoints = new List <Vector3>();
            foreach (TuioPoint pnt in contr)
            {
                float xC = pnt.getX();
                float yC = pnt.getY();
                cntrPoints.Add(new Vector3(xC * cameraPixelWidth, (1.0f - yC) * cameraPixelHeight, 0));
            }
            anEvent.contour = cntrPoints.ToArray();
            //calibrate and CoM (center of mass)
            float  xCoM = 0.0F;
            float  yCoM = 0.0F;
            Matrix mat  = Matrix.Translate(xTCalib, yTCalib, 0.0F);
            for (int i = 0; i < anEvent.contour.Length; i++)
            {
                anEvent.contour[i] = mat.TransformVector(anEvent.contour[i]);
                xCoM += anEvent.contour[i].x;
                yCoM += anEvent.contour[i].y;
            }
            xCoM /= anEvent.contour.Length;
            yCoM /= anEvent.contour.Length;

            //translate to 0
            for (int i = 0; i < anEvent.contour.Length; i++)
            {
                anEvent.contour[i].x -= xCoM;
                anEvent.contour[i].y -= yCoM;
            }

            anEvent.lastScreenPosition = anEvent.screenPosition;
            anEvent.screenPosition     = new Vector3(xCoM, 0, yCoM);



            /*
             * anEvent.lastTime = anEvent.currentTime;
             * anEvent.currentTime = Time.time;
             * float dt = anEvent.currentTime - anEvent.lastTime; //delta time
             * if(dt > 0)
             * {
             *      float dx = anEvent.lastScreenPosition.x - anEvent.screenPosition.x;
             *      float dy = anEvent.lastScreenPosition.z - anEvent.screenPosition.z;
             *      float distance = (float)Mathf.Sqrt(dx*dx+dy*dy);
             *      float lastMspeed = anEvent.mAccel;
             *      anEvent.x_speed = dx / dt; // delta x / delta time = velocity x
             *      anEvent.y_speed = dy / dt; // -||-
             *      anEvent.mSpeed = distance / dt;
             *      anEvent.mAccel = (anEvent.mSpeed - lastMspeed) / dt;
             * }
             */
        }

        lock (eventQueueLock) eventQueue.Add(anEvent);
        didChange = true;
    }
Example #19
0
 public void updateTuioCursor(TuioCursor tcur)
 {
     Console.WriteLine("set cur " + tcur.getCursorID() + " (" + tcur.getSessionID() + ") " + tcur.getX() + " " + tcur.getY() + " " + tcur.getMotionSpeed() + " " + tcur.getMotionAccel());
 }
        public void UpdateTuioCursor(TuioCursor tuioCursor)
        {
            _refreshTimer.Stop();

            int pid = tuioCursor.getCursorID();

            int i = _pointerTouchInfos.FindIndex(pti => pti.PointerInfo.PointerId == pid);

            if (i != -1)
            {
                int x = (int)((tuioCursor.getX() * (_screenRect.Width + _calibrationBuffer.Width)) + _calibrationBuffer.Left + _screenRect.Left);
                int y = (int)((tuioCursor.getY() * (_screenRect.Height + _calibrationBuffer.Height)) + _calibrationBuffer.Top + _screenRect.Top);

                PointerTouchInfo pointerTouchInfo = _pointerTouchInfos[i];
                pointerTouchInfo.PointerInfo.PointerFlags    = PointerFlags.UPDATE | PointerFlags.INRANGE | ((this.IsContactEnabled) ? PointerFlags.INCONTACT : PointerFlags.NONE);
                pointerTouchInfo.PointerInfo.PtPixelLocation = new PointerTouchPoint {
                    X = x, Y = y
                };
                pointerTouchInfo.ContactArea = new ContactArea
                {
                    Left   = x - CONTACT_AREA_RADIUS,
                    Right  = x + CONTACT_AREA_RADIUS,
                    Top    = y - CONTACT_AREA_RADIUS,
                    Bottom = y + CONTACT_AREA_RADIUS
                };
                _pointerTouchInfos[i] = pointerTouchInfo;

                Trace.WriteLine(string.Format("set cur {0} ({1}) {2} {3} {4} {5}", pid, tuioCursor.getSessionID(), x, y, tuioCursor.getMotionSpeed(), tuioCursor.getMotionAccel()), "TUIO");
            }
        }
Example #21
0
        //here we go, thats the method called by vvvv each frame
        //all data handling should be in here
        public void Evaluate(int SpreadMax)
        {
            //if any of the inputs has changed
            //recompute the outputs
            if (FTUIOPacketInput.PinIsChanged)
            {
                string currentPacket;
                FTUIOPacketInput.GetString(0, out currentPacket);
                if (currentPacket == "" || currentPacket == null)
                {
                    return;
                }
                int tuioPosition = currentPacket.IndexOf("#bundle");
                if (tuioPosition == -1)
                {
                    return;
                }


                while ((tuioPosition = currentPacket.IndexOf("#bundle")) >= 0)
                {
                    int    nextpos = currentPacket.IndexOf("#bundle", tuioPosition + 1);
                    string currentSeperatedPacket = "";
                    if (nextpos == -1)
                    {
                        currentSeperatedPacket = currentPacket;
                        currentPacket          = "";
                    }
                    else
                    {
                        currentSeperatedPacket = currentPacket.Substring(tuioPosition, nextpos - tuioPosition);
                        currentPacket          = currentPacket.Substring(nextpos);
                    }
                    OSC.NET.OSCPacket packet = OSC.NET.OSCPacket.Unpack(Encoding.Default.GetBytes(currentSeperatedPacket));
                    if (packet.IsBundle())
                    {
                        ArrayList messages = packet.Values;
                        for (int i = 0; i < messages.Count; i++)
                        {
                            FTuioClient.ProcessMessage((OSC.NET.OSCMessage)messages[i]);
                        }
                    }
                    else
                    {
                        FTuioClient.ProcessMessage((OSC.NET.OSCMessage)packet);
                    }
                }
            }
            List <TuioCursor> cursors = FTuioClient.getTuioCursors();
            List <TuioObject> objects = FTuioClient.getTuioObjects();
            List <TuioBlob>   blobs   = FTuioClient.getTuioBlobs();
            int slicecount            = cursors.Count + objects.Count + blobs.Count;

            FSessionIDOut.SliceCount            = slicecount;
            FClassIDOut.SliceCount              = slicecount;
            FUniqueIDOut.SliceCount             = slicecount;
            FPosXOut.SliceCount                 = slicecount;
            FPosYOut.SliceCount                 = slicecount;
            FWidthOut.SliceCount                = slicecount;
            FHeightOut.SliceCount               = slicecount;
            FAreaOut.SliceCount                 = slicecount;
            FAngleOut.SliceCount                = slicecount;
            FMovementXOut.SliceCount            = slicecount;
            FMovementYOut.SliceCount            = slicecount;
            FMotionAccelerationOut.SliceCount   = slicecount;
            FRotationAccelerationOut.SliceCount = slicecount;
            FMotionSpeedOut.SliceCount          = slicecount;
            FRotationSpeedOut.SliceCount        = slicecount;

            int curindex = 0;

            for (int i = 0; i < cursors.Count; i++)
            {
                TuioCursor cur = cursors[i];
                FSessionIDOut.SetValue(curindex, cur.getSessionID());
                FClassIDOut.SetValue(curindex, 0);
                FUniqueIDOut.SetValue(curindex, cur.getFingerID());
                FPosXOut.SetValue(curindex, cur.getPosition().getX() * 2 - 1);
                FPosYOut.SetValue(curindex, -cur.getPosition().getY() * 2 + 1);
                FAngleOut.SetValue(curindex, 0);
                FMovementXOut.SetValue(curindex, cur.getXSpeed());
                FMovementYOut.SetValue(curindex, cur.getYSpeed());
                FMotionAccelerationOut.SetValue(curindex, cur.getMotionAccel());
                FRotationAccelerationOut.SetValue(curindex, 0);
                FMotionSpeedOut.SetValue(curindex, cur.getMotionSpeed());
                FRotationSpeedOut.SetValue(curindex, 0);
                curindex++;
            }
            int objectOffset = 1000;

            for (int i = 0; i < objects.Count; i++)
            {
                TuioObject obj = objects[i];
                FSessionIDOut.SetValue(curindex, obj.getSessionID());
                FClassIDOut.SetValue(curindex, 1);
                FUniqueIDOut.SetValue(curindex, obj.getFiducialID() + objectOffset);
                FPosXOut.SetValue(curindex, obj.getPosition().getX() * 2 - 1);
                FPosYOut.SetValue(curindex, -obj.getPosition().getY() * 2 + 1);
                FAngleOut.SetValue(curindex, 1 - ((obj.getAngle()) / (Math.PI + Math.PI)));
                FMovementXOut.SetValue(curindex, obj.getXSpeed());
                FMovementYOut.SetValue(curindex, obj.getYSpeed());
                FMotionAccelerationOut.SetValue(curindex, obj.getMotionAccel());
                FRotationAccelerationOut.SetValue(curindex, obj.getRotationAccel());
                FMotionSpeedOut.SetValue(curindex, obj.getMotionSpeed());
                FRotationSpeedOut.SetValue(curindex, obj.getRotationSpeed());
                curindex++;
            }

            int blobOffset = 2000;

            for (int i = 0; i < blobs.Count; i++)
            {
                TuioBlob blb = blobs[i];
                FSessionIDOut.SetValue(curindex, blb.getSessionID());
                FClassIDOut.SetValue(curindex, 2);
                FUniqueIDOut.SetValue(curindex, blb.getBlobID() + blobOffset);
                FPosXOut.SetValue(curindex, blb.getPosition().getX() * 2 - 1);
                FPosYOut.SetValue(curindex, -blb.getPosition().getY() * 2 + 1);
                FWidthOut.SetValue(curindex, blb.getWidth());
                FHeightOut.SetValue(curindex, blb.getHeight());
                FAreaOut.SetValue(curindex, blb.getArea());
                FAngleOut.SetValue(curindex, 1 - ((blb.getAngle()) / (Math.PI + Math.PI)));
                FMovementXOut.SetValue(curindex, blb.getXSpeed());
                FMovementYOut.SetValue(curindex, blb.getYSpeed());
                FMotionAccelerationOut.SetValue(curindex, blb.getMotionAccel());
                FRotationAccelerationOut.SetValue(curindex, blb.getRotationAccel());
                FMotionSpeedOut.SetValue(curindex, blb.getMotionSpeed());
                FRotationSpeedOut.SetValue(curindex, blb.getRotationSpeed());
                curindex++;
            }
        }
Example #22
0
        private void TuioChannel_OnTuioRefresh(TuioTime t)
        {
            //TODO: re-enable frequent screen monitoring
            //if (frameCount % checkScreenEvery == 0)
            //    ScanScreens();
            //loop through the TuioObjects
            List <PointerTouchInfo> toFire = new List <PointerTouchInfo>();

            if (channel.CursorList.Count > 0)
            {
                foreach (var kvp in channel.CursorList)
                {
                    TuioCursor   cur  = kvp.Value.TuioCursor;
                    IncomingType type = kvp.Value.Type;
                    int[]        injectionCoordinates = ToInjectionCoordinates(cur.getX(), cur.getY());

                    //make a new pointertouchinfo with all neccessary information
                    PointerTouchInfo contact = new PointerTouchInfo();
                    contact.PointerInfo.pointerType = PointerInputType.TOUCH;
                    contact.TouchFlags = TouchFlags.NONE;
                    //contact.Orientation = (uint)cur.getAngleDegrees();//this is only valid for TuioObjects
                    contact.Pressure   = pressure;
                    contact.TouchMasks = TouchMask.CONTACTAREA | TouchMask.ORIENTATION | TouchMask.PRESSURE;
                    contact.PointerInfo.PtPixelLocation.X = injectionCoordinates[0];
                    contact.PointerInfo.PtPixelLocation.Y = injectionCoordinates[1];
                    contact.PointerInfo.PointerId         = SessionIDToTouchID(cur.getSessionID());
                    contact.ContactArea.left   = injectionCoordinates[0] - areaRadius;
                    contact.ContactArea.right  = injectionCoordinates[0] + areaRadius;
                    contact.ContactArea.top    = injectionCoordinates[1] - areaRadius;
                    contact.ContactArea.bottom = injectionCoordinates[1] + areaRadius;
                    //set the right flag
                    if (type == IncomingType.New)
                    {
                        contact.PointerInfo.PointerFlags = PointerFlags.DOWN | PointerFlags.INRANGE | PointerFlags.INCONTACT;
                    }
                    else if (type == IncomingType.Update)
                    {
                        contact.PointerInfo.PointerFlags = PointerFlags.UPDATE | PointerFlags.INRANGE | PointerFlags.INCONTACT;
                    }
                    else if (type == IncomingType.Remove)
                    {
                        contact.PointerInfo.PointerFlags = PointerFlags.UP;
                    }
                    //add it to 'toFire'
                    toFire.Add(contact);
                }
            }

            //fire the events
            bool success = TouchInjector.InjectTouchInput(toFire.Count, toFire.ToArray());

            //remove those with type == IncomingType.Remove
            List <long> removeList = new List <long>();

            foreach (var kvp in channel.CursorList)
            {
                if (kvp.Value.Type == IncomingType.Remove)
                {
                    removeList.Add(kvp.Key);
                }
            }
            foreach (long key in removeList)
            {
                channel.CursorList.Remove(key);//remove from the tuio channel
            }
        }