So I noticed that unity modifies obj vertices and faces(triangles) when i dragged my obj files into the scene, and I think what it does is duplicates every vertex that has more than one normals(connected with different faces) for rendering purpose, and… my question is, is there api in unity that resembles that procedure? because i need to create procedurally generated geometry and then call that api to optimize the mesh for rendering in unity. thanks.
If you’re generating geometry procedurally in Unity, you’re already optimizing it for rendering in Unity just by getting it to work at all. Although there is Mesh.Optimize(), but honestly I don’t use it because every time I tried it, it never made any actual difference in rendering speed. In any case, it doesn’t do what Unity does to imported models, which is a different thing. But if you generate a mesh and it looks the way you want it to, you don’t have to do anything else.
–Eric
Thanks for the answer, however, the way i generate the geometry doesnt look right when it is displayed in unity, because im using shared vertices instead of duplicate vertices for each face normal it is connected to, and I do that for a particular reason, that is, i have an external dll which does some algorithm to the mesh, and it requires geometry without duplicated vertices as in unity representation, so I need some sort of algorithm to alternate between those two mesh representations, Im trying to make one but still no luck… thats why im thinking of getting help from here
Im just curious what unity exactly does when I drag an obj file to the scene, and I need to make something resembles that function, and also, I noticed that unity somehow invert x coordinates…
sure that x coordinates are inverted? commonly its z, where this “inversion” comes from the fact that 3D systems can either be left handed or right handed and switching between them causes the z axis to invert.
As for model dragging into scene: unity has its own optimized mesh format, to which your asset is built when it is used within the project (assets not used are not used in the build). What this thought exactly does and does not to the mesh is something that likely only the devs can answer …
yeah i think it does invert the x coords, first because I tried myself, let me explain what exactly I did,…
-
I took a 3d model in obj format, dragged it into the scene, and then I obtained the mesh from the script, lets call this unity mesh.
-
I read the same 3d model using my own obj importer (i just read the vertices directly and the triangles) and pass this mesh to a dll , which put some values that need to be applied to each vertex in the mesh.
-
for each vertex in the 2nd mesh, I look for the corresponding vertex in the unity mesh and apply the values to the vertices.
and then I observed that the x values are inverted, so I inverted all the x coords before applying the values, and it works…
second, I just saw this in the unity wiki
http://www.unifycommunity.com/wiki/index.php?title=ObjExporter
and there is a comment saying that unity has inverted x-component (different coordinate system than everyone is used to)