Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7810 in orxonox.OLD for trunk/src/lib/graphics/effects


Ignore:
Timestamp:
May 24, 2006, 3:57:04 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: merged the Weather effects back here

Location:
trunk/src/lib/graphics/effects
Files:
4 edited
16 copied

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/graphics/effects/fog_effect.cc

    r7221 r7810  
     1/*
     2        orxonox - the future of 3D-vertical-scrollers
    13
     4        Copyright (C) 2004 orx
    25
    3 /*
    4    orxonox - the future of 3D-vertical-scrollers
    5 
    6    Copyright (C) 2004 orx
    7 
    8    This program is free software; you can redistribute it and/or modify
    9    it under the terms of the GNU General Public License as published by
    10    the Free Software Foundation; either version 2, or (at your option)
    11    any later version.
     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.
    1210
    1311### File Specific:
    14    main-programmer: Patrick Boenzli
     12        main-programmer: hdavid, amaechler
    1513*/
    16 
    17 #define DEBUG_SPECIAL_MODULE DEBUG_MODULE_GRAPHICS
    1814
    1915#include "fog_effect.h"
     
    2420#include "glincl.h"
    2521
    26 
     22/*#include "shell_command.h"
     23SHELL_COMMAND(activateFog, FogEffect, FogEffect::activate)
     24        ->setAlias("aFog");
     25SHELL_COMMAND(deactivateFog, FogEffect, FogEffect::deactivate)
     26        ->setAlias("dFog");*/
    2727
    2828using namespace std;
     
    3030CREATE_FACTORY(FogEffect, CL_FOG_EFFECT);
    3131
     32FogEffect::FogEffect(const TiXmlElement* root)
     33{
     34        this->setClassID(CL_FOG_EFFECT, "FogEffect");
    3235
    33 /**
    34  *  default constructor
    35  * @param root The XML-element to load the FogEffect from
    36  */
    37  FogEffect::FogEffect(const TiXmlElement* root)
    38 {
    39   this->setClassID(CL_FOG_EFFECT, "FogEffect");
     36        this->init();
    4037
    41   this->fogMode = GL_LINEAR;
    42   this->fogDensity = 0.001f;
    43   this->fogStart = 10.0f;
    44   this->fogEnd = 1000.0f;
     38        if (root != NULL)
     39                this->loadParams(root);
    4540
    46   if (root != NULL)
    47     this->loadParams(root);
    48 
    49   this->activate();
     41        this->activate();
    5042}
    5143
    5244
    53 /**
    54  *  destroys a FogEffect
    55  */
    5645FogEffect::~FogEffect()
    5746{
    58   this->deactivate();
     47        this->deactivate();
    5948}
    6049
    6150
    62 /**
    63  * @param root The XML-element to load the FogEffect from
    64  */
    6551void FogEffect::loadParams(const TiXmlElement* root)
    6652{
    67   GraphicsEffect::loadParams(root);
     53        WeatherEffect::loadParams(root);
    6854
     55        LoadParam(root, "mode", this, FogEffect, setFogMode);
     56        LoadParam(root, "density", this, FogEffect, setFogDensity);
     57        LoadParam(root, "range", this, FogEffect, setFogRange);
     58        LoadParam(root, "color", this, FogEffect, setFogColor);
     59}
    6960
    70   LoadParam(root, "fog-mode", this, FogEffect, setFogMode)
    71       .describe("sets the the fog mode {GL_LINEAR, GL_EXP, GL_EXP2}");
    72 
    73   LoadParam(root, "fog-density", this, FogEffect, setFogDensity)
    74       .describe("sets the the fog density of the exponentionl functions");
    75 
    76   LoadParam(root, "fog-color", this, FogEffect, setFogColor)
    77       .describe("sets the fog color");
    78 
     61bool FogEffect::init()
     62{
     63        //default values
     64        this->fogMode = GL_EXP2;
     65        this->fogDensity = 0.001;
     66        this->fogStart = 0;
     67        this->fogEnd = 5000;
     68  this->colorVector = Vector(0.7, 0.7, 0.7);
    7969}
    8070
    8171
    82 /**
    83  * initializes the fog effect
    84  */
    85 bool FogEffect::init()
    86 {}
    8772
    88 
    89 /**
    90  * activates the fog effect
    91  */
    9273bool FogEffect::activate()
    9374{
    94   PRINTF(0)( "Enabling Fog Effect, mode: %i, density: %f, start: %f, end: %f, color %f, %f, %f\n", this->fogMode, this->fogDensity,
    95              this->fogStart, this->fogEnd, this->colorVector.x, this->colorVector.y, this->colorVector.z);
     75        PRINTF(0)( "Enabling FogEffect, mode: %i, density: %f, start: %f, end: %f, color %f, %f, %f\n", this->fogMode, this->fogDensity, this->fogStart, this->fogEnd, this->colorVector.x, this->colorVector.y, this->colorVector.z);
    9676
    97   glEnable(GL_FOG);
    98   {
    99 //     GLfloat fogColor[4] = {0.7, 0.6, 0.6, 1.0};
    100     GLfloat fogColor[4] = { colorVector.x, colorVector.y, colorVector.z, 1.0};
     77        glEnable(GL_FOG);
     78        {
     79                GLfloat fogColor[4] = { colorVector.x, colorVector.y, colorVector.z, 1.0};
    10180
    102     glFogi(GL_FOG_MODE, this->fogMode);
    103     glFogfv(GL_FOG_COLOR, fogColor);
    104     glFogf(GL_FOG_DENSITY, this->fogDensity);
    105     glHint(GL_FOG_HINT, GL_DONT_CARE);
    106     glFogf(GL_FOG_START, this->fogStart);
    107     glFogf(GL_FOG_END, this->fogEnd);
    108 
    109     //glFogi(GL_FOG_COORDINATE_SOURCE, GL_FOG_COORDINATE);
    110   }
    111   glClearColor(0.5, 0.5, 0.5, 1.0);
     81                glFogi(GL_FOG_MODE, this->fogMode);
     82                glFogfv(GL_FOG_COLOR, fogColor);
     83                glFogf(GL_FOG_DENSITY, this->fogDensity);
     84                glHint(GL_FOG_HINT, GL_DONT_CARE);
     85                glFogf(GL_FOG_START, this->fogStart);
     86                glFogf(GL_FOG_END, this->fogEnd);
     87        }
     88        glClearColor(0.5, 0.5, 0.5, 1.0);
    11289}
    11390
    11491
    115 /**
    116  * deactivates the fog effect
    117  */
    11892bool FogEffect::deactivate()
    11993{
    120   glDisable(GL_FOG);
     94        PRINTF(0)("Deactivating FogEffect\n");
     95        glDisable(GL_FOG);
    12196}
    12297
    12398
    124 /**
    125  * converts a gl mode char to a GLint
    126  * @param mode the mode character
    127  */
    12899GLint FogEffect::stringToFogMode(const std::string& mode)
    129100{
    130   if(mode == "GL_LINEAR")
    131     return GL_LINEAR;
    132   else if(mode == "GL_EXP")
    133     return GL_EXP;
    134   else if(mode == "GL_EXP2" )
    135     return GL_EXP2;
    136   else
    137     return -1;
     101        if(mode == "GL_LINEAR")
     102                return GL_LINEAR;
     103        else if(mode == "GL_EXP")
     104                return GL_EXP;
     105        else if(mode == "GL_EXP2" )
     106                return GL_EXP2;
     107        else
     108                return -1;
    138109}
    139110
     111
  • trunk/src/lib/graphics/effects/fog_effect.h

    r7221 r7810  
    11/**
    2  * @file fog_effect.h
    3  *  atmospheric fog
    4  */
     2* @file fog_effect.h
     3*/
    54
    65#ifndef _FOG_EFFECT
     
    87
    98#include "vector.h"
    10 #include "graphics_effect.h"
    119
    12 class TiXmlElement;
     10#include "weather_effect.h"
    1311
    14 //! A class that handles FogEffects. The FogEffectManager operates on this.
    15 class FogEffect : public GraphicsEffect
     12class FogEffect : public WeatherEffect
    1613{
    17   public:
    18     FogEffect(const TiXmlElement* root = NULL);
    19     virtual ~FogEffect();
     14        public:
     15                FogEffect(const TiXmlElement* root = NULL);
     16                virtual ~FogEffect();
    2017
    21     virtual void loadParams(const TiXmlElement* root);
     18                virtual void loadParams(const TiXmlElement* root);
    2219
    23     virtual bool init();
     20                virtual bool init();
    2421
    25     virtual bool activate();
    26     virtual bool deactivate();
     22                virtual bool activate();
     23                virtual bool deactivate();
    2724
    28     inline void setFogMode(const std::string& mode) { this->fogMode = this->stringToFogMode(mode); }
    29     inline void setFogDensity(float density) { this->fogDensity = density; }
    30     inline void setFogRange(float start, float end) { this->fogStart = start; this->fogEnd = end; }
    31     inline void setFogColor(float r, float g, float b) { this->colorVector = Vector(r, g, b); }
     25                inline void setFogMode(const std::string& mode) { this->fogMode = this->stringToFogMode(mode); }
     26                inline void setFogDensity(float density) { this->fogDensity = density; }
     27                inline void setFogRange(float start, float end) { this->fogStart = start; this->fogEnd = end; }
     28                inline void setFogColor(float r, float g, float b) { this->colorVector = Vector(r, g, b); }
    3229
     30        private:
     31                GLint stringToFogMode(const std::string& mode);
    3332
    34   private:
    35     GLint stringToFogMode(const std::string& mode);
    36 
    37 
    38   private:
    39     GLint                   fogMode;
    40     GLfloat                 fogDensity;
    41     GLfloat                 fogStart;
    42     GLfloat                 fogEnd;
    43     Vector                  colorVector;
     33        private:
     34                GLint                   fogMode;
     35                GLfloat                 fogDensity;
     36                GLfloat                 fogStart;
     37                GLfloat                 fogEnd;
     38                Vector                  colorVector;
    4439};
    4540
    4641
    47 #endif /* _FOG_EFFECT */
     42#endif  /* _FOG_EFFECT */
  • trunk/src/lib/graphics/effects/lense_flare.cc

    r7316 r7810  
    2828#include "state.h"
    2929
    30 #include "render2D/billboard.h"
     30#include "render2D/image_plane.h"
    3131
    3232#include "light.h"
     
    8080LenseFlare::~LenseFlare()
    8181{
    82   std::vector<Billboard*>::iterator it;
     82  std::vector<ImagePlane*>::iterator it;
    8383  for( it = flares.begin(); it != flares.end(); it++)
    8484    delete (*it);
     
    155155  }
    156156
    157   Billboard* bb = new Billboard(NULL);
     157  ImagePlane* bb = new ImagePlane(NULL);
    158158  bb->setTexture(textureName);
    159159  bb->setSize(50, 50);
    160160  this->flares.push_back(bb);
    161   PRINTF(4)("Added a Lenseflare Billboard with texture %s\n", textureName.c_str());
     161  PRINTF(4)("Added a Lenseflare ImagePlane with texture %s\n", textureName.c_str());
    162162
    163163  // the first flare belongs to the light source
     
    178178  float dist = this->frustumPlane.distancePoint(this->lightSource->getAbsCoor());
    179179  PRINTF(0)("dist: %f\n", dist);
    180   std::vector<Billboard*>::const_iterator it;
     180  std::vector<ImagePlane*>::const_iterator it;
    181181    for(it = flares.begin(); it != flares.end(); it++)
    182182      (*it)->setVisibility(visibility);
     
    220220
    221221  // now calculate the new coordinates of the billboards
    222   std::vector<Billboard*>::iterator it;
     222  std::vector<ImagePlane*>::iterator it;
    223223  int i;
    224224  for( it = flares.begin(), i = 0; it != flares.end(); it++, i++)
  • trunk/src/lib/graphics/effects/lense_flare.h

    r7316 r7810  
    2020class TiXmlElement;
    2121class Light;
    22 class Billboard;
     22class ImagePlane;
    2323
    2424//! A class that handles LenseFlares. The LenseFlareManager operates on this.
     
    5050    float                    isVisible;          //!< Checks visibility
    5151    Light*                   lightSource;        //!< reference to the sun (or primary light source)
    52     std::vector<Billboard*>  flares;             //!< the flares array
     52    std::vector<ImagePlane*>  flares;             //!< the flares array
    5353
    5454    Vector2D                 flareVector;        //!< the axis to draw the flares on
  • trunk/src/lib/graphics/effects/rain_effect.cc

    r7808 r7810  
    4747        if (this->rainBuffer != NULL)
    4848                ResourceManager::getInstance()->unload(this->rainBuffer);
    49         this->rainBuffer = (SoundBuffer*)ResourceManager::getInstance()->load("sound/rain.wav", WAV);
     49        this->rainBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load("sound/rain.wav", WAV);
    5050
    5151        //load wind sound
     
    5353                if (this->windBuffer != NULL)
    5454                        ResourceManager::getInstance()->unload(this->windBuffer);
    55                 this->windBuffer = (SoundBuffer*)ResourceManager::getInstance()->load("sound/wind.wav", WAV);
     55                this->windBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load("sound/wind.wav", WAV);
    5656        }
    5757
  • trunk/src/lib/graphics/effects/rain_effect.h

    r7808 r7810  
    6161                bool                                                                                                                    rainMove;
    6262
    63                 SoundSource                                                                                             soundSource;
    64                 SoundBuffer*                                                                                    rainBuffer;
    65                 SoundBuffer*                                                                                    windBuffer;
     63                OrxSound::SoundSource                   soundSource;
     64                OrxSound::SoundBuffer*                  rainBuffer;
     65                OrxSound::SoundBuffer*                  windBuffer;
    6666};
    6767
  • trunk/src/lib/graphics/effects/snow_effect.cc

    r7808 r7810  
    5050                if (this->windBuffer != NULL)
    5151                        ResourceManager::getInstance()->unload(this->windBuffer);
    52                 this->windBuffer = (SoundBuffer*)ResourceManager::getInstance()->load("sound/wind.wav", WAV);
     52                        this->windBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load("sound/wind.wav", WAV);
    5353        }
    5454
  • trunk/src/lib/graphics/effects/snow_effect.h

    r7808 r7810  
    1717class PNode;
    1818
     19#include "sound_source.h"
    1920#include "sound_buffer.h"
    20 #include "sound_source.h"
    2121
    2222class SnowEffect : public WeatherEffect
     
    7070
    7171                static SpriteParticles*                                                 snowParticles;
     72                OrxSound::SoundSource              soundSource;
     73                OrxSound::SoundBuffer*             windBuffer;
    7274
    73                 SoundSource                                                                                                     soundSource;
    74                 SoundBuffer*                                                                                            windBuffer;
    7575};
    7676
Note: See TracChangeset for help on using the changeset viewer.