-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEntity.h
174 lines (147 loc) · 4.47 KB
/
Entity.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
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
/*
* CUDARadiosity 0.87a
* Copyright 2012 by David Sargeant, Patrick Gradie, Michael Rogers
*
* Based on code from rrv (Radiosity Renderer and Visualizer) by TODO
* Distributed under GPL (see <http://www.gnu.org/licenses/>)
*
*/
#ifndef ENTITY_H
#define ENTITY_H
/**
* @file Entity.h
* @brief Abstract class Entity - wrapper around TriangleSet performing its (de)serialization.
* @author xdudka00, xfilak01
* @date 2007-11-17
*/
#include <string>
#include "XMLWrapper.h"
#include "TriangleSet.h"
#include "TransformMatrix.h"
#ifndef BUILDING_DOX
class TransformMatrix;
class PatchSequenceEnumerator;
class TriangleSetExt;
#endif
/**
* @brief Wrapper around TriangleSet performing its (de)serialization.
*/
class Entity
{
public:
Entity();
virtual ~Entity();
/**
* @brief Deep copy
*/
Entity(const Entity&);
/**
* @brief Deep copy
*/
Entity& operator=(const Entity&);
/**
* @brief Create a instantiate of special entity class.
* @param from XMLNode containing entity declaration.
* @return entity created from XMLNode
*/
static Entity* create (XMLNode *from );
/**
* @brief Set transofrmation matrix.
* @attention Calling this method after deserialize has no effect.
* @param matrix Transformation matrix to set. There is no need to keep it
* in memory after call of this method.
*/
void setTransformMatrix (TransformMatrix *matrix);
/**
* @brief Entity deserialization from XMLNode.
* @attention this method is unimlemented in this class
* @param from XMLNode which contains entity declaration
*/
void deserialize (XMLNode *from);
/**
* @brief Perform patch division.
* @param size Size of the largest acceptable patch.
*/
void divide (float size);
/**
* @brief Create enumerator for entity's patches.
* @return Return instance of PatchSequenceEnumerator allocated on the heap.
*/
PatchSequenceEnumerator* createPatchSequenceEnumerator ( );
/**
* @brief Compute per-vertex colors using simple interpolation.
* @return Return instance of TriangleSetExt allocated on the heap.
*/
TriangleSetExt* computeVertexColors();
/**
* @brief Entity serialization to XMLNode.
* @return XMLNode wich is representation of entity.
*/
XMLNode serialize ( );
/**
* @brief All entities in input file can have explicit name. And this method set it.
* @param from XMLNode wich contains entity declaration.
* @param implicit name when in xml doesn't exist
*/
void setName( XMLNode* from, const char* implicit="entity");
/**
* @brief Set entity name
* @param name of entity
*/
void setName( std::string name ) { this->name_ = name; }
/**
* @brief Get name of entity
* @return Name of entity
*/
std::string& getName() { return this->name_; }
/**
* @brief Read color value from attribute of XMLNode and create its object representation
* @param from XMLnode with attribute contains color value
* @param attName name of attribute with color
* @param to reference of object to store value
* @param wlevel is warnings level
* @return treu if color is succesfuly read and stored
*/
#ifndef NDEBUG
static bool colorFromXMLNode( XMLNode* from, XMLCSTR attName, Color& to, int wlevel=2 );
#else
static bool colorFromXMLNode( XMLNode* from, XMLCSTR attName, Color& to );
#endif
protected:
/**
* @brief Add triangle to entity using tranformation matrix.
* @param triangle Triangle to add.
*/
void addTriangle( Triangle *triangle );
/**
* @brief Set protperties to from entity properties.
* @param triangle Updated triangle.
*/
void setTriangleProperties( Triangle& triangle );
/**
* @brief Read three colors from XMLnode from specified attributs and ctore its valeus
* @param from XMLNode containing entity declaration.
* @param em Emmision color value
* @param refl Reflectiovity color value
* @param rad Radiosity color value
*/
static void setColors( XMLNode* from, Color& em, Color& refl, Color& rad );
/**
* @brief Entity deserialization from XMLNode.
* @attention this method is unimlemented in this class
* @param from XMLNode which contains entity declaration
*/
virtual void impl_deserialize (XMLNode *from);
Color reflectivity_;
Color emission_;
Color radiosity_;
double spec_;
double refl_;
double refr_;
private:
TransformMatrix transformMatrix_;
TriangleSet triangleSet_;
TriangleSet *patchSet_;
std::string name_;
};
#endif // ENTITY_H