1 | |
---|
2 | |
---|
3 | /* |
---|
4 | orxonox - the future of 3D-vertical-scrollers |
---|
5 | |
---|
6 | Copyright (C) 2004 orx |
---|
7 | |
---|
8 | This program is free software; you can redistribute it and/or modify |
---|
9 | it under the terms of the GNU General Public License as published by |
---|
10 | the Free Software Foundation; either version 2, or (at your option) |
---|
11 | any later version. |
---|
12 | |
---|
13 | ### File Specific: |
---|
14 | main-programmer: Patrick Boenzli |
---|
15 | */ |
---|
16 | |
---|
17 | #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_GRAPHICS |
---|
18 | |
---|
19 | #include "lense_flare.h" |
---|
20 | |
---|
21 | #include "load_param.h" |
---|
22 | #include "factory.h" |
---|
23 | |
---|
24 | #include "glincl.h" |
---|
25 | #include "texture.h" |
---|
26 | |
---|
27 | #include "light.h" |
---|
28 | |
---|
29 | #include "render2D/billboard.h" |
---|
30 | |
---|
31 | using namespace std; |
---|
32 | |
---|
33 | CREATE_FACTORY(LenseFlare, CL_LENSE_FLARE); |
---|
34 | |
---|
35 | |
---|
36 | |
---|
37 | /** |
---|
38 | * default constructor |
---|
39 | * @param root The XML-element to load the LenseFlare from |
---|
40 | */ |
---|
41 | LenseFlare::LenseFlare(const TiXmlElement* root) |
---|
42 | { |
---|
43 | if (root != NULL) |
---|
44 | this->loadParams(root); |
---|
45 | } |
---|
46 | |
---|
47 | |
---|
48 | /** |
---|
49 | * destroys a LenseFlare |
---|
50 | */ |
---|
51 | LenseFlare::~LenseFlare() |
---|
52 | { |
---|
53 | std::vector<Billboard*>::iterator it; |
---|
54 | for( it = flares.begin(); it != flares.end(); it++) |
---|
55 | delete (*it); |
---|
56 | } |
---|
57 | |
---|
58 | |
---|
59 | /** |
---|
60 | * @param root The XML-element to load the LenseFlare from |
---|
61 | */ |
---|
62 | void LenseFlare::loadParams(const TiXmlElement* root) |
---|
63 | { |
---|
64 | GraphicsEffect::loadParams(root); |
---|
65 | |
---|
66 | LoadParam(root, "add-flare-texture", this, LenseFlare, addFlare) |
---|
67 | .describe("adds a lensflare texture to the engine"); |
---|
68 | } |
---|
69 | |
---|
70 | |
---|
71 | /** |
---|
72 | * initializes the fog effect |
---|
73 | */ |
---|
74 | bool LenseFlare::init() |
---|
75 | {} |
---|
76 | |
---|
77 | |
---|
78 | /** |
---|
79 | * activates the fog effect |
---|
80 | */ |
---|
81 | bool LenseFlare::activate() |
---|
82 | { |
---|
83 | this->bActivated = true; |
---|
84 | } |
---|
85 | |
---|
86 | |
---|
87 | /** |
---|
88 | * deactivates the fog effect |
---|
89 | */ |
---|
90 | bool LenseFlare::deactivate() |
---|
91 | { |
---|
92 | this->bActivated = false; |
---|
93 | } |
---|
94 | |
---|
95 | |
---|
96 | /** |
---|
97 | * converts a gl mode char to a GLint |
---|
98 | * @param mode the mode character |
---|
99 | */ |
---|
100 | GLint LenseFlare::charToFogMode(const char* mode) |
---|
101 | {} |
---|
102 | |
---|
103 | |
---|
104 | /** |
---|
105 | * adds a texture flare |
---|
106 | * @param textureName the name of the flare texture |
---|
107 | * |
---|
108 | * 1st: Texture of the Sun/Light source itself |
---|
109 | * 2nd: Texture of the fist halo |
---|
110 | * 3rd: Texture of small burst |
---|
111 | * 4th: Texture of the second halo |
---|
112 | * 5th: Texutre of the second burst |
---|
113 | * 6th: Texture of the third halo |
---|
114 | * 7th: Texture of the third burst |
---|
115 | */ |
---|
116 | void LenseFlare::addFlare(const char* textureName) |
---|
117 | { |
---|
118 | Billboard* bb = new Billboard(NULL); |
---|
119 | bb->setTexture(textureName); |
---|
120 | this->flares.push_back(bb); |
---|
121 | |
---|
122 | // the first flare belongs to the light source |
---|
123 | if( this->flares.size() == 1 && this->lightSource != NULL) |
---|
124 | { |
---|
125 | bb->setBindNode(static_cast<PNode*>(this->lightSource)); |
---|
126 | } |
---|
127 | } |
---|
128 | |
---|
129 | |
---|
130 | |
---|
131 | /** |
---|
132 | * tick the effect |
---|
133 | */ |
---|
134 | void LenseFlare::tick(float dt) |
---|
135 | { |
---|
136 | |
---|
137 | } |
---|
138 | |
---|
139 | |
---|
140 | /** |
---|
141 | * draws the LenseFlares |
---|
142 | */ |
---|
143 | void LenseFlare::draw() const |
---|
144 | { |
---|
145 | if( !this->bActivated) |
---|
146 | return; |
---|
147 | |
---|
148 | std::vector<Billboard*>::const_iterator it; |
---|
149 | for( it = flares.begin(); it != flares.end(); it++) |
---|
150 | (*it)->draw(); |
---|
151 | } |
---|