Ejemplo n.º 1
0
        /// <summary>
        /// Update an Augmenta object extra data from incoming data.
        /// </summary>
        /// <param name="augmentaObject"></param>
        /// <param name="args"></param>
        private void UpdateAugmentaObjectExtra(AugmentaObject augmentaObject, ArrayList args)
        {
            Vector3 highest = new Vector3((float)args[3], (float)args[4], augmentaObject.highest.z);

            if (flipX)
            {
                highest.x = 1 - highest.x;
            }

            if (flipY)
            {
                highest.y = 1 - highest.y;
            }

            augmentaObject.id               = (int)args[1];
            augmentaObject.oid              = (int)args[2];
            augmentaObject.highest          = highest;
            augmentaObject.distanceToSensor = (float)args[5];
            augmentaObject.reflectivity     = (float)args[6];

            //Inactive time reset to zero : the object has just been updated
            augmentaObject.inactiveTime = 0;

            augmentaObject.UpdateAugmentaObject();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Update an Augmenta object main data from incoming data.
        /// </summary>
        /// <param name="augmentaObject"></param>
        /// <param name="args"></param>
        private void UpdateAugmentaObjectMain(AugmentaObject augmentaObject, ArrayList args)
        {
            Vector2 centroid     = Vector2.zero;
            Vector2 velocity     = Vector2.zero;
            Vector3 highest      = Vector3.zero;
            Rect    boundingRect = new Rect();
            float   orientation  = 0;
            float   rotation     = 0;

            switch (protocolVersion)
            {
            case AugmentaProtocolVersion.V1:

                augmentaObject.id          = (int)args[0];
                augmentaObject.oid         = (int)args[1];
                augmentaObject.ageInFrames = (int)args[2];
                centroid             = new Vector2((float)args[3], (float)args[4]);
                velocity             = new Vector2((float)args[5], (float)args[6]);
                augmentaObject.depth = (float)args[7];
                boundingRect         = new Rect((float)args[8], (float)args[9], (float)args[10], (float)args[11]);
                highest = new Vector3((float)args[12], (float)args[13], (float)args[14]);
                break;

            case AugmentaProtocolVersion.V2:

                augmentaObject.id           = (int)args[1];
                augmentaObject.oid          = (int)args[2];
                augmentaObject.ageInSeconds = (float)args[3];
                centroid     = new Vector2((float)args[4], (float)args[5]);
                velocity     = new Vector2((float)args[6], (float)args[7]);
                orientation  = (float)args[8];
                boundingRect = new Rect((float)args[9], (float)args[10], (float)args[11], (float)args[12]);
                rotation     = (float)args[13];
                highest      = new Vector3(augmentaObject.highest.x, augmentaObject.highest.y, (float)args[14]);
                break;
            }

            if (flipX)
            {
                centroid.x     = 1 - centroid.x;
                velocity.x     = -velocity.x;
                orientation    = orientation > 180 ? 360.0f - orientation : 180.0f - orientation;
                boundingRect.x = 1 - boundingRect.x;
                rotation       = rotation > 180 ? 360.0f - rotation : 180.0f - rotation;
                highest.x      = 1 - highest.x;
            }

            if (flipY)
            {
                centroid.y     = 1 - centroid.y;
                velocity.y     = -velocity.y;
                orientation    = 360.0f - orientation;
                boundingRect.y = 1 - boundingRect.y;
                rotation       = 360.0f - rotation;
                highest.y      = 1 - highest.y;
            }

            augmentaObject.centroid             = centroid;
            augmentaObject.velocity             = velocity;
            augmentaObject.orientation          = orientation;
            augmentaObject.boundingRect         = boundingRect;
            augmentaObject.boundingRectRotation = rotation;
            augmentaObject.highest = highest;

            //Inactive time reset to zero : the object has just been updated
            augmentaObject.inactiveTime = 0;

            augmentaObject.UpdateAugmentaObject();
        }