Пример #1
0
        private void WriteAnimationClips(BinaryBlockWriter w)
        {
            var animClips = AnimData.Animations;

            if (animClips == null || animClips.Count == 0)
            {
                return;
            }

            w.StartBlock((byte)MeshDataType.ANIMATIONCLIPS);

            w.Write((ushort)animClips.Count);
            foreach (var clip in animClips)
            {
                w.Write(clip.Name);
                w.Write(clip.Duration);
                w.Write(clip.TicksPerSecond);
                w.Write((ushort)clip.Keys.Count);
                foreach (var key in clip.Keys)
                {
                    w.Write(key.Tick);
                    w.Write((ushort)key.BoneTransforms.Count);
                    foreach (var m in key.BoneTransforms)
                    {
                        w.Write(m);
                    }
                }
            }

            w.EndBlock();
        }
Пример #2
0
 private void WriteHeader(BinaryBlockWriter w)
 {
     w.StartBlock((byte)MeshDataType.HEADER);
     w.Write(MeshData.Name);
     w.Write(MeshData.VertexCount);
     w.Write(MeshData.IndexCount);
     w.EndBlock();
 }
Пример #3
0
        private void WritePositonData(BinaryBlockWriter w)
        {
            var positions = MeshData.VertexPositions;

            if (positions == null || positions.Count == 0)
            {
                return;
            }

            w.StartBlock((byte)MeshDataType.POSITIONS);
            foreach (var pos in positions)
            {
                w.Write(pos);
            }

            w.EndBlock();
        }
Пример #4
0
        private void WriteSkeletonData(BinaryBlockWriter w)
        {
            w.StartBlock((byte)MeshDataType.SKELETON);
            w.Write((ushort)AnimData.BoneCount);

            foreach (var bone in AnimData.Bones)
            {
                w.Write((ushort)bone.Index);
                w.Write(bone.Name);
                w.Write((short)bone.ParentIndex);
                w.Write(bone.OffsetMatrix);
                w.Write(bone.LocalMatrix);
                w.Write(bone.GlobalMatrix);
            }

            w.EndBlock();
        }
Пример #5
0
        private void WriteBlendWeights(BinaryBlockWriter w)
        {
            var blendWeights = AnimData.BlendWeights;

            if (blendWeights == null || blendWeights.Count == 0)
            {
                return;
            }

            w.StartBlock((byte)MeshDataType.BLENDWEIGHTS);
            foreach (var weight in blendWeights)
            {
                w.Write(weight);
            }

            w.EndBlock();
        }
Пример #6
0
        private void WriteBlendIndices(BinaryBlockWriter w)
        {
            var blendIndices = AnimData.BlendIndices;

            if (blendIndices == null || blendIndices.Count == 0)
            {
                return;
            }

            w.StartBlock((byte)MeshDataType.BLENDINDICES);
            foreach (var indices in blendIndices)
            {
                w.Write(indices);
            }

            w.EndBlock();
        }
Пример #7
0
        private void WriteTextcoordData(BinaryBlockWriter w)
        {
            var coords = MeshData.VertexTextureCoordinates;

            if (coords == null || coords.Count == 0)
            {
                return;
            }

            w.StartBlock((byte)MeshDataType.TEXCOORDS);
            foreach (var uv in coords)
            {
                w.Write(uv);
            }

            w.EndBlock();
        }
Пример #8
0
        private void WriteNormalData(BinaryBlockWriter w)
        {
            var normals = MeshData.VertexNormals;

            if (normals == null || normals.Count == 0)
            {
                return;
            }

            w.StartBlock((byte)MeshDataType.NORMALS);
            foreach (var normal in normals)
            {
                w.Write(normal);
            }

            w.EndBlock();
        }
Пример #9
0
        private void WriteIndexData(BinaryBlockWriter w)
        {
            var indices = MeshData.Indices;

            if (indices == null || indices.Count == 0)
            {
                return;
            }

            w.StartBlock((byte)MeshDataType.INDICES);
            foreach (var index in indices)
            {
                w.Write(index);
            }

            w.EndBlock();
        }