Exemplo n.º 1
0
 public void Save(Stream output)
 {
     StreamHelpers.WriteValueU32(output, 1);
     StreamHelpers.WriteValueU32(output, (uint)this.entries.Count);
     foreach (var kvp in this.entries)
     {
         StreamHelpers.WriteValueU64(output, kvp.Key);
         StreamHelpers.WriteValueU32(output, (uint)kvp.Value.Length);
         StreamHelpers.WriteStringASCII(output, kvp.Value);
     }
 }
Exemplo n.º 2
0
        public void Save(Stream output)
        {
            long startOfChunk = output.Position;

            this.offsize.offset = (uint)startOfChunk;

            StreamHelpers.WriteStringASCII(output, this.magic);
            StreamHelpers.WriteValueU32(output, this.version);

            StreamHelpers.WriteValueU32(output, (uint)this.Routes.Count);
            StreamHelpers.WriteValueU32(output, (uint)this.Containers.Count);
            StreamHelpers.WriteValueU32(output, (uint)this.Effects.Count);
            StreamHelpers.WriteValueU32(output, (uint)this.IKTargets.Count);
            StreamHelpers.WriteValueU32(output, this.count5);

            for (int i = 0; i < this.Routes.Count; i++)
            {
                StreamHelpers.WriteValueU32(output, this.Routes[i].slotName);
            }
            for (int i = 0; i < this.Routes.Count; i++)
            {
                StreamHelpers.WriteValueU32(output, this.Routes[i].boneName);
            }
            for (int i = 0; i < this.Routes.Count; i++)
            {
                this.Routes[i].matrix.Save(output);
            }
            if (this.Routes.Count > 0)
            {
                StreamHelpers.WriteValueU32(output, 0);
            }

            // Containers
            for (int i = 0; i < this.Containers.Count; i++)
            {
                StreamHelpers.WriteValueU32(output, this.Containers[i].slotName);
            }
            for (int i = 0; i < this.Containers.Count; i++)
            {
                StreamHelpers.WriteValueU32(output, this.Containers[i].boneName);
            }
            for (int i = 0; i < this.Containers.Count; i++)
            {
                StreamHelpers.WriteValueU32(output, this.Containers[i].flags);
            }
            for (int i = 0; i < this.Containers.Count; i++)
            {
                this.Containers[i].matrix.Save(output);
            }
            if (this.Containers.Count > 0)
            {
                StreamHelpers.WriteValueU32(output, 0);
            }

            // Effects
            for (int i = 0; i < this.Effects.Count; i++)
            {
                StreamHelpers.WriteValueU32(output, this.Effects[i].slotName);
            }
            for (int i = 0; i < this.Effects.Count; i++)
            {
                StreamHelpers.WriteValueU32(output, this.Effects[i].boneName);
            }
            for (int i = 0; i < this.Effects.Count; i++)
            {
                this.Effects[i].matrix.Save(output);
            }
            if (this.Effects.Count > 0)
            {
                StreamHelpers.WriteValueU32(output, 0);
            }

            // IK Targets
            for (int i = 0; i < this.IKTargets.Count; i++)
            {
                StreamHelpers.WriteValueU32(output, this.IKTargets[i].slotName);
            }
            for (int i = 0; i < this.IKTargets.Count; i++)
            {
                StreamHelpers.WriteValueU32(output, this.IKTargets[i].boneName);
            }
            for (int i = 0; i < this.IKTargets.Count; i++)
            {
                this.IKTargets[i].matrix.Save(output);
            }
            if (this.IKTargets.Count > 0)
            {
                StreamHelpers.WriteValueU32(output, 0);
            }

            long chunkSize = output.Position - startOfChunk;

            this.offsize.size = (uint)chunkSize;
        }
Exemplo n.º 3
0
        public void Save(Stream output)
        {
            this.offSize.offset = (uint)output.Position;

            StreamHelpers.WriteStringASCII(output, this.magic);
            StreamHelpers.WriteValueU32(output, this.version);

            StreamHelpers.WriteValueU32(output, 0);
            StreamHelpers.WriteValueU32(output, 0);

            StreamHelpers.WriteValueU32(output, this.embeddedId);
            if (this.embeddedId != 0)
            {
                StreamHelpers.WriteValueU32(output, 0);
                this.mtnfChunk.Save(output);

                output.Seek(this.mtnfChunk.offSize.offset - 4, SeekOrigin.Begin);
                StreamHelpers.WriteValueU32(output, this.mtnfChunk.offSize.size);
                output.Seek(this.mtnfChunk.offSize.offset + this.mtnfChunk.offSize.size, SeekOrigin.Begin);
            }

            StreamHelpers.WriteValueU32(output, this.unk1);
            StreamHelpers.WriteValueU32(output, this.unk2);

            StreamHelpers.WriteValueU32(output, (uint)this.vertices.Count);
            StreamHelpers.WriteValueU32(output, (uint)this.vertexFormats.Count);
            for (int i = 0; i < this.vertexFormats.Count; i++)
            {
                this.vertexFormats[i].Save(output);
            }

            for (int i = 0; i < this.vertices.Count; i++)
            {
                for (int j = 0; j < this.vertexFormats.Count; j++)
                {
                    SimGeomVertexFormat vf = this.vertexFormats[j];
                    switch (vf.dataType)
                    {
                    case 1:
                        this.vertices[i].Save(output);
                        break;

                    case 2:
                        this.normals[i].Save(output);
                        break;

                    case 3:
                        this.uvs[i].Save(output);
                        break;

                    case 4:
                        StreamHelpers.WriteValueU32(output, this.bones[i]);
                        break;

                    case 5:
                        this.weights[i].Save(output);
                        break;

                    case 6:
                        this.tangentNormals[i].Save(output);
                        break;

                    case 7:
                        StreamHelpers.WriteValueU32(output, this.tagVals[i]);
                        break;

                    case 10:
                        StreamHelpers.WriteValueU32(output, this.vertexIds[i]);
                        break;
                    }
                }
            }

            StreamHelpers.WriteValueU32(output, this.faceFormatItemCount);
            StreamHelpers.WriteValueU8(output, this.faceFormatBytesPerFacePoint);

            StreamHelpers.WriteValueU32(output, (uint)(this.faces.Count * 3));
            for (int i = 0; i < this.faces.Count; i++)
            {
                switch (this.faceFormatBytesPerFacePoint)
                {
                case 2:
                    this.faces[i].Save(output);
                    break;
                }
            }

            StreamHelpers.WriteValueU32(output, this.flags);
            StreamHelpers.WriteValueU32(output, (uint)this.boneHashes.Count);
            for (int i = 0; i < this.boneHashes.Count; i++)
            {
                StreamHelpers.WriteValueU32(output, this.boneHashes[i]);
            }

            this.keytable.offset = (uint)(output.Position - this.offSize.offset) - 12;
            this.keytable.size   = 0;
            this.keytable.Save(output);

            this.offSize.size = (uint)(output.Position - this.offSize.offset);

            output.Seek(this.offSize.offset + 8, SeekOrigin.Begin);
            StreamHelpers.WriteValueU32(output, this.keytable.offset);
            StreamHelpers.WriteValueU32(output, this.keytable.size);

            output.Seek(this.offSize.offset + this.offSize.size, SeekOrigin.Begin);
        }