Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/branches/gui/src/lib/graphics/effects/cloud_effect.cc @ 8543

Last change on this file since 8543 was 8495, checked in by bensch, 18 years ago

merged the branche atmos back. no conflicts

File size: 3.5 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        INSPIRED BY http://www.codesampler.com/usersrc/usersrc_6.htm#oglu_sky_dome_shader
15*/
16
17#include "cloud_effect.h"
18
19#include "util/loading/load_param.h"
20#include "util/loading/factory.h"
21#include "util/loading/resource_manager.h"
22
23#include "material.h"
24#include <math.h>
25#include "state.h"
26#include "p_node.h"
27#include "shader.h"
28#include "shell_command.h"
29
30#include "parser/tinyxml/tinyxml.h"
31
32
33using namespace std;
34
35SHELL_COMMAND(activate, CloudEffect, activateCloud);
36SHELL_COMMAND(deactivate, CloudEffect, deactivateCloud);
37
38CREATE_FACTORY(CloudEffect, CL_CLOUD_EFFECT);
39
40CloudEffect::CloudEffect(const TiXmlElement* root)
41{
42        this->setClassID(CL_CLOUD_EFFECT, "CloudEffect");
43//  this->toList(OM_ENVIRON);
44
45        this->init();
46
47        if (root != NULL)
48                this->loadParams(root);
49
50        //if(cloudActivate)
51                this->activate();
52}
53
54CloudEffect::~CloudEffect()
55{
56        this->deactivate();
57}
58
59
60void CloudEffect::init()
61{
62        PRINTF(0)("Initializing CloudEffect\n");
63 
64    /// initialization of the texture coords, speeds etc...
65/*  this->move = 0.0f;
66  this->g_WaterUV = 35.0f;
67  this->kNormalMapScale = 0.25f;
68  this->g_WaterFlow = 0.0015f;*/
69 
70  cloudMaterial.setDiffuseMap("pictures/sky/cloud1.jpg", GL_TEXTURE_2D, 0);
71
72  shader = new Shader(ResourceManager::getInstance()->getDataDir() + "/shaders/cloud.vert",
73                      ResourceManager::getInstance()->getDataDir() + "/shaders/cloud.frag");
74 
75  this->shader->activateShader();
76
77  Shader::Uniform(shader, "Noise").set(0);
78  Shader::Uniform(shader, "SkyColor").set(0.0f, 0.0f, 0.8f);
79  Shader::Uniform(shader, "CloudColor").set(0.8f, 0.8f, 0.8f);
80 
81  // Change: Have to be updated each frame!like camerpos in mapped_water.cc
82  Shader::Uniform(shader, "Offset").set(0.0f, 0.0f, 0.0f);
83 
84  Shader::Uniform(shader, "LightPos").set(100.0f, 100.0f, 100.0f);
85  Shader::Uniform(shader, "Scale").set(1.0f);
86 
87  this->shader->deactivateShader();
88}
89
90
91void CloudEffect::loadParams(const TiXmlElement* root)
92{
93        WeatherEffect::loadParams(root);
94
95        // LoadParam(root, "speed", this, CloudEffect, setCloudAnimation);
96        // LoadParam(root, "texture", this, CloudEffect, setCloudTexture);
97  /*
98        LOAD_PARAM_START_CYCLE(root, element);
99        {
100                LoadParam_CYCLE(element, "option", this, CloudEffect, setCloudOption);
101        }
102  LOAD_PARAM_END_CYCLE(element);*/
103}
104
105
106void CloudEffect::activate()
107{
108        PRINTF(0)( "Activating\n");
109
110//      this->cloudActivate = true;
111}
112
113void CloudEffect::deactivate()
114{
115        PRINTF(0)("Deactivating CloudEffect\n");
116
117//      this->cloudActivate = false;
118}
119
120void CloudEffect::draw() const
121{
122        //if (!this->cloudActivate)
123        //      return;
124
125  //glMatrixMode(GL_MODELVIEW);
126  //glColor4f(1,1,1,1);
127  glPushMatrix();
128  //glTranslatef(0,this->waterHeight,0);
129
130  cloudMaterial.unselect();
131  cloudMaterial.select();
132
133  this->shader->activateShader();
134
135
136  glBegin(GL_QUADS);
137 
138  glTexCoord2f(1.0f, 1.0f); glVertex3f(0.0f, 0.0f,  0.0f);
139  glTexCoord2f(0.0f, 1.0f); glVertex3f( 0.0f, 0.0f,  100.0f);
140  glTexCoord2f(0.0f, 0.0f); glVertex3f( 100.0f, 0.0f,  100.0f);
141  glTexCoord2f(1.0f, 0.0f); glVertex3f(100.0f, 0.0f,  0.0f);
142 
143  glEnd();
144
145  this->shader->deactivateShader();
146
147  cloudMaterial.unselect();
148
149  glPopMatrix();
150
151}
152
153void CloudEffect::tick (float dt)
154{
155        //if (!this->cloudActivate)
156        //      return;
157}
158
Note: See TracBrowser for help on using the repository browser.