geometry-central icon indicating copy to clipboard operation
geometry-central copied to clipboard

Tutorial to write the normals into obj or standard PLY.

Open fire opened this issue 3 years ago • 1 comments

How do you write the object vertex normals into a 3D format?

fire avatar Jun 05 '22 14:06 fire

In the function

void SimplePolygonMesh::writeMeshObj(std::ostream& out) inside geometry-central/src/surface/simple_polygon_mesh.cpp

add the vertex normal code below this section

  // Write vertices
  for (Vector3 p : vertexCoordinates) {
    out << "v " << p.x << " " << p.y << " " << p.z << std::endl;
  }

To add vertex normals you just need to do something like this

out << "vn " << p.xn << " " << p.yn << " " << p.zn << std::endl;

Here

  • p.xn - X Normal
  • p.yn - Y Normal
  • p.zn - Z Normal

The keyword vn is the keyword in obj for vertex normals

vijaiaeroastro avatar Oct 28 '22 18:10 vijaiaeroastro