geometry-central
geometry-central copied to clipboard
Tutorial to write the normals into obj or standard PLY.
How do you write the object vertex normals into a 3D format?
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