Ejemplo n.º 1
0
 public void Load(SwfStream stream, uint length, byte version)
 {
     CharacterID = stream.ReadUShort();
     Depth = stream.ReadUShort();
     Matrix = stream.ReadMatrix();
     CxForm = stream.TagPosition < length ? stream.ReadCxForm(false) : VGCxForm.Identity;
 }
Ejemplo n.º 2
0
        public bool CheckHit(Vector2 mousePos, VGMatrix matrix)
        {
            if (_hitBounds.IsEmpty) return false;

            mousePos = ~matrix * mousePos;
            mousePos.X = (mousePos.X - _hitBounds.Left) / _hitBounds.Width;
            mousePos.Y = (mousePos.Y - _hitBounds.Top) / _hitBounds.Height;

            if (mousePos.X < 0f || mousePos.X > 1f) return false;
            if (mousePos.Y < 0f || mousePos.Y > 1f) return false;

            int xPx = (int)(mousePos.X * (HitTestSize - 1));
            int yPx = (int)(mousePos.Y * (HitTestSize - 1));

            return (_hitTestBitmap[xPx >> 3, yPx] & (0x80 >> (xPx & 0x07))) != 0;
        }
Ejemplo n.º 3
0
 private Rectangle TransformBounds(Rectangle r, VGMatrix m)
 {
     var b = m.TransformExtents(new Vector4(r.Left, r.Top, r.Right, r.Bottom));
     return new Rectangle((int)b.X, (int)b.Y, (int)(b.Z - b.X + 1), (int)(b.W - b.Y + 1));
 }
Ejemplo n.º 4
0
        internal bool SetPlacement(PlaceObject2Tag tag, StageObject parent)
        {
            bool load = false;

            // TODO: Morph ratio
            if (tag.HasCxForm) CxForm = tag.CxForm;
            if (tag.HasMatrix) Matrix = new VGMatrix(tag.Matrix);
            if (tag.HasCharacter)
            {
                var character = parent.Root.Document[tag.CharacterID];
                if (character == null) return false;

                var newInstance = character.MakeInstance(this, parent.Root);
                if (newInstance == null) return false;

                Removed();
                Character = character;
                Object = newInstance;
                Object.SetParent(parent);
                load = true;
            }

            if (tag.HasClipDepth) ClipDepth = tag.ClipDepth;
            if (Object is IInstanceable)
            {
                var obj = Object as IInstanceable;
                if (tag.HasName) obj.SetName(tag.Name);
                if (tag.HasActions) obj.SetClipActions(tag.Actions);
                if (load) obj.Load();
            }

            return Object != null;
        }
Ejemplo n.º 5
0
        internal bool SetPlacement(ButtonPart part, StageObject parent)
        {
            if (part.Character == null) return false;
            if (!part.CxForm.IsIdentity) CxForm = part.CxForm;
            Matrix = new VGMatrix(part.Matrix);

            if (part.Character != Character)
            {
                Object = part.Character.MakeInstance(this, parent.Root);
                if (Object == null) return false;
                Object.SetParent(parent);
                Character = part.Character;

                if (Object is IInstanceable)
                {
                    var obj = Object as IInstanceable;
                    obj.Load();
                }
            }

            return Object != null;
        }
Ejemplo n.º 6
0
 public VGMatrix(VGMatrix other)
 {
     Array.Copy(other._m, _m, _m.Length);
 }
Ejemplo n.º 7
0
 public bool Equals(VGMatrix other)
 {
     return this == other;
 }
Ejemplo n.º 8
0
        public static VGMatrix operator /(VGMatrix matrix1, VGMatrix matrix2)
        {
            VGMatrix m = new VGMatrix();

            m._m[0] = matrix1._m[0] / matrix2._m[0];
            m._m[1] = matrix1._m[1] / matrix2._m[1];
            m._m[2] = matrix1._m[2] / matrix2._m[2];
            m._m[3] = matrix1._m[3] / matrix2._m[3];
            m._m[4] = matrix1._m[4] / matrix2._m[4];
            m._m[5] = matrix1._m[5] / matrix2._m[5];
            m._m[6] = matrix1._m[6] / matrix2._m[6];
            m._m[7] = matrix1._m[7] / matrix2._m[7];
            m._m[8] = matrix1._m[8] / matrix2._m[8];
            return m;
        }
Ejemplo n.º 9
0
        public static VGMatrix operator /(VGMatrix matrix, float divider)
        {
            VGMatrix m = new VGMatrix();

            divider = 1f / divider;
            m._m[0] = matrix._m[0] * divider;
            m._m[1] = matrix._m[1] * divider;
            m._m[2] = matrix._m[2] * divider;
            m._m[3] = matrix._m[3] * divider;
            m._m[4] = matrix._m[4] * divider;
            m._m[5] = matrix._m[5] * divider;
            m._m[6] = matrix._m[6] * divider;
            m._m[7] = matrix._m[7] * divider;
            m._m[8] = matrix._m[8] * divider;

            return m;
        }
Ejemplo n.º 10
0
        public static VGMatrix operator -(VGMatrix matrix1, VGMatrix matrix2)
        {
            VGMatrix m = new VGMatrix();

            m._m[0] = matrix1._m[0] - matrix2._m[0];
            m._m[1] = matrix1._m[1] - matrix2._m[1];
            m._m[2] = matrix1._m[2] - matrix2._m[2];
            m._m[3] = matrix1._m[3] - matrix2._m[3];
            m._m[4] = matrix1._m[4] - matrix2._m[4];
            m._m[5] = matrix1._m[5] - matrix2._m[5];
            m._m[6] = matrix1._m[6] - matrix2._m[6];
            m._m[7] = matrix1._m[7] - matrix2._m[7];
            m._m[8] = matrix1._m[8] - matrix2._m[8];
            return m;
        }
Ejemplo n.º 11
0
        public static VGMatrix operator +(VGMatrix matrix1, VGMatrix matrix2)
        {
            VGMatrix m = new VGMatrix();

            m._m[0] = matrix1._m[0] + matrix2._m[0];
            m._m[1] = matrix1._m[1] + matrix2._m[1];
            m._m[2] = matrix1._m[2] + matrix2._m[2];
            m._m[3] = matrix1._m[3] + matrix2._m[3];
            m._m[4] = matrix1._m[4] + matrix2._m[4];
            m._m[5] = matrix1._m[5] + matrix2._m[5];
            m._m[6] = matrix1._m[6] + matrix2._m[6];
            m._m[7] = matrix1._m[7] + matrix2._m[7];
            m._m[8] = matrix1._m[8] + matrix2._m[8];
            return m;
        }
Ejemplo n.º 12
0
        public static VGMatrix operator *(float scaleFactor, VGMatrix matrix)
        {
            VGMatrix m = new VGMatrix();

            m._m[0] = matrix._m[0] * scaleFactor;
            m._m[1] = matrix._m[1] * scaleFactor;
            m._m[2] = matrix._m[2] * scaleFactor;
            m._m[3] = matrix._m[3] * scaleFactor;
            m._m[4] = matrix._m[4] * scaleFactor;
            m._m[5] = matrix._m[5] * scaleFactor;
            m._m[6] = matrix._m[6] * scaleFactor;
            m._m[7] = matrix._m[7] * scaleFactor;
            m._m[8] = matrix._m[8] * scaleFactor;
            return m;
        }