Example #1
0
        public static void SetVector(BinaryDeserializer Deserializer, GfxFloatKeyFrameGroup[] Vector)
        {
            long Position = Deserializer.BaseStream.Position;

            uint Flags = GetFlagsFromElem(Deserializer, Position);

            uint ConstantMask = 1u;
            uint NotExistMask = 1u << Vector.Length;

            for (int Axis = 0; Axis < Vector.Length; Axis++)
            {
                Deserializer.BaseStream.Seek(Position, SeekOrigin.Begin);

                Position += 4;

                bool Constant = (Flags & ConstantMask) != 0;
                bool Exists   = (Flags & NotExistMask) == 0;

                if (Exists)
                {
                    Vector[Axis] = GfxFloatKeyFrameGroup.ReadGroup(Deserializer, Constant);
                }

                ConstantMask <<= 1;
                NotExistMask <<= 1;
            }
        }
Example #2
0
        private GfxFloatKeyFrameGroup GetFrameGrpByElemIndex(int ElemIndex)
        {
            GfxFloatKeyFrameGroup FrameGrp = null;

            switch (ElemIndex)
            {
            case 0: FrameGrp = _ScaleX; break;

            case 1: FrameGrp = _ScaleY; break;

            case 2: FrameGrp = _ScaleZ; break;

            case 3: FrameGrp = _RotationX; break;

            case 4: FrameGrp = _RotationY; break;

            case 5: FrameGrp = _RotationZ; break;

            case 7: FrameGrp = _TranslationX; break;

            case 8: FrameGrp = _TranslationY; break;

            case 9: FrameGrp = _TranslationZ; break;
            }
            return(FrameGrp);
        }
Example #3
0
        public static void SetVector(BinaryDeserializer Deserializer, GfxFloatKeyFrameGroup Vector)
        {
            uint Flags = GetFlagsFromElem(Deserializer, Deserializer.BaseStream.Position);

            bool Constant = (Flags & 1) != 0;
            bool Exists   = (Flags & 2) == 0;

            if (Exists)
            {
                Vector = GfxFloatKeyFrameGroup.ReadGroup(Deserializer, Constant);
            }
        }
Example #4
0
        public static GfxFloatKeyFrameGroup SetVector(BinaryDeserializer Deserializer)
        {
            uint Flags = GetFlagsFromElem(Deserializer, Deserializer.BaseStream.Position);

            bool Constant = (Flags & 1) != 0;
            bool Exists   = (Flags & 2) == 0;

            if (Exists)
            {
                return(GfxFloatKeyFrameGroup.ReadGroup(Deserializer, Constant));
            }
            return(null);
        }
Example #5
0
        public GfxAnimTransform()
        {
            _ScaleX = new GfxFloatKeyFrameGroup();
            _ScaleY = new GfxFloatKeyFrameGroup();
            _ScaleZ = new GfxFloatKeyFrameGroup();

            _RotationX = new GfxFloatKeyFrameGroup();
            _RotationY = new GfxFloatKeyFrameGroup();
            _RotationZ = new GfxFloatKeyFrameGroup();

            _TranslationX = new GfxFloatKeyFrameGroup();
            _TranslationY = new GfxFloatKeyFrameGroup();
            _TranslationZ = new GfxFloatKeyFrameGroup();
        }
Example #6
0
        void ICustomSerialization.Deserialize(BinaryDeserializer Deserializer)
        {
            long Position = Deserializer.BaseStream.Position;

            uint Flags = GfxAnimVector.GetFlagsFromElem(Deserializer, Position);

            uint ConstantMask = (uint)GfxAnimTransformFlags.IsScaleXConstant;
            uint NotExistMask = (uint)GfxAnimTransformFlags.IsScaleXInexistent;

            for (int ElemIndex = 0; ElemIndex < 10; ElemIndex++)
            {
                Deserializer.BaseStream.Seek(Position, SeekOrigin.Begin);

                Position += 4;

                bool Constant = (Flags & ConstantMask) != 0;
                bool Exists   = (Flags & NotExistMask) == 0;

                if (Exists)
                {
                    GfxFloatKeyFrameGroup FrameGrp = GfxFloatKeyFrameGroup.ReadGroup(Deserializer, Constant);

                    switch (ElemIndex)
                    {
                    case 0: _ScaleX = FrameGrp; break;

                    case 1: _ScaleY = FrameGrp; break;

                    case 2: _ScaleZ = FrameGrp; break;

                    case 3: _RotationX = FrameGrp; break;

                    case 4: _RotationY = FrameGrp; break;

                    case 5: _RotationZ = FrameGrp; break;

                    case 7: _TranslationX = FrameGrp; break;

                    case 8: _TranslationY = FrameGrp; break;

                    case 9: _TranslationZ = FrameGrp; break;
                    }
                }

                ConstantMask <<= 1;
                NotExistMask <<= 1;
            }
        }
Example #7
0
        internal static GfxFloatKeyFrameGroup ReadGroup(BinaryDeserializer Deserializer, bool Constant)
        {
            GfxFloatKeyFrameGroup FrameGrp = new GfxFloatKeyFrameGroup();

            if (Constant)
            {
                FrameGrp.KeyFrames.Add(new KeyFrame(0, Deserializer.Reader.ReadSingle()));
            }
            else
            {
                uint Address = Deserializer.ReadPointer();

                Deserializer.BaseStream.Seek(Address, SeekOrigin.Begin);

                FrameGrp = Deserializer.Deserialize <GfxFloatKeyFrameGroup>();
            }

            return(FrameGrp);
        }
