blob: cbed101b878e3b2e3f6af5856db2da87cb731bc0 (
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
/*
model/face.h
This file is part of the Osirion project and is distributed under
the terms of the GNU General Public License version 2
*/
#ifndef __INCLUDED_MODEL_FACE_H__
#define __INCLUDED_MODEL_FACE_H__
#include <string>
#include "math/vector2f.h"
#include "math/vector3f.h"
#include "model/material.h"
namespace model
{
/** @brief A class representing the plane of a single model face
* all points p(x, y, z) on the plane satisfy the general equation
* x*a() + y*b() + z*c() + d() = 0
*/
class Face
{
public:
/// a plane defined by 3 points in space
Face(math::Vector3f const & point0, math::Vector3f const &point1, math::Vector3f const &point2);
/// copy constructor
Face(Face const & other);
/// normal of the plane, not normalized to lenght 1
inline math::Vector3f const & normal() const {
return face_normal;
}
/// the points defining the plane.
/// @param index 0 <= i < 3
inline math::Vector3f const & point(size_t index) const {
return face_point[index];
}
/// face material
inline Material *material() const {
return face_material;
}
/// first parameter of the general plane equation
inline float a() const {
return face_normal[0];
}
/// second parameter of the general plane equation
inline float b() const {
return face_normal[1];
}
/// third param of the general plane equation
inline float c() const {
return face_normal[2];
}
/// fourth parameter of the general plane equation
inline float d() const {
return pd;
}
/// indidcates if this plane was generated from a detail brush
inline bool detail() const {
return face_detail;
}
/// surface flags
inline unsigned int surface_flags() const {
return face_surface_flags;
}
/**
* @brief return texture transformation vectors
* @param index 0 <= i < 2
*/
inline const math::Vector3f &tex_vec(size_t index) {
return face_tex_vec[index];
}
/// return texture shift
inline const math::Vector2f &tex_shift() {
return face_tex_shift;
}
inline void set_material(Material *material) {
face_material = material;
}
inline void set_detail(const bool detail = true) {
face_detail = detail;
}
inline void set_surface_flags(const unsigned int flags) {
face_surface_flags = flags;
}
/**
* @brief return texture transformation vectors
* @param index 0 <= i < 2
*/
inline math::Vector3f &get_tex_vec(size_t index) {
return face_tex_vec[index];
}
/// return texture shift
inline math::Vector2f &get_tex_shift() {
return face_tex_shift;
}
private:
math::Vector3f face_normal;
math::Vector3f face_point[3];
math::Vector3f face_tex_vec[2];
math::Vector2f face_tex_shift;
Material *face_material;
unsigned int face_surface_flags;
bool face_detail;
float pd;
};
}
#endif // __INCLUDED_MODEL_FACE_H__
|