1 | /* |
---|
2 | orxonox - the future of 3D-vertical-scrollers |
---|
3 | |
---|
4 | Copyright (C) 2004 orx |
---|
5 | |
---|
6 | This program is free software; you can redistribute it and/or modify |
---|
7 | it under the terms of the GNU General Public License as published by |
---|
8 | the Free Software Foundation; either version 2, or (at your option) |
---|
9 | any later version. |
---|
10 | |
---|
11 | ### File Specific: |
---|
12 | main-programmer: hdavid, amaechler |
---|
13 | */ |
---|
14 | |
---|
15 | #include "volfog_effect.h" |
---|
16 | |
---|
17 | #include "util/loading/load_param.h" |
---|
18 | #include "util/loading/factory.h" |
---|
19 | |
---|
20 | #include "glincl.h" |
---|
21 | |
---|
22 | #include "shell_command.h" |
---|
23 | |
---|
24 | using namespace std; |
---|
25 | |
---|
26 | CREATE_FACTORY(VolFogEffect, CL_VOLFOG_EFFECT); |
---|
27 | |
---|
28 | VolFogEffect::VolFogEffect(const TiXmlElement* root) |
---|
29 | { |
---|
30 | this->setClassID(CL_VOLFOG_EFFECT, "VolFogEffect"); |
---|
31 | |
---|
32 | if (root != NULL) |
---|
33 | this->loadParams(root); |
---|
34 | |
---|
35 | this->activate(); |
---|
36 | } |
---|
37 | |
---|
38 | |
---|
39 | VolFogEffect::~VolFogEffect() |
---|
40 | { |
---|
41 | this->deactivate(); |
---|
42 | } |
---|
43 | |
---|
44 | void VolFogEffect::loadParams(const TiXmlElement* root) |
---|
45 | { |
---|
46 | WeatherEffect::loadParams(root); |
---|
47 | |
---|
48 | //LoadParam(root, "fog-altitude", this, VolFogEffect, setFogAltitude); |
---|
49 | //LoadParam(root, "fog-color", this, VolFogEffect, startFogColor); |
---|
50 | LoadParam(root, "test", this, VolFogEffect, test); |
---|
51 | } |
---|
52 | |
---|
53 | void VolFogEffect::test(int t) |
---|
54 | { |
---|
55 | PRINTF(0)("Test: %i\n", t); |
---|
56 | } |
---|
57 | |
---|
58 | bool VolFogEffect::init() |
---|
59 | { |
---|
60 | PRINTF(0)("Initalize VolFogEffect\n"); |
---|
61 | }; |
---|
62 | |
---|
63 | |
---|
64 | bool VolFogEffect::activate() |
---|
65 | { |
---|
66 | //PRINTF(0)( "Enabling Volumetric Fog Effect, altitude: %i, color %f, %f, %f\n", this->fogAltitude, this->colorVector.x, this->colorVector.y, this->colorVector.z); |
---|
67 | |
---|
68 | PRINTF(0)("Activate VolFogEffect\n"); |
---|
69 | } |
---|
70 | |
---|
71 | bool VolFogEffect::deactivate() |
---|
72 | { |
---|
73 | PRINTF(0)("Deactivate VolFogEffect\n"); |
---|
74 | } |
---|
75 | |
---|
76 | /* |
---|
77 | void VolFogEffect::setFogColor(int v) |
---|
78 | { |
---|
79 | float z; |
---|
80 | float f; |
---|
81 | |
---|
82 | z = 0.0 - vertices[v].y; |
---|
83 | f = (60.0 - z) / (60.0 - 0.0); |
---|
84 | glColor4f(this->colorVector.x, this->colorVector.y, this->colorVector.z, f); |
---|
85 | } |
---|
86 | */ |
---|
87 | |
---|
88 | /** |
---|
89 | * draws the effect, if needed |
---|
90 | */ |
---|
91 | void VolFogEffect::draw() const |
---|
92 | { |
---|
93 | // PRINTF(0)("DRAW VolFogEffect\n"); |
---|
94 | |
---|
95 | glDepthMask(GL_TRUE); |
---|
96 | glEnable(GL_BLEND); |
---|
97 | glBlendFunc(GL_ONE_MINUS_SRC_ALPHA, GL_SRC_ALPHA); |
---|
98 | // glDisable(GL_TEXTURE_2D); |
---|
99 | // draw the fog panels |
---|
100 | |
---|
101 | glBegin(GL_QUADS); |
---|
102 | |
---|
103 | glColor4f(0.6, 0.2, 0.0, (10.0 - (0.0 - -10.0f)) / (10.0 - 0.0)); |
---|
104 | glVertex3f( 10.0f,-10.0f, 10.0f); // Top Right Of The Quad (Bottom) |
---|
105 | glColor4f(0.6, 0.2, 0.0, (10.0 - (0.0 - -10.0f)) / (10.0 - 0.0)); |
---|
106 | glVertex3f(-10.0f,-10.0f, 10.0f); // Top Left Of The Quad (Bottom) |
---|
107 | glColor4f(0.6, 0.2, 0.0, (10.0 - (0.0 - -10.0f)) / (10.0 - 0.0)); |
---|
108 | glVertex3f(-10.0f,-10.0f,-10.0f); // Bottom Left Of The Quad (Bottom) |
---|
109 | glColor4f(0.6, 0.2, 0.0, (10.0 - (0.0 - -10.0f)) / (10.0 - 0.0)); |
---|
110 | glVertex3f( 10.0f,-10.0f,-10.0f); // Bottom Right Of The Quad (Bottom) |
---|
111 | |
---|
112 | glColor4f(0.6, 0.2, 0.0, (10.0 - (0.0 - 10.0f)) / (10.0 - 0.0)); |
---|
113 | glVertex3f( 10.0f, 10.0f, 10.0f); // Top Right Of The Quad (Front) |
---|
114 | glColor4f(0.6, 0.2, 0.0, (10.0 - (0.0 - 10.0f)) / (10.0 - 0.0)); |
---|
115 | glVertex3f(-10.0f, 10.0f, 10.0f); // Top Left Of The Quad (Front) |
---|
116 | glColor4f(0.6, 0.2, 0.0, (10.0 - (0.0 - -10.0f)) / (10.0 - 0.0)); |
---|
117 | glVertex3f(-10.0f,-10.0f, 10.0f); // Bottom Left Of The Quad (Front) |
---|
118 | glColor4f(0.6, 0.2, 0.0, (10.0 - (0.0 - -10.0f)) / (10.0 - 0.0)); |
---|
119 | glVertex3f( 10.0f,-10.0f, 10.0f); // Bottom Right Of The Quad (Front) |
---|
120 | |
---|
121 | glColor4f(0.6, 0.2, 0.0, (10.0 - (0.0 - -10.0f)) / (10.0 - 0.0)); |
---|
122 | glVertex3f( 10.0f,-10.0f,-10.0f); // Top Right Of The Quad (Back) |
---|
123 | glColor4f(0.6, 0.2, 0.0, (10.0 - (0.0 - -10.0f)) / (10.0 - 0.0)); |
---|
124 | glVertex3f(-10.0f,-10.0f,-10.0f); // Top Left Of The Quad (Back) |
---|
125 | glColor4f(0.6, 0.2, 0.0, (10.0 - (0.0 - 10.0f)) / (10.0 - 0.0)); |
---|
126 | glVertex3f(-10.0f, 10.0f,-10.0f); // Bottom Left Of The Quad (Back) |
---|
127 | glColor4f(0.6, 0.2, 0.0, (10.0 - (0.0 - 10.0f)) / (10.0 - 0.0)); |
---|
128 | glVertex3f( 10.0f, 10.0f,-10.0f); // Bottom Right Of The Quad (Back) |
---|
129 | |
---|
130 | glColor4f(0.6, 0.2, 0.0, (10.0 - (0.0 - 10.0f)) / (10.0 - 0.0)); |
---|
131 | glVertex3f(-10.0f, 10.0f, 10.0f); // Top Right Of The Quad (Left) |
---|
132 | glColor4f(0.6, 0.2, 0.0, (10.0 - (0.0 - 10.0f)) / (10.0 - 0.0)); |
---|
133 | glVertex3f(-10.0f, 10.0f,-10.0f); // Top Left Of The Quad (Left) |
---|
134 | glColor4f(0.6, 0.2, 0.0, (10.0 - (0.0 - -10.0f)) / (10.0 - 0.0)); |
---|
135 | glVertex3f(-10.0f,-10.0f,-10.0f); // Bottom Left Of The Quad (Left) |
---|
136 | glColor4f(0.6, 0.2, 0.0, (10.0 - (0.0 - -10.0f)) / (10.0 - 0.0)); |
---|
137 | glVertex3f(-10.0f,-10.0f, 10.0f); // Bottom Right Of The Quad (Left) |
---|
138 | |
---|
139 | glColor4f(0.6, 0.2, 0.0, (10.0 - (0.0 - 10.0f)) / (10.0 - 0.0)); |
---|
140 | glVertex3f( 10.0f, 10.0f,-10.0f); // Top Right Of The Quad (Right) |
---|
141 | glColor4f(0.6, 0.2, 0.0, (10.0 - (0.0 - 10.0f)) / (10.0 - 0.0)); |
---|
142 | glVertex3f( 10.0f, 10.0f, 10.0f); // Top Left Of The Quad (Right) |
---|
143 | glColor4f(0.6, 0.2, 0.0, (10.0 - (0.0 - -10.0f)) / (10.0 - 0.0)); |
---|
144 | glVertex3f( 10.0f,-10.0f, 10.0f); // Bottom Left Of The Quad (Right) |
---|
145 | glColor4f(0.6, 0.2, 0.0, (10.0 - (0.0 - -10.0f)) / (10.0 - 0.0)); |
---|
146 | glVertex3f( 10.0f,-10.0f,-10.0f); // Bottom Right Of The Quad (Right) |
---|
147 | |
---|
148 | glEnd(); |
---|
149 | |
---|
150 | // restore rendering state |
---|
151 | |
---|
152 | // glEnable(GL_TEXTURE_2D); |
---|
153 | glDisable(GL_BLEND); |
---|
154 | |
---|
155 | } |
---|
156 | |
---|
157 | |
---|
158 | |
---|
159 | /** |
---|
160 | * ticks the effect if there is any time dependancy |
---|
161 | */ |
---|
162 | void VolFogEffect::tick(float dt) |
---|
163 | { |
---|
164 | } |
---|