public glTF RecursivelyAddChilren(glTF gltf, Va3cObject obj, int parentIndex) { foreach (var child in obj.children) { glTFNode childNode = new glTFNode(); childNode.name = child.name; foreach (double coord in child.matrix) { childNode.matrix.Add((float)coord); } int childIndex = gltf.AddChildNode(childNode, parentIndex); if (child.geometry != null) { Va3cGeometry geom = _geometries[child.geometry]; // make an accessor, buffer, and bufferView glTFBinaryData dataContainer = gltf.AddGeometryMeta(geom, child.uuid); binaryFileData.Add(dataContainer); // add geometry to meshes array glTFMesh mesh = new glTFMesh(); glTFMeshPrimitive primative = new glTFMeshPrimitive(); primative.attributes.POSITION = dataContainer.vertexAccessorIndex; primative.attributes.NORMAL = dataContainer.normalsAccessorIndex; primative.indices = dataContainer.indexAccessorIndex; mesh.primitives = new List <glTFMeshPrimitive>() { primative }; int meshIndex = gltf.AddMesh(mesh); gltf.nodes[childIndex].mesh = meshIndex; } if (child.children != null && child.children.Count > 0) { return(RecursivelyAddChilren(gltf, child, childIndex)); } } return(gltf); }
public int AddMesh(glTFMesh mesh) { this.meshes.Add(mesh); return(this.meshes.Count - 1); }