Write() public static method

public static Write ( BinaryWriter writer, SoftwareModel softwareModel, SoftwareMesh softwareMesh, bool loadColors, bool loadUVs, bool loadNormals ) : void
writer System.IO.BinaryWriter
softwareModel SoftwareModel
softwareMesh SoftwareMesh
loadColors bool
loadUVs bool
loadNormals bool
return void
Example #1
0
        public static void Save(Stream stream, bool compress, SoftwareModel softwareModel, bool loadColors, bool loadUVs, bool loadNormals)
        {
            var writer = new BinaryWriter(stream);

            // meta data
            writer.Write(Streams.MakeFourCC('R', 'M', 'F', 'T')); // tag
            writer.Write(1.0f);                                   // version
            writer.Write(false);                                  //compress);// TODO: add zip compression

            // frames
            writer.Write(softwareModel.FrameStart);
            writer.Write(softwareModel.FrameEnd);
            writer.Write(softwareModel.FPS);

            // materials
            writer.Write(softwareModel.Materials.Count);
            foreach (var material in softwareModel.Materials)
            {
                writer.Write(material.Name);

                // values1
                writer.Write(material.Values1.Count);
                foreach (var value in material.Values1)
                {
                    writer.Write(value.Key);
                    writer.Write(value.Value);
                }

                // values2
                writer.Write(material.Values2.Count);
                foreach (var value in material.Values2)
                {
                    writer.Write(value.Key);
                    writer.WriteVector(value.Value);
                }

                // values3
                writer.Write(material.Values3.Count);
                foreach (var value in material.Values3)
                {
                    writer.Write(value.Key);
                    writer.WriteVector(value.Value);
                }

                // values4
                writer.Write(material.Values4.Count);
                foreach (var value in material.Values4)
                {
                    writer.Write(value.Key);
                    writer.WriteVector(value.Value);
                }

                // textures
                writer.Write(material.Textures.Count);
                foreach (var texture in material.Textures)
                {
                    writer.Write(texture.Key);
                    writer.Write(texture.Value);
                }
            }

            // meshes
            writer.Write(softwareModel.Meshes.Count);
            foreach (var mesh in softwareModel.Meshes)
            {
                Mesh.Write(writer, softwareModel, mesh, loadColors, loadUVs, loadNormals);
            }

            // actions
            writer.Write(softwareModel.Actions.Count);
            foreach (var action in softwareModel.Actions)
            {
                Action.Write(writer, action);
            }

            // armatures
            writer.Write(softwareModel.Armatures.Count);
            foreach (var armature in softwareModel.Armatures)
            {
                Armature.Write(writer, armature);
            }

            // objects
            writer.Write(softwareModel.Objects.Count);
            foreach (var o in softwareModel.Objects)
            {
                Object.Write(writer, o);
            }
        }