Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 24, 2006, 3:35:07 PM (19 years ago)
Author:
amaechler
Message:

branches/atmospheric_engine: rainsound fade working and comments

File:
1 edited

Legend:

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

    r8734 r8771  
    2020#include "shell_command.h"
    2121
     22// Define shell commands
    2223SHELL_COMMAND(activate, FogEffect, activateFog);
    2324SHELL_COMMAND(deactivate, FogEffect, deactivateFog);
     
    2526SHELL_COMMAND(fadeout, FogEffect, fadeOutFog);
    2627
    27 // TODO: Fix fades
    28 
    2928using namespace std;
    3029
    3130CREATE_FACTORY(FogEffect, CL_FOG_EFFECT);
    3231
     32/**
     33 * @brief standard constructor
     34 */
    3335FogEffect::FogEffect(const TiXmlElement* root) {
    3436    this->setClassID(CL_FOG_EFFECT, "FogEffect");
    3537
     38    // Initialize values
    3639    this->init();
    3740
     41    // Load XML params
    3842    if (root != NULL)
    3943        this->loadParams(root);
    4044
     45    // Activate fog, if chosen to be activated by default
    4146    if (this->fogActivate)
    4247        this->activate();
    4348}
    4449
    45 
     50/**
     51 * @brief standard destructor
     52 */
    4653FogEffect::~FogEffect() {
    4754    this->deactivate();
    4855}
    4956
    50 
     57/**
     58 * @brief initalizes the fog effect with default values
     59 */
     60void FogEffect::init() {
     61    // default values
     62  this->fogMode = GL_LINEAR;
     63  this->fogDensity = 0.005;
     64  this->fogStart = 0;
     65  this->fogEnd = 300;
     66  this->colorVector = Vector(0.6, 0.0, 0.0);
     67
     68    // init variables
     69  this->fogFadeInDuration = 0;
     70  this->fogFadeOutDuration = 0;
     71  this->fogFadeDensity = 0;
     72  this->fogFadeEnd = 0;
     73
     74  this->localTimer = 0;
     75  this->fogActivate = false;
     76  this->fogFadeInActivate = false;
     77  this->fogFadeOutActivate = false;
     78}
     79
     80/**
     81 * @brief loads the fog effect parameters.
     82 * @param root: the XML-Element to load the data from
     83 */
    5184void FogEffect::loadParams(const TiXmlElement* root) {
    5285    WeatherEffect::loadParams(root);
    5386
    54     LoadParam(root, "mode", this, FogEffect, setFogMode);
    55     LoadParam(root, "density", this, FogEffect, setFogDensity);
    56     LoadParam(root, "range", this, FogEffect, setFogRange);
    57     LoadParam(root, "color", this, FogEffect, setFogColor);
    58     LoadParam(root, "fadeinduration", this, FogEffect, setFogFadeIn);
    59     LoadParam(root, "fadeoutduration", this, FogEffect, setFogFadeOut);
     87    LoadParam(root, "mode", this, FogEffect, setFogMode).describe("fog mode (linear, exponential)");;
     88    LoadParam(root, "density", this, FogEffect, setFogDensity).describe("fog density if exp. fog");;
     89    LoadParam(root, "range", this, FogEffect, setFogRange).describe("fog range: start, end");;
     90    LoadParam(root, "color", this, FogEffect, setFogColor).describe("fog color: r,g,b");;
     91    LoadParam(root, "fadeinduration", this, FogEffect, setFogFadeIn).describe("duration of the fade in");;
     92    LoadParam(root, "fadeoutduration", this, FogEffect, setFogFadeOut).describe("duration of the fade out");;
    6093
    6194    LOAD_PARAM_START_CYCLE(root, element);
    6295    {
    63         LoadParam_CYCLE(element, "option", this, FogEffect, setFogOption);
     96      LoadParam_CYCLE(element, "option", this, FogEffect, setFogOption).describe("sets a fog option: activate");;
    6497    }
    6598    LOAD_PARAM_END_CYCLE(element);
    6699}
    67100
    68 void FogEffect::init() {
    69     // default values
    70     this->fogMode = GL_LINEAR;
    71     this->fogDensity = 0.005;
    72     this->fogStart = 0;
    73     this->fogEnd = 300;
    74     this->colorVector = Vector(0.6, 0.0, 0.0);
    75 
    76     // init variables
    77     this->fogFadeInDuration = 0;
    78     this->fogFadeOutDuration = 0;
    79     this->fogFadeDensity = 0;
    80     this->fogFadeEnd = 0;
    81 
    82     this->localTimer = 0;
    83     this->fogActivate = false;
    84     this->fogFadeInActivate = false;
    85     this->fogFadeOutActivate = false;
    86 
    87 }
    88 
    89 
     101/**
     102 * @brief activates the fog effect
     103 */
    90104void FogEffect::activate() {
    91105    PRINTF(0)( "Activating FogEffect\n");
     
    103117
    104118    glEnable(GL_FOG);
    105 
    106 }
    107 
    108 
     119}
     120
     121/**
     122 * @brief deactivates the fog effect
     123 */
    109124void FogEffect::deactivate() {
    110125    PRINTF(0)("Deactivating FogEffect\n");
     
    115130
    116131    glDisable(GL_FOG);
    117 
    118 }
    119 
     132}
     133
     134/**
     135 * @brief draws the fog effect
     136 */
    120137void FogEffect::draw() const {
    121138
     
    123140        return;
    124141
    125     // If Fog Fade
     142    // If fog is fading
    126143    if ( this->fogFadeInActivate || this->fogFadeOutActivate ) {
    127144        if ( this->fogMode == GL_LINEAR)
     
    132149}
    133150
     151/**
     152 * @brief ticks the fog effect
     153 * @param dt: tick float
     154 */
    134155void FogEffect::tick(float dt) {
    135156
     
    137158        return;
    138159
     160    // If fog is fading in
    139161    if ( this->fogFadeInActivate ) {
    140162        this->localTimer += dt;
     
    149171    }
    150172
     173    // If fog is fading out
    151174    if ( this->fogFadeOutActivate ) {
    152175        this->localTimer += dt;
     
    162185}
    163186
     187/**
     188 * @brief fades the fog in
     189 */
    164190void FogEffect::fadeInFog() {
    165191
     
    183209    // set FogFadeIn activate
    184210    this->fogFadeInActivate = true;
    185 
    186 }
    187 
    188 
     211}
     212
     213/**
     214 * @brief fades the fog out
     215 */
    189216void FogEffect::fadeOutFog() {
    190217
     
    205232    // Reset local timer
    206233    this->localTimer = 0;
    207 
    208 }
    209 
     234}
     235
Note: See TracChangeset for help on using the changeset viewer.