Exemplo n.º 1
0
    public void removeCursor(TuioCursor cursor)
    {
        if (!activeEvents.ContainsKey(cursor.getSessionID()))
        {
            return;
        }
        ibheTuioEvent anEvent = activeEvents[cursor.getSessionID()];

        anEvent.eventState = mtEventState.Ended;
        lock (eventQueueLock) {
            eventQueue.Add(anEvent);
        }
        activeEvents.Remove(cursor.getSessionID());
        didChange = true;
    }
Exemplo n.º 2
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;
    }
Exemplo n.º 3
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;
    }
Exemplo n.º 4
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;
    }