-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathdrawMesh.h
executable file
·44 lines (37 loc) · 980 Bytes
/
drawMesh.h
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#ifndef GLDRAW_DRAW_MESH_H
#define GLDRAW_DRAW_MESH_H
#include <KrisLibrary/meshing/TriMesh.h>
#include "GL.h"
#include "drawextra.h"
namespace GLDraw {
inline void DrawGLTris(const Meshing::TriMesh& mesh)
{
glBegin(GL_TRIANGLES);
for(size_t i=0;i<mesh.tris.size();i++) {
Math3D::Vector3 normal = mesh.TriangleNormal(i);
glNormal3v(normal);
glVertex3v(mesh.verts[mesh.tris[i].a]);
glVertex3v(mesh.verts[mesh.tris[i].b]);
glVertex3v(mesh.verts[mesh.tris[i].c]);
}
glEnd();
}
inline void DrawGLEdges(const Meshing::TriMesh& mesh)
{
for(size_t i=0;i<mesh.tris.size();i++) {
glBegin(GL_LINE_LOOP);
glVertex3v(mesh.verts[mesh.tris[i].a]);
glVertex3v(mesh.verts[mesh.tris[i].b]);
glVertex3v(mesh.verts[mesh.tris[i].c]);
glEnd();
}
}
inline void DrawGLVerts(const Meshing::TriMesh& mesh)
{
glBegin(GL_POINTS);
for(size_t i=0;i<mesh.verts.size();i++)
glVertex3v(mesh.verts[i]);
glEnd();
}
} //namespace GLDraw
#endif