Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/atmospheric_engine/src/lib/graphics/effects/cloud_effect.cc @ 8052

Last change on this file since 8052 was 8052, checked in by amaechler, 18 years ago

branches/atmospheric_engine: sound now with gain control, new cloud thoughts / todo..maaaan

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