3d mesh serialize

Hi all,

I’m currently doing a project where we stream 3d model from another place.

Right now I’m planning to serialize the 3d mesh to send it over with the technique below
basically writing all the vertex, normal and triangle information in to the data file.

However this only works with a vertex and triangle count less than 65535 (shown in the code). Can someone explain to why is this?, and is there a way to store more than 65535 vertex.

Will it be better to just send over a obj or fbx file and import them real time?

Well in the past Unity has a fix index size of 16bit. This only allowed to index 65535 vertices. However Unity now allows you to change the index buffer format of a mesh. So when using a 32 bit index buffer it supports up to 4 billion vertices. The mesh serializer on the wiki is quite old and only supports rudimentary informations. A Mesh could have several submeshes, different mesh topologies per submesh. Also the vertex data could also contain several uv channels or vertex colors.

I’ve written a general purpose mesh serializer some time ago. It should be able to serialize any kind of mesh (including skinning information and blendshapes). However at the time i wrote it the 32 bit index buffer support wasn’t a thing yet. Though the serializer doesn’t care about how many vertices the mesh has. You probably need to set the index buffer format explicitly before deserializing if the mesh has more than 64k vertices.

If i find the time I’ll add this small change to the deserializer. The Mesh class now also supports up to 8 uv channels while in the past it only supported 4. So that’s another thing that need to be adjusted to guarantee that every mesh can be serialized / deserialized.