Project::OSiRiON - Git repositories
Project::OSiRiON
News . About . Screenshots . Downloads . Forum . Wiki . Tracker . Git
summaryrefslogtreecommitdiff
blob: 5be7576ca846fb4727fda24d5db8a5fd8cc20ecb (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
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
/*
   model/tags.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_TAGS_H__
#define __INCLUDED_MODEL_TAGS_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 Tag -------------------------------------------------- */

/**
 * @brief a location tag
 * A location tag provides an anchor point for model extenions 
 * like lights, flares and sounds.
 * */

class Tag
{
public:
	/**
	 * @brief default constructor
	 * */
	Tag();

	/**
	 * @brief copy constructor
	 * */
	Tag(const Tag& other);

	/**
	 * @brief default destructor
	 * */
	~Tag();

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

	/**
	 * @brief location of this part within the parent model
	 * */
	inline const math::Vector3f& location() const
	{
		return tag_location;
	}
	
	/**
	 * @brief tag info text
	 * */
	inline const std::string & info() const
	{
		return tag_info;
	}

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

	/**
	 * @brief set the location within the parent model
	 * */
	inline void set_location(const float x, const float y, const float z)
	{
		tag_location.assign(x, y, z);
	}
	
	/**
	 * @brief set the info text
	 * */
	inline void set_info(const std::string &text)
	{
		tag_info.assign(text);
	}

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

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

private:
	math::Vector3f		tag_location;
	std::string		tag_info;
};

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

/**
 * @brief an exterior light
 * a tag used to attach exterior lights
 */
class Light : public Tag
{
public:
	/**
	 * @brief default constructor
	 * */
	Light();

	/**
	 * @brief copy constructor
	 * */
	Light(const Light& other);

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

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

	/**
	 * @brief light color
	 * */
	inline const math::Color& color() const
	{
		return light_color;
	}
	
	/**
	 * @brief true if the color was set
	 * */
	inline bool has_color() const
	{
		return light_has_color;
	}

	/**
	 * @brief true if this is a strobe light
	 * */
	inline bool strobe() const
	{
		return light_strobe;
	}

	/**
	 * @brief true if this light has entity primary color
	 * */
	inline bool entity() const
	{
		return light_entity;
	}
	
	/**
	 * @brief true if this light has entity secondary color
	 * */
	inline bool entity_second() const
	{
		return light_entity_second;
	}

	/**
	 * @brief true if this light has engine activation
	 * The light's intensity will vary depedning on entity thrust,
	 * */
	inline bool engine() const
	{
		return light_engine;
	}

	/**
	 * @brief size of the light, default is 1.0f
	 * */
	inline float radius() const
	{
		return light_radius;
	}

	/**
	 * @brief strobe time offset, in seconds
	 * */
	inline float offset() const
	{
		return light_offset;
	}

	/**
	 * @brief strobe frequency in strobes per second, default is 1.0f
	 * */
	inline float frequency() const
	{
		return light_frequency;
	}

	/**
	 * @brief fraction a strobe light will be on, default is 0.5f
	 * */
	inline float time() const
	{
		return light_time;
	}

	/**
	 * @brief flare texture number
	 * */
	inline unsigned int flare() const
	{
		return light_flare;
	}

	/**
	 * @brief render texture id
	 * */
	inline size_t texture() const
	{
		return light_texture;
	}
	/* ---- mutators ------------------------------------------- */

	/**
	 * @brief set the light color
	 * light color overrides engine color if the engine flag is set
	 * @see engine()
	 */
	inline void set_color(const math::Color& color) {
		light_color.assign(color);
		light_has_color = true;
	}

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

	/**
	 * @brief set entity prinary color on or off
	 * */
	inline void set_entity(const bool entity)
	{
		light_entity = entity;
	}
	
	/**
	 * @brief set entity secondary color on or off
	 * */
	inline void set_entity_second(const bool entity_second)
	{
		light_entity_second = entity_second;
	}

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

	/**
	 * @brief set the light radius
	 * */
	inline void set_radius(const float radius)
	{
		light_radius = radius;
	}

	/**
	 * @brief set the light strobe frequency, in strobes per second
	 * */
	inline void set_frequency(const float frequency)
	{
		light_frequency = frequency;
	}

	/**
	 * @brief set the light on time, from 0.0 (always off) to 1.0 (always on)
	 * */
	inline void set_time(const float time)
	{
		light_time = time;
	}

	/**
	 * @brief set the light strobe time offset, in seconds
	 * */
	inline void set_offset(const float offset)
	{
		light_offset = offset;
	}

	/**
	 * @brief set the flare texture number
	 * */
	inline void set_flare(unsigned int flare)
	{
		light_flare = flare;
	}

	/**
	 * @brief set the render texture id
	 * */
	inline void set_texture(size_t texture)
	{
		light_texture = texture;
	}
	
private:
	bool			light_strobe;
	bool			light_engine;
	bool			light_entity;
	bool			light_entity_second;

	unsigned int		light_flare;

	float			light_radius;
	float			light_frequency;
	float			light_offset;
	float			light_time;

	math::Color		light_color;
	bool			light_has_color;

	size_t			light_texture;
};

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

/**
 * @brief a directional light
 */
class Flare : public Light
{
public:
	Flare();

	/**
	 * @brief copy constructor
	 */
	Flare(const Flare& other);

	~Flare();

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

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

	inline 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:
	Cull			flare_cull;
	math::Axis		flare_axis;
};

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

/**
 * @brief a particle system
 * */
class Particles : public Tag
{
public:
	/**
	 * @brief default constructor
	 * */
	Particles();

	/**
	 * @brief copy constructor
	 * */
	Particles(const Particles & other);

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

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

	/**
	 * @brief name of the script to load
	 * */
	inline const std::string&  script() const
	{
		return particles_script;
	}

	/**
	 * @brief if true, the particle system has entity primary color
	 * */
	inline bool entity() const
	{
		return particles_entity;
	}
	
	/**
	 * @brief if true, the particle system has entity secondary color
	 * */
	inline bool entity_second() const
	{
		return particles_entity_second;
	}

	inline bool engine() const
	{
		return particles_engine;
	}
	
	inline const math::Color & color() const
	{
		return particles_color;
	}
	
	/**
	 * @brief true if the color was set
	 * */
	inline bool has_color() const
	{
		return particles_has_color;
	}

	inline float scale() const
	{
		return particles_scale;
	}

	inline Cull cull() const
	{
		return particles_cull;
	}

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

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

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

	inline void set_cull(const Cull cull)
	{
		particles_cull = cull;
	}

	inline void set_script(const std::string& script)
	{
		particles_script.assign(script);
	}
	
	inline void set_scale(const float scale)
	{
		particles_scale = scale;
	}
	
	inline void set_color(const math::Color &color)
	{
		particles_color.assign(color);
		particles_has_color = true;
	}	

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

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

private:
	bool			particles_entity;
	bool			particles_entity_second;
	bool			particles_engine;
	bool			particles_has_color;

	Cull			particles_cull;

	float			particles_scale;
	
	math::Color		particles_color;
	math::Axis		particles_axis;
	std::string		particles_script;
};

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

/// a docking location tag
class Dock : public Tag
{
public:
	/**
	 * @brief default constructor
	 * */
	Dock();

	/**
	 * @brief copy constructor
	 * */
	Dock(const Dock& other);

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

	/**
	 * @brief dock radius, default is 0.01f
	 * */
	inline float radius() const
	{
		return dock_radius;
	}

	inline const math::Axis &axis() const
	{
		return dock_axis;
	}
	
	/* ---- mutators ------------------------------------------- */

	/**
	 * @brief set dock radius
	 * */
	inline void set_radius(const float radius)
	{
		dock_radius = radius;
	}

	/**
	 * @brief set dock axis
	 * */
	inline void set_axis(const math::Axis& axis)
	{
		dock_axis.assign(axis);
	}

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

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

private:
	float			dock_radius;
	math::Axis		dock_axis;
};

/* ---- class Sound ------------------------------------------------ */

/**
 * @brief a sound location tag
 */
class Sound : public Tag
{
public:
	Sound();

	Sound(const Sound& other);

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

	/**
	 * @brief name of the sound sample
	 * */
	inline const std::string& name() const
	{
		return sound_name;
	}

	/* ---- mutators ------------------------------------------- */
	
	/**
	 * @brief set the name name of the sound sample
	 * */
	inline void set_name(const std::string& name)
	{
		sound_name.assign(name);
	}	
private:
	std::string		sound_name;
};

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

/**
 * @brief a submodel tag
 */
class SubModel : public Tag
{
public:
	SubModel();

	SubModel(const SubModel& other);

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

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

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

	inline float scale() const
	{
		return submodel_scale;
	}
	
	/* ---- mutators ------------------------------------------- */

	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_axis(const math::Axis& axis) {
		submodel_axis.assign(axis);
	}

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

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

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

/* ---- class Weapon ----------------------------------------------- */

/**
 * @brief a weapon slot tag
 * */
class Weapon : public Tag
{
public:
	enum Type {Unmountable = 0, Cannon = 1, Turret = 2 };
	
	/**
	 * @brief default constructor
	 * */
	Weapon(const Type type = Cannon);

	/**
	 * @brief copy constructor
	 * */
	Weapon(const Weapon& other);

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

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

	/**
	 * @brief weapon fire cone, in degrees
	 * */
	inline float cone() const
	{
		return weapon_cone;
	}
	
	/**
	 * @brief weapon slot type
	 * */
	inline const Type type() const
	{
		return weapon_type;
	}
	
	/* ---- mutators ------------------------------------------- */

	/**
	 * @brief set weapon fire cone, in degrees
	 * */
	inline void set_cone(const float cone)
	{
		weapon_cone = cone;
	}

	/**
	 * @brief set weapon slot axis
	 * */
	inline void set_axis(const math::Axis& axis)
	{
		weapon_axis.assign(axis);
	}
	
	/**
	 * @brief set weapon slot type
	 * */
;	void set_type(const Type type);

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

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

private:
	Type			weapon_type;
	math::Axis		weapon_axis;
	float			weapon_cone;
};


}

#endif // __INCLUDED_MODEL_TAGS_H__