private void AddComponentsToMesh(gltf.Mesh targetMesh, ShapeComponentIds osgGeom, int materialIndex) { gltf.MeshPrimitive thisPrimitive = new gltf.MeshPrimitive(); Dictionary <string, int> att = new Dictionary <string, int>(); att.Add("NORMAL", osgGeom.NormalsAccessorId); att.Add("POSITION", osgGeom.VerticesAccessorId); thisPrimitive.Attributes = att; thisPrimitive.Indices = osgGeom.IndicesAccessorId; thisPrimitive.Material = materialIndex; thisPrimitive.Mode = gltf.MeshPrimitive.ModeEnum.TRIANGLES; int initSize = targetMesh.Primitives != null ? targetMesh.Primitives.Length : 0; if (initSize == 0) { targetMesh.Primitives = new gltf.MeshPrimitive[] { thisPrimitive }; } else { var concat = targetMesh.Primitives.ToList(); concat.Add(thisPrimitive); targetMesh.Primitives = concat.ToArray(); } }
private ShapeComponentIds AddGeom(List <float> positions, List <int> indices, List <float> normals) { // indices ShapeComponentIds ret = new ShapeComponentIds(); ret.IndicesAccessorId = AddIndices(indices); ret.NormalsAccessorId = AddCoordinates(normals); ret.VerticesAccessorId = AddCoordinates(positions); return(ret); }