Beispiel #1
0
bool Face::isPlanar() {
	float e = 0.01;
	glm::vec3 norm;
	float thisNorm;
	HalfEdge* he = first;
	while (true) {
		norm = he->getNormAtVert();
		thisNorm = glm::dot(*he->next->v->xyz, norm);
		if (thisNorm < -e || thisNorm > e) {
			return false;
		}
		he = he->next;
		if (he == first) {
			break;
		}
	}
	return true;
}
Beispiel #2
0
	void Mesh::generateNormArray() {
		if (normals != NULL) {
			delete normals;
			normals = 0;
		}
		normals = new float[getTotalVerts() * 4];
		int j = 0;
		HalfEdge* he = NULL;
		float* normX;
		float* normY;
		float* normZ;
		float* normH;
		Vertex* v;
		glm::vec3 norm;
		for (int i = 0; i < faces->size(); i++) {
			he = faces->at(i)->first;
			v = he->v;
			while (true) {
				norm = he->getNormAtVert();
				normX = new float(norm.x);
				normals[j] = *normX;
				delete normX;
				j++;
				normY = new float(norm.y);
				normals[j] = *normY;
				delete normY;
				j++;
				normZ = new float(norm.z);
				normals[j] = *normZ;
				delete normZ;
				j++;
				normH = new float(0.0f);
				normals[j] = *normH;
				delete normH;
				j++;
				he = he->next;
				if (he == faces->at(i)->first) {
					break;
				}
			}
		}
	}