Пример #1
0
 /// <inheritdoc/>
 void IDataSerializable.Serialize(BinarySerializer serializer)
 {
     serializer.Serialize(ref Name);
     serializer.Serialize(ref ShareConstantBuffers);
     serializer.Serialize(ref Techniques);
     serializer.Serialize(ref Arguments, SerializeFlags.Nullable);
 }
Пример #2
0
            void IDataSerializable.Serialize(BinarySerializer serializer)
            {
                if (serializer.Mode == SerializerMode.Write)
                {
                    serializer.Writer.Write(Textures.Count);
                    foreach (var texture in Textures)
                    {
                        var name = texture.Key;
                        var list = texture.Value;
                        serializer.Serialize(ref name);
                        serializer.Serialize(ref list);
                    }
                }
                else
                {
                    var count = serializer.Reader.ReadInt32();
                    Textures = new Dictionary<string, List<MaterialTexture>>(count);
                    for(int i = 0; i < count; i++)
                    {
                        string name = null;
                        List<MaterialTexture> list = null;
                        serializer.Serialize(ref name);
                        serializer.Serialize(ref list);
                        Textures.Add(name, list);
                    }
                }

                serializer.Serialize(ref Properties);
            }
 void IDataSerializable.Serialize(BinarySerializer serializer)
 {
     serializer.Serialize(ref FilePath);
     serializer.Serialize(ref DependencyFilePath);
     serializer.SerializeEnum(ref CompilerFlags);
     serializer.Serialize(ref Macros, SerializeFlags.Nullable);
     serializer.Serialize(ref IncludeDirectoryList, serializer.Serialize, SerializeFlags.Nullable);
 }
Пример #4
0
            /// <inheritdoc/>
            void IDataSerializable.Serialize(BinarySerializer serializer)
            {
                serializer.Serialize(ref Name, SerializeFlags.Nullable);

                serializer.Serialize(ref IsSubPass);
                serializer.Serialize(ref Properties);
                serializer.Serialize(ref Pipeline);
            }
Пример #5
0
 void IDataSerializable.Serialize(BinarySerializer serializer)
 {
     serializer.Serialize(ref Index);
     serializer.Serialize(ref ParentIndex);
     serializer.Serialize(ref Transform);
     serializer.Serialize(ref Name, false, SerializeFlags.Nullable);
     serializer.Serialize(ref Children, serializer.Serialize, SerializeFlags.Nullable);
 }
Пример #6
0
 void IDataSerializable.Serialize(BinarySerializer serializer)
 {
     serializer.Serialize(ref Character);
     serializer.Serialize(ref Subrect);
     serializer.Serialize(ref Offset);
     serializer.Serialize(ref XAdvance);
     serializer.Serialize(ref BitmapIndex);
 }
Пример #7
0
 void IDataSerializable.Serialize(BinarySerializer serializer)
 {
     serializer.Serialize(ref MaterialIndex);
     serializer.Serialize(ref IndexBufferRange);
     serializer.Serialize(ref VertexBufferRange);
     serializer.Serialize(ref SkinnedBones);
     serializer.Serialize(ref Properties);
 }
 public void Serialize(BinarySerializer serializer)
 {
     serializer.Serialize(ref FilePath);
     serializer.Serialize(ref Index);
     serializer.Serialize(ref UVIndex);
     serializer.Serialize(ref BlendFactor);
     serializer.SerializeEnum(ref Operation);
     serializer.SerializeEnum(ref WrapMode);
     serializer.SerializeEnum(ref Flags);
 }
Пример #9
0
 public void Serialize(BinarySerializer serializer)
 {
     serializer.Serialize(ref Name, false, SerializeFlags.Nullable);
     serializer.Serialize(ref ParentBoneIndex);
     serializer.Serialize(ref BoundingSphere);
     serializer.Serialize(ref VertexBuffers);
     serializer.Serialize(ref IndexBuffers);
     serializer.Serialize(ref MeshParts);
     serializer.Serialize(ref Properties);
 }
