Skip to content
Snippets Groups Projects
Commit aacd2217 authored by Bocska Karina's avatar Bocska Karina
Browse files

use normals as origin point

parent 057a1392
Branches
No related tags found
No related merge requests found
...@@ -52,6 +52,7 @@ inline void createTetrahedronModel(std::string plyFile) { ...@@ -52,6 +52,7 @@ inline void createTetrahedronModel(std::string plyFile) {
dist *= 0.2f; dist *= 0.2f;
int i = 1; int i = 1;
int vn_i = 1;
for (pcl::PointXYZRGB &pt : cloud->points) { for (pcl::PointXYZRGB &pt : cloud->points) {
std::vector<pcl::PointXYZ> vertex = std::vector<pcl::PointXYZ> vertex =
calculateTetrahedronVertices(dist, pt.x, pt.y, pt.z); calculateTetrahedronVertices(dist, pt.x, pt.y, pt.z);
...@@ -63,12 +64,22 @@ inline void createTetrahedronModel(std::string plyFile) { ...@@ -63,12 +64,22 @@ inline void createTetrahedronModel(std::string plyFile) {
<< std::endl; << std::endl;
} }
// write the original point coordinate as the vertex normal
fout << "vn " << pt.x << " " << pt.y << " " << pt.z << std::endl;
// write the faces // write the faces
fout << "f " << i << " " << i + 1 << " " << i + 2 << std::endl; std::string vn = "//" + std::to_string(vn_i);
fout << "f " << i << " " << i + 2 << " " << i + 3 << std::endl; fout << "f " << i << vn << " " << i + 1 << vn << " " << i + 2 << vn
fout << "f " << i << " " << i + 3 << " " << i + 1 << std::endl; << std::endl;
fout << "f " << i + 1 << " " << i + 3 << " " << i + 2 << std::endl; fout << "f " << i << vn << " " << i + 2 << vn << " " << i + 3 << vn
<< std::endl;
fout << "f " << i << vn << " " << i + 3 << vn << " " << i + 1 << vn
<< std::endl;
fout << "f " << i + 1 << vn << " " << i + 3 << vn << " " << i + 2 << vn
<< std::endl;
i += 4; i += 4;
vn_i++;
} }
fout.close(); fout.close();
......
No preview for this file type
Source diff could not be displayed: it is stored in LFS. Options to address this: view the blob.
File added
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment