Example #1
0
 protected override void WriteObject(AssetsWriter writer)
 {
     writer.Write(Name);
     //writer.Write(MeshData);
     writer.WriteArrayOf(SubMeshes, (o, w) => o.Write(w));
     BlendShapeData.Write(writer);
     writer.WriteArrayOf(BindPose, (o, w) => w.Write(o));
     writer.WriteArrayOf(BoneNameHashes, (o, w) => w.Write(o));
     writer.Write(RootBoneNameHash);
     writer.Write(MeshCompression);
     writer.Write(IsReadable);
     writer.Write(KeepVerticies);
     writer.Write(KeepIndicies);
     writer.AlignTo(4);
     writer.Write(IndexFormat);
     writer.WriteArray(IndexBuffer);
     writer.AlignTo(4);
     VertexData.Write(writer);
     CompressedMesh.Write(writer);
     LocalAABB.Write(writer);
     writer.Write(MeshUsageFlags);
     writer.WriteArray(BakedConvexCollisionMesh);
     writer.AlignTo(4);
     writer.WriteArray(BakedTriangleCollisionMesh);
     writer.AlignTo(4);
     writer.Write(MeshMetrics1);
     writer.Write(MeshMetrics2);
     StreamData.Write(writer);
 }
Example #2
0
 public void Write(AssetsWriter writer)
 {
     writer.Write(FirstByte);
     writer.Write(IndexCount);
     writer.Write(Topology);
     writer.Write(BaseVertex);
     writer.Write(FirstVertex);
     writer.Write(VertexCount);
     LocalAABB.Write(writer);
 }
Example #3
0
 public void Write(AssetWriter writer)
 {
     writer.Write((uint)FirstByte);
     writer.Write((uint)IndexCount);
     writer.Write((int)Topology);
     if (HasTriangleCount(writer.Version))
     {
         writer.Write(TriangleCount);
     }
     if (HasBaseVertex(writer.Version))
     {
         writer.Write((uint)BaseVertex);
     }
     if (HasVertex(writer.Version))
     {
         writer.Write((uint)FirstVertex);
         writer.Write((uint)VertexCount);
         LocalAABB.Write(writer);
     }
 }
Example #4
0
        public override void Write(AssetWriter writer)
        {
            base.Write(writer);

            if (HasLODData(writer.Version))
            {
                LODData.Write(writer);
            }
            else
            {
                if (HasUse16bitIndices(writer.Version))
                {
                    writer.Write(Use16BitIndices);
                }
                if (IsIndexBufferFirst(writer.Version))
                {
                    IndexBuffer.Write(writer);
                    writer.AlignStream(AlignType.Align4);
                }
                SubMeshes.Write(writer);
            }

            if (HasBlendShapes(writer.Version))
            {
                if (HasBlendChannels(writer.Version))
                {
                    Shapes.Write(writer);
                }
                else
                {
                    BlendShapes.Write(writer);
                    writer.AlignStream(AlignType.Align4);
                    ShapeVertices.Write(writer);
                }
            }
            if (HasBindPose(writer.Version))
            {
                if (IsBindPoseFirst(writer.Version))
                {
                    BindPose.Write(writer);
                }
            }
            if (HasBoneNameHashes(writer.Version))
            {
                BoneNameHashes.Write(writer);
                writer.Write(RootBoneNameHash);
            }
            if (HasBonesAABB(writer.Version))
            {
                BonesAABB.Write(writer);
                VariableBoneCountWeights.Write(writer);
            }

            if (HasMeshCompression(writer.Version))
            {
                writer.Write((byte)MeshCompression);
            }
            if (HasStreamCompression(writer.Version))
            {
                writer.Write(StreamCompression);
            }
            if (HasIsReadable(writer.Version))
            {
                writer.Write(IsReadable);
                writer.Write(KeepVertices);
                writer.Write(KeepIndices);
            }
            if (IsAlignFlags(writer.Version))
            {
                writer.AlignStream(AlignType.Align4);
            }

            if (HasIndexFormat(writer.Version))
            {
                if (IsIndexFormatCondition(writer.Version))
                {
                    if (MeshCompression == MeshCompression.Off)
                    {
                        writer.Write((int)IndexFormat);
                    }
                }
                else
                {
                    writer.Write((int)IndexFormat);
                }
            }

            if (!HasLODData(writer.Version))
            {
                if (!IsIndexBufferFirst(writer.Version))
                {
                    IndexBuffer.Write(writer);
                    writer.AlignStream(AlignType.Align4);
                }
            }

            if (HasVertexData(writer.Version))
            {
                if (!IsOnlyVertexData(writer.Version))
                {
                    if (MeshCompression != MeshCompression.Off)
                    {
                        Vertices.Write(writer);
                    }
                }
            }
            else
            {
                Vertices.Write(writer);
            }

            if (HasSkin(writer.Version))
            {
                Skin.Write(writer);
            }
            if (HasBindPose(writer.Version))
            {
                if (!IsBindPoseFirst(writer.Version))
                {
                    BindPose.Write(writer);
                }
            }

            if (HasVertexData(writer.Version))
            {
                if (IsOnlyVertexData(writer.Version))
                {
                    VertexData.Write(writer);
                }
                else
                {
                    if (MeshCompression == MeshCompression.Off)
                    {
                        VertexData.Write(writer);
                    }
                    else
                    {
                        UV.Write(writer);
                        UV1.Write(writer);
                        Tangents.Write(writer);
                        Normals.Write(writer);
                        Colors.Write(writer);
                    }
                }
            }
            else
            {
                UV.Write(writer);
                if (HasUV1(writer.Version))
                {
                    UV1.Write(writer);
                }
                if (HasTangentSpace(writer.Version))
                {
                    TangentSpace.Write(writer);
                }
                else
                {
                    Tangents.Write(writer);
                    Normals.Write(writer);
                }
            }
            if (IsAlignVertex(writer.Version))
            {
                writer.AlignStream(AlignType.Align4);
            }

            if (HasCompressedMesh(writer.Version))
            {
                CompressedMesh.Write(writer);
            }

            LocalAABB.Write(writer);
            if (!HasVertexData(writer.Version))
            {
                Colors.Write(writer);
            }
            if (HasCollisionTriangles(writer.Version))
            {
                CollisionTriangles.Write(writer);
                writer.Write(CollisionVertexCount);
            }
            if (HasMeshUsageFlags(writer.Version))
            {
                writer.Write(MeshUsageFlags);
            }

            if (HasCollision(writer.Version))
            {
                CollisionData.Write(writer);
            }
            if (HasMeshMetrics(writer.Version))
            {
                writer.Write(MeshMetrics[0]);
                writer.Write(MeshMetrics[1]);
            }
#if UNIVERSAL
            if (HasMeshOptimization(writer.Version, writer.Flags))
            {
                if (IsMeshOptimizationFlags(writer.Version))
                {
                    writer.Write((int)MeshOptimizationFlags);
                }
                else
                {
                    writer.Write(MeshOptimized);
                }
            }
#endif
            if (HasStreamData(writer.Version))
            {
                writer.AlignStream(AlignType.Align4);
                StreamData.Write(writer);
            }
        }