コード例 #1
0
        private void ProcessObjects(List <RecognizedTangibleMarker> tangibles)
        {
            foreach (var tangible in tangibles)
            {
                switch (tangible.Type)
                {
                case RecognizedTangibleMarker.ActionType.Added:
                    Console.WriteLine($"Tuio object added {tangible.Id}");
                    var objectToAdd = new TUIOObject(_tuioTransmitter.NextSessionId(), tangible.Id, tangible.center.X, tangible.center.Y, 0.0f, 0f, 0f, 0f, 0f, 0f);
                    objects[tangible.Id] = objectToAdd;
                    _tuioTransmitter.Add(objectToAdd);
                    break;

                case RecognizedTangibleMarker.ActionType.Updated:
                    Console.WriteLine($"Tuio object Updated {tangible.Id}");
                    objects[tangible.Id]?.Update(tangible.center.X, tangible.center.Y, 0.0f, 0f, 0f, 0f, 0f, 0f);
                    break;

                case RecognizedTangibleMarker.ActionType.Removed:
                    Console.WriteLine($"Tuio object Removed {tangible.Id}");
                    var objectToRemove = objects[tangible.Id];
                    _tuioTransmitter.Remove(objectToRemove);
                    objects.Remove(tangible.Id);
                    break;

                default:
                    Console.WriteLine($"ERROR: unkown tangible action type");
                    break;
                }
            }
        }
コード例 #2
0
    //
    // surface
    //

    public void AddToSurface()
    {
        if (surface != null)
        {
            RemoveFromSurface();
        }

        surface = GetComponentInParent <Surface>();

        Vector2 normalisedPosition = surface.GetNormalisedPosition(transform);
        float   angleRads          = (transform.localEulerAngles.z < 0f) ? ((transform.localEulerAngles.z % 360f + 360f) * Mathf.Deg2Rad) : ((transform.localEulerAngles.z % 360f) * Mathf.Deg2Rad);

        tuioObject = new TUIOObject(surface.NextSessionId(), _id, normalisedPosition.x, normalisedPosition.y, -angleRads, 0f, 0f, 0f, 0f, 0f);
        surface.Add(this);
        surface.ShowSurfaceObjectOnTop(this);
    }