Continuing the discussion from Re-import only the mesh:
I have worked quite a bit with the model format recently, and thought I would provide some feedback on the current format of storing the mesh/material/model data. While I do not expect anything to come of it, when you next update the model format, remember this thread and maybe give it a read.
Currently the model format works, but it akward to do several things, particularly where generating and working with the data directly.
Good Points of Current Format
- Mesh data is stored separate to instance data allowing instanced meshes (keeping filesizes small)
- Instances have parenting, support different scales, rotations etc.
- Somewhat human readable
Things I would like improved (summary)
- The material data is separate to the instace, despite being logically related
- Things are heavily dependant on order - UV, mesh index, nodes
- Unnecessary/easily computed data
Material Data:
In the json file, there is:
'meshInstances':{
'node': ob_num,
'mesh': mesh_num
}
Then there is a whole separate file to say âthis meshInstance has this material.â In my mind it would be much more logical to simply do:
'meshInstances':{
'node': ob_num,
'mesh': mesh_num
'material':'path/to/material.json'
}
This reduces the filecount/number of http requests, and keeps logical data together. I guess why you separated it out is so that the model data only contains model data, not any material data at all. But I think these should be linked in the way described above.
Linking by Order vs Linking by Name
Currently the model format has a lot of lists and other order based things:
One example, the nodes:
'nodes': [
{
"name": "RootNode",
"position": [0, 0, 0],
"rotation": [0, 0, 0],
"scale": [1, 1, 1],
}, {
"name": "Object1",
"position": [0, 1, 0],
"rotation": [0, 90, 0],
"scale": [1, 1, 1],
},
]
And then in the meshinstances:
'meshInstances':{
'node': 1,
'mesh': 0
}
I would suggest:
'meshInstances':{
'node': 'NodeName',
'mesh': 'MeshName'
}
Yes, it takes more work to parse from within playcanvas (you have to extract the name and store in an associative array/object rather than just read it into a list), and it means nodes have to be uniquely named (which they are in every modelling software Iâve ever used), but it means that the file is more human readable and exporting to the format is easier. Neither of these are likely to be your priorities though.
The same goes for UVdata (currently stored as âtexCoord0â, âtexCoord1â Not even in a list but indexed by some ID rather than a name. Iâd do UVData:[{'name':'Lightmap', 'data':[]}, {}...]
. This one means that when using the same material for different meshes, the order UVData is stored is not important as it is referenced by name.
There are other things stored by implicit order (vertex positions, vertex normals, vertex colors) which I think are OK, but if they are things that may want to be dealt with on a higher level, I think they should be indexed by name.
Also, does a node ever have multiple meshes? I have never seen more than one meshinstance mapped to a node. Could the nodes list with the meshInstances list be combined?
Unnecessary Data
mesh:{
'aabb': {'min': minpos, 'max': maxpos},
'vertices': vertices,
'indices': indices,
'type': typ,
'base': base,
'count': count
}
âaabbâ can be calculated easily while parseing the json file
âtypâ never changes?
âbaseâ is always zero?
âcountâ is just the length of vertices divided by three. You donât ask for length of lists in other places.
In other places:
- âtypeâ: âfloat32â everywhere. Is anything else valid? (I do think âcomponentsâ is a good one to have in otherwise unstructured lists though)
- There is always a rootNode at zero position,rotation and 1 scale. This then is parented to -1. This doesnât seem to add any actual information that canât be assumed
Well, I hope that was interesting.
On a side note, some other questions: what languages/what is the current model conversion pipeline? Is their a summary of material format somwhere? How is animation data stored anyway?