Пример #10
0
 void IDataSerializable.Serialize(BinarySerializer serializer)
 {
     if (serializer.Mode == SerializerMode.Read)
     {
         var data = new BitmapData();
         serializer.Serialize(ref data);
         Data = data;
     }
     else
     {
         var data = (BitmapData)Data;
         serializer.Serialize(ref data);
     }
 }
        /// <summary>
        ///  This method for loading/saving a font file generated from MakeSpriteFont.
        /// </summary>
        /// <param name="serializer">The binary serializer to use.</param>
        /// <returns></returns>
        private void SerializeMakeSpriteFont(BinarySerializer serializer)
        {
            FourCC magicCode2 = "font";
            serializer.Serialize(ref magicCode2);
            if (magicCode2 != "font")
                return;

            // Writes the version
            if (serializer.Mode == SerializerMode.Read)
            {
                int version = serializer.Reader.ReadInt32();
                if (version != Version)
                {
                    throw new NotSupportedException(string.Format("SpriteFontData version [0x{0:X}] is not supported. Expecting [0x{1:X}]", version, Version));
                }
            }
            else
            {
                serializer.Writer.Write(Version);
            }
            
            // Deserialize Glyphs
            int glyphCount = 0;
            serializer.Serialize(ref glyphCount);

            // For MakeSpriteFont, there is only one GlyphPage.
            Glyphs = new Glyph[glyphCount];
            for (int i = 0; i < glyphCount; i++)
            {
                serializer.Serialize(ref Glyphs[i].Character);
                serializer.Serialize(ref Glyphs[i].Subrect);
                serializer.Serialize(ref Glyphs[i].Offset);
                serializer.Serialize(ref Glyphs[i].XAdvance);
            }

            serializer.Serialize(ref LineSpacing);
            serializer.Serialize(ref DefaultCharacter);

            var image = new BitmapData();
            Bitmaps = new Bitmap[1] {new Bitmap()};
            Bitmaps[0].Data = image;

            serializer.Serialize(ref image.Width);
            serializer.Serialize(ref image.Height);
            serializer.SerializeEnum(ref image.PixelFormat);
            serializer.Serialize(ref image.RowStride);
            serializer.Serialize(ref image.CompressedHeight);
            serializer.Serialize(ref image.Data, image.RowStride * image.CompressedHeight);
        }
Пример #12
0
 public void Serialize(BinarySerializer serializer)
 {
     if (serializer.Mode == SerializerMode.Read)
     {
         var reader = serializer.Reader;
         Slot = reader.ReadInt32();
         Start = reader.ReadInt32();
         Count = reader.ReadInt32();
     }
     else
     {
         var writer = serializer.Writer;
         writer.Write(Slot);
         writer.Write(Start);
         writer.Write(Count);
     }
 }
            public void Serialize(BinarySerializer serializer)
            {
                int expectedBlockSize = 0;
                serializer.Serialize(ref expectedBlockSize);

                var blockPosition = serializer.Stream.Position;

                serializer.Serialize(ref LineHeight);
                serializer.Serialize(ref Base);
                serializer.Serialize(ref ScaleW);
                serializer.Serialize(ref ScaleH);
                serializer.Serialize(ref PageCount);
                serializer.Serialize(ref BitField);
                serializer.SerializeEnum(ref Alpha);
                serializer.SerializeEnum(ref Red);
                serializer.SerializeEnum(ref Green);
                serializer.SerializeEnum(ref Blue);

                var blockSize = serializer.Stream.Position - blockPosition;
                if (blockSize != expectedBlockSize)
                    throw new NotSupportedException("Invalid BMF font format");
            }
Пример #14
0
        /// <inheritdoc/>
        void IDataSerializable.Serialize(BinarySerializer serializer)
        {
            // Starts the whole EffectData by the magiccode "TKFX"
            // If the serializer don't find the TKFX, It will throw an
            // exception that will be caught by Load method.
            serializer.BeginChunk(MagicCode);

            // Writes the version
            if (serializer.Mode == SerializerMode.Read)
            {
                int version = serializer.Reader.ReadInt32();
                if (version != Version)
                {
                    throw new NotSupportedException(string.Format("EffectData version [0x{0:X}] is not supported. Expecting [0x{1:X}]", version, Version));
                }
            }
            else
            {
                serializer.Writer.Write(Version);
            }

            // Shaders section
            serializer.BeginChunk("SHDR");
            serializer.Serialize(ref Shaders);
            serializer.EndChunk();

            // Effects section
            serializer.BeginChunk("EFFX");
            serializer.Serialize(ref Description);
            serializer.EndChunk();

            // Close TKFX section
            serializer.EndChunk();
        }
