blob: 31b7fcc46073a3b26ad20023385eb1ce2bcfa851 (
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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
/*
render/face.cc
This file is part of the Osirion project and is distributed under
the terms of the GNU General Public License version 2
*/
#include "render/face.h"
#include "render/gl.h"
namespace render {
Face::Face(math::Vector3f const & normal, math::Color const *color) :
face_normal(normal)
{
face_normal.normalize();
if (color)
face_color = new math::Color(*color);
else
face_color = 0;
}
Face::~Face()
{
for (std::vector<math::Vector3f *>::iterator it = face_vertex.begin(); it != face_vertex.end(); it++) {
delete (*it);
}
face_vertex.clear();
if (face_color)
delete face_color;
}
void Face::add_vertex(math::Vector3f const & vertex)
{
math::Vector3f *v = new math::Vector3f(vertex);
face_vertex.push_back(v);
}
void Face::draw()
{
//gl::begin(gl::LineLoop);
gl::begin(gl::Polygon);
gl::normal(face_normal); // face_normal already has unit lenght
for (std::vector<math::Vector3f *>::iterator it = face_vertex.begin(); it != face_vertex.end(); it++) {
gl::vertex(*(*it));
}
gl::end();
}
}
|