Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7652 in orxonox.OLD


Ignore:
Timestamp:
May 17, 2006, 6:41:58 PM (18 years ago)
Author:
amaechler
Message:

branches/atmosphere_engine: cosmetics2

Location:
branches/atmospheric_engine/src/lib/graphics/effects
Files:
8 edited

Legend:

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

    r7628 r7652  
    11/*
    2    orxonox - the future of 3D-vertical-scrollers
     2        orxonox - the future of 3D-vertical-scrollers
    33
    4    Copyright (C) 2004 orx
     4        Copyright (C) 2004 orx
    55
    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.
     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.
    1010
    1111### File Specific:
    12    main-programmer: hdavid, amaechler
     12        main-programmer: hdavid, amaechler
    1313*/
    1414
     
    2222/*#include "shell_command.h"
    2323SHELL_COMMAND(activateFog, FogEffect, FogEffect::activate)
    24   ->setAlias("aFog");
     24        ->setAlias("aFog");
    2525SHELL_COMMAND(deactivateFog, FogEffect, FogEffect::deactivate)
    26   ->setAlias("dFog");*/
     26        ->setAlias("dFog");*/
    2727
    2828using namespace std;
     
    3232FogEffect::FogEffect(const TiXmlElement* root)
    3333{
    34   this->setClassID(CL_FOG_EFFECT, "FogEffect");
    35  
    36   this->fogMode = GL_LINEAR;
    37   this->fogDensity = 0.001f;
    38   this->fogStart = 10.0f;
    39   this->fogEnd = 1000.0f;
     34        this->setClassID(CL_FOG_EFFECT, "FogEffect");
     35       
     36        this->fogMode = GL_LINEAR;
     37        this->fogDensity = 0.001f;
     38        this->fogStart = 10.0f;
     39        this->fogEnd = 1000.0f;
    4040
    41   if (root != NULL)
    42     this->loadParams(root);
     41        if (root != NULL)
     42                this->loadParams(root);
    4343
    44   this->activate();
     44        this->activate();
    4545}
    4646
     
    4949FogEffect::~FogEffect()
    5050{
    51   this->deactivate();
     51        this->deactivate();
    5252}
    5353
     
    5555void FogEffect::loadParams(const TiXmlElement* root)
    5656{
    57   WeatherEffect::loadParams(root);
     57        WeatherEffect::loadParams(root);
    5858
    59   LoadParam(root, "fog-mode", this, FogEffect, setFogMode);
    60   LoadParam(root, "fog-density", this, FogEffect, setFogDensity);
    61   LoadParam(root, "fog-color", this, FogEffect, setFogColor);
     59        LoadParam(root, "fog-mode", this, FogEffect, setFogMode);
     60        LoadParam(root, "fog-density", this, FogEffect, setFogDensity);
     61        LoadParam(root, "fog-color", this, FogEffect, setFogColor);
    6262
    6363
     
    7171bool FogEffect::activate()
    7272{
    73   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);
     73        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);
    7474
    75   glEnable(GL_FOG);
    76   {
    77     //GLfloat fogColor[4] = {0.7, 0.6, 0.6, 1.0};
    78     GLfloat fogColor[4] = { colorVector.x, colorVector.y, colorVector.z, 1.0};
     75        glEnable(GL_FOG);
     76        {
     77                //GLfloat fogColor[4] = {0.7, 0.6, 0.6, 1.0};
     78                GLfloat fogColor[4] = { colorVector.x, colorVector.y, colorVector.z, 1.0};
    7979
    80     glFogi(GL_FOG_MODE, this->fogMode);
    81     glFogfv(GL_FOG_COLOR, fogColor);
    82     glFogf(GL_FOG_DENSITY, this->fogDensity);
    83     glHint(GL_FOG_HINT, GL_DONT_CARE);
    84     glFogf(GL_FOG_START, this->fogStart);
    85     glFogf(GL_FOG_END, this->fogEnd);
     80                glFogi(GL_FOG_MODE, this->fogMode);
     81                glFogfv(GL_FOG_COLOR, fogColor);
     82                glFogf(GL_FOG_DENSITY, this->fogDensity);
     83                glHint(GL_FOG_HINT, GL_DONT_CARE);
     84                glFogf(GL_FOG_START, this->fogStart);
     85                glFogf(GL_FOG_END, this->fogEnd);
    8686
    87     //glFogi(GL_FOG_COORDINATE_SOURCE, GL_FOG_COORDINATE);
    88   }
    89   glClearColor(0.5, 0.5, 0.5, 1.0);
     87                //glFogi(GL_FOG_COORDINATE_SOURCE, GL_FOG_COORDINATE);
     88        }
     89        glClearColor(0.5, 0.5, 0.5, 1.0);
    9090}
    9191
     
    9393bool FogEffect::deactivate()
    9494{
    95   PRINTF(0)("Deactivating FogEffect\n");
     95        PRINTF(0)("Deactivating FogEffect\n");
    9696        glDisable(GL_FOG);
    9797}
     
    101101GLint FogEffect::stringToFogMode(const std::string& mode)
    102102{
    103   if(mode == "GL_LINEAR")
    104     return GL_LINEAR;
    105   else if(mode == "GL_EXP")
    106     return GL_EXP;
    107   else if(mode == "GL_EXP2" )
    108     return GL_EXP2;
    109   else
    110     return -1;
     103        if(mode == "GL_LINEAR")
     104                return GL_LINEAR;
     105        else if(mode == "GL_EXP")
     106                return GL_EXP;
     107        else if(mode == "GL_EXP2" )
     108                return GL_EXP2;
     109        else
     110                return -1;
    111111}
    112112
  • branches/atmospheric_engine/src/lib/graphics/effects/fog_effect.h

    r7416 r7652  
    11/**
    2  * @file fog_effect.h
    3  */
     2* @file fog_effect.h
     3*/
    44
    55#ifndef _FOG_EFFECT
     
    1212class FogEffect : public WeatherEffect
    1313{
    14   public:
    15     FogEffect(const TiXmlElement* root = NULL);
    16     virtual ~FogEffect();
     14        public:
     15                FogEffect(const TiXmlElement* root = NULL);
     16                virtual ~FogEffect();
    1717
    18     virtual void loadParams(const TiXmlElement* root);
     18                virtual void loadParams(const TiXmlElement* root);
    1919
    20     virtual bool init();
     20                virtual bool init();
    2121
    22     virtual bool activate();
    23     virtual bool deactivate();
     22                virtual bool activate();
     23                virtual bool deactivate();
    2424
    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); }
     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); }
    2929
    3030
    31   private:
    32     GLint stringToFogMode(const std::string& mode);
     31        private:
     32                GLint stringToFogMode(const std::string& mode);
    3333
    3434
    35   private:
    36     GLint                   fogMode;
    37     GLfloat                 fogDensity;
    38     GLfloat                 fogStart;
    39     GLfloat                 fogEnd;
    40     Vector                  colorVector;
     35        private:
     36                GLint                   fogMode;
     37                GLfloat                 fogDensity;
     38                GLfloat                 fogStart;
     39                GLfloat                 fogEnd;
     40                Vector                  colorVector;
    4141};
    4242
  • branches/atmospheric_engine/src/lib/graphics/effects/rain_effect.cc

    r7646 r7652  
    2020
    2121#include "glincl.h"
    22 // #include "debug.h"
    23 
     22#include "p_node.h"
    2423#include "state.h"
    2524#include "spark_particles.h"
     
    3736RainEffect::RainEffect(const TiXmlElement* root)
    3837{
    39   this->setClassID(CL_RAIN_EFFECT, "RainEffect");
     38        this->setClassID(CL_RAIN_EFFECT, "RainEffect");
    4039
    41   if (root != NULL)
    42     this->loadParams(root);
     40        this->init();
    4341
    44   // this->soundSource.setSourceNode(this);
     42        if (root != NULL)
     43                this->loadParams(root);
    4544
    46   //load sound
    47   if (this->rainBuffer != NULL)
    48     ResourceManager::getInstance()->unload(this->rainBuffer);
    49   this->rainBuffer = (SoundBuffer*)ResourceManager::getInstance()->load("sound/rain.wav", WAV);
     45        //load sound
     46        if (this->rainBuffer != NULL)
     47                ResourceManager::getInstance()->unload(this->rainBuffer);
     48        this->rainBuffer = (SoundBuffer*)ResourceManager::getInstance()->load("sound/rain.wav", WAV);
    5049
    51   this->init();
    52 
    53   this->activate();
     50        this->activate();
    5451}
    5552
    5653RainEffect::~RainEffect()
    5754{
    58   this->deactivate();
     55        this->deactivate();
    5956}
    6057
     
    6360        WeatherEffect::loadParams(root);
    6461
     62        LoadParam(root, "moverain", this, RainEffect, setMoveRain);
    6563        LoadParam(root, "coord", this, RainEffect, setRainCoord);
    6664        LoadParam(root, "size", this, RainEffect, setRainSize);
    6765        LoadParam(root, "rate", this, RainEffect, setRainRate);
    6866        LoadParam(root, "velocity", this, RainEffect, setRainVelocity);
     67        LoadParam(root, "life", this, RainEffect, setRainLife);
    6968}
    7069
     
    7271bool RainEffect::init()
    7372{
    74   this->emitter = new PlaneEmitter(this->rainSize);
     73        //Default values
     74        this->rainCoord = Vector(500, 500, 500);
     75        this->rainSize = Vector2D(1000, 1000);
     76        this->rainRate = 5000;
     77        this->rainVelocity = -300;
     78        this->rainLife = 2;
    7579
     80        this->emitter = new PlaneEmitter(this->rainSize);
    7681}
    7782
     
    8186bool RainEffect::activate()
    8287{
    83         PRINTF(0)( "Activating RainEffect, coord: %f, %f, %f, size: %f, %f, rate: %f, velocity: %f\n", this->rainCoord.x, this->rainCoord.y, this->rainCoord.z, this->rainSize.x, this-> rainSize.y, this->rainRate, this->rainVelocity );
     88        PRINTF(0)( "Activating RainEffect, coord: %f, %f, %f, size: %f, %f, rate: %f, velocity: %f, moveRain: %s\n", this->rainCoord.x, this->rainCoord.y, this->rainCoord.z, this->rainSize.x, this-> rainSize.y, this->rainRate, this->rainVelocity, this->rainMove ? "true" : "false" );
    8489
    8590        if (unlikely(RainEffect::rainParticles == NULL))
    8691        {
    87                 RainEffect::rainParticles = new SparkParticles(10000);
     92                RainEffect::rainParticles = new SparkParticles(50000);
    8893                RainEffect::rainParticles->setName("RainParticles");
    89                 RainEffect::rainParticles->setLifeSpan(2, 2);
     94                RainEffect::rainParticles->setLifeSpan(this->rainLife, 2);
    9095                RainEffect::rainParticles->setRadius(0.02, 0.02);
    9196                RainEffect::rainParticles->setRadius(0.01, 0.01);
     
    98103
    99104        this->emitter->setSystem(RainEffect::rainParticles);
    100 
    101         // RainEffect::rainParticles->debug();
    102105
    103106        this->emitter->setRelCoor(this->rainCoord);
     
    115118bool RainEffect::deactivate()
    116119{
    117   PRINTF(0)("Deactivating RainEffect\n");
     120        PRINTF(0)("Deactivating RainEffect\n");
    118121
    119   this->emitter->setSystem(NULL);
     122        this->emitter->setSystem(NULL);
    120123}
    121124
    122125void RainEffect::tick (float dt)
    123126{
     127        //float distance = (State::getCameraNode()->getAbsCoor() - rainCoord).len();
     128       
     129        // PRINTF(0)( "RainEffect, coords: %f, %f, %f\n", this->rainCoord.x, this->rainCoord.y, this->rainCoord.z );
    124130
     131        //if (this->rainMove) {
     132                //PRINTF(0)( "Moving Rain" );
     133        //      this->rainCoord = State::getCameraNode()->getAbsCoor();
     134        //      this->emitter->setRelCoor(this->rainCoord.x +150, this->rainCoord.y+700, this->rainCoord.z+150);
     135        //}
    125136}
  • branches/atmospheric_engine/src/lib/graphics/effects/rain_effect.h

    r7646 r7652  
    11/**
    2  * @file rain_effect.h
    3  */
     2* @file rain_effect.h
     3*/
    44
    55#ifndef _RAIN_EFFECT
     
    2222class RainEffect : public WeatherEffect
    2323{
    24   public:
    25     RainEffect(const TiXmlElement* root = NULL);
    26     virtual ~RainEffect();
     24        public:
     25                RainEffect(const TiXmlElement* root = NULL);
     26                virtual ~RainEffect();
    2727
    28     virtual void loadParams(const TiXmlElement* root);
     28                virtual void loadParams(const TiXmlElement* root);
    2929
    30     virtual bool init();
     30                virtual bool init();
    3131
    32     virtual bool activate();
    33     virtual bool deactivate();
     32                virtual bool activate();
     33                virtual bool deactivate();
    3434
    35     virtual void tick(float dt);
     35                virtual void tick(float dt);
    3636
    37     inline void setRainCoord(float x, float y, float z) { this->rainCoord = Vector(x, y, z); }
    38     inline void setRainSize(float x, float y) { this->rainSize = Vector2D(x, y); }
    39     inline void setRainRate(float rate) { this->rainRate = rate;}
    40     inline void setRainVelocity(float velocity) { this->rainVelocity = -velocity; }
     37                inline void setRainCoord(float x, float y, float z) { this->rainCoord = Vector(x, y, z); }
     38                inline void setRainSize(float x, float y) { this->rainSize = Vector2D(x, y); }
     39                inline void setRainRate(float rate) { this->rainRate = rate;}
     40                inline void setRainVelocity(float velocity) { this->rainVelocity = -velocity; }
     41                inline void setRainLife(float life) { this->rainLife = life; }
     42                inline void setMoveRain() { PRINTF(0)( "setting move true\n"); this->rainMove = true; }
    4143
    42   private:
    43     static SparkParticles*            rainParticles;
    44     ParticleEmitter*                  emitter;
    4544
    46     Vector                            rainCoord;
    47     Vector2D                          rainSize;
    48     GLfloat                           rainRate;
    49     GLfloat                           rainVelocity;
     45        private:
     46                static SparkParticles*                                          rainParticles;
     47                ParticleEmitter*                                                                        emitter;
    5048
    51     SoundSource                       soundSource;
    52     SoundBuffer*                      rainBuffer;
     49                Vector                                                                                                          rainCoord;
     50                Vector2D                                                                                                        rainSize;
     51                GLfloat                                                                                                         rainRate;
     52                GLfloat                                                                                                         rainVelocity;
     53                GLfloat                                                                                                         rainLife;
     54                bool                                                                                                                    rainMove;
     55
     56                SoundSource                                                                                             soundSource;
     57                SoundBuffer*                                                                                    rainBuffer;
    5358};
    5459
  • branches/atmospheric_engine/src/lib/graphics/effects/snow_effect.cc

    r7651 r7652  
    11/*
    2    orxonox - the future of 3D-vertical-scrollers
     2        orxonox - the future of 3D-vertical-scrollers
    33
    4    Copyright (C) 2004 orx
     4        Copyright (C) 2004 orx
    55
    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.
     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.
    1010
    1111### File Specific:
    12    main-programmer: hdavid, amaechler
     12        main-programmer: hdavid, amaechler
    1313*/
    1414
     
    3838SnowEffect::SnowEffect(const TiXmlElement* root)
    3939{
    40   this->setClassID(CL_SNOW_EFFECT, "SnowEffect");
     40        this->setClassID(CL_SNOW_EFFECT, "SnowEffect");
    4141
    42   this->init();
     42        this->init();
    4343
    44   if (root != NULL)
    45     this->loadParams(root);
     44        if (root != NULL)
     45                this->loadParams(root);
    4646
    47   this->activate();
     47        this->activate();
    4848}
    4949
     
    5151SnowEffect::~SnowEffect()
    5252{
    53   this->deactivate();
     53        this->deactivate();
    5454}
    5555
     
    5858void SnowEffect::loadParams(const TiXmlElement* root)
    5959{
    60   WeatherEffect::loadParams(root);
     60        WeatherEffect::loadParams(root);
    6161
    62   LoadParam(root, "numParticles", this, SnowEffect, numParticles);
    63   LoadParam(root, "materialTexture", this, SnowEffect, materialTexture);
    64   LoadParam(root, "lifeSpans", this, SnowEffect, lifeSpan);
    65   LoadParam(root, "radius", this, SnowEffect, radius);
    66   LoadParam(root, "mass", this, SnowEffect, mass);
    67   LoadParam(root, "emissionRate", this, SnowEffect, emissionRate);
    68   LoadParam(root, "emissionVelocity", this, SnowEffect, emissionVelocity);
    69   LoadParam(root, "spread", this, SnowEffect, spread);
    70   LoadParam(root, "size", this, SnowEffect, size);
    71   LoadParam(root, "coord", this, SnowEffect, coord);
     62        LoadParam(root, "numParticles", this, SnowEffect, numParticles);
     63        LoadParam(root, "materialTexture", this, SnowEffect, materialTexture);
     64        LoadParam(root, "lifeSpans", this, SnowEffect, lifeSpan);
     65        LoadParam(root, "radius", this, SnowEffect, radius);
     66        LoadParam(root, "mass", this, SnowEffect, mass);
     67        LoadParam(root, "emissionRate", this, SnowEffect, emissionRate);
     68        LoadParam(root, "emissionVelocity", this, SnowEffect, emissionVelocity);
     69        LoadParam(root, "spread", this, SnowEffect, spread);
     70        LoadParam(root, "size", this, SnowEffect, size);
     71        LoadParam(root, "coord", this, SnowEffect, coord);
    7272}
    7373
    7474bool SnowEffect::init()
    7575{
    76   this->emitter = new PlaneEmitter();
     76        this->emitter = new PlaneEmitter();
    7777
    78   // Default values
    79   particles = 10000;
    80   texture = "maps/snow_flake_01_32x32.png";
    81   life = 8;
    82   randomLife = 2;
    83   snowRadius = 3.5;
    84   randomRadius = 1;
    85   snowMass = 1.0;
    86   randomMass = 0.3;
    87   rate = 900;
    88   velocity = -100;
    89   randomVelocity = 5;
    90   angle = 0;
    91   randomAngle = 0.3;
    92   alpha = 0.5;
    93   snowSize = Vector2D(1200, 1200);
    94   snowCoord = Vector(100, 600, 200);
     78        // Default values
     79        particles = 10000;
     80        texture = "maps/snow_flake_01_32x32.png";
     81        life = 8;
     82        randomLife = 2;
     83        snowRadius = 3.5;
     84        randomRadius = 1;
     85        snowMass = 1.0;
     86        randomMass = 0.3;
     87        rate = 900;
     88        velocity = -100;
     89        randomVelocity = 5;
     90        angle = 0;
     91        randomAngle = 0.3;
     92        alpha = 0.5;
     93        snowSize = Vector2D(1200, 1200);
     94        snowCoord = Vector(100, 600, 200);
    9595
    96   activated = false;
     96        activated = false;
    9797}
    9898
    9999bool SnowEffect::activate()
    100100{
    101   PRINTF(0)("Activating SnowEffect\n");
    102   activated = true;
    103  
    104   SnowEffect::snowParticles = new SpriteParticles(particles);
    105   SnowEffect::snowParticles->setName("SnowEffectTrailParticles");
    106   SnowEffect::snowParticles->setMaterialTexture(texture);
    107   SnowEffect::snowParticles->setLifeSpan(life, randomLife);
    108   SnowEffect::snowParticles->setRadius(0.0, snowRadius, randomRadius);
    109   SnowEffect::snowParticles->setRadius(0.2, snowRadius, randomRadius);
    110   SnowEffect::snowParticles->setRadius(1.0, snowRadius, randomRadius);
    111   SnowEffect::snowParticles->setMass(0, snowMass, randomMass);
    112   SnowEffect::snowParticles->setColor(0,1, 1, 1, alpha);
    113   SnowEffect::snowParticles->setColor(.5, .6, .6, .6, alpha/2);
    114   SnowEffect::snowParticles->setColor(1, .0, .0, .0, .0);
     101        PRINTF(0)("Activating SnowEffect\n");
     102        activated = true;
    115103
    116  
    117   this->emitter->setSystem(SnowEffect::snowParticles);
    118  
    119  // this->updateNode(0);
    120   this->emitter->setRelCoor(snowCoord);
    121   this->emitter->setEmissionRate(rate);
    122   this->emitter->setEmissionVelocity(velocity, randomVelocity);
    123   this->emitter->setSpread(angle, randomAngle);
    124   this->emitter->setSize(snowSize);
     104        SnowEffect::snowParticles = new SpriteParticles(particles);
     105        SnowEffect::snowParticles->setName("SnowEffectTrailParticles");
     106        SnowEffect::snowParticles->setMaterialTexture(texture);
     107        SnowEffect::snowParticles->setLifeSpan(life, randomLife);
     108        SnowEffect::snowParticles->setRadius(0.0, snowRadius, randomRadius);
     109        SnowEffect::snowParticles->setRadius(0.2, snowRadius, randomRadius);
     110        SnowEffect::snowParticles->setRadius(1.0, snowRadius, randomRadius);
     111        SnowEffect::snowParticles->setMass(0, snowMass, randomMass);
     112        SnowEffect::snowParticles->setColor(0,1, 1, 1, alpha);
     113        SnowEffect::snowParticles->setColor(.5, .6, .6, .6, alpha/2);
     114        SnowEffect::snowParticles->setColor(1, .0, .0, .0, .0);
     115
     116        this->emitter->setSystem(SnowEffect::snowParticles);
     117
     118// this->updateNode(0);
     119        this->emitter->setRelCoor(snowCoord);
     120        this->emitter->setEmissionRate(rate);
     121        this->emitter->setEmissionVelocity(velocity, randomVelocity);
     122        this->emitter->setSpread(angle, randomAngle);
     123        this->emitter->setSize(snowSize);
    125124}
    126125
     
    128127bool SnowEffect::deactivate()
    129128{
    130   PRINTF(0)("Deactivating SnowEffect\n");
    131   activated = false;
    132  
    133   this->emitter->setSystem(NULL);
     129        PRINTF(0)("Deactivating SnowEffect\n");
     130        activated = false;
     131
     132        this->emitter->setSystem(NULL);
    134133}
    135134
    136135void SnowEffect::activateSnow()
    137136{
    138   this->activate();
     137        this->activate();
    139138}
    140139
    141140void SnowEffect::deactivateSnow()
    142141{
    143   this->deactivate();
     142        this->deactivate();
    144143}
    145144
     
    150149void SnowEffect::tick(float dt)
    151150{
    152   float distance = (State::getCameraNode()->getAbsCoor() - snowCoord).len();
    153   if( activated && ( distance > 0.6*snowSize.x || distance > 0.6*snowSize.y) )
    154     this->deactivate();
    155   if( !activated && ( distance < 0.6*snowSize.x || distance < 0.6*snowSize.y ))
    156     this->activate();
     151        float distance = (State::getCameraNode()->getAbsCoor() - snowCoord).len();
     152        if( activated && ( distance > 0.6*snowSize.x || distance > 0.6*snowSize.y) )
     153                this->deactivate();
     154        if( !activated && ( distance < 0.6*snowSize.x || distance < 0.6*snowSize.y ))
     155                this->activate();
    157156}
    158157
  • branches/atmospheric_engine/src/lib/graphics/effects/snow_effect.h

    r7651 r7652  
    11/**
    2  * @file snow_effect.h
    3  */
     2* @file snow_effect.h
     3*/
    44
    55#ifndef _SNOW_EFFECT
     
    1919class SnowEffect : public WeatherEffect
    2020{
    21   public:
    22     SnowEffect(const TiXmlElement* root = NULL);
    23     virtual ~SnowEffect();
     21        public:
     22                SnowEffect(const TiXmlElement* root = NULL);
     23                virtual ~SnowEffect();
    2424
    25     virtual void loadParams(const TiXmlElement* root);
     25                virtual void loadParams(const TiXmlElement* root);
    2626
    27     virtual bool init();
     27                virtual bool init();
    2828
    29     virtual bool activate();
    30     virtual bool deactivate();
     29                virtual bool activate();
     30                virtual bool deactivate();
    3131
    32     virtual void draw() const;
    33     virtual void tick(float dt);
     32                virtual void draw() const;
     33                virtual void tick(float dt);
    3434
    35     void activateSnow();
    36     void deactivateSnow();
     35                void activateSnow();
     36                void deactivateSnow();
    3737
    38   private:
    39     void numParticles(int n) { this->particles = n; }
    40     void materialTexture(const std::string& texture) { this->texture = texture; }
    41     void lifeSpan(float lifeSpan, float randomLifeSpan) { this->life = lifeSpan; this->randomLife = randomLifeSpan; }
    42     void radius(float radius, float randomRadius) { this->snowRadius = radius; this->randomRadius = randomRadius; }
    43     void mass(float mass, float randomMass) { this->snowMass = mass; this->randomMass = randomMass; }
    44     void emissionRate(float emissionRate){ this->rate = emissionRate; }
    45     void emissionVelocity(float velocity, float randomVelocity){ this->velocity = velocity; this->randomVelocity = randomVelocity; }
    46     void spread(float angle, float randomAngle) { this->angle = angle; this->randomAngle = randomAngle; }
    47     void size(float sizeX, float sizeY) { this->snowSize = Vector2D(sizeX, sizeY); }
    48     void coord(float x, float y, float z) { this->snowCoord = Vector(x, y, z); }
     38        private:
     39                void numParticles(int n) { this->particles = n; }
     40                void materialTexture(const std::string& texture) { this->texture = texture; }
     41                void lifeSpan(float lifeSpan, float randomLifeSpan) { this->life = lifeSpan; this->randomLife = randomLifeSpan; }
     42                void radius(float radius, float randomRadius) { this->snowRadius = radius; this->randomRadius = randomRadius; }
     43                void mass(float mass, float randomMass) { this->snowMass = mass; this->randomMass = randomMass; }
     44                void emissionRate(float emissionRate){ this->rate = emissionRate; }
     45                void emissionVelocity(float velocity, float randomVelocity){ this->velocity = velocity; this->randomVelocity = randomVelocity; }
     46                void spread(float angle, float randomAngle) { this->angle = angle; this->randomAngle = randomAngle; }
     47                void size(float sizeX, float sizeY) { this->snowSize = Vector2D(sizeX, sizeY); }
     48                void coord(float x, float y, float z) { this->snowCoord = Vector(x, y, z); }
    4949
    50     int particles;
    51     std::string texture;
    52     float life, randomLife;
    53     float snowRadius, randomRadius;
    54     float snowMass, randomMass;
    55     float rate;
    56     float velocity, randomVelocity;
    57     float angle, randomAngle;
    58     float alpha;
    59     Vector snowCoord;
    60     Vector2D snowSize;
     50                int particles;
     51                std::string texture;
     52                float life, randomLife;
     53                float snowRadius, randomRadius;
     54                float snowMass, randomMass;
     55                float rate;
     56                float velocity, randomVelocity;
     57                float angle, randomAngle;
     58                float alpha;
     59                Vector snowCoord;
     60                Vector2D snowSize;
    6161
    62     bool activated;
     62                bool activated;
    6363
    64     static SpriteParticles* snowParticles;
     64                static SpriteParticles* snowParticles;
    6565
    66     PlaneEmitter*          emitter;
     66                PlaneEmitter*          emitter;
    6767};
    6868
  • branches/atmospheric_engine/src/lib/graphics/effects/volfog_effect.cc

    r7577 r7652  
    11/*
    2    orxonox - the future of 3D-vertical-scrollers
     2        orxonox - the future of 3D-vertical-scrollers
    33
    4    Copyright (C) 2004 orx
     4        Copyright (C) 2004 orx
    55
    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.
     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.
    1010
    1111### File Specific:
    12    main-programmer: hdavid, amaechler
     12        main-programmer: hdavid, amaechler
    1313*/
    1414
     
    2727VolFogEffect::VolFogEffect(const TiXmlElement* root)
    2828{
    29   this->setClassID(CL_VOLFOG_EFFECT, "VolFogEffect");
     29        this->setClassID(CL_VOLFOG_EFFECT, "VolFogEffect");
    3030
    31   if (root != NULL)
    32     this->loadParams(root);
     31        if (root != NULL)
     32                this->loadParams(root);
    3333
    34   // Initialize Effect
    35   this->init();
     34        // Initialize Effect
     35        this->init();
    3636
    37   // Activate Effect
    38   this->activate();
     37        // Activate Effect
     38        this->activate();
    3939}
    4040
     
    4242VolFogEffect::~VolFogEffect()
    4343{
    44   this->deactivate();
     44        this->deactivate();
    4545}
    4646
    4747void VolFogEffect::loadParams(const TiXmlElement* root)
    4848{
    49   WeatherEffect::loadParams(root);
     49        WeatherEffect::loadParams(root);
    5050}
    5151
    5252bool VolFogEffect::init()
    5353{
    54   PRINTF(0)("Initalize VolFogEffect\n");
    55  
    56   if (glewInit() == GLEW_OK)
    57     PRINTF(0)("glewInit OK\n");
    58   else
    59     PRINTF(0)("glewInit failed\n");
     54        PRINTF(0)("Initalize VolFogEffect\n");
     55       
     56        if (glewInit() == GLEW_OK)
     57                PRINTF(0)("glewInit OK\n");
     58        else
     59                PRINTF(0)("glewInit failed\n");
    6060
    61   // Set fog color
    62   float fogColor[4] = {0.0, 1.0, 0.0, 1.0};
     61        // Set fog color
     62        float fogColor[4] = {0.0, 1.0, 0.0, 1.0};
    6363
    64   /* set up fog params */       
    65   glEnable(GL_FOG);                                             // Enable Fog
    66   glFogi(GL_FOG_MODE, GL_LINEAR);                               // Fog Fade Is Linear
    67   glFogfv(GL_FOG_COLOR, fogColor);                              // Set The Fog Color
    68   glFogf(GL_FOG_START, 0.0f);                                   // Set The Fog Start
    69   glFogf(GL_FOG_END, 1.0f);                                     // Set The Fog End
    70   glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FOG_COORDINATE_EXT);  // Set The Fog based on vertice coordinates
    71   // glHint(GL_FOG_HINT, GL_NICEST);                            // Per-Pixel Fog Calculation
     64        /* set up fog params */
     65        glEnable(GL_FOG);                                               // Enable Fog
     66        glFogi(GL_FOG_MODE, GL_LINEAR);                         // Fog Fade Is Linear
     67        glFogfv(GL_FOG_COLOR, fogColor);                                // Set The Fog Color
     68        glFogf(GL_FOG_START, 0.0f);                                     // Set The Fog Start
     69        glFogf(GL_FOG_END, 1.0f);                                       // Set The Fog End
     70        glFogi(GL_FOG_COORDINATE_SOURCE_EXT, GL_FOG_COORDINATE_EXT);    // Set The Fog based on vertice coordinates
     71        // glHint(GL_FOG_HINT, GL_NICEST);                              // Per-Pixel Fog Calculation
    7272
    73   // glClearColor(0.0, 0.0, 0.0, 1.0);  //sets bg color?!
     73        // glClearColor(0.0, 0.0, 0.0, 1.0);  //sets bg color?!
    7474
    75   /* enable texturing & set texturing function */
    76   // glEnable(GL_TEXTURE_2D);
    77   // glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
     75        /* enable texturing & set texturing function */
     76        // glEnable(GL_TEXTURE_2D);
     77        // glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
    7878
    79   if (glewGetExtension("GL_EXT_fog_coord"))
    80   {
    81     PRINTF(0)("GL_EXT_fog_coord extension found\n");
    82     return true;
    83   }
    84   else
    85   {
    86     PRINTF(0)("GL_EXT_fog_coord extension NOT found\n");
    87     return false;
    88   }
     79        if (glewGetExtension("GL_EXT_fog_coord"))
     80        {
     81                PRINTF(0)("GL_EXT_fog_coord extension found\n");
     82                return true;
     83        }
     84        else
     85        {
     86                PRINTF(0)("GL_EXT_fog_coord extension NOT found\n");
     87                return false;
     88        }
    8989}
    9090
     
    9292bool VolFogEffect::activate()
    9393{
    94   PRINTF(0)("Activating VolFogEffect\n");
     94        PRINTF(0)("Activating VolFogEffect\n");
    9595}
    9696
    9797bool VolFogEffect::deactivate()
    9898{
    99   PRINTF(0)("Deactivating VolFogEffect\n");
     99        PRINTF(0)("Deactivating VolFogEffect\n");
    100100}
    101101
    102102
    103103/**
    104  * draws the effect, if needed
    105  */
     104* draws the effect, if needed
     105*/
    106106void VolFogEffect::draw() const
    107107{
     
    134134
    135135        glBegin(GL_QUADS); // Back Wall
    136                 glFogCoordfEXT(0.0f);   glVertex3f(0.0f,0.0f,0.0f);
     136                glFogCoordfEXT(0.0f);   glVertex3f(0.0f,0.0f,0.0f);
    137137                glFogCoordfEXT(0.0f);   glVertex3f( 100.0f,0.0f,0.0f);
    138138                glFogCoordfEXT(1.0f);   glVertex3f( 100.0f, 100.0f,0.0f);
     
    141141
    142142        glBegin(GL_QUADS); // Front Wall
    143                 glFogCoordfEXT(0.0f);   glVertex3f(0.0f,0.0f,100.0f);
     143                glFogCoordfEXT(0.0f);   glVertex3f(0.0f,0.0f,100.0f);
    144144                glFogCoordfEXT(0.0f);   glVertex3f( 100.0f,0.0f,100.0f);
    145145                glFogCoordfEXT(1.0f);   glVertex3f( 100.0f, 100.0f,100.0f);
     
    155155
    156156        glBegin(GL_QUADS); // Left Wall
    157                 glFogCoordfEXT(0.0f);   glVertex3f(0.0f,0.0f, 100.0f);
     157                glFogCoordfEXT(0.0f);   glVertex3f(0.0f,0.0f, 100.0f);
    158158                glFogCoordfEXT(1.0f);   glVertex3f(0.0f, 100.0f, 100.0f);
    159159                glFogCoordfEXT(1.0f);   glVertex3f(0.0f, 100.0f,0.0f);
     
    169169
    170170/**
    171  * ticks the effect if there is any time dependancy
    172  */
     171* ticks the effect if there is any time dependancy
     172*/
    173173void VolFogEffect::tick(float dt)       
    174174{
  • branches/atmospheric_engine/src/lib/graphics/effects/volfog_effect.h

    r7568 r7652  
    11/**
    2  * @file volfog_effect.h
    3  */
     2* @file volfog_effect.h
     3*/
    44
    55#ifndef _VOLFOG_EFFECT
     
    1212class VolFogEffect : public WeatherEffect
    1313{
    14   public:
    15     VolFogEffect(const TiXmlElement* root = NULL);
    16     virtual ~VolFogEffect();
     14        public:
     15                VolFogEffect(const TiXmlElement* root = NULL);
     16                virtual ~VolFogEffect();
    1717
    18     virtual void loadParams(const TiXmlElement* root);
     18                virtual void loadParams(const TiXmlElement* root);
    1919
    20     virtual bool init();
     20                virtual bool init();
    2121
    22     virtual bool activate();
    23     virtual bool deactivate();
     22                virtual bool activate();
     23                virtual bool deactivate();
    2424
    25     virtual void draw() const;
    26     virtual void tick(float dt);
     25                virtual void draw() const;
     26                virtual void tick(float dt);
    2727
    28   private:
    29     GLfloat fogColor[4];
     28        private:
     29                GLfloat fogColor[4];
    3030
    3131};
Note: See TracChangeset for help on using the changeset viewer.