add Normals to meshes
This commit is contained in:
@@ -60,5 +60,18 @@ void QuadMesh::AddQuad(const Vector4i &id)
|
||||
this->m_Quads.push_back(id);
|
||||
}
|
||||
|
||||
Vector3f QuadMesh::GetNormal(const Id_t id) const
|
||||
{
|
||||
const Vector4i &quad = m_Quads.at(id);
|
||||
const Vector3f &v0 = m_Points.at(quad(0));
|
||||
const Vector3f &v1 = m_Points.at(quad(1));
|
||||
const Vector3f &v3 = m_Points.at(quad(3));
|
||||
|
||||
Vector3f edge1 = v1 - v0;
|
||||
Vector3f edge2 = v3 - v0;
|
||||
|
||||
return edge1.cross(edge2).normalized();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user