I'm working on some code to convert a 3d geometry from IFC to gltf/glb. One of the challenges I'm facing with this is that - IFC provides transformations for each primitive separately i.e., if I have a mesh (MeshA) which has 4 primitives, i'm getting a transformation matrix for each of the primitive. And once I construct MeshA using all these primitives, I would like to re-use this mesh in all other nodes where this mesh is referenced and apply a new transformation which I can retrieve from the respective mesh in IFC file.
Below is the available structure of Geometry from IFC File:
|Mesh 1||primitive A - TransformationA-1
primitive B - TransformationB-1
|Mesh 2||primitive A - TransformationA-2
primitive B - TransformationB-2
Below is the expected structure of geometry:
|Mesh 1||Primitive A + Primitive B|
|Node 1||Mesh 1||TransformationA-1 + TransformationB-1|
|Node 2||Mesh 1||TransformationA-2 + TransformationB-2|
What I have currently tried is to
- apply the transformations of each primitive on each of its respective Vertex & Normal arrays to get a new set of arrays with the actual location after applying the transformation.
- Then I add each primitive to a mesh and then add the mesh into a node
But I'm having to do this to each mesh and create new mesh - instead of referencing the existing mesh (because I don't know the transformation of the entire mesh) - which is increasing the output size significantly.
Can someone help me in understanding how to combine transformations of multiple primitives and apply it to a mesh?