Example #8
0
        bool ICustomSerialization.Serialize(BinarySerializer Serializer)
        {
            uint ConstantMask = (uint)GfxAnimTransformFlags.IsScaleXConstant;
            uint NotExistMask = (uint)GfxAnimTransformFlags.IsScaleXInexistent;

            long Position = Serializer.BaseStream.Position;

            GfxAnimTransformFlags Flags = 0;

            //Serializer.Writer.Write(0u);
            bool[] HasFrameGrp = new bool[10];

            for (int ElemIndex = 0; ElemIndex < 10; ElemIndex++)
            {
                GfxFloatKeyFrameGroup FrameGrp = GetFrameGrpByElemIndex(ElemIndex);

                if (FrameGrp == null)
                {
                    Flags |= (GfxAnimTransformFlags)NotExistMask;

                    Serializer.Writer.Write(0u);
                }
                else if (FrameGrp.KeyFrames.Count == 1)
                {
                    Flags |= (GfxAnimTransformFlags)ConstantMask;

                    Serializer.Writer.Write(FrameGrp.KeyFrames[0].Value);
                }
                else
                {
                    if (FrameGrp.KeyFrames.Count > 1)
                    {
                        /*Serializer.Sections[(uint)GfxSectionId.Contents].Values.Add(new RefValue()
                         * {
                         *  Value    = FrameGrp,
                         *  Position = Serializer.BaseStream.Position
                         * });*/
                        HasFrameGrp[ElemIndex] = true;
                    }
                    else
                    {
                        Flags |= (GfxAnimTransformFlags)NotExistMask;
                    }

                    Serializer.Writer.Write(0u);
                }

                ConstantMask <<= 1;
                NotExistMask <<= 1;
            }

            long[] AxisPtrs = new long[10];

            for (int ElemIndex = 0; ElemIndex < 10; ElemIndex++)
            {
                if (HasFrameGrp[ElemIndex])
                {
                    AxisPtrs[ElemIndex] = Serializer.BaseStream.Position;
                    Serializer.WriteValue(GetFrameGrpByElemIndex(ElemIndex));
                }
            }

            long EndPos = Serializer.BaseStream.Position;

            GfxAnimVector.WriteFlagsToElem(Serializer, Position, (uint)Flags);

            Serializer.BaseStream.Seek(Position, SeekOrigin.Begin);
            foreach (ulong Ptr in AxisPtrs)
            {
                Serializer.WritePointer((uint)Ptr);
            }

            Serializer.BaseStream.Seek(EndPos, SeekOrigin.Begin);

            return(true);
        }
Example #9
0
        bool ICustomSerialization.Serialize(BinarySerializer Serializer)
        {
            uint ConstantMask = (uint)GfxAnimTransformFlags.IsScaleXConstant;
            uint NotExistMask = (uint)GfxAnimTransformFlags.IsScaleXInexistent;

            long Position = Serializer.BaseStream.Position;

            GfxAnimTransformFlags Flags = 0;

            Serializer.Writer.Write(0u);

            for (int ElemIndex = 0; ElemIndex < 10; ElemIndex++)
            {
                GfxFloatKeyFrameGroup FrameGrp = null;

                switch (ElemIndex)
                {
                case 0: FrameGrp = _ScaleX;       break;

                case 1: FrameGrp = _ScaleY;       break;

                case 2: FrameGrp = _ScaleZ;       break;

                case 3: FrameGrp = _RotationX;    break;

                case 4: FrameGrp = _RotationY;    break;

                case 5: FrameGrp = _RotationZ;    break;

                case 7: FrameGrp = _TranslationX; break;

                case 8: FrameGrp = _TranslationY; break;

                case 9: FrameGrp = _TranslationZ; break;
                }

                if (FrameGrp == null)
                {
                    Flags |= (GfxAnimTransformFlags)NotExistMask;

                    Serializer.Writer.Write(0u);
                }
                else if (FrameGrp.KeyFrames.Count == 1)
                {
                    Flags |= (GfxAnimTransformFlags)ConstantMask;

                    Serializer.Writer.Write(FrameGrp.KeyFrames[0].Value);
                }
                else
                {
                    if (FrameGrp.KeyFrames.Count > 1)
                    {
                        Serializer.Sections[(uint)GfxSectionId.Contents].Values.Add(new RefValue()
                        {
                            Value    = FrameGrp,
                            Position = Serializer.BaseStream.Position
                        });
                    }
                    else
                    {
                        Flags |= (GfxAnimTransformFlags)NotExistMask;
                    }

                    Serializer.Writer.Write(0u);
                }

                ConstantMask <<= 1;
                NotExistMask <<= 1;
            }

            GfxAnimVector.WriteFlagsToElem(Serializer, Position, (uint)Flags);

            Serializer.BaseStream.Seek(Position + 4 + 9 * 4, SeekOrigin.Begin);

            return(true);
        }
Example #10
0
 public GfxAnimFloat()
 {
     _Value = new GfxFloatKeyFrameGroup();
 }
Example #11
0
 public static void WriteVector(BinarySerializer Serializer, GfxFloatKeyFrameGroup Vector)
 {
     WriteVector(Serializer, new GfxFloatKeyFrameGroup[] { Vector });
 }
Example #12
0
 void ICustomSerialization.Deserialize(BinaryDeserializer Deserializer)
 {
     _Value = GfxAnimVector.SetVector(Deserializer);
 }