예제 #1
0
        public static void SetVector(BinaryDeserializer Deserializer, H3DFloatKeyFrameGroup[] Vector)
        {
            uint Flags = Deserializer.Reader.ReadUInt32();

            long Position = Deserializer.BaseStream.Position;

            uint ConstantMask = (uint)H3DAnimVectorFlags.IsXConstant;
            uint NotExistMask = (uint)H3DAnimVectorFlags.IsXInexistent;

            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] = H3DFloatKeyFrameGroup.ReadGroup(Deserializer, Constant);
                }

                ConstantMask <<= 1;
                NotExistMask <<= 1;
            }
        }
예제 #2
0
        public static void SetVector(BinaryDeserializer Deserializer, ref H3DFloatKeyFrameGroup Vector)
        {
            H3DAnimVectorFlags Flags = (H3DAnimVectorFlags)Deserializer.Reader.ReadUInt32();

            bool Constant = (Flags & H3DAnimVectorFlags.IsXConstant) != 0;
            bool Exists   = (Flags & H3DAnimVectorFlags.IsXInexistent) == 0;

            if (Exists)
            {
                Vector = H3DFloatKeyFrameGroup.ReadGroup(Deserializer, Constant);
            }
        }
예제 #3
0
        void ICustomSerialization.Deserialize(BinaryDeserializer Deserializer)
        {
            long Position = Deserializer.BaseStream.Position;

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

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

                Position += 4;

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

                if (Exists)
                {
                    H3DFloatKeyFrameGroup FrameGrp = H3DFloatKeyFrameGroup.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 6: _TranslationX = FrameGrp; break;

                    case 7: _TranslationY = FrameGrp; break;

                    case 8: _TranslationZ = FrameGrp; break;
                    }
                }

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

                if (ConstantMask == (uint)H3DAnimTransformFlags.IsRotationWConstant)
                {
                    ConstantMask <<= 1;
                }
            }
        }
예제 #4
0
        public H3DAnimTransform()
        {
            _ScaleX = new H3DFloatKeyFrameGroup();
            _ScaleY = new H3DFloatKeyFrameGroup();
            _ScaleZ = new H3DFloatKeyFrameGroup();

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

            _TranslationX = new H3DFloatKeyFrameGroup();
            _TranslationY = new H3DFloatKeyFrameGroup();
            _TranslationZ = new H3DFloatKeyFrameGroup();
        }
예제 #5
0
        internal static H3DFloatKeyFrameGroup ReadGroup(BinaryDeserializer Deserializer, bool Constant)
        {
            H3DFloatKeyFrameGroup FrameGrp = new H3DFloatKeyFrameGroup();

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

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

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

            return(FrameGrp);
        }
예제 #6
0
        bool ICustomSerialization.Serialize(BinarySerializer Serializer)
        {
            uint ConstantMask = (uint)H3DAnimTransformFlags.IsScaleXConstant;
            uint NotExistMask = (uint)H3DAnimTransformFlags.IsScaleXInexistent;

            long Position = Serializer.BaseStream.Position;

            Flags = 0;

            Serializer.Writer.Write(0u);

            for (int ElemIndex = 0; ElemIndex < 9; ElemIndex++)
            {
                H3DFloatKeyFrameGroup 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 6: FrameGrp = _TranslationX; break;

                case 7: FrameGrp = _TranslationY; break;

                case 8: FrameGrp = _TranslationZ; break;
                }

                if (FrameGrp.KeyFrames.Count == 1)
                {
                    Flags |= (H3DAnimTransformFlags)ConstantMask;

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

                    Serializer.Writer.Write(0u);
                }

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

                if (ConstantMask == (uint)H3DAnimTransformFlags.IsRotationWConstant)
                {
                    ConstantMask <<= 1;
                }
            }

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

            Serializer.Writer.Write((uint)Flags);

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

            return(true);
        }
예제 #7
0
 public H3DAnimFloat()
 {
     _Value = new H3DFloatKeyFrameGroup();
 }
예제 #8
0
 public static void WriteVector(BinarySerializer Serializer, H3DFloatKeyFrameGroup Vector)
 {
     WriteVector(Serializer, new H3DFloatKeyFrameGroup[] { Vector });
 }