- Home /
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 http://wiki.unity3d.com/index.php/MeshSerializer 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?
To answer your last question: No. Unity doesn't support any dynamic model loading at runtime besides assetbundles. So to import obj or fbx files you need a custom importer that works at runtime. If you already have the mesh imported in Unity's $$anonymous$$esh format it would be better to either use AssetBundles or serialize the mesh yourself.
Answer by Bunny83 · Aug 21, 2018 at 11:56 AM
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.
Your answer
![](https://koobas.hobune.stream/wayback/20220612173221im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Serialize a mesh 1 Answer
Assigning SharedMesh is creating an unreferenced instance 0 Answers
Send a mesh filter data(640kb) via PUN/UNET/Any network continously 1 Answer
How to prevent editor to set the scene dirty if a script changes a mesh (@ExecuteInEditMode) 1 Answer
Generate a highpoly sphere with mesh collider procedurally 2 Answers