예제 #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;
 }
예제 #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;
        }
예제 #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));
 }
예제 #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;
        }
예제 #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;
        }
예제 #6
0
파일: VGMatrix.cs 프로젝트: liwq-net/XnaVG
 public VGMatrix(VGMatrix other)
 {
     Array.Copy(other._m, _m, _m.Length);
 }
예제 #7
0
파일: VGMatrix.cs 프로젝트: liwq-net/XnaVG
 public bool Equals(VGMatrix other)
 {
     return this == other;
 }
예제 #8
0
파일: VGMatrix.cs 프로젝트: liwq-net/XnaVG
        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;
        }
예제 #9
0
파일: VGMatrix.cs 프로젝트: liwq-net/XnaVG
        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;
        }
예제 #10
0
파일: VGMatrix.cs 프로젝트: liwq-net/XnaVG
        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;
        }
예제 #11
0
파일: VGMatrix.cs 프로젝트: liwq-net/XnaVG
        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;
        }
예제 #12
0
파일: VGMatrix.cs 프로젝트: liwq-net/XnaVG
        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;
        }