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 "rain_effect.h" |
---|
16 | |
---|
17 | #include "util/loading/load_param.h" |
---|
18 | #include "util/loading/factory.h" |
---|
19 | |
---|
20 | #include "glincl.h" |
---|
21 | |
---|
22 | using namespace std; |
---|
23 | |
---|
24 | CREATE_FACTORY(RainEffect, CL_RAIN_EFFECT); |
---|
25 | |
---|
26 | RainEffect::RainEffect(const TiXmlElement* root) |
---|
27 | { |
---|
28 | this->setClassID(CL_RAIN_EFFECT, "RainEffect"); |
---|
29 | |
---|
30 | // this->rainMode = GL_LINEAR; |
---|
31 | // this->rainDensity = 0.001f; |
---|
32 | // this->rainStart = 10.0f; |
---|
33 | // this->rainEnd = 1000.0f; |
---|
34 | |
---|
35 | if (root != NULL) |
---|
36 | this->loadParams(root); |
---|
37 | |
---|
38 | this->activate(); |
---|
39 | } |
---|
40 | |
---|
41 | |
---|
42 | |
---|
43 | RainEffect::~RainEffect() |
---|
44 | { |
---|
45 | this->deactivate(); |
---|
46 | } |
---|
47 | |
---|
48 | |
---|
49 | void RainEffect::loadParams(const TiXmlElement* root) |
---|
50 | { |
---|
51 | WeatherEffect::loadParams(root); |
---|
52 | |
---|
53 | // LoadParam(root, "rain-mode", this, RainEffect, setRainMode); |
---|
54 | // LoadParam(root, "rain-density", this, RainEffect, setRainDensity); |
---|
55 | // LoadParam(root, "rain-color", this, RainEffect, setRainColor); |
---|
56 | |
---|
57 | |
---|
58 | } |
---|
59 | |
---|
60 | bool RainEffect::init() |
---|
61 | {} |
---|
62 | |
---|
63 | |
---|
64 | |
---|
65 | bool RainEffect::activate() |
---|
66 | { |
---|
67 | // PRINTF(0)( "Enabling Rain Effect, mode: %i, density: %f, start: %f, end: %f, color %f, %f, %f\n", this->rainMode, this->rainDensity, this->rainStart, this->rainEnd, this->colorVector.x, this->colorVector.y, this->colorVector.z); |
---|
68 | // |
---|
69 | // glEnable(GL_RAIN); |
---|
70 | // { |
---|
71 | // //GLfloat rainColor[4] = {0.7, 0.6, 0.6, 1.0}; |
---|
72 | // GLfloat rainColor[4] = { colorVector.x, colorVector.y, colorVector.z, 1.0}; |
---|
73 | // |
---|
74 | // glRaini(GL_RAIN_MODE, this->rainMode); |
---|
75 | // glRainfv(GL_RAIN_COLOR, rainColor); |
---|
76 | // glRainf(GL_RAIN_DENSITY, this->rainDensity); |
---|
77 | // glHint(GL_RAIN_HINT, GL_DONT_CARE); |
---|
78 | // glRainf(GL_RAIN_START, this->rainStart); |
---|
79 | // glRainf(GL_RAIN_END, this->rainEnd); |
---|
80 | // |
---|
81 | // //glRaini(GL_RAIN_COORDINATE_SOURCE, GL_RAIN_COORDINATE); |
---|
82 | // } |
---|
83 | // glClearColor(0.5, 0.5, 0.5, 1.0); |
---|
84 | } |
---|
85 | |
---|
86 | |
---|
87 | bool RainEffect::deactivate() |
---|
88 | { |
---|
89 | PRINTF(0)("Deactivating Rain Effect\n"); |
---|
90 | // glDisable(GL_RAIN); |
---|
91 | } |
---|
92 | |
---|
93 | void RainEffect::draw() |
---|
94 | { |
---|
95 | Particle* drawPart = particles; |
---|
96 | |
---|
97 | glDepthMask(GL_FALSE); |
---|
98 | glPushAttrib(GL_ENABLE_BIT); |
---|
99 | |
---|
100 | glDisable(GL_LIGHTING); |
---|
101 | glDisable(GL_TEXTURE_2D); |
---|
102 | |
---|
103 | glEnable(GL_LINE_SMOOTH); |
---|
104 | glEnable(GL_BLEND); |
---|
105 | glBlendFunc(GL_SRC_ALPHA, GL_DST_ALPHA); |
---|
106 | |
---|
107 | glLineWidth(2.0); |
---|
108 | glBegin(GL_LINES); |
---|
109 | while (likely(drawPart != NULL)) |
---|
110 | { |
---|
111 | // printf("%f %f %f %f\n", drawPart->color[0], drawPart->color[1], drawPart->color[2], drawPart->color[3]); |
---|
112 | glColor4fv(drawPart->color); |
---|
113 | glVertex3f(drawPart->position.x, drawPart->position.y, drawPart->position.z); |
---|
114 | glVertex3f(drawPart->position.x - drawPart->velocity.x * drawPart->radius, |
---|
115 | drawPart->position.y - drawPart->velocity.y * drawPart->radius, |
---|
116 | drawPart->position.z - drawPart->velocity.z * drawPart->radius); |
---|
117 | drawPart = drawPart->next; |
---|
118 | } |
---|
119 | glEnd(); |
---|
120 | |
---|
121 | glDepthMask(GL_TRUE); |
---|
122 | glPopAttrib(); |
---|
123 | } |
---|