MCPcopy Create free account
hub / github.com/RenderKit/embree / import

Method import

tutorials/common/scenegraph/ply_loader.cpp:289–324  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

287 }
288
289 Ref<SceneGraph::Node> import()
290 {
291 Ref<SceneGraph::MaterialNode> material = new OBJMaterial;
292 Ref<SceneGraph::TriangleMeshNode> mesh_o = new SceneGraph::TriangleMeshNode(material,BBox1f(0,1),1);
293
294 /* convert all vertices */
295 const Element& vertices = mesh.elements.at("vertex");
296 const std::vector<float>& posx = vertices.data.at("x");
297 const std::vector<float>& posy = vertices.data.at("y");
298 const std::vector<float>& posz = vertices.data.at("z");
299
300 mesh_o->positions[0].resize(vertices.size);
301 for (size_t i=0; i<vertices.size; i++) {
302 mesh_o->positions[0][i].x = posx[i];
303 mesh_o->positions[0][i].y = posy[i];
304 mesh_o->positions[0][i].z = posz[i];
305 }
306
307 /* convert all faces */
308 const Element& faces = mesh.elements.at("face");
309 const std::vector<std::vector<size_t> >& polygons = faces.list.at("vertex_indices");
310
311 for (size_t j=0; j<polygons.size(); j++)
312 {
313 const std::vector<size_t>& face = polygons[j];
314 if (face.size() < 3) continue;
315
316 /* triangulate the face with a triangle fan */
317 size_t i0 = face[0], i1 = 0, i2 = face[1];
318 for (size_t k=2; k<face.size(); k++) {
319 i1 = i2; i2 = face[k];
320 mesh_o->triangles.push_back(SceneGraph::TriangleMeshNode::Triangle((unsigned int)i0, (unsigned int)i1, (unsigned int)i2));
321 }
322 }
323 return mesh_o.dynamicCast<SceneGraph::Node>();
324 }
325 };
326
327 Ref<Node> loadPLY(const FileName& fileName) {

Callers

nothing calls this directly

Calls 5

TriangleClass · 0.70
atMethod · 0.45
resizeMethod · 0.45
sizeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected