Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: orxonox.OLD/trunk/src/lib/graphics/effects/cloud_effect.cc @ 8565

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

merged the branche atmos back. no conflicts

File size: 3.5 KB
RevLine 
[7679]1/*
[7768]2        orxonox - the future of 3D-vertical-scrollers
[7679]3
[7768]4        Copyright (C) 2004 orx
[7679]5
[7768]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.
[7679]10
11### File Specific:
[7768]12        main-programmer: hdavid, amaechler
[8255]13
14        INSPIRED BY http://www.codesampler.com/usersrc/usersrc_6.htm#oglu_sky_dome_shader
[7679]15*/
16
17#include "cloud_effect.h"
18
19#include "util/loading/load_param.h"
20#include "util/loading/factory.h"
[8255]21#include "util/loading/resource_manager.h"
[7679]22
[8255]23#include "material.h"
[7795]24#include <math.h>
[8255]25#include "state.h"
26#include "p_node.h"
27#include "shader.h"
28#include "shell_command.h"
[7679]29
30#include "parser/tinyxml/tinyxml.h"
31
[8255]32
[7679]33using namespace std;
34
[8255]35SHELL_COMMAND(activate, CloudEffect, activateCloud);
36SHELL_COMMAND(deactivate, CloudEffect, deactivateCloud);
37
[7679]38CREATE_FACTORY(CloudEffect, CL_CLOUD_EFFECT);
39
40CloudEffect::CloudEffect(const TiXmlElement* root)
41{
42        this->setClassID(CL_CLOUD_EFFECT, "CloudEffect");
[8495]43//  this->toList(OM_ENVIRON);
[7679]44
45        this->init();
46
47        if (root != NULL)
48                this->loadParams(root);
49
[8495]50        //if(cloudActivate)
[8255]51                this->activate();
[7679]52}
53
54CloudEffect::~CloudEffect()
55{
56        this->deactivate();
57}
58
59
[8495]60void CloudEffect::init()
[7679]61{
[8495]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);
[7768]71
[8495]72  shader = new Shader(ResourceManager::getInstance()->getDataDir() + "/shaders/cloud.vert",
73                      ResourceManager::getInstance()->getDataDir() + "/shaders/cloud.frag");
74 
75  this->shader->activateShader();
[7768]76
[8495]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();
[7679]88}
89
90
[8255]91void CloudEffect::loadParams(const TiXmlElement* root)
[7768]92{
[8255]93        WeatherEffect::loadParams(root);
[7768]94
[8255]95        // LoadParam(root, "speed", this, CloudEffect, setCloudAnimation);
96        // LoadParam(root, "texture", this, CloudEffect, setCloudTexture);
[8495]97  /*
[8255]98        LOAD_PARAM_START_CYCLE(root, element);
99        {
100                LoadParam_CYCLE(element, "option", this, CloudEffect, setCloudOption);
101        }
[8495]102  LOAD_PARAM_END_CYCLE(element);*/
[8255]103}
[7768]104
105
[8495]106void CloudEffect::activate()
[7679]107{
[8495]108        PRINTF(0)( "Activating\n");
[7784]109
[8495]110//      this->cloudActivate = true;
[7768]111}
[7679]112
[8495]113void CloudEffect::deactivate()
[7768]114{
[8255]115        PRINTF(0)("Deactivating CloudEffect\n");
116
[8495]117//      this->cloudActivate = false;
[7679]118}
[7768]119
[8255]120void CloudEffect::draw() const
[7768]121{
[8495]122        //if (!this->cloudActivate)
123        //      return;
[7768]124
[8495]125  //glMatrixMode(GL_MODELVIEW);
126  //glColor4f(1,1,1,1);
127  glPushMatrix();
128  //glTranslatef(0,this->waterHeight,0);
[7768]129
[8495]130  cloudMaterial.unselect();
131  cloudMaterial.select();
[7768]132
[8495]133  this->shader->activateShader();
[7768]134
135
[8495]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();
[7768]144
[8495]145  this->shader->deactivateShader();
[7768]146
[8495]147  cloudMaterial.unselect();
[7768]148
[8495]149  glPopMatrix();
[7768]150
151}
152
[8255]153void CloudEffect::tick (float dt)
[7768]154{
[8495]155        //if (!this->cloudActivate)
156        //      return;
[7768]157}
[7784]158
Note: See TracBrowser for help on using the repository browser.