Пример #1
0
 private void OnEntityUpdated(ITUIOEntity entity)
 {
     if (entity is TUIOCursor)
     {
         cursorsChangedFseq = fseq;
     }
     else if (entity is TUIOObject)
     {
         objectsChangedFseq = fseq;
     }
     else if (entity is TUIOBlob)
     {
         blobsChangedFseq = fseq;
     }
 }
Пример #2
0
        public void Remove(ITUIOEntity entity)
        {
            if (entity == null || !_entities.Remove(entity))
            {
                return;
            }

            entity.onUpdated -= OnEntityUpdated;

            if (entity is TUIOCursor)
            {
                cursorCount--; cursorsChangedFseq = fseq;
            }
            else if (entity is TUIOObject)
            {
                objectCount--; objectsChangedFseq = fseq;
            }
            else if (entity is TUIOBlob)
            {
                blobCount--; blobsChangedFseq = fseq;
            }
        }
Пример #3
0
        private void AppendToBundle <T>(OscBundle oscBundle, OscMessage sourceMsg, OscMessage aliveMsg, OscMessage fseqMsg, bool forceSet = false) where T : ITUIOEntity
        {
            // http://www.tuio.org/?specification - Message & Bundle Format
            //
            // /tuio/2Dcur source application@address
            // /tuio/2Dcur alive s_id0 ... s_idN
            // /tuio/2Dcur set s x y X Y m
            // /tuio/2Dcur fseq f_id
            //
            // nb. TUIOsharp does not enforce an order for alive/set messages so long as they're before fseq

            oscBundle.Append(sourceMsg);

            // entities: alive, set
            aliveMsg.ClearData();             // nb. also clears address
            aliveMsg.Append("alive");

            oscBundle.Append(aliveMsg);

            for (int i = 0; i < _entities.Count; i++)
            {
                ITUIOEntity e = _entities[i];
                if (e.GetType() != typeof(T))
                {
                    continue;
                }

                aliveMsg.Append(e.Id);
                if (forceSet || e.isSendRequired)
                {
                    oscBundle.Append(e.oscMessage);                     // set
                    e.isSendRequired = false;
                }
            }

            // frame sequence
            fseqMsg.UpdateDataAt(1, fseq);
            oscBundle.Append(fseqMsg);
        }
Пример #4
0
        public void Add(ITUIOEntity entity)
        {
            if (entity == null || _entities.Contains(entity))
            {
                return;
            }

            _entities.Add(entity);

            entity.onUpdated += OnEntityUpdated;

            if (entity is TUIOCursor)
            {
                cursorCount++; cursorsChangedFseq = fseq;
            }
            else if (entity is TUIOObject)
            {
                objectCount++; objectsChangedFseq = fseq;
            }
            else if (entity is TUIOBlob)
            {
                blobCount++; blobsChangedFseq = fseq;
            }
        }