Пример #15
0
 public void Serialize(BinarySerializer serializer)
 {
     serializer.Serialize(ref First);
     serializer.Serialize(ref Second);
     serializer.Serialize(ref Offset);
 }
Пример #16
0
 void IDataSerializable.Serialize(BinarySerializer serializer)
 {
     serializer.Serialize(ref Count);
     serializer.Serialize(ref Layout);
     serializer.Serialize(ref Buffer);
 }
Пример #17
0
 private static BinarySerializer GetSerializer(Stream stream, SerializerMode mode)
 {
     var serializer = new BinarySerializer(stream, mode, Text.Encoding.ASCII);
     return serializer;
 }
Пример #18
0
        /// <inheritdoc/>
        void IDataSerializable.Serialize(BinarySerializer serializer)
        {
            // Starts the whole ModelData by the magiccode "TKMD"
            // If the serializer don't find the TKMD, It will throw an
            // exception that will be caught by Load method.

            // This code should not be modified without modifying the serialize code in Model.

            serializer.BeginChunk(MagicCode);

            // Writes the version
            if (serializer.Mode == SerializerMode.Read)
            {
                int version = serializer.Reader.ReadInt32();
                if (version != Version)
                {
                    throw new NotSupportedException(string.Format("ModelData version [0x{0:X}] is not supported. Expecting [0x{1:X}]", version, Version));
                }
            }
            else
            {
                serializer.Writer.Write(Version);
            }

            // Serialize the maximum buffer size used when loading this model.
            serializer.Serialize(ref MaximumBufferSizeInBytes);

            // Texture section
            serializer.BeginChunk("TEXS");
            if (serializer.Mode == SerializerMode.Read)
            {
                int textureCount = serializer.Reader.ReadInt32();
                Textures = new List<byte[]>(textureCount);
                for (int i = 0; i < textureCount; i++)
                {
                    byte[] textureData = null;
                    serializer.Serialize(ref textureData);
                    Textures.Add(textureData);
                }
            }
            else
            {
                serializer.Writer.Write(Textures.Count);
                for (int i = 0; i < Textures.Count; i++)
                {
                    byte[] textureData = Textures[i];
                    serializer.Serialize(ref textureData);
                }
            }
            serializer.EndChunk();

            // Material section
            serializer.BeginChunk("MATL");
            serializer.Serialize(ref Materials);
            serializer.EndChunk();

            // Bones section
            serializer.BeginChunk("BONE");
            serializer.Serialize(ref Bones);
            serializer.EndChunk();

            // Mesh section
            serializer.BeginChunk("MESH");
            serializer.Serialize(ref Meshes);
            serializer.EndChunk();

            // Animation section
            serializer.BeginChunk("ANIM");
            serializer.Serialize(ref Animations);
            serializer.EndChunk();

            // Serialize attributes
            serializer.Serialize(ref Attributes);

            // Close TKMD section
            serializer.EndChunk();
        }
Пример #19
0
            /// <inheritdoc/>
            void IDataSerializable.Serialize(BinarySerializer serializer)
            {
                serializer.Serialize(ref Name, SerializeFlags.Nullable);

                serializer.Serialize(ref Passes);
            }
Пример #20
0
 /// <inheritdoc/>
 void IDataSerializable.Serialize(BinarySerializer serializer)
 {
     serializer.Serialize(ref Time);
     serializer.Serialize(ref Value);
 }
Пример #21
0
 private static BinarySerializer GetSerializer(Stream stream, SerializerMode mode)
 {
     var serializer = new BinarySerializer(stream, mode, Text.Encoding.ASCII);
     serializer.ArrayLengthType = ArrayLengthType.Int;
     serializer.RegisterDynamicList<MaterialTexture>("MATL");
     return serializer;
 }
