Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
blob: 78ad5e4663ff063c20207cb77f0f01cd1d36e13d (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
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
/*
   model/classes.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_PARTS_H__
#define __INCLUDED_MODEL_PARTS_H__

#include "math/axis.h"
#include "math/color.h"
#include "math/vector3f.h"

namespace model
{

/* ---- globals ---------------------------------------------------- */

// FIXME this should end up in material.h

/**
 * @brief
 * culling parameter values
 * Culling is a paremeter used by flares and particles to indicate
 * with side of the polygons should be culled during rendering
 */
enum Cull { CullNone=0, CullBack=1, CullFront=2 };

/* ---- class Part ------------------------------------------------- */

/**
 * @brief a special part of a model
 */
class Part
{
public:
	/**
	 * @brief default constructor
	 */
	inline Part() : part_location()
	{
	}

	/**
	 * @brief constructor with location
	 */
	inline Part(const math::Vector3f &location) : part_location(location)
	{
	}

	/* ---- inspectors ----------------------------------------- */

	/**
	 * @brief location of this part within the parent model
	 */
	inline const math::Vector3f &location() const
	{
		return part_location;
	}

	/* ---- mutators ------------------------------------------- */
	/**
	 * @brief set the location within the parent model
	 */
	inline void set_location(const math::Vector3f location) { part_location.assign(location); }

	/**
	 * @brief set the location within the parent model
	 */
	inline void set_location(const float x, const float y, const float z) { part_location.assign(x, y, z); }

	/* ---- actors --------------------------------------------- */

	/**
	 * @brief mutable reference to the location of this part within the parent model
	 */
	inline math::Vector3f &get_location()
	{
		return part_location;
	}	

private:
	math::Vector3f		part_location;
};

/* ---- class Light ------------------------------------------------ */

/// an exterior light
class Light : public Part
{
public:
	/**
	 * @brief default constructor
	 */
	Light();

	/**
	 * @brief destructor
	 */
	~Light();
	
	/* ---- inspectors ----------------------------------------- */

	/// light color
	inline const math::Color & color() const
	{
		return light_color;
	};
	
	/// true if this is a strobe light
	inline bool strobe() const
	{
		return light_strobe;
	}
	
	/// true if this light has entity color
	inline bool entity() const
	{
		return light_entity;
	}

	/// true if this light has engine activation
	inline const bool engine() const
	{
		return light_engine;
	}
	
	/// size of the light, default is 1.0f
	inline float radius() const
	{
		return light_radius;
	}
	
	/// strobe time offset, in seconds
	inline float offset() const
	{
		return light_offset;
	}
	
	/// frequency in strobes per second
	inline float frequency() const
	{
		return light_frequency;
	}
	
	/// fraction a strobe light will be on, default is 0.5f
	inline float time() const
	{
		return light_time;
	}
	
	/// flare texture number
	inline unsigned int flare() const
	{
		return light_flare;
	}
	
	/// render texture number
	inline size_t texture() const
	{
		return render_texture;
	}
	/* ---- mutators ------------------------------------------- */

	/// set strobe on or off
	inline void set_strobe(bool strobe) { light_strobe = strobe; }

	/**
	 * @brief set entity color on or off
	 */
	inline void set_entity(bool entity) { light_entity = entity; }

	/**
	 * @brief set engine activation on or off
	 */
	inline void set_engine(bool engine) { light_engine = engine; }


	math::Color		light_color;
	float			light_radius;
	float			light_frequency;
	float			light_offset;
	float			light_time;

	unsigned int		light_flare;

	size_t			render_texture;

private:
	bool			light_strobe;
	bool			light_engine;
	bool			light_entity;
};

/* ---- class Flare ------------------------------------------------ */

/// a flare is a directional light
class Flare : public Light
{
public:
	Flare();

	~Flare();
	
	/* ---- inspectors ----------------------------------------- */

	inline const math::Axis axis() const
	{
		return flare_axis;
	}
	
	inline const Cull cull() const
	{
		return flare_cull;
	}

	/* ---- mutators ------------------------------------------- */
	
	inline void set_cull(const Cull cull) { flare_cull = cull; }

	/* ---- actors --------------------------------------------- */

	/**
	 * @brief mutable reference to the axis
	 */
	inline math::Axis &get_axis() { return flare_axis; }

private:
	math::Axis		flare_axis;
	Cull			flare_cull;
};

/* ---- class Particles -------------------------------------------- */

/// a particle system
class Particles : public Part
{
public:
	Particles();
	Particles(const math::Vector3f & location);
	~Particles();
	
	inline const math::Axis &axis() const
	{
		return particles_axis;
	}
	
	inline const std::string & script() const
	{
		return particles_script;
	}

	inline const bool entity() const
	{
		return particles_entity;
	}

	inline const bool engine() const
	{
		return particles_engine;
	}
	
	inline const float radius() const
	{
		return particles_radius;
	}

	inline const Cull cull() const
	{
		return particles_cull;
	}

	/* ---- mutators ------------------------------------------- */

	/**
	 * @brief set entity color on or off
	 */
	inline void set_entity(const bool entity) { particles_entity = entity; }

	/**
	 * @brief set engine activation on or off
	 */
	inline void set_engine(const bool engine) { particles_engine = engine; }

	inline void set_radius(const float radius) { particles_radius = radius;	}

	inline void set_cull(const Cull cull) { particles_cull = cull; }
	
	/* ---- actors --------------------------------------------- */

	/**
	 * @brief mutable reference to the axis
	 */
	inline math::Axis &get_axis() { return particles_axis; }

	std::string		particles_script;

private:
	math::Axis		particles_axis;	
	float			particles_radius;
	bool			particles_entity;
	bool			particles_engine;
	Cull			particles_cull;
};

/* ---- class Dock ------------------------------------------------- */

/// a docking location
class Dock
{
public:
	Dock();
	~Dock();
	
	/// location of the dock
	inline const math::Vector3f & location() const
	{
		return dock_location;
	}
	
	/// trigger distance default is 0.01f
	inline float radius() const
	{
		return dock_radius;
	}
	
	
	math::Vector3f		dock_location;
	float			dock_radius;
};

/* ---- class SubModel --------------------------------------------- */

/// a submodel
class SubModel
{
public:
	SubModel();
	~SubModel();

	inline const std::string &name() const { return submodel_name; }

	inline const float scale() const { return submodel_scale; }

	inline const math::Vector3f &location() const { return submodel_location; }

	inline math::Axis &axis() { return submodel_axis; }

	inline void set_scale(const float scale) { submodel_scale = scale; }

	inline void set_name(const std::string &name) { submodel_name.assign(name); }

	inline void set_location(const math::Vector3f &location) { submodel_location.assign(location); }

	inline void set_axis(const math::Axis &axis) { submodel_axis.assign(axis); }

private:
	std::string		submodel_name;
	float			submodel_scale;
	math::Vector3f		submodel_location;
	math::Axis		submodel_axis;
};

}

#endif // __INCLUDED_MODEL_PARTS_H__