blob: bf10a474fbea3bbe4b4dc8d2c588a0dbee1a30b3 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
// This code is in the public domain -- Ignacio Castaño <castano@gmail.com>
#include "TriMesh.h"
using namespace nv;
/// Triangle mesh.
Vector3 TriMesh::faceNormal(uint f) const
{
const Face & face = this->faceAt(f);
const Vector3 & p0 = this->vertexAt(face.v[0]).pos;
const Vector3 & p1 = this->vertexAt(face.v[1]).pos;
const Vector3 & p2 = this->vertexAt(face.v[2]).pos;
return normalizeSafe(cross(p1 - p0, p2 - p0), Vector3(0.0f), 0.0f);
}
/// Get face vertex.
const TriMesh::Vertex & TriMesh::faceVertex(uint f, uint v) const
{
nvDebugCheck(v < 3);
const Face & face = this->faceAt(f);
return this->vertexAt(face.v[v]);
}
|