void Shape::init(VertexList& vertexList, FaceList& faceList, STLVectorf& UVList) { setVertexList(vertexList); setFaceList(faceList); setUVCoord(UVList); color_list.resize(vertex_list.size(), 0.5); std::cout<<"Building face adjacent list...\n"; buildFaceAdj(); std::cout<<"Building 1-ring neighbors list...\n"; buildVertexShareFaces(); std::cout<<"Building vertex adjacent list...\n"; buildVertexAdj(); std::cout << "Building edge connectivity...\n"; computeEdgeConnectivity(); std::cout<<"Computing bounding box...\n"; computeBounds(); std::cout<<"Computing face normals...\n"; computeFaceNormal(); computeVertexNormal(); buildKDTree(); }
void Shape::updateShape(VertexList& new_vertex_list) { vertex_list = new_vertex_list; computeFaceNormal(); computeVertexNormal(); computeBounds(); buildKDTree(); }
void Disk::calculateNormals() { std::vector<glm::vec3> vertices; for (auto& p : points) { vertices.emplace_back(p); } std::vector<int> ind; for (auto& i : indices) { ind.emplace_back(i); } for (size_t i = 0;i < points.size();i++) { std::vector<glm::vec3> normalsVec = getAdjacentTriangleNormals(i, vertices, ind); normals[i] = computeVertexNormal(normalsVec); //printf("%llu: %f,%f,%f\n",i,normals[i][0],normals[i][1],normals[i][2]); normalsVec.clear(); } }