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 | // TODO: Vektortextur erzeugen und Regionen auswählen, Sky... |
---|
16 | |
---|
17 | #include "cloud_effect.h" |
---|
18 | |
---|
19 | #include "util/loading/load_param.h" |
---|
20 | #include "util/loading/factory.h" |
---|
21 | |
---|
22 | #include "glincl.h" |
---|
23 | //#include "graphics_engine.h" |
---|
24 | #include "material.h" |
---|
25 | #include <math.h> |
---|
26 | #include "material.h" |
---|
27 | |
---|
28 | #include "parser/tinyxml/tinyxml.h" |
---|
29 | |
---|
30 | using namespace std; |
---|
31 | |
---|
32 | CREATE_FACTORY(CloudEffect, CL_CLOUD_EFFECT); |
---|
33 | |
---|
34 | CloudEffect::CloudEffect(const TiXmlElement* root) |
---|
35 | { |
---|
36 | this->setClassID(CL_CLOUD_EFFECT, "CloudEffect"); |
---|
37 | |
---|
38 | this->init(); |
---|
39 | |
---|
40 | if (root != NULL) |
---|
41 | this->loadParams(root); |
---|
42 | |
---|
43 | this->activate(); |
---|
44 | } |
---|
45 | |
---|
46 | CloudEffect::~CloudEffect() |
---|
47 | { |
---|
48 | this->deactivate(); |
---|
49 | } |
---|
50 | |
---|
51 | void CloudEffect::loadParams(const TiXmlElement* root) |
---|
52 | { |
---|
53 | WeatherEffect::loadParams(root); |
---|
54 | |
---|
55 | LoadParam(root, "animSpeed", this, CloudEffect, setCloudAnimation); |
---|
56 | |
---|
57 | } |
---|
58 | |
---|
59 | |
---|
60 | bool CloudEffect::init() |
---|
61 | { |
---|
62 | // default values |
---|
63 | this->cloudAnimTimeStep = 0; |
---|
64 | |
---|
65 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); |
---|
66 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); |
---|
67 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); |
---|
68 | glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); |
---|
69 | |
---|
70 | glGenTextures(2, &texID[0]); |
---|
71 | |
---|
72 | // Generate noise map a |
---|
73 | //CloudEffect::genNoiseMap(cloudMap32_a); |
---|
74 | |
---|
75 | if (this->cloudAnimTimeStep > 0) { |
---|
76 | // Generate noise map b |
---|
77 | //CloudEffect::genNoiseMap(cloudMap32_b); |
---|
78 | } |
---|
79 | |
---|
80 | this->material = new Material(); |
---|
81 | |
---|
82 | } |
---|
83 | |
---|
84 | bool CloudEffect::activate() |
---|
85 | { |
---|
86 | PRINTF(0)( "Activating CloudEffect\n"); |
---|
87 | |
---|
88 | |
---|
89 | } |
---|
90 | |
---|
91 | bool CloudEffect::deactivate() |
---|
92 | { |
---|
93 | PRINTF(0)("Deactivating CloudEffect\n"); |
---|
94 | } |
---|
95 | |
---|
96 | void CloudEffect::draw() const |
---|
97 | { |
---|
98 | /* TODO: |
---|
99 | -Load a texture, for now from an existing image, a cloud texture |
---|
100 | -Blend / Overlay this with a blue sky like in the tutorial |
---|
101 | -Make a skybox or whatever.... |
---|
102 | -Animate it (for now move it along the sky) |
---|
103 | */ |
---|
104 | |
---|
105 | // glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); |
---|
106 | |
---|
107 | this->material->setDiffuseMap("maps/lightning_bolt.png"); |
---|
108 | this->material->select(); |
---|
109 | |
---|
110 | glPushMatrix(); |
---|
111 | // glEnable(GL_TEXTURE_2D); |
---|
112 | |
---|
113 | // glBindTexture(GL_TEXTURE_2D, texID[0]); |
---|
114 | PRINTF(0)("Draw tralala\n"); |
---|
115 | |
---|
116 | // FIXME : Bind this to the sky - how do I do this? |
---|
117 | glBegin(GL_QUADS); |
---|
118 | glTexCoord2f(0.0f, 0.0f); |
---|
119 | glVertex3f(20, 20, 60); // Bottom Left Of The Texture and Quad |
---|
120 | |
---|
121 | glTexCoord2f(1.0f, 0.0f); |
---|
122 | glVertex3f(60, 20, 60); // Bottom Right Of The Texture and Quad |
---|
123 | |
---|
124 | glTexCoord2f(1.0f, 1.0f); |
---|
125 | glVertex3f(60, 60, 60); // Top Right Of The Texture and Quad |
---|
126 | |
---|
127 | glTexCoord2f(0.0f, 1.0f); |
---|
128 | glVertex3f(20, 60, 60); // Top Left Of The Texture and Quad |
---|
129 | glEnd(); |
---|
130 | |
---|
131 | glPopMatrix(); |
---|
132 | |
---|
133 | } |
---|
134 | |
---|
135 | void CloudEffect::tick (float dt) |
---|
136 | { |
---|
137 | |
---|
138 | } |
---|