Пример #22
0
 void IDataSerializable.Serialize(BinarySerializer serializer)
 {
     serializer.Serialize(ref Name, SerializeFlags.Nullable);
     serializer.SerializeEnum(ref Type);
     serializer.SerializeEnum(ref CompilerFlags);
     serializer.SerializeEnum(ref Level);
     serializer.Serialize(ref Bytecode);
     serializer.Serialize(ref Hashcode);
     serializer.Serialize(ref InputSignature);
     serializer.Serialize(ref OutputSignature);
     serializer.Serialize(ref ConstantBuffers);
     serializer.Serialize(ref ResourceParameters);
 }
Пример #23
0
        /// <summary>
        /// Loads a <see cref="SpriteFontData"/> from the specified stream.
        /// </summary>
        /// <param name="stream">The stream.</param>
        /// <param name="bitmapDataLoader">A delegate to load bitmap data that are not stored in the buffer.</param>
        /// <returns>An <see cref="SpriteFontData"/>. Null if the stream is not a serialized <see cref="SpriteFontData"/>.</returns>
        public static SpriteFontData Load(Stream stream, SpriteFontBitmapDataLoaderDelegate bitmapDataLoader = null)
        {
            var serializer = new BinarySerializer(stream, SerializerMode.Read, Text.Encoding.ASCII) {ArrayLengthType = ArrayLengthType.Int};

            var data = new SpriteFontData();

            var magicCode = FourCC.Empty;
            serializer.Serialize(ref magicCode);

            if (magicCode == "DXTK")
            {
                data.SerializeMakeSpriteFont(serializer);
            }
            else if (magicCode == new FourCC(0x03464D42)) // BMF\3
            {
                data.SerializeBMFFont(serializer);
            }
            else
            {
                return null;
            }

            // Glyphs are null, then this is not a SpriteFondData
            if (data.Glyphs == null)
                return null;

            if (bitmapDataLoader != null)
            {
                foreach (var bitmap in data.Bitmaps)
                {
                    // If the bitmap data is a string, then this is a texture to load
                    if (bitmap.Data is string)
                    {
                        bitmap.Data = bitmapDataLoader((string) bitmap.Data);
                    }
                }
            }

            return data;
        }
 private static void SerializeVector4(ref Vector4 value, BinarySerializer serializer)
 {
     serializer.Serialize(ref value);
 }
 private static void SerializeColor3(ref Color3 value, BinarySerializer serializer)
 {
     serializer.Serialize(ref value);
 }
Пример #26
0
 /// <inheritdoc/>
 void IDataSerializable.Serialize(BinarySerializer serializer)
 {
     serializer.Serialize(ref Name);
     serializer.Serialize(ref Duration);
     serializer.Serialize(ref Channels);
 }
Пример #27
0
 /// <inheritdoc/>
 void IDataSerializable.Serialize(BinarySerializer serializer)
 {
     serializer.Serialize(ref BoneIndex);
     serializer.Serialize(ref InverseBindTransform);
 }
 /// <inheritdoc/>
 void IDataSerializable.Serialize(BinarySerializer serializer)
 {
     serializer.Serialize(ref BoneName);
     serializer.Serialize(ref KeyFrames);
 }
Пример #29
0
 void IDataSerializable.Serialize(BinarySerializer serializer)
 {
     serializer.Serialize(ref Width);
     serializer.Serialize(ref Height);
     serializer.SerializeEnum(ref PixelFormat);
     serializer.Serialize(ref RowStride);
     serializer.Serialize(ref CompressedHeight);
     serializer.Serialize(ref Data, RowStride * CompressedHeight);
 }
Пример #30
0
        void IDataSerializable.Serialize(BinarySerializer serializer)
        {
            // TODO implement a custom serial here
            throw new NotImplementedException();
        //    string magic = FontMagicCode;
        //    serializer.Serialize(ref magic, FontMagicCode.Length);

        //    if (magic != FontMagicCode)
        //    {
        //        // Make sure that Glyphs is null
        //        //Glyphs = null;
        //        return;
        //    }

        //    //serializer.Serialize(ref Glyphs);
        //    serializer.Serialize(ref LineSpacing);
        //    serializer.Serialize(ref DefaultCharacter);

        //    //serializer.Serialize(ref Image);
        }