Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8495 in orxonox.OLD


Ignore:
Timestamp:
Jun 15, 2006, 9:50:56 PM (18 years ago)
Author:
bensch
Message:

merged the branche atmos back. no conflicts

Location:
trunk/src
Files:
2 deleted
27 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/collision_reaction/collision_handle.cc

    r8490 r8495  
    11/*
    2    orxonox - the future of 3D-vertical-scrollers
     2   orxonox - the future of 3D-vertical-scrollersf
    33
    44   Copyright (C) 2004 orx
     
    101101      return;
    102102
    103   // add element
    104    PRINTF(0)("addTarget: %i \n", target);
     103   // add element
     104   //PRINTF(0)("addTarget: %i \n", target);
     105
    105106   this->targetList.push_back(target);
    106107}
  • trunk/src/lib/graphics/effects/atmospheric_engine.cc

    r8190 r8495  
    3030 * @param root The XML-element to load the AtmosphericEngine from
    3131 */
    32 AtmosphericEngine::AtmosphericEngine()
    33 {
    34   this->setClassID(CL_ATMOSPHERIC_ENGINE, "AtmosphericEngine");
     32AtmosphericEngine::AtmosphericEngine() {
     33    this->setClassID(CL_ATMOSPHERIC_ENGINE, "AtmosphericEngine");
    3534}
    3635
     
    4443 *  destroys a AtmosphericEngine
    4544 */
    46 AtmosphericEngine::~AtmosphericEngine()
    47 {
    48   AtmosphericEngine::singletonRef = NULL;
     45AtmosphericEngine::~AtmosphericEngine() {
     46    AtmosphericEngine::singletonRef = NULL;
    4947
    50   const std::list<BaseObject*>* weatherEffects = ClassList::getList( CL_WEATHER_EFFECT);
     48    const std::list<BaseObject*>* weatherEffects = ClassList::getList( CL_WEATHER_EFFECT);
    5149
    52   if (weatherEffects != NULL)
    53   {
    54       while(!weatherEffects->empty())
    55         delete weatherEffects->front();
    56   }
     50    if (weatherEffects != NULL) {
     51        while(!weatherEffects->empty())
     52            delete weatherEffects->front();
     53    }
    5754}
    5855
     
    6057 * @param root The XML-element to load the AtmosphericEngine from
    6158 */
    62 void AtmosphericEngine::loadParams(const TiXmlElement* root)
    63 {
    64   LoadParamXML(root, "WeatherEffect", this, AtmosphericEngine, loadWeatherEffect);
    65   LoadParamXML(root, "SunEffect", this, AtmosphericEngine, loadSunEffect);
     59void AtmosphericEngine::loadParams(const TiXmlElement* root) {
     60    LoadParamXML(root, "WeatherEffect", this, AtmosphericEngine, loadWeatherEffect);
     61    LoadParamXML(root, "SunEffect", this, AtmosphericEngine, loadSunEffect);
    6662}
    6763
     
    6965 * @param root The XML-element to load WeatherEffects from
    7066 */
    71 void AtmosphericEngine::loadWeatherEffect(const TiXmlElement* root)
    72 {
    73   LOAD_PARAM_START_CYCLE(root, element);
    74   {
    75     PRINTF(4)("element is: %s\n", element->Value());
    76     // Factory::fabricate(element);
     67void AtmosphericEngine::loadWeatherEffect(const TiXmlElement* root) {
     68    LOAD_PARAM_START_CYCLE(root, element);
     69    {
     70        PRINTF(4)("element is: %s\n", element->Value());
     71        // Factory::fabricate(element);
    7772
    78     BaseObject* bo = Factory::fabricate(element);
    79     if( bo == NULL)
    80       PRINTF(0)(" Could not create Element %s\n", element->Value());
    81   }
    82   LOAD_PARAM_END_CYCLE(element);
     73        BaseObject* bo = Factory::fabricate(element);
     74        if( bo == NULL)
     75            PRINTF(0)(" Could not create Element %s\n", element->Value());
     76    }
     77    LOAD_PARAM_END_CYCLE(element);
    8378}
    8479
     
    8681 * @param root The XML-element to load SunEffects from
    8782 */
    88 void AtmosphericEngine::loadSunEffect(const TiXmlElement* root)
    89 {
    90   LOAD_PARAM_START_CYCLE(root, element);
    91   {
    92     PRINTF(4)("element is: %s\n", element->Value());
    93   }
    94   LOAD_PARAM_END_CYCLE(element);
     83void AtmosphericEngine::loadSunEffect(const TiXmlElement* root) {
     84    LOAD_PARAM_START_CYCLE(root, element);
     85    {
     86        PRINTF(4)("element is: %s\n", element->Value());
     87    }
     88    LOAD_PARAM_END_CYCLE(element);
    9589}
    9690
     
    9993 * draws the effect, if needed
    10094 */
    101 void AtmosphericEngine::draw() const
    102 {
    103   const std::list<BaseObject*>* weatherEffects = ClassList::getList( CL_WEATHER_EFFECT);
     95void AtmosphericEngine::draw() const {
     96    const std::list<BaseObject*>* weatherEffects = ClassList::getList( CL_WEATHER_EFFECT);
    10497
    105   // draw the weather effects
    106   if (weatherEffects != NULL)
    107   {
    108     std::list<BaseObject*>::const_iterator it;
    109     for (it = weatherEffects->begin(); it != weatherEffects->end(); it++)
    110       dynamic_cast<WeatherEffect*>(*it)->draw();
    111   }
     98    // draw the weather effects
     99    if (weatherEffects != NULL) {
     100        std::list<BaseObject*>::const_iterator it;
     101        for (it = weatherEffects->begin(); it != weatherEffects->end(); it++)
     102            dynamic_cast<WeatherEffect*>(*it)->draw();
     103    }
    112104}
    113105
     
    117109 * ticks the effect if there is any time dependancy
    118110 */
    119 void AtmosphericEngine::tick(float dt)
    120 {
    121   const std::list<BaseObject*>* weatherEffects = ClassList::getList( CL_WEATHER_EFFECT);
     111void AtmosphericEngine::tick(float dt) {
     112    const std::list<BaseObject*>* weatherEffects = ClassList::getList( CL_WEATHER_EFFECT);
    122113
    123   // tick the weather effects
    124   if (weatherEffects != NULL)
    125   {
    126     std::list<BaseObject*>::const_iterator it;
    127     for (it = weatherEffects->begin(); it != weatherEffects->end(); it++)
    128     {
    129 /*      printf("%s::%s \n", (*it)->getClassName(), (*it)->getName());*/
    130       dynamic_cast<WeatherEffect*>(*it)->tick(dt);
     114    // tick the weather effects
     115    if (weatherEffects != NULL) {
     116        std::list<BaseObject*>::const_iterator it;
     117        for (it = weatherEffects->begin(); it != weatherEffects->end(); it++) {
     118            /*      printf("%s::%s \n", (*it)->getClassName(), (*it)->getName());*/
     119            dynamic_cast<WeatherEffect*>(*it)->tick(dt);
     120        }
    131121    }
    132   }
    133122}
  • trunk/src/lib/graphics/effects/cloud_effect.cc

    r8255 r8495  
    2121#include "util/loading/resource_manager.h"
    2222
    23 #include "glincl.h"
    2423#include "material.h"
    2524#include <math.h>
     
    3130#include "parser/tinyxml/tinyxml.h"
    3231
    33 #include "sglmodel.h"
    3432
    3533using namespace std;
     
    4341{
    4442        this->setClassID(CL_CLOUD_EFFECT, "CloudEffect");
     43//  this->toList(OM_ENVIRON);
    4544
    4645        this->init();
     
    4948                this->loadParams(root);
    5049
    51         if(cloudActivate)
     50        //if(cloudActivate)
    5251                this->activate();
    5352}
     
    5655{
    5756        this->deactivate();
    58 
    59         delete this->cloudMaterial;
    60 
    61         cloudModel.Delete();
    62         Shader::unload(this->cloudShader);
    63 
    6457}
    6558
    6659
    67 bool CloudEffect::init()
     60void CloudEffect::init()
    6861{
    69         PRINTF(1)("Initializing CloudEffect\n");
     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);
    7071
    71         // Default values
    72         this->cloudActivate = false;
    73         this->cloudTint[4] = ( 0.9f, 0.7f, 0.7f, 1.0f );
    74         this->cloudScroll = 1.0f;
    75         this->time = 0.0f;
    76         //g_cloud_texture = 0;
     72  shader = new Shader(ResourceManager::getInstance()->getDataDir() + "/shaders/cloud.vert",
     73                      ResourceManager::getInstance()->getDataDir() + "/shaders/cloud.frag");
     74 
     75  this->shader->activateShader();
    7776
    78         this->cloudTexture = "pictures/sky/cloud1.jpg";
    79 
    80         cloudModel.Load("sky.sgl");
    81         cloudModel.Unitize();
    82 
    83         // Get the bounding box of the sky dome
    84         float bbox[3] = {0};
    85         cloudModel.GetDimensions(bbox[0], bbox[1], bbox[2]);
    86        
    87         // Load Shaders
    88         this->cloudShader = new Shader( ResourceManager::getInstance()->getDataDir() + "/shaders/sky.vert", ResourceManager::getInstance()->getDataDir() +"/shaders/sky.frag");
    89 
    90         // Tell the shader the bounding box of the sky dome
    91         this->cloudShader->bindShader("bbox", bbox, 4);
    92 
    93         // Initialze Cloud Material
    94         this->cloudMaterial = new Material("Sky");
    95         this->cloudMaterial->setIllum(3);
    96         this->cloudMaterial->setAmbient(1.0, 1.0, 1.0);
    97         this->cloudMaterial->setDiffuseMap(this->cloudTexture);
    98 
     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();
    9988}
    10089
     
    10695        // LoadParam(root, "speed", this, CloudEffect, setCloudAnimation);
    10796        // LoadParam(root, "texture", this, CloudEffect, setCloudTexture);
    108 
     97  /*
    10998        LOAD_PARAM_START_CYCLE(root, element);
    11099        {
    111100                LoadParam_CYCLE(element, "option", this, CloudEffect, setCloudOption);
    112101        }
    113         LOAD_PARAM_END_CYCLE(element);
     102  LOAD_PARAM_END_CYCLE(element);*/
    114103}
    115104
    116105
    117 bool CloudEffect::activate()
     106void CloudEffect::activate()
    118107{
    119         PRINTF(0)( "Activating CloudEffect with Material %s\n", this->cloudTexture.c_str());
     108        PRINTF(0)( "Activating\n");
    120109
    121         this->cloudActivate = true;
    122        
     110//      this->cloudActivate = true;
    123111}
    124112
    125 bool CloudEffect::deactivate()
     113void CloudEffect::deactivate()
    126114{
    127115        PRINTF(0)("Deactivating CloudEffect\n");
    128116
    129         this->cloudActivate = false;
     117//      this->cloudActivate = false;
    130118}
    131119
    132120void CloudEffect::draw() const
    133121{
    134         if (!this->cloudActivate)
    135                 return;
    136                
    137         //      glMatrixMode(GL_MODELVIEW);
    138         //      glPushMatrix();
    139         //
    140         //      // Move sphere along with the camera
    141         //      Vector r = State::getCameraNode()->getAbsCoor();
    142         //      glTranslatef(r.x, r.y, r.z);
    143         //
    144         //      // Sky movement
    145         //      glRotatef(mover, 0, 0, 1);
    146         //
    147         //      cloudMaterial->select();
    148         //      gluSphere(this->sphereObj, this->sphereRadius, 20, 20);
    149         //      glPopMatrix();
     122        //if (!this->cloudActivate)
     123        //      return;
    150124
    151         // ******
     125  //glMatrixMode(GL_MODELVIEW);
     126  //glColor4f(1,1,1,1);
     127  glPushMatrix();
     128  //glTranslatef(0,this->waterHeight,0);
    152129
    153         glMatrixMode(GL_MODELVIEW);
    154         glPushMatrix();
     130  cloudMaterial.unselect();
     131  cloudMaterial.select();
    155132
    156         // glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
    157         // glShadeModel(GL_SMOOTH);
    158         // glEnable(GL_DEPTH_TEST);
    159         // glEnable(GL_CULL_FACE);
    160         // glCullFace(GL_BACK);
    161         // glHint(GL_PERSPECTIVE_CORRECTION_HINT, GL_NICEST);
    162        
    163         // glLineWidth(3.0f);
     133  this->shader->activateShader();
    164134
    165         static float time = 0.0f;
    166         // static vector3f eye = {0.0f, 0.0f, 0.0f}, look = {0.0f, 0.0f, 1.0f}, up = {0.0f, 1.0f, 0.0f};
    167135
    168         // glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    169         // glLoadIdentity();
    170         // gluLookAt(eye[x], eye[y], eye[z], look[x], look[y], look[z], up[x], up[y], up[z]);
     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();
    171144
    172         // Turn off the depth buffer when rendering the background
    173         // glDisable(GL_DEPTH_TEST);
     145  this->shader->deactivateShader();
    174146
    175         this->cloudShader->activateShader();
     147  cloudMaterial.unselect();
    176148
    177         /* Select the shader program and update parameters. */
    178         /* The "time" parameter controls the cloud scrolling. */
    179         this->cloudShader->bindShader("time", &time, 1);
    180         /* The "horizon" parameter controls the sky tinting. */
    181         this->cloudShader->bindShader("horizon", cloudTint, 4);
     149  glPopMatrix();
    182150
    183         glActiveTexture(GL_TEXTURE0 + 0);
    184         glActiveTexture(GL_TEXTURE0 + 1);
    185 
    186         // Load the cloud texture
    187         //glBindTexture(GL_TEXTURE_2D, g_cloud_texture);
    188         this->cloudMaterial->select();
    189 
    190         // Render the sky dome
    191         cloudModel.Render();
    192 
    193         // Unselect the shader
    194         Shader::deactivateShader();
    195 
    196         /* Turn on the depth buffer when rendering the foreground. */
    197         // glEnable(GL_DEPTH_TEST);
    198 
    199         /* Render the forground, for example, a teapot or bunny. */
    200         //    glEnable(GL_LIGHTING);
    201         //    glColor3f(0.0f, 1.0f, 0.0f);
    202         //    glBegin(GL_QUADS);
    203         //    glNormal3f( 0.0f,  1.0f,  0.0f);
    204         //    glVertex3f( 20.0f, -1.0f,  20.0f);
    205         //    glVertex3f( 20.0f, -1.0f, -20.0f);
    206         //    glVertex3f(-20.0f, -1.0f, -20.0f);
    207         //    glVertex3f(-20.0f, -1.0f,  20.0f);
    208         //    glEnd();
    209         //    glDisable(GL_LIGHTING);
    210 
    211         glPopMatrix();
    212        
    213151}
    214152
    215153void CloudEffect::tick (float dt)
    216154{
    217         if (!this->cloudActivate)
    218                 return;
    219 
    220         // Update the timer for scrolling the clouds
    221         time = time + ((1.0f / 2000.0f) * cloudScroll);
     155        //if (!this->cloudActivate)
     156        //      return;
    222157}
    223158
  • trunk/src/lib/graphics/effects/cloud_effect.h

    r8255 r8495  
    1212
    1313#include "world_entity.h"
    14 #include "glincl.h"
     14#include "material.h"
     15#include "shader.h"
    1516
    16 #include "sglmodel.h"
     17class CloudEffect : public WeatherEffect {
     18public:
     19    CloudEffect(const TiXmlElement* root = NULL);
     20    virtual ~CloudEffect();
    1721
    18 class Shader;
    19 class Material;
    20 class Vector;
     22    virtual void loadParams(const TiXmlElement* root);
    2123
    22 class CloudEffect : public WeatherEffect
    23 {
    24         public:
    25                 CloudEffect(const TiXmlElement* root = NULL);
    26                 virtual ~CloudEffect();
     24    virtual void init();
    2725
    28                 virtual void loadParams(const TiXmlElement* root);
     26    virtual void activate();
     27    virtual void deactivate();
    2928
    30                 virtual bool init();
     29    inline void activateCloud() {
     30        this->activate();
     31    }
     32    inline void deactivateCloud() {
     33        this->deactivate();
     34    }
    3135
    32                 virtual bool activate();
    33                 virtual bool deactivate();
     36    virtual void draw() const;
     37    virtual void tick(float dt);
    3438
    35                 inline void activateCloud() { this->activate(); }
    36                 inline void deactivateCloud() { this->deactivate(); }
    37                
    38                 virtual void draw() const;
    39                 virtual void tick(float dt);
    40 
    41                 inline void setCloudOption(const std::string& option) {
    42                         if (option == "activate") this->cloudActivate = true;
    43                 }
     39    /*inline void setCloudOption(const std::string& option) {
     40        if (option == "activate")
     41    this->cloudActivate = true;
     42}*/
    4443
    4544
    46         private:
    47                 void initialize(char* fileName);
     45private:
     46    //void initialize(char* fileName);
    4847
    49                 bool                            cloudActivate;
     48    //bool        cloudActivate;
    5049
    51                 Material*                       cloudMaterial;          // A Material for the Sphere.
    52 
    53                 std::string                     cloudTexture;
    54 
    55                 Sglmodel_sgl                    cloudModel;
    56                 Shader*                         cloudShader;
    57 
    58                 GLfloat                         cloudTint[4];
    59                 GLfloat                         cloudScroll;
    60 
    61                 float                           time;
    62 
     50    Material                 cloudMaterial;
     51    Shader*                 shader;
    6352};
    6453
  • trunk/src/lib/graphics/effects/fog_effect.cc

    r8362 r8495  
    11/*
    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.
     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.
    1010
    1111### File Specific:
    12         main-programmer: hdavid, amaechler
     12  main-programmer: hdavid, amaechler
    1313*/
    1414
     
    2222SHELL_COMMAND(activate, FogEffect, activateFog);
    2323SHELL_COMMAND(deactivate, FogEffect, deactivateFog);
    24 SHELL_COMMAND(startfogging, FogEffect, startFogging);
     24SHELL_COMMAND(fadein, FogEffect, fadeInFog);
     25SHELL_COMMAND(fadeout, FogEffect, fadeOutFog);
     26
     27// TODO: Fix fades
    2528
    2629using namespace std;
     
    2831CREATE_FACTORY(FogEffect, CL_FOG_EFFECT);
    2932
    30 FogEffect::FogEffect(const TiXmlElement* root)
    31 {
    32         this->setClassID(CL_FOG_EFFECT, "FogEffect");
    33 
    34         this->init();
    35 
    36         if (root != NULL)
    37                 this->loadParams(root);
    38 
    39         if (this->fogActivate)
    40                 this->activate();
    41 }
    42 
    43 
    44 FogEffect::~FogEffect()
    45 {
    46         this->deactivate();
    47 }
    48 
    49 
    50 void FogEffect::loadParams(const TiXmlElement* root)
    51 {
    52         WeatherEffect::loadParams(root);
    53 
    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 
    59         LOAD_PARAM_START_CYCLE(root, element);
    60         {
    61                 LoadParam_CYCLE(element, "option", this, FogEffect, setFogOption);
    62         }
    63         LOAD_PARAM_END_CYCLE(element);
    64 }
    65 
    66 bool FogEffect::init()
    67 {
    68         //default values
    69         this->fogActivate = false;
    70         this->fogFadeDuration = 0;
    71         this->localTimer = 0;
    72 
    73         this->fogMode = GL_EXP2;
    74         this->fogDensity = 0.001;
    75         this->fogStart = 0;
    76         this->fogEnd = 5000;
    77         this->colorVector = Vector(0.7, 0.7, 0.7);
    78 
    79         return true;
    80 }
    81 
    82 
    83 bool FogEffect::activate()
    84 {
    85         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);
    86 
    87         this->fogActivate = true;
    88 
    89         GLfloat fogColor[4] = { colorVector.x, colorVector.y, colorVector.z, 1.0};
    90         glFogi(GL_FOG_MODE, this->fogMode);
    91         glFogfv(GL_FOG_COLOR, fogColor);
    92         glFogf(GL_FOG_DENSITY, this->fogDensity);
    93         glHint(GL_FOG_HINT, GL_DONT_CARE);
    94         glFogf(GL_FOG_START, this->fogStart);
    95         glFogf(GL_FOG_END, this->fogEnd);
    96 
    97         glEnable(GL_FOG);
    98         // glClearColor(0.5, 0.5, 0.5, 1.0);
    99         return true;
    100 }
    101 
    102 
    103 bool FogEffect::deactivate()
    104 {
    105         PRINTF(0)("Deactivating FogEffect\n");
    106 
    107         this->fogActivate = false;
    108 
    109         glDisable(GL_FOG);
    110 
    111         return true;
     33FogEffect::FogEffect(const TiXmlElement* root) {
     34    this->setClassID(CL_FOG_EFFECT, "FogEffect");
     35
     36    this->init();
     37
     38    if (root != NULL)
     39        this->loadParams(root);
     40
     41    if (this->fogActivate)
     42        this->activate();
     43}
     44
     45
     46FogEffect::~FogEffect() {
     47    this->deactivate();
     48}
     49
     50
     51void FogEffect::loadParams(const TiXmlElement* root) {
     52    WeatherEffect::loadParams(root);
     53
     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);
     60
     61    LOAD_PARAM_START_CYCLE(root, element);
     62    {
     63        LoadParam_CYCLE(element, "option", this, FogEffect, setFogOption);
     64    }
     65    LOAD_PARAM_END_CYCLE(element);
     66}
     67
     68void FogEffect::init() {
     69    // default values
     70    this->fogMode = GL_LINEAR;
     71    this->fogDensity = 0.03;
     72    this->fogStart = 0;
     73    this->fogEnd = 50;
     74    this->colorVector = Vector(0.3, 0.3, 0.3);
     75
     76    // init variables
     77    this->fogFadeInDuration = 0;
     78    this->fogFadeOutDuration = 0;
     79    this->fogFadeDensity = 0;
     80    this->localTimer = 0;
     81    this->fogActivate = false;
     82    this->fogFadeInActivate = false;
     83    this->fogFadeOutActivate = false;
     84
     85}
     86
     87
     88void FogEffect::activate() {
     89    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);
     90
     91    this->fogActivate = true;
     92
     93    GLfloat fogColor[4] = { colorVector.x, colorVector.y, colorVector.z, 1.0};
     94    glFogi(GL_FOG_MODE, this->fogMode);
     95    glFogfv(GL_FOG_COLOR, fogColor);
     96    glHint(GL_FOG_HINT, GL_DONT_CARE);
     97    glFogf(GL_FOG_DENSITY, this->fogDensity);
     98    glFogf(GL_FOG_START, this->fogStart);
     99    glFogf(GL_FOG_END, this->fogEnd);
     100
     101    glEnable(GL_FOG);
     102
     103}
     104
     105
     106void FogEffect::deactivate() {
     107    PRINTF(0)("Deactivating FogEffect\n");
     108
     109    this->fogFadeInActivate = false;
     110    this->fogFadeOutActivate = false;
     111    this->fogActivate = false;
     112
     113    glDisable(GL_FOG);
     114
    112115}
    113116
    114117void FogEffect::draw() const {
    115118
    116         if (this->fogFadeDuration != 0 && this->localTimer < this->fogFadeDuration)
    117                 glFogf(GL_FOG_DENSITY, this->fogFadeDensity);
    118         //else
    119         //      glFogf(GL_FOG_DENSITY, this->fogDensity);
    120 
    121 }
    122 void FogEffect::tick(float dt)
    123 {
    124         if (!this->fogActivate)
    125                 return;
    126 
    127 
    128         if (this->fogFadeDuration != 0 && this->localTimer < this->fogFadeDuration) {
    129                 this->localTimer += dt;
    130                 float progress = this->localTimer / this->fogFadeDuration;
    131                 this->fogFadeDensity = progress * this->fogDensity;
    132         }
    133 }
    134 
    135 void FogEffect::startFogging() {
    136 
    137         if (this->fogActivate)
    138                 this->deactivate();
    139 
    140         this->fogFadeDuration = 10;
    141         this->localTimer = 0;
    142         this->activate();
    143 
    144 }
    145 
    146 
    147 GLint FogEffect::stringToFogMode(const std::string& mode)
    148 {
    149         if(mode == "GL_LINEAR")
    150                 return GL_LINEAR;
    151         else if(mode == "GL_EXP")
    152                 return GL_EXP;
    153         else if(mode == "GL_EXP2" )
    154                 return GL_EXP2;
    155         else
    156                 return -1;
    157 }
    158 
    159 
     119    if (!this->fogActivate)
     120        return;
     121
     122    // If Fog Fade
     123    if ( this->fogFadeInActivate || this->fogFadeOutActivate )
     124        glFogf(GL_FOG_DENSITY, this->fogFadeDensity);
     125
     126}
     127
     128void FogEffect::tick(float dt) {
     129    if (!this->fogActivate)
     130        return;
     131
     132    if ( this->fogFadeInActivate ) {
     133        this->localTimer += dt;
     134        this->fogFadeDensity = ( this->localTimer / this->fogFadeInDuration ) * this->fogDensity;
     135
     136        if ( this->localTimer >= this->fogFadeOutDuration )
     137            this->fogFadeInActivate = false;
     138    }
     139
     140    if ( this->fogFadeOutActivate ) {
     141        this->localTimer += dt;
     142        this->fogFadeDensity = 1 - (( this->localTimer / this->fogFadeInDuration ) * this->fogDensity);
     143
     144        if ( this->localTimer >= this->fogFadeOutDuration )
     145            this->deactivate();
     146    }
     147}
     148
     149void FogEffect::fadeInFog() {
     150
     151    // If Fog is already fading out, stop it
     152    this->fogFadeOutActivate = false;
     153
     154    // If Fog is already on, turn it off first
     155    if (this->fogActivate)
     156        this->deactivate();
     157
     158    // If no manual FadeIn value was set, set a default value
     159    if (!this->fogFadeInDuration > 0)
     160        this->fogFadeInDuration = 20;
     161
     162    // Reset local timer
     163    this->localTimer = 0;
     164
     165    // set FogFadeIn activate
     166    this->fogFadeInActivate = true;
     167
     168    // Activate Fog
     169    this->activate();
     170
     171}
     172
     173
     174void FogEffect::fadeOutFog() {
     175
     176    // If Fog is already fading in, stop it
     177    this->fogFadeInActivate = false;
     178
     179    // If Fog is off, turn it on first
     180    if (!this->fogActivate)
     181        this->activate();
     182
     183    // If no manual FadeOut value was set, set a default value
     184    if (!this->fogFadeOutDuration > 0)
     185        this->fogFadeOutDuration = 20;
     186
     187    // set FogFadeOut activate
     188    this->fogFadeOutActivate = true;
     189
     190    // Reset local timer
     191    this->localTimer = 0;
     192
     193}
     194
     195
     196GLint FogEffect::stringToFogMode(const std::string& mode) {
     197    if(mode == "GL_LINEAR")
     198        return GL_LINEAR;
     199    else if(mode == "GL_EXP")
     200        return GL_EXP;
     201    else if(mode == "GL_EXP2" )
     202        return GL_EXP2;
     203    else
     204        return -1;
     205}
     206
     207
  • trunk/src/lib/graphics/effects/fog_effect.h

    r8362 r8495  
    66#define _FOG_EFFECT
    77
    8 #include "vector.h"
    98
    109#include "weather_effect.h"
    1110#include "glincl.h"
     11#include "vector.h"
     12
     13class FogEffect : public WeatherEffect {
     14public:
     15    FogEffect(const TiXmlElement* root = NULL);
     16    virtual ~FogEffect();
     17
     18    virtual void loadParams(const TiXmlElement* root);
     19
     20    virtual void init();
     21
     22    virtual void activate();
     23    virtual void deactivate();
     24
     25    void activateFog() {
     26        this->activate();
     27    }
     28    void deactivateFog() {
     29        this->deactivate();
     30    }
     31
     32    virtual void draw() const;
     33    virtual void tick(float dt);
     34
     35    inline void setFogMode(const std::string& mode) {
     36        this->fogMode = this->stringToFogMode(mode);
     37    }
     38    inline void setFogDensity(float density) {
     39        this->fogDensity = density;
     40    }
     41    inline void setFogRange(float start, float end) {
     42        this->fogStart = start;
     43        this->fogEnd = end;
     44    }
     45    inline void setFogColor(float r, float g, float b) {
     46        this->colorVector = Vector(r, g, b);
     47    }
     48    inline void setFogFadeIn(float fadein) {
     49        this->fogFadeInDuration = fadein;
     50    }
     51    inline void setFogFadeOut(float fadeout) {
     52        this->fogFadeOutDuration = fadeout;
     53    }
     54
     55    inline void setFogOption(const std::string& option) {
     56        if (option == "activate")
     57            this->fogActivate = true;
     58    }
     59
     60    void fadeInFog();
     61    void fadeOutFog();
    1262
    1363
    14 class FogEffect : public WeatherEffect
    15 {
    16         public:
    17                 FogEffect(const TiXmlElement* root = NULL);
    18                 virtual ~FogEffect();
     64private:
     65    GLint stringToFogMode(const std::string& mode);
    1966
    20                 virtual void loadParams(const TiXmlElement* root);
     67    bool          fogActivate;
    2168
    22                 virtual bool init();
     69    bool          fogFadeInActivate;
     70    bool          fogFadeOutActivate;
    2371
    24                 virtual bool activate();
    25                 virtual bool deactivate();
     72    GLfloat       fogFadeInDuration;
     73    GLfloat       fogFadeOutDuration;
    2674
    27                 void activateFog() { this->activate(); }
    28                 void deactivateFog() { this->deactivate(); }
     75    float         localTimer;
    2976
    30                 virtual void draw() const;
    31                 virtual void tick(float dt);
     77    GLint         fogMode;
     78    GLfloat       fogDensity;
     79    GLfloat       fogFadeDensity;
    3280
    33                 inline void setFogMode(const std::string& mode) { this->fogMode = this->stringToFogMode(mode); }
    34                 inline void setFogDensity(float density) { this->fogDensity = density; }
    35                 inline void setFogRange(float start, float end) { this->fogStart = start; this->fogEnd = end; }
    36                 inline void setFogColor(float r, float g, float b) { this->colorVector = Vector(r, g, b); }
    37                 inline void setFogOption(const std::string& option) { if (option == "activate") this->fogActivate = true; }
    38 
    39                 void startFogging();
    40 
    41         private:
    42                 GLint stringToFogMode(const std::string& mode);
    43 
    44                 bool                            fogActivate;
    45                 GLfloat                         fogFadeDuration;
    46                 float                           localTimer;
    47 
    48                 GLint                           fogMode;
    49                 GLfloat                         fogDensity;
    50                 GLfloat                         fogFadeDensity;
    51 
    52                 GLfloat                         fogStart;
    53                 GLfloat                         fogEnd;
    54                 Vector                          colorVector;
     81    GLfloat       fogStart;
     82    GLfloat       fogEnd;
     83    Vector        colorVector;
    5584};
    5685
  • trunk/src/lib/graphics/effects/graphics_effect.cc

    r8316 r8495  
    3232  @todo what to do, if no GraphicsEffect-Slots are open anymore ???
    3333 */
    34 GraphicsEffect::GraphicsEffect(const TiXmlElement* root)
    35 {
    36   this->setClassID(CL_GRAPHICS_EFFECT, "GraphicsEffect");
    37   this->bActivated = false;
     34GraphicsEffect::GraphicsEffect(const TiXmlElement* root) {
     35    this->setClassID(CL_GRAPHICS_EFFECT, "GraphicsEffect");
     36    this->bActivated = false;
    3837}
    3938
     
    4241 *  destroys a GraphicsEffect
    4342 */
    44 GraphicsEffect::~GraphicsEffect()
    45 {
    46 
     43GraphicsEffect::~GraphicsEffect() {
    4744}
    4845
     
    5148 * @param root The XML-element to load the GraphicsEffect from
    5249 */
    53 void GraphicsEffect::loadParams(const TiXmlElement* root)
    54 {
    55   BaseObject::loadParams(root);
     50void GraphicsEffect::loadParams(const TiXmlElement* root) {
     51    BaseObject::loadParams(root);
    5652}
    5753
     
    6056 *  initializes the graphics effect
    6157 */
    62 bool GraphicsEffect::init()
    63 {
    64   return true;
    65 }
     58void GraphicsEffect::init() {}
    6659
    6760
     
    7063 * draws the effect, if needed
    7164 */
    72 void GraphicsEffect::draw() const
    73 {}
     65void GraphicsEffect::draw() const {}
    7466
    7567
     
    7870 * ticks the effect if there is any time dependancy
    7971 */
    80 void GraphicsEffect::tick(float dt)
    81 {}
     72void GraphicsEffect::tick(float dt) {}
  • trunk/src/lib/graphics/effects/graphics_effect.h

    r6815 r8495  
    1212
    1313//! A class that handles GraphicsEffects. The GraphicsEffectManager operates on this.
    14 class GraphicsEffect : public BaseObject
    15 {
    16   public:
     14class GraphicsEffect : public BaseObject {
     15public:
    1716    GraphicsEffect(const TiXmlElement* root = NULL);
    1817    virtual ~GraphicsEffect();
     
    2019    virtual void loadParams(const TiXmlElement* root);
    2120
    22     virtual bool init();
     21    virtual void init();
    2322
    24     virtual bool activate() = 0;
    25     virtual bool deactivate() = 0;
     23    virtual void activate() = 0;
     24    virtual void deactivate() = 0;
    2625
    2726    virtual void draw() const;
    2827    virtual void tick(float dt);
    2928
    30     inline bool isActivated() const { return this->bActivated; }
     29    inline bool isActivated() const {
     30        return this->bActivated;
     31    }
    3132
    3233
    33   protected:
     34protected:
    3435    bool              bActivated;
    3536};
  • trunk/src/lib/graphics/effects/lense_flare.cc

    r8362 r8495  
    2222#include "util/loading/factory.h"
    2323
     24#include "glincl.h"
    2425#include "texture.h"
    2526
     
    4344 * @param root The XML-element to load the LenseFlare from
    4445 */
    45  LenseFlare::LenseFlare(const TiXmlElement* root)
    46 {
    47   this->setClassID(CL_LENSE_FLARE, "LenseFlare");
    48 
    49   this->flareMatrix = new float[14];
    50   /*          length                      image scale */
    51   this->flareMatrix[0] = 1.0f; this->flareMatrix[1] = 1.0f;
    52   this->flareMatrix[2] = 0.5f; this->flareMatrix[3] = 0.5f;
    53   this->flareMatrix[4] = 0.33f; this->flareMatrix[5] = 0.25f;
    54   this->flareMatrix[6] = 0.125f; this->flareMatrix[7] = 1.0f;
    55   this->flareMatrix[8] = -0.5f; this->flareMatrix[9] = 0.5f;
    56   this->flareMatrix[10] = -0.25f; this->flareMatrix[11] = 0.15f;
    57   this->flareMatrix[12] = -1.82f; this->flareMatrix[13] = 0.25f;
    58 
    59   this->lightSource = (LightManager::getInstance())->getLight(0);
    60   PRINTF(0)("light is: %p\n", this->lightSource);
    61 
    62   if (root != NULL)
    63   {
    64     this->loadParams(root);
    65     this->activate();
    66   }
    67 
    68   this->bVisible = true;
    69   this->setSourceVisibility(false);
     46LenseFlare::LenseFlare(const TiXmlElement* root) {
     47    this->setClassID(CL_LENSE_FLARE, "LenseFlare");
     48
     49    this->flareMatrix = new float[14];
     50    /*          length                      image scale */
     51    this->flareMatrix[0] = 1.0f;
     52    this->flareMatrix[1] = 1.0f;
     53    this->flareMatrix[2] = 0.5f;
     54    this->flareMatrix[3] = 0.5f;
     55    this->flareMatrix[4] = 0.33f;
     56    this->flareMatrix[5] = 0.25f;
     57    this->flareMatrix[6] = 0.125f;
     58    this->flareMatrix[7] = 1.0f;
     59    this->flareMatrix[8] = -0.5f;
     60    this->flareMatrix[9] = 0.5f;
     61    this->flareMatrix[10] = -0.25f;
     62    this->flareMatrix[11] = 0.15f;
     63    this->flareMatrix[12] = -1.82f;
     64    this->flareMatrix[13] = 0.25f;
     65
     66    this->lightSource = (LightManager::getInstance())->getLight(0);
     67    PRINTF(0)("light is: %p\n", this->lightSource);
     68
     69    if (root != NULL) {
     70        this->loadParams(root);
     71        this->activate();
     72    }
     73
     74    this->bVisible = true;
     75    this->setSourceVisibility(false);
    7076
    7177}
     
    7581 *  destroys a LenseFlare
    7682 */
    77 LenseFlare::~LenseFlare()
    78 {
    79   std::vector<ImagePlane*>::iterator it;
    80   for( it = flares.begin(); it != flares.end(); it++)
    81     delete (*it);
     83LenseFlare::~LenseFlare() {
     84    std::vector<ImagePlane*>::iterator it;
     85    for( it = flares.begin(); it != flares.end(); it++)
     86        delete (*it);
    8287}
    8388
     
    8691 * @param root The XML-element to load the LenseFlare from
    8792 */
    88 void LenseFlare::loadParams(const TiXmlElement* root)
    89 {
    90   GraphicsEffect::loadParams(root);
    91 
    92   LOAD_PARAM_START_CYCLE(root, element);
    93   {
    94     LoadParam_CYCLE(element, "add-flare-texture", this, LenseFlare, addFlare)
     93void LenseFlare::loadParams(const TiXmlElement* root) {
     94    GraphicsEffect::loadParams(root);
     95
     96    LOAD_PARAM_START_CYCLE(root, element);
     97    {
     98        LoadParam_CYCLE(element, "add-flare-texture", this, LenseFlare, addFlare)
    9599        .describe("adds a lensflare texture to the engine");
    96   }
    97   LOAD_PARAM_END_CYCLE(element);
     100    }
     101    LOAD_PARAM_END_CYCLE(element);
    98102}
    99103
     
    102106 * initializes the fog effect
    103107 */
    104 bool LenseFlare::init()
    105 {
    106   return true;
    107 }
     108void LenseFlare::init() {}
    108109
    109110
     
    111112 * activates the fog effect
    112113 */
    113 bool LenseFlare::activate()
    114 {
    115   this->bActivated = true;
    116 
    117   return true;
     114void LenseFlare::activate() {
     115    this->bActivated = true;
    118116}
    119117
     
    122120 * deactivates the fog effect
    123121 */
    124 bool LenseFlare::deactivate()
    125 {
    126   this->bActivated = false;
    127 
    128   return true;
     122void LenseFlare::deactivate() {
     123    this->bActivated = false;
    129124}
    130125
     
    134129 * @param mode the mode character
    135130 */
    136 GLint LenseFlare::stringToFogMode(const std::string& mode)
    137 {
    138   PRINTF(1)("NOT IMPLEMENTED");
    139   return 0;
     131GLint LenseFlare::stringToFogMode(const std::string& mode) {
     132    return 0;
    140133}
    141134
     
    153146 *  7th: Texture of the third burst
    154147 */
    155 void LenseFlare::addFlare(const std::string& textureName)
    156 {
    157   if( this->flares.size() > LF_MAX_FLARES)
    158   {
    159     PRINTF(2)("You tried to add more than %i lense flares, ignoring\n", LF_MAX_FLARES);
    160     return;
    161   }
    162 
    163   ImagePlane* bb = new ImagePlane(NULL);
    164   if (this->flares.empty())
    165     bb->setLayer(E2D_LAYER_BELOW_ALL);
    166   bb->setTexture(textureName);
    167   bb->setSize(50, 50);
    168   this->flares.push_back(bb);
    169   bb->setVisibility(true);
    170 
    171   PRINTF(4)("Added a Lenseflare ImagePlane with texture %s\n", textureName.c_str());
    172 
    173   // the first flare belongs to the light source
    174   if( this->flares.size() == 1 && this->lightSource != NULL)
    175   {
    176     bb->setBindNode(static_cast<PNode*>(this->lightSource));
    177   }
    178 
    179   PRINTF(4)("Finished adding\n");
    180 }
    181 
    182 
    183 void LenseFlare::setSourceVisibility(bool visibility)
    184 {
    185    if (this->bVisible == visibility)
    186      return;
    187 
    188   std::vector<ImagePlane*>::const_iterator it;
     148void LenseFlare::addFlare(const std::string& textureName) {
     149    if( this->flares.size() > LF_MAX_FLARES) {
     150        PRINTF(2)("You tried to add more than %i lense flares, ignoring\n", LF_MAX_FLARES);
     151        return;
     152    }
     153
     154    ImagePlane* bb = new ImagePlane(NULL);
     155    if (this->flares.empty())
     156        bb->setLayer(E2D_LAYER_BELOW_ALL);
     157    bb->setTexture(textureName);
     158    bb->setSize(50, 50);
     159    this->flares.push_back(bb);
     160    bb->setVisibility(true);
     161
     162    PRINTF(4)("Added a Lenseflare ImagePlane with texture %s\n", textureName.c_str());
     163
     164    // the first flare belongs to the light source
     165    if( this->flares.size() == 1 && this->lightSource != NULL) {
     166        bb->setBindNode(static_cast<PNode*>(this->lightSource));
     167    }
     168
     169    PRINTF(4)("Finished adding\n");
     170}
     171
     172
     173void LenseFlare::setSourceVisibility(bool visibility) {
     174    if (this->bVisible == visibility)
     175        return;
     176
     177    std::vector<ImagePlane*>::const_iterator it;
    189178    for(it = ++flares.begin(); it != flares.end(); it++)
    190       (*it)->setVisibility(visibility);
    191   this->bVisible = visibility;
     179        (*it)->setVisibility(visibility);
     180    this->bVisible = visibility;
    192181}
    193182
     
    196185 * tick the effect
    197186 */
    198 void LenseFlare::tick(float dt)
    199 {
    200   if( unlikely(!this->bActivated || this->flares.size() == 0))
    201     return;
    202 
    203   // refetch light source information if needed
    204   if( unlikely( this->lightSource == NULL))
    205   {
    206     this->lightSource = (LightManager::getInstance())->getLight(0);
    207     if( this->flares.size() > 0)
    208       this->flares[0]->setBindNode(static_cast<PNode*>(this->lightSource));
    209   }
     187void LenseFlare::tick(float dt) {
     188    if( unlikely(!this->bActivated || this->flares.size() == 0))
     189        return;
     190
     191    // refetch light source information if needed
     192    if( unlikely( this->lightSource == NULL)) {
     193        this->lightSource = (LightManager::getInstance())->getLight(0);
     194        if( this->flares.size() > 0)
     195            this->flares[0]->setBindNode(static_cast<PNode*>(this->lightSource));
     196    }
    210197
    211198    //set the frustum plane
    212   if (!flares.empty())
    213     this->setSourceVisibility(this->flares[0]->isVisible());
    214 
    215 
    216   // always update the screen center, it could be, that the window is resized
    217   this->screenCenter = Vector2D(State::getResX()/2.0f, State::getResY()/2.0f);
    218 
    219   // flare vector is the direction from the center to the light source
    220   this->flareVector = this->flares[0]->getAbsCoor2D() - this->screenCenter;
    221   this->distance = this->flareVector.len();
    222   this->flareVector.normalize();
    223 
    224   // now calculate the new coordinates of the billboards
    225   std::vector<ImagePlane*>::iterator it;
    226   int i;
    227   for( it = flares.begin(), i = 0; it != flares.end(); it++, i++)
    228   {
    229     // set the new position
    230     if( i == 0)
    231       continue;
    232 
    233     (*it)->setAbsCoor2D( this->screenCenter + this->flareVector * this->flareMatrix[i * 2] * this->distance);
    234     (*it)->setSize2D(50.0f * this->flareMatrix[i * 2 + 1], 50.0f * this->flareMatrix[i * 2 + 1]);
    235     PRINTF(5)("Tick flare %i @ (%f, %f)\n", i, (*it)->getAbsCoor2D().x, (*it)->getAbsCoor2D().y);
    236   }
     199    if (!flares.empty())
     200        this->setSourceVisibility(this->flares[0]->isVisible());
     201
     202
     203    // always update the screen center, it could be, that the window is resized
     204    this->screenCenter = Vector2D(State::getResX()/2.0f, State::getResY()/2.0f);
     205
     206    // flare vector is the direction from the center to the light source
     207    this->flareVector = this->flares[0]->getAbsCoor2D() - this->screenCenter;
     208    this->distance = this->flareVector.len();
     209    this->flareVector.normalize();
     210
     211    // now calculate the new coordinates of the billboards
     212    std::vector<ImagePlane*>::iterator it;
     213    int i;
     214    for( it = flares.begin(), i = 0; it != flares.end(); it++, i++) {
     215        // set the new position
     216        if( i == 0)
     217            continue;
     218
     219        (*it)->setAbsCoor2D( this->screenCenter + this->flareVector * this->flareMatrix[i * 2] * this->distance);
     220        (*it)->setSize2D(50.0f * this->flareMatrix[i * 2 + 1], 50.0f * this->flareMatrix[i * 2 + 1]);
     221        PRINTF(5)("Tick flare %i @ (%f, %f)\n", i, (*it)->getAbsCoor2D().x, (*it)->getAbsCoor2D().y);
     222    }
    237223}
    238224
     
    241227 * draws the LenseFlares
    242228 */
    243 void LenseFlare::draw() const
    244 {
    245   if( !this->bActivated)
    246     return;
    247 }
     229void LenseFlare::draw() const {
     230    if( !this->bActivated)
     231        return;
     232}
  • trunk/src/lib/graphics/effects/lense_flare.h

    r8362 r8495  
    3232    virtual void loadParams(const TiXmlElement* root);
    3333
    34     virtual bool init();
     34    virtual void init();
    3535
    36     virtual bool activate();
    37     virtual bool deactivate();
     36    virtual void activate();
     37    virtual void deactivate();
    3838
    3939    virtual void draw() const;
  • trunk/src/lib/graphics/effects/lightening_effect.cc

    r8316 r8495  
    3333CREATE_FACTORY(LighteningEffect, CL_LIGHTENING_EFFECT);
    3434
     35// TODO: FIx Lightening with Fog enabled
     36
    3537LighteningEffect::LighteningEffect(const TiXmlElement* root)
    3638{
     
    4244                this->loadParams(root);
    4345
    44   if(this->lighteningActivate)
    45          this->activate();
     46        if(this->lighteningActivate)
     47                this->activate();
    4648}
    4749
     
    5557        WeatherEffect::loadParams(root);
    5658
    57   LoadParam(root, "coord", this, LighteningEffect, coord);
    58   LoadParam(root, "option", this, LighteningEffect, setLighteningOption);
    59   LoadParam(root, "frequency", this, LighteningEffect, setFlashFrequency);
    60   LoadParam(root, "const-time", this, LighteningEffect, setFlashConstTime);
    61   LoadParam(root, "rising-time", this, LighteningEffect, setFlashRisingTime);
    62   LoadParam(root, "size", this, LighteningEffect, setFlashSize);
    63   LoadParam(root, "seed", this, LighteningEffect, setFlashSeed);
    64 }
    65 
    66 
    67 bool LighteningEffect::init()
    68 {
    69   lighteningActivate = false;
    70 
    71   this->time = 0.0;
    72   this->flashFrequency = 1.4f;
    73   this->flashConstTime = 0.5f;
    74   this->flashRisingTime = 0.1f;
    75 
    76   this->width = 400.0f;
    77   this->height = 100.0f;
    78   this->seedWidth = 50;
    79   this->seedHeight = 50;
    80   this->bNewCoordinate = false;
    81 
    82   this->seedX = 500.f;
    83   this->seedZ = 1000.0f;
    84   this->seedTime = 4.0f;
    85 
    86   this->billboard[0] = new Billboard(NULL);
    87   this->billboard[0]->setTexture("maps/lightning_bolt1.png");
    88   this->billboard[0]->setSize(this->width, this->height);
    89   this->billboard[0]->setAbsCoor(3000,850,0);
    90   this->billboard[0]->setVisibiliy(false);
    91 
    92   this->billboard[1] = new Billboard(NULL);
    93   this->billboard[1]->setTexture("maps/lightning_bolt2.png");
    94   this->billboard[1]->setSize(this->width, this->height);
    95   this->billboard[1]->setAbsCoor(3000,850,0);
    96   this->billboard[1]->setVisibiliy(false);
    97 
    98   this->billboard[2] = new Billboard(NULL);
    99   this->billboard[2]->setTexture("maps/lightning_bolt3.png");
    100   this->billboard[2]->setSize(this->width, this->height);
    101   this->billboard[2]->setAbsCoor(3000,850,0);
    102   this->billboard[2]->setVisibiliy(false);
    103 
    104   this->billboard[3] = new Billboard(NULL);
    105   this->billboard[3]->setTexture("maps/lightning_bolt4.png");
    106   this->billboard[3]->setSize(this->width, this->height);
    107   this->billboard[3]->setAbsCoor(0.0f, 50.0f, 0.0f);
    108   this->billboard[3]->setVisibiliy(false);
    109 /*
    110   this->soundSource = NULL;
    111   this->thunderBuffer = NULL;
    112 
    113   this->soundSource.setSourceNode(this);
    114 
    115   //load sound
    116   if (this->thunderBuffer != NULL)
    117     ResourceManager::getInstance()->unload(this->thunderBuffer);
    118   this->thunderBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load("sound/thunder.wav", WAV);*/
    119 
    120   return true;
     59        LoadParam(root, "coord", this, LighteningEffect, coord);
     60        LoadParam(root, "frequency", this, LighteningEffect, setFlashFrequency);
     61        LoadParam(root, "const-time", this, LighteningEffect, setFlashConstTime);
     62        LoadParam(root, "rising-time", this, LighteningEffect, setFlashRisingTime);
     63        LoadParam(root, "size", this, LighteningEffect, setFlashSize);
     64        LoadParam(root, "seed", this, LighteningEffect, setFlashSeed);
     65
     66        LOAD_PARAM_START_CYCLE(root, element);
     67        {
     68                LoadParam_CYCLE(element, "option", this, LighteningEffect, setLighteningOption);
     69        }
     70        LOAD_PARAM_END_CYCLE(element);
     71}
     72
     73
     74void LighteningEffect::init()
     75{
     76        //default values
     77        this->lighteningActivate = false;
     78
     79        this->time = 0.0;
     80        this->flashFrequency = 4.0f;
     81        this->mainFrequency = 4.0f;
     82        this->flashConstTime = 0.1f;
     83        this->flashRisingTime = 0.03f;
     84
     85        this->width = 700.0f;
     86        this->height = 250.0f;
     87        this->seedWidth = 50.0f;
     88        this->seedHeight = 50.0f;
     89        this->bNewCoordinate = false;
     90  this->lighteningMove = false;
     91
     92        this->seedX = 500.f;
     93        this->seedZ = 1000.0f;
     94        this->seedTime = 2.0f;
     95
     96  this->mainPosX = 3000;
     97  this->mainPosY = 900;
     98  this->mainPosZ = 0;
     99
     100        // initialize lightening textures
     101        this->billboard[0] = new Billboard(NULL);
     102        this->billboard[0]->setTexture("maps/lightning_bolt1.png");
     103        this->billboard[0]->setSize(this->width, this->height);
     104        this->billboard[0]->setVisibiliy(false);
     105
     106        this->billboard[1] = new Billboard(NULL);
     107        this->billboard[1]->setTexture("maps/lightning_bolt2.png");
     108        this->billboard[1]->setSize(this->width, this->height);
     109        this->billboard[1]->setVisibiliy(false);
     110
     111        this->billboard[2] = new Billboard(NULL);
     112        this->billboard[2]->setTexture("maps/lightning_bolt3.png");
     113        this->billboard[2]->setSize(this->width, this->height);
     114        this->billboard[2]->setVisibiliy(false);
     115
     116        this->billboard[3] = new Billboard(NULL);
     117        this->billboard[3]->setTexture("maps/lightning_bolt4.png");
     118        this->billboard[3]->setSize(this->width, this->height);
     119        this->billboard[3]->setVisibiliy(false);
     120
     121        if (this->lighteningMove) {
     122                this->cameraCoor = State::getCameraNode()->getAbsCoor();
     123                this->billboard[0]->setAbsCoor(this->cameraCoor.x+3000,900,this->cameraCoor.z+0);
     124                this->billboard[1]->setAbsCoor(this->cameraCoor.x+3000,900,this->cameraCoor.z+0);
     125                this->billboard[2]->setAbsCoor(this->cameraCoor.x+3000,900,this->cameraCoor.z+0);
     126                this->billboard[3]->setAbsCoor(this->cameraCoor.x+3000,900,this->cameraCoor.z+0);
     127        } else {
     128                this->billboard[0]->setAbsCoor(3000,900,0);
     129                this->billboard[1]->setAbsCoor(3000,900,0);
     130                this->billboard[2]->setAbsCoor(3000,900,0);
     131                this->billboard[3]->setAbsCoor(3000,900,0);
     132        }
     133
     134        this->flashLight = new Light();
     135        this->flashLight->setDiffuseColor(0,0,0);
     136        this->flashLight->setSpecularColor(0,0,0);
     137
     138        /*
     139        this->soundSource = NULL;
     140        this->thunderBuffer = NULL;
     141
     142        this->soundSource.setSourceNode(this);
     143
     144        //load sound
     145        if (this->thunderBuffer != NULL)
     146        ResourceManager::getInstance()->unload(this->thunderBuffer);
     147        this->thunderBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load("sound/thunder.wav", WAV);*/
     148
    121149}
    122150
    123151void LighteningEffect::coord(float x, float y, float z)
    124152{
    125   this->billboard[0]->setAbsCoor(x, y, z);
    126   this->billboard[1]->setAbsCoor(x, y, z);
    127   this->billboard[2]->setAbsCoor(x, y, z);
    128   this->billboard[3]->setAbsCoor(x, y, z);
    129   this->mainPosX = x;
    130   this->mainPosY = y;
    131   this->mainPosZ = z;
     153        if (this->lighteningMove) {
     154                this->cameraCoor = State::getCameraNode()->getAbsCoor();
     155                this->billboard[0]->setAbsCoor(this->cameraCoor.x+x, y, this->cameraCoor.z+z);
     156                this->billboard[1]->setAbsCoor(this->cameraCoor.x+x, y, this->cameraCoor.z+z);
     157                this->billboard[2]->setAbsCoor(this->cameraCoor.x+x, y, this->cameraCoor.z+z);
     158                this->billboard[3]->setAbsCoor(this->cameraCoor.x+x, y, this->cameraCoor.z+z);
     159        } else {
     160                this->billboard[0]->setAbsCoor(x, y, z);
     161                this->billboard[1]->setAbsCoor(x, y, z);
     162                this->billboard[2]->setAbsCoor(x, y, z);
     163                this->billboard[3]->setAbsCoor(x, y, z);
     164        }
     165
     166        this->mainPosX = x;
     167        this->mainPosY = y;
     168        this->mainPosZ = z;
    132169}
    133170
     
    135172void LighteningEffect::setFlashSize(float width, float height, float seedWidth, float seedHeight)
    136173{
    137   this->width = width;
    138   this->height = height;
    139   this->seedWidth = seedWidth;
    140   this->seedHeight = seedHeight;
    141   this->billboard[0]->setSize(this->width, this->height);
    142   this->billboard[1]->setSize(this->width, this->height);
    143   this->billboard[2]->setSize(this->width, this->height);
    144   this->billboard[3]->setSize(this->width, this->height);
    145 }
    146 
    147 
    148 bool LighteningEffect::activate()
     174        this->width = width;
     175        this->height = height;
     176        this->seedWidth = seedWidth;
     177        this->seedHeight = seedHeight;
     178
     179        this->billboard[0]->setSize(this->width, this->height);
     180        this->billboard[1]->setSize(this->width, this->height);
     181        this->billboard[2]->setSize(this->width, this->height);
     182        this->billboard[3]->setSize(this->width, this->height);
     183}
     184
     185
     186void LighteningEffect::activate()
    149187{
    150188        PRINTF(0)( "Activating LighteningEffect\n" );
    151   this->time = 0;
    152   lighteningActivate = true;
    153 
    154   return true;
    155 }
    156 
    157 
    158 bool LighteningEffect::deactivate()
     189        this->lighteningActivate = true;
     190
     191        this->time = 0;
     192}
     193
     194
     195void LighteningEffect::deactivate()
    159196{
    160197        PRINTF(0)("Deactivating LighteningEffect\n");
    161   this->billboard[0]->setVisibiliy(false);
    162   this->billboard[1]->setVisibiliy(false);
    163   this->billboard[2]->setVisibiliy(false);
    164   this->billboard[3]->setVisibiliy(false);
    165   lighteningActivate = false;
    166 
    167 
    168   return true;
     198        this->lighteningActivate = false;
     199
     200        this->billboard[0]->setVisibiliy(false);
     201        this->billboard[1]->setVisibiliy(false);
     202        this->billboard[2]->setVisibiliy(false);
     203        this->billboard[3]->setVisibiliy(false);
    169204}
    170205
    171206void LighteningEffect::tick (float dt)
    172207{
    173   if(!lighteningActivate)
    174     return;
    175 
    176   this->time += dt;
    177 
    178   /*if( flashLight != NULL)
    179   {
    180     if((int)(100*time)%2)
    181       this->flashLight->setDiffuseColor(0,0,0);
    182     else
    183       this->flashLight->setDiffuseColor(100,100,100);
    184 
    185     //PRINTF(0)("100*time: %f %i\n", 100*time, (int)(100*time));
    186 }*/
    187 
    188   if( this->time > this->flashFrequency)
    189   {
    190     this->billboard[0]->setVisibiliy(true);
    191     this->time = 0.0f;
    192 
    193     this->flashLight = new Light();
    194     this->flashLight->setAbsCoor(this->billboard[0]->getAbsCoor().x, this->billboard[0]->getAbsCoor().y, this->billboard[0]->getAbsCoor().z);
    195     this->flashLight->setDiffuseColor(100,100,100);
    196 
    197     //this->soundSource.play(this->thunderBuffer);
    198   }
    199   else if( this->billboard[3]->isVisible() && this->time > this->flashConstTime)
    200   {
    201     this->billboard[3]->setVisibiliy(false);
    202     this->time = 0.0f;
    203     this->bNewCoordinate = true;
    204 
    205     if(flashLight != NULL)
    206     {
    207       delete this->flashLight;
    208       flashLight = NULL;
    209     }
    210   }
    211 
    212   if( this->billboard[2]->isVisible() && this->time > this->flashRisingTime)
    213   {
    214     this->billboard[2]->setVisibiliy(false);
    215     this->billboard[3]->setVisibiliy(true);
    216     this->flashLight->setDiffuseColor(100,100,100);
    217   }
    218   else if( this->billboard[1]->isVisible() && this->time > this->flashRisingTime*2/3 )
    219   {
    220     this->billboard[1]->setVisibiliy(false);
    221     this->billboard[2]->setVisibiliy(true);
    222     this->flashLight->setDiffuseColor(0,0,0);
    223   }
    224   else if( this->billboard[0]->isVisible() && this->time > this->flashRisingTime*1/3 )
    225   {
    226     this->billboard[0]->setVisibiliy(false);
    227     this->billboard[1]->setVisibiliy(true);
    228     this->flashLight->setDiffuseColor(100,100,100);
    229   }
    230 
    231   if( this->bNewCoordinate)
    232   {
    233     float posX = this->mainPosX - this->seedX * (float)rand()/(float)RAND_MAX;
    234     float posZ = this->mainPosZ + this->seedZ * (float)rand()/(float)RAND_MAX;
    235     this->billboard[0]->setAbsCoor(posX, this->mainPosY, posZ);
    236     this->billboard[1]->setAbsCoor(posX, this->mainPosY, posZ);
    237     this->billboard[2]->setAbsCoor(posX, this->mainPosY, posZ);
    238     this->billboard[3]->setAbsCoor(posX, this->mainPosY, posZ);
    239     this->bNewCoordinate = false;
    240   }
     208        if(!lighteningActivate)
     209                return;
     210
     211        this->time += dt;
     212
     213        // TODO: Make random flashing with short light dingsda:)
     214
     215        if( this->time > this->flashFrequency) {
     216
     217                this->billboard[0]->setVisibiliy(true);
     218                this->time = 0.0f;
     219
     220                this->flashLight->setAbsCoor(this->billboard[0]->getAbsCoor().x, this->billboard[0]->getAbsCoor().y, this->billboard[0]->getAbsCoor().z);
     221
     222                // flash environmental lightening
     223                this->flashLight->setDiffuseColor(1,1,1);
     224                this->flashLight->setSpecularColor(1,1,1);
     225
     226                //this->soundSource.play(this->thunderBuffer);
     227
     228        } else if( this->billboard[3]->isVisible() && this->time > this->flashConstTime) {
     229
     230                this->billboard[3]->setVisibiliy(false);
     231                this->time = 0.0f;
     232                this->flashLight->setDiffuseColor(0,0,0);
     233                this->flashLight->setSpecularColor(0,0,0);
     234                this->bNewCoordinate = true;
     235
     236        }
     237
     238        if( this->billboard[2]->isVisible() && this->time > this->flashRisingTime) {
     239
     240                this->billboard[2]->setVisibiliy(false);
     241                this->billboard[3]->setVisibiliy(true);
     242                // this->flashLight->setDiffuseColor(1,1,1);
     243                // this->flashLight->setSpecularColor(1,1,1);
     244
     245        } else if( this->billboard[1]->isVisible() && this->time > this->flashRisingTime*2/3 ) {
     246
     247                this->billboard[1]->setVisibiliy(false);
     248                this->billboard[2]->setVisibiliy(true);
     249                //this->flashLight->setDiffuseColor(0,0,0);
     250                //this->flashLight->setSpecularColor(0,0,0);
     251
     252        } else if( this->billboard[0]->isVisible() && this->time > this->flashRisingTime*1/3 ) {
     253
     254                this->billboard[0]->setVisibiliy(false);
     255                this->billboard[1]->setVisibiliy(true);
     256                //this->flashLight->setDiffuseColor(1,1,1);
     257                //this->flashLight->setSpecularColor(1,1,1);
     258
     259        }
     260
     261        if( this->bNewCoordinate) {
     262                float posX, posZ;
     263
     264                if(this->lighteningMove) {
     265
     266                        this->cameraCoor = State::getCameraNode()->getAbsCoor();
     267                        posX = this->mainPosX - this->seedX * (float)rand()/(float)RAND_MAX + this->cameraCoor.x;
     268                        posZ = this->mainPosZ + this->seedZ * (float)rand()/(float)RAND_MAX + this->cameraCoor.z;
     269
     270                } else {
     271
     272                        posX = this->mainPosX - this->seedX * (float)rand()/(float)RAND_MAX;
     273                        posZ = this->mainPosZ + this->seedZ * (float)rand()/(float)RAND_MAX;
     274
     275                }
     276
     277                this->billboard[0]->setAbsCoor(posX, this->mainPosY, posZ);
     278                this->billboard[1]->setAbsCoor(posX, this->mainPosY, posZ);
     279                this->billboard[2]->setAbsCoor(posX, this->mainPosY, posZ);
     280                this->billboard[3]->setAbsCoor(posX, this->mainPosY, posZ);
     281
     282                this->flashFrequency = this->mainFrequency + this->seedTime * (float)rand()/(float)RAND_MAX;
     283
     284                float w = this->width + this->seedWidth * (float)rand()/(float)RAND_MAX;
     285                float h = this->height + this->seedHeight * (float)rand()/(float)RAND_MAX;
     286
     287                this->billboard[0]->setSize(w, h);
     288                this->billboard[1]->setSize(w, h);
     289                this->billboard[2]->setSize(w, h);
     290                this->billboard[3]->setSize(w, h);
     291
     292                this->bNewCoordinate = false;
     293        }
    241294}
    242295
  • trunk/src/lib/graphics/effects/lightening_effect.h

    r8255 r8495  
    1414#include "sound_source.h"
    1515
    16 
    1716class Billboard;
    1817class Light;
     
    2625                virtual void loadParams(const TiXmlElement* root);
    2726
    28                 virtual bool init();
     27                virtual void init();
    2928
    30                 virtual bool activate();
    31                 virtual bool deactivate();
     29                virtual void activate();
     30                virtual void deactivate();
    3231
    33     virtual void draw() const;
    34     virtual void tick(float dt);
    35    
    36     void coord(float x, float y, float z);
    37     void setFlashSize(float width, float height, float seedWidth, float seedHeight);
    38    
    39     inline void setLighteningOption(const std::string& option) { if (option == "activate") this->lighteningActivate = true;}
    40     inline void setFlashFrequency(float flashFrequency) { this->flashFrequency = flashFrequency; }
    41     inline void setFlashConstTime(float flashConstTime) { this->flashConstTime = flashConstTime; }
    42     inline void setFlashRisingTime(float flashRisingTime) { if(flashRisingTime > this->flashConstTime)
    43                                                                                         this->flashRisingTime = this->flashConstTime/2;
    44                                                                                       else
    45                                                                                         this->flashRisingTime = flashRisingTime; }
    46     inline void setFlashSeed(float seedX, float seedZ, float seedTime) { this->seedX = seedX;
    47                                                                                                          this->seedZ = seedZ;
    48                                                                                                          this->seedTime = seedTime; }
     32                inline  void activateLightening() { this->activate(); }
     33                inline  void deactivateLightening() { this->deactivate(); }
    4934
    50     void activateLightening() { this->activate(); }
    51     void deactivateLightening() { this->deactivate(); }
    52    
     35                virtual void draw() const;
     36                virtual void tick(float dt);
     37               
     38                void coord(float x, float y, float z);
     39                void setFlashSize(float width, float height, float seedWidth, float seedHeight);
     40               
     41                inline void setLighteningOption(const std::string& option) {
     42                        if (option == "activate") this->lighteningActivate = true;
     43                        if (option == "movelightening") this->lighteningMove = true;
     44                }
     45
     46                inline void setFlashFrequency(float mainFrequency, float seedTime) {
     47                        this->mainFrequency = mainFrequency;
     48                        this->flashFrequency = mainFrequency;
     49                        this->seedTime = seedTime;
     50                }
     51               
     52                inline void setFlashConstTime(float flashConstTime) { this->flashConstTime = flashConstTime; }
     53
     54                inline void setFlashRisingTime(float flashRisingTime) {
     55                        if(flashRisingTime > this->flashConstTime)
     56                                this->flashRisingTime = this->flashConstTime/2;
     57                        else
     58                                this->flashRisingTime = flashRisingTime;
     59                }
     60               
     61                inline void setFlashSeed(float seedX, float seedZ) {
     62                        this->seedX = seedX;
     63                        this->seedZ = seedZ;
     64                }
     65               
     66
    5367        private:
    54     Billboard* billboard[4];
    55     bool lighteningActivate;
    56 
    57     float flashFrequency;
    58     float flashConstTime;
    59     float flashRisingTime;
    60 
    61     float time;
    62 
    63     bool  bNewCoordinate;
    64     float width;
    65     float height;
    66     float seedWidth;
    67     float seedHeight;
    68 
    69     float seedX;
    70     float seedZ;
    71     float seedTime;
    72    
    73     float mainPosX;
    74     float mainPosY;
    75     float mainPosZ;
    76 
    77     Light* flashLight;
    78    
    79     //OrxSound::SoundSource    soundSource;
    80     //OrxSound::SoundBuffer*   thunderBuffer;
     68                Billboard* billboard[4];
     69                bool lighteningActivate;
     70                bool lighteningMove;
     71               
     72                float flashFrequency;
     73                float mainFrequency;
     74                float flashConstTime;
     75                float flashRisingTime;
     76               
     77                float time;
     78               
     79                bool  bNewCoordinate;
     80                float width;
     81                float height;
     82                float seedWidth;
     83                float seedHeight;
     84               
     85                float seedX;
     86                float seedZ;
     87                float seedTime;
     88               
     89                float mainPosX;
     90                float mainPosY;
     91                float mainPosZ;
     92               
     93                Vector cameraCoor;
     94               
     95                Light* flashLight;
     96               
     97                //OrxSound::SoundSource    soundSource;
     98                //OrxSound::SoundBuffer*   thunderBuffer;
    8199
    82100};
  • trunk/src/lib/graphics/effects/rain_effect.cc

    r8316 r8495  
    3131SHELL_COMMAND(activate, RainEffect, activateRain);
    3232SHELL_COMMAND(deactivate, RainEffect, deactivateRain);
    33 
    34 SHELL_COMMAND(startRaining, RainEffect, startRaining);
     33SHELL_COMMAND(startraining, RainEffect, startRaining);
     34SHELL_COMMAND(stopraining, RainEffect, stopRaining);
    3535
    3636using namespace std;
     
    3838CREATE_FACTORY(RainEffect, CL_RAIN_EFFECT);
    3939
    40 // TODO: Dim Light with Rain, Finish preCaching, check out if multiple rain emitters work,  Think about what happens with building poss. to hang movewithcam off, benchmark, possible to activate lightening, turn off visibility when in a building, variable emitter size depending on playable, also rain velocity
    41 
    42 RainEffect::RainEffect(const TiXmlElement* root)
    43 {
    44         this->setClassID(CL_RAIN_EFFECT, "RainEffect");
    45 
    46         this->init();
    47 
    48         if (root != NULL)
    49                 this->loadParams(root);
    50 
    51         //load rain sound
    52         if (this->rainBuffer != NULL)
    53                 ResourceManager::getInstance()->unload(this->rainBuffer);
    54         this->rainBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load("sound/rain.wav", WAV);
    55 
    56         //load wind sound
    57         if (this->rainWindForce != 0) {
    58                 if (this->windBuffer != NULL)
    59                         ResourceManager::getInstance()->unload(this->windBuffer);
    60                 this->windBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load("sound/wind.wav", WAV);
    61         }
    62 
    63         if(rainActivate)
    64                 this->activate();
    65 }
    66 
    67 RainEffect::~RainEffect()
    68 {
    69         this->deactivate();
    70 
    71         if (this->rainBuffer != NULL)
    72                 ResourceManager::getInstance()->unload(this->rainBuffer);
    73 
    74         if (this->windBuffer != NULL)
    75                 ResourceManager::getInstance()->unload(this->windBuffer);
    76 }
    77 
    78 void RainEffect::loadParams(const TiXmlElement* root)
    79 {
    80         WeatherEffect::loadParams(root);
    81 
    82         LoadParam(root, "coord", this, RainEffect, setRainCoord);
    83         LoadParam(root, "size", this, RainEffect, setRainSize);
    84         LoadParam(root, "rate", this, RainEffect, setRainRate);
    85         LoadParam(root, "velocity", this, RainEffect, setRainVelocity);
    86         LoadParam(root, "life", this, RainEffect, setRainLife);
    87         LoadParam(root, "wind", this, RainEffect, setRainWind);
    88         LoadParam(root, "startraining", this, RainEffect, setRainStart);
    89 
    90         LOAD_PARAM_START_CYCLE(root, element);
    91         {
    92                 LoadParam_CYCLE(element, "option", this, RainEffect, setRainOption);
    93         }
    94         LOAD_PARAM_END_CYCLE(element);
    95 
    96 }
    97 
    98 
    99 bool RainEffect::init()
    100 {
    101         //Default values
    102         this->rainActivate = false;
    103         this->rainMove = false;
    104         this->rainCoord = Vector(500, 500, 500);
    105         this->rainSize = Vector2D(1000, 1000);
    106         this->rainRate = 3000;
    107         this->rainVelocity = -300;
    108         this->rainLife = 4;
    109         this->rainMaxParticles = this->rainRate * this->rainLife;
    110         this->rainWindForce  = 0;
    111         this->rainStartDuration = 0;
    112         this->localTimer = 0;
    113         this->soundRainVolume = 0.8f;
    114 
    115         this->emitter = new PlaneEmitter(this->rainSize);
    116 
    117         lightMan = LightManager::getInstance();
    118         this->rainAmbient = lightMan->getAmbientColor();
    119 
    120         return true;
     40/* TODO:
     41  - test multiple rain emitters
     42  - Think about what happens with building poss. to hang movewithcam off
     43  - Possible to activate lightening
     44  - turn off visibility when in a building
     45  - variable emitter size depending on playable
     46*/
     47
     48RainEffect::RainEffect(const TiXmlElement* root) {
     49    this->setClassID(CL_RAIN_EFFECT, "RainEffect");
     50
     51    this->init();
     52
     53    if (root != NULL)
     54        this->loadParams(root);
     55
     56    //load rain sound
     57    if (this->rainBuffer != NULL)
     58        ResourceManager::getInstance()->unload(this->rainBuffer);
     59    this->rainBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load("sound/atmosphere/rain.wav", WAV);
     60
     61    //load wind sound
     62    if (this->rainWindForce != 0) {
     63        if (this->windBuffer != NULL)
     64            ResourceManager::getInstance()->unload(this->windBuffer);
     65        this->windBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load("sound/atmosphere/wind.wav", WAV);
     66    }
     67
     68    if(rainActivate) {
     69        this->activate();
     70        RainEffect::rainParticles->precache((int)this->rainLife * 5); // TODO: Figure out the correct value
     71    }
     72}
     73
     74RainEffect::~RainEffect() {
     75    this->deactivate();
     76
     77    if (this->rainBuffer != NULL)
     78        ResourceManager::getInstance()->unload(this->rainBuffer);
     79
     80    if (this->windBuffer != NULL)
     81        ResourceManager::getInstance()->unload(this->windBuffer);
     82}
     83
     84void RainEffect::loadParams(const TiXmlElement* root) {
     85    WeatherEffect::loadParams(root);
     86
     87    LoadParam(root, "coord", this, RainEffect, setRainCoord);
     88    LoadParam(root, "size", this, RainEffect, setRainSize);
     89    LoadParam(root, "rate", this, RainEffect, setRainRate);
     90    LoadParam(root, "velocity", this, RainEffect, setRainVelocity);
     91    LoadParam(root, "life", this, RainEffect, setRainLife);
     92    LoadParam(root, "wind", this, RainEffect, setRainWind);
     93    LoadParam(root, "fadeinduration", this, RainEffect, setRainFadeIn);
     94    LoadParam(root, "fadeoutduration", this, RainEffect, setRainFadeOut);
     95
     96    LOAD_PARAM_START_CYCLE(root, element);
     97    {
     98        LoadParam_CYCLE(element, "option", this, RainEffect, setRainOption);
     99    }
     100    LOAD_PARAM_END_CYCLE(element);
     101
     102}
     103
     104
     105void RainEffect::init() {
     106    //Default values
     107    this->rainActivate = false;
     108    this->rainMove = false;
     109    this->rainCoord = Vector(500, 500, 500);
     110    this->rainSize = Vector2D(1000, 1000);
     111    this->rainRate = 4000;
     112    this->rainVelocity = -300;
     113    this->rainLife = 4;
     114    this->rainMaxParticles = this->rainRate * this->rainLife;
     115    this->rainWindForce  = 0;
     116    this->rainFadeInDuration = 0;
     117    this->rainFadeOutDuration = 0;
     118    this->localTimer = 0;
     119    this->soundRainVolume = 0.8f;
     120
     121    this->emitter = new PlaneEmitter(this->rainSize);
     122
     123    lightMan = LightManager::getInstance();
     124    this->rainAmbient = lightMan->getAmbientColor();
    121125}
    122126
     
    124128SparkParticles* RainEffect::rainParticles = NULL;
    125129
    126 bool RainEffect::activate()
    127 {
    128         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" );
    129 
    130         this->rainActivate = true;
    131 
    132         if (unlikely(RainEffect::rainParticles == NULL))
    133         {
    134                 RainEffect::rainParticles = new SparkParticles((int) this->rainMaxParticles);
    135                 RainEffect::rainParticles->setName("RainParticles");
    136                 RainEffect::rainParticles->precache((int)this->rainLife);
    137                 RainEffect::rainParticles->setLifeSpan(this->rainLife, 2);
    138                 RainEffect::rainParticles->setRadius(0, 0.03);
    139                 RainEffect::rainParticles->setRadius(0.2, 0.02);
    140                 RainEffect::rainParticles->setRadius(1, 0.01);
    141                 RainEffect::rainParticles->setColor(0, 0.3, 0.3, 0.5, 0.2);     // grey blue 1
    142                 RainEffect::rainParticles->setColor(0.5, 0.4, 0.4, 0.5, 0.2);   // grey blue 2
    143                 RainEffect::rainParticles->setColor(1, 0.7, 0.7, 0.7, 0.2);     // light grey
    144         }
    145 
    146         this->emitter->setSystem(RainEffect::rainParticles);
    147 
    148         this->emitter->setRelCoor(this->rainCoord);
    149 
    150         this->emitter->setEmissionRate(this->rainRate);
    151         this->emitter->setEmissionVelocity(this->rainVelocity);
    152 
    153         this->emitter->setSpread(this->rainWindForce / 50, 0.2);
    154 
    155         this->soundSource.loop(this->rainBuffer, this->soundRainVolume);
    156         if (this->rainWindForce != 0) this->soundSource.loop(this->windBuffer, 0.1f * this->rainWindForce);
    157 
    158         lightMan->setAmbientColor(.1,.1,.1);
    159 
    160         return true;
    161 }
    162 
    163 
    164 bool RainEffect::deactivate()
    165 {
    166         PRINTF(0)("Deactivating RainEffect\n");
    167 
    168         this->rainActivate = false;
    169         this->emitter->setSystem(NULL);
    170 
    171         // Stop Sound
    172         this->soundSource.stop();
    173 
    174         // Restore Light Ambient
    175         lightMan->setAmbientColor(this->rainAmbient, this->rainAmbient, this->rainAmbient);
    176 
    177         return true;
    178 }
    179 
    180 void RainEffect::tick (float dt)
    181 {
    182         if (!this->rainActivate)
    183                 return;
    184 
    185         if (this->rainMove) {
    186                 this->rainCoord = State::getCameraNode()->getAbsCoor();
    187                 this->emitter->setRelCoor(this->rainCoord.x , this->rainCoord.y+800, this->rainCoord.z);
    188         }
    189 
    190         if (this->rainStartDuration != 0 && this->localTimer < this->rainStartDuration) {
    191                 this->localTimer += dt;
    192                 float progress = this->localTimer / this->rainStartDuration;
    193 
    194                 // Dim Light
    195                 lightMan->setAmbientColor(1.1 - progress, 1.1 - progress, 1.1 - progress);
    196 
    197                 // use alpha in color to fade in
    198                 RainEffect::rainParticles->setColor(0,   0.3, 0.3, 0.5, 0.2 * progress); // grey blue 1
    199                 RainEffect::rainParticles->setColor(0.5, 0.4, 0.4, 0.5, 0.2 * progress); // grey blue 2
    200                 RainEffect::rainParticles->setColor(1,   0.7, 0.7, 0.7, 0.2 * progress); // light grey
    201 
    202                 // increase radius for more "heavy" rain
    203                 RainEffect::rainParticles->setRadius(0, 0.03 * progress);
    204                 RainEffect::rainParticles->setRadius(0.2, 0.02 * progress);
    205                 RainEffect::rainParticles->setRadius(1, 0.01 * progress);
    206 
    207                 // increase sound volume
    208                 // this->soundSource.fadein(this->rainBuffer, 10);
    209         }
     130void RainEffect::activate() {
     131    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" );
     132
     133    this->rainActivate = true;
     134
     135    if (unlikely(RainEffect::rainParticles == NULL)) {
     136        RainEffect::rainParticles = new SparkParticles((int) this->rainMaxParticles);
     137        RainEffect::rainParticles->setName("RainParticles");
     138        RainEffect::rainParticles->setLifeSpan(this->rainLife, 2);
     139        RainEffect::rainParticles->setRadius(0, 0.03);
     140        RainEffect::rainParticles->setRadius(0.2, 0.02);
     141        RainEffect::rainParticles->setRadius(1, 0.01);
     142        RainEffect::rainParticles->setColor(0, 0.3, 0.3, 0.5, 0.2); // grey blue 1
     143        RainEffect::rainParticles->setColor(0.5, 0.4, 0.4, 0.5, 0.2); // grey blue 2
     144        RainEffect::rainParticles->setColor(1, 0.7, 0.7, 0.7, 0.2); // light grey
     145    }
     146
     147    this->emitter->setSystem(RainEffect::rainParticles);
     148
     149    this->emitter->setRelCoor(this->rainCoord);
     150
     151    this->emitter->setEmissionRate(this->rainRate);
     152    this->emitter->setEmissionVelocity(this->rainVelocity);
     153
     154    this->emitter->setSpread(this->rainWindForce / 50, 0.2);
     155
     156    this->soundSource.play(this->rainBuffer, this->soundRainVolume, true);
     157
     158    if (this->rainWindForce != 0)
     159        this->soundSource.play(this->windBuffer, 0.1f * this->rainWindForce, true);
     160
     161    if (this->rainFadeInDuration == 0)
     162        lightMan->setAmbientColor(.1,.1,.1);
     163
     164}
     165
     166
     167void RainEffect::deactivate() {
     168    PRINTF(0)("Deactivating RainEffect\n");
     169
     170    this->rainActivate = false;
     171    this->emitter->setSystem(NULL);
     172
     173    // Stop Sound
     174    this->soundSource.stop();
     175
     176    // Restore Light Ambient
     177    lightMan->setAmbientColor(this->rainAmbient, this->rainAmbient, this->rainAmbient);
     178
     179}
     180
     181void RainEffect::tick (float dt) {
     182    if (!this->rainActivate)
     183        return;
     184
     185    if (this->rainMove) {
     186        this->rainCoord = State::getCameraNode()->getAbsCoor();
     187        this->emitter->setRelCoor(this->rainCoord.x , this->rainCoord.y+800, this->rainCoord.z);
     188    }
     189
     190    if (this->rainFadeInDuration != 0 && this->localTimer < this->rainFadeInDuration) {
     191        this->localTimer += dt;
     192        float progress = this->localTimer / this->rainFadeInDuration;
     193
     194        // Dim Light
     195        lightMan->setAmbientColor(1 - progress * 0.9, 1 - progress * 0.9, 1 - progress * 0.9);
     196
     197        // use alpha in color to fade in
     198        RainEffect::rainParticles->setColor(0,   0.3, 0.3, 0.5, 0.2 * progress); // grey blue 1
     199        RainEffect::rainParticles->setColor(0.5, 0.4, 0.4, 0.5, 0.2 * progress); // grey blue 2
     200        RainEffect::rainParticles->setColor(1,   0.7, 0.7, 0.7, 0.2 * progress); // light grey
     201
     202        // increase radius for more "heavy" rain
     203        RainEffect::rainParticles->setRadius(0, 0.03 * progress);
     204        RainEffect::rainParticles->setRadius(0.2, 0.02 * progress);
     205        RainEffect::rainParticles->setRadius(1, 0.01 * progress);
     206
     207        // increase sound volume
     208        // this->soundSource.fadein(this->rainBuffer, 10);
     209    } else if ( this->rainFadeOutDuration != 0 ) {
     210        if ( this->localTimer < this->rainFadeOutDuration ) {
     211            this->localTimer += dt;
     212            float progress = 1 - (this->localTimer / this->rainFadeOutDuration);
     213
     214            // Fade In Light
     215            lightMan->setAmbientColor(1 - progress * 0.9, 1 - progress * 0.9, 1 - progress * 0.9);
     216
     217            // use alpha in color to fade out
     218            RainEffect::rainParticles->setColor(0,   0.3, 0.3, 0.5, 0.2 * progress); // grey blue 1
     219            RainEffect::rainParticles->setColor(0.5, 0.4, 0.4, 0.5, 0.2 * progress); // grey blue 2
     220            RainEffect::rainParticles->setColor(1,   0.7, 0.7, 0.7, 0.2 * progress); // light grey
     221
     222            // decrease radius
     223            RainEffect::rainParticles->setRadius(0, 0.03 * progress);
     224            RainEffect::rainParticles->setRadius(0.2, 0.02 * progress);
     225            RainEffect::rainParticles->setRadius(1, 0.01 * progress);
     226
     227            // decrease sound volume
     228            // this->soundSource.fadeout(this->rainBuffer, 10);
     229        } else
     230            this->deactivate();
     231    }
    210232
    211233}
     
    213235void RainEffect::startRaining() {
    214236
    215         if (this->rainActivate)
    216                 this->deactivate();
    217 
    218         this->rainStartDuration = 10;
    219         this->localTimer = 0;
    220         this->activate();
    221 
    222 }
     237    if (this->rainActivate)
     238        this->deactivate();
     239
     240    if (!this->rainFadeInDuration > 0)
     241        this->rainFadeInDuration = 20;
     242
     243    this->localTimer = 0;
     244
     245    this->activate();
     246
     247}
     248
     249void RainEffect::stopRaining() {
     250
     251    if (!this->rainActivate)
     252        this->activate();
     253
     254    if (!this->rainFadeOutDuration > 0)
     255        this->rainFadeOutDuration = 20;
     256
     257    this->localTimer = 0;
     258
     259}
  • trunk/src/lib/graphics/effects/rain_effect.h

    r8255 r8495  
    2222
    2323
    24 class RainEffect : public WeatherEffect
    25 {
    26         public:
    27                 RainEffect(const TiXmlElement* root = NULL);
    28                 virtual ~RainEffect();
     24class RainEffect : public WeatherEffect {
     25public:
     26    RainEffect(const TiXmlElement* root = NULL);
     27    virtual ~RainEffect();
    2928
    30                 virtual void loadParams(const TiXmlElement* root);
     29    virtual void loadParams(const TiXmlElement* root);
    3130
    32                 virtual bool init();
     31    virtual void init();
    3332
    34                 virtual bool activate();
    35                 virtual bool deactivate();
     33    virtual void activate();
     34    virtual void deactivate();
    3635
    37                 virtual void tick(float dt);
     36    inline void activateRain() {
     37        this->activate();
     38    }
     39    inline void deactivateRain() {
     40        this->deactivate();
     41    }
    3842
    39                 inline void activateRain() { this->activate(); }
    40                 inline void deactivateRain() { this->deactivate(); }
    41                 void startRaining();
     43    virtual void tick(float dt);
    4244
    43                 inline void setRainCoord(float x, float y, float z) { this->rainCoord = Vector(x, y, z); }
    44                 inline void setRainSize(float x, float y) { this->rainSize = Vector2D(x, y); }
    45                 inline void setRainRate(float rate) { this->rainRate = rate;}
    46                 inline void setRainVelocity(float velocity) { this->rainVelocity = -velocity; }
    47                 inline void setRainLife(float life) { this->rainLife = life; }
    48                 inline void setRainWind(int force) { this->rainWindForce = force; }
    49                 inline void setRainStart(float duration) { this->rainStartDuration = duration; }
     45    void startRaining();
     46    void stopRaining();
    5047
    51                 inline void setRainOption(const std::string& option) {
    52                         if (option == "moverain") this->rainMove = true;
    53                         if (option == "activate") this->rainActivate = true;
    54                 }
     48    inline void setRainCoord(float x, float y, float z) {
     49        this->rainCoord = Vector(x, y, z);
     50    }
     51    inline void setRainSize(float x, float y) {
     52        this->rainSize = Vector2D(x, y);
     53    }
     54    inline void setRainRate(float rate) {
     55        this->rainRate = rate;
     56    }
     57    inline void setRainVelocity(float velocity) {
     58        this->rainVelocity = -velocity;
     59    }
     60    inline void setRainLife(float life) {
     61        this->rainLife = life;
     62    }
     63    inline void setRainWind(int force) {
     64        this->rainWindForce = force;
     65    }
     66
     67    inline void setRainFadeIn(float fadein) {
     68        this->rainFadeInDuration = fadein;
     69    }
     70    inline void setRainFadeOut(float fadeout) {
     71        this->rainFadeOutDuration = fadeout;
     72    }
     73
     74    inline void setRainOption(const std::string& option) {
     75        if (option == "moverain")
     76            this->rainMove = true;
     77        if (option == "activate")
     78            this->rainActivate = true;
     79    }
    5580
    5681
    57         private:
    58                 static SparkParticles*                  rainParticles;
    59                 ParticleEmitter*                        emitter;
     82private:
     83    static SparkParticles*      rainParticles;
     84    ParticleEmitter*            emitter;
    6085
    61                 float                                   localTimer;
     86    GLfloat         rainFadeInDuration;
     87    GLfloat         rainFadeOutDuration;
     88    float           localTimer;
    6289
    63                 Vector                                  rainCoord;
    64                 Vector2D                                rainSize;
    65                 GLfloat                                 rainRate;
    66                 GLfloat                                 rainVelocity;
    67                 GLfloat                                 rainLife;
    68                 GLfloat                                 rainMaxParticles;
    69                 int                                     rainWindForce;
    70                 GLfloat                                 rainStartDuration;
    71                 bool                                    rainMove;
    72                 bool                                    rainActivate;
     90    Vector          rainCoord;
     91    Vector2D        rainSize;
     92    GLfloat         rainRate;
     93    GLfloat         rainVelocity;
     94    GLfloat         rainLife;
     95    GLfloat         rainMaxParticles;
     96    int             rainWindForce;
     97    bool            rainMove;
     98    bool            rainActivate;
    7399
    74                 OrxSound::SoundSource                   soundSource;
    75                 OrxSound::SoundBuffer*                  rainBuffer;
    76                 OrxSound::SoundBuffer*                  windBuffer;
     100    OrxSound::SoundSource     soundSource;
     101    OrxSound::SoundBuffer*      rainBuffer;
     102    OrxSound::SoundBuffer*      windBuffer;
    77103
    78                 float                                   soundRainVolume;
     104    float         soundRainVolume;
    79105
    80                 LightManager*                           lightMan;
    81                 GLfloat                                 rainAmbient;
     106    LightManager*       lightMan;
     107    GLfloat         rainAmbient;
    82108
    83109};
  • trunk/src/lib/graphics/effects/snow_effect.cc

    r8316 r8495  
    5050                if (this->windBuffer != NULL)
    5151                        ResourceManager::getInstance()->unload(this->windBuffer);
    52                         this->windBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load("sound/wind.wav", WAV);
    53         }
    54 
    55         if(snowActivate)
     52                        this->windBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load("sound/atmosphere/wind.wav", WAV);
     53        }
     54
     55  if(snowActivate) {
    5656                this->activate();
     57    SnowEffect::snowParticles->precache((int) this->snowLife);
     58  } 
    5759}
    5860
     
    8789}
    8890
    89 bool SnowEffect::init()
     91void SnowEffect::init()
    9092{
    9193        this->emitter = new PlaneEmitter();
     
    9698        this->particles = 12000;
    9799        this->texture = "maps/snow_flake_01_32x32.png";
    98         this->life = 8;
     100        this->snowLife = 8;
    99101        this->randomLife = 2;
    100102        this->snowRadius = 3.5;
     
    111113        this->snowCoord = Vector(100,450,400);
    112114        this->snowWindForce = 1;
    113 
    114         return true;
    115 }
    116 
    117 bool SnowEffect::activate()
     115}
     116
     117void SnowEffect::activate()
    118118{
    119119        PRINTF(0)("Activating SnowEffect\n");
     
    124124        SnowEffect::snowParticles->setName("SnowEffectTrailParticles");
    125125        SnowEffect::snowParticles->setMaterialTexture(texture);
    126         SnowEffect::snowParticles->setLifeSpan(life, randomLife);
     126        SnowEffect::snowParticles->setLifeSpan(snowLife, randomLife);
    127127        SnowEffect::snowParticles->setRadius(0.0, snowRadius, randomRadius);
    128128        SnowEffect::snowParticles->setRadius(0.2, snowRadius, randomRadius*0.8);
     
    141141        this->emitter->setSize(snowSize);
    142142
    143         // SnowEffect::snowParticles->precache(8);
    144 
    145         if (this->snowWindForce > 1)
    146                 this->soundSource.loop(this->windBuffer);
    147 
    148         return true;
    149 }
    150 
    151 
    152 bool SnowEffect::deactivate()
     143  if (this->snowWindForce != 0)
     144    this->soundSource.play(this->windBuffer, 0.1f * this->snowWindForce, true);
     145 
     146}
     147
     148
     149void SnowEffect::deactivate()
    153150{
    154151        PRINTF(0)("Deactivating SnowEffect\n");
     
    159156        if (this->windBuffer != NULL)
    160157                ResourceManager::getInstance()->unload(this->windBuffer);
    161 
    162         return true;
    163158}
    164159
  • trunk/src/lib/graphics/effects/snow_effect.h

    r8255 r8495  
    2020#include "sound_buffer.h"
    2121
    22 class SnowEffect : public WeatherEffect
    23 {
    24         public:
    25                 SnowEffect(const TiXmlElement* root = NULL);
    26                 virtual ~SnowEffect();
     22class SnowEffect : public WeatherEffect {
     23public:
     24    SnowEffect(const TiXmlElement* root = NULL);
     25    virtual ~SnowEffect();
    2726
    28                 virtual void loadParams(const TiXmlElement* root);
     27    virtual void loadParams(const TiXmlElement* root);
    2928
    30                 virtual bool init();
     29    virtual void init();
    3130
    32                 virtual bool activate();
    33                 virtual bool deactivate();
     31    virtual void activate();
     32    virtual void deactivate();
    3433
    35                 inline void activateSnow() { this->activate(); }
    36                 inline void deactivateSnow() { this->deactivate(); }
    37                
    38                 virtual void draw() const;
    39                 virtual void tick(float dt);
     34    inline void activateSnow() {
     35        this->activate();
     36    }
     37    inline void deactivateSnow() {
     38        this->deactivate();
     39    }
     40
     41    virtual void draw() const;
     42    virtual void tick(float dt);
    4043
    4144
    42                 inline void numParticles(int n) { this->particles = n; }
    43                 inline void materialTexture(const std::string& texture) { this->texture = texture; }
    44                 inline void lifeSpan(float lifeSpan, float randomLifeSpan) { this->life = lifeSpan; this->randomLife = randomLifeSpan; }
    45                 inline void radius(float radius, float randomRadius) { this->snowRadius = radius; this->randomRadius = randomRadius; }
    46                 inline void mass(float mass, float randomMass) { this->snowMass = mass; this->randomMass = randomMass; }
    47                 inline void emissionRate(float emissionRate){ this->rate = emissionRate; }
    48                 inline void emissionVelocity(float velocity, float randomVelocity){ this->velocity = velocity; this->randomVelocity = randomVelocity; }
    49                 inline void size(float sizeX, float sizeY) { this->snowSize = Vector2D(sizeX, sizeY); }
    50                 inline void coord(float x, float y, float z) { this->snowCoord = Vector(x, y, z); }
    51                 inline void wind(int force) { this->snowWindForce = force; }
     45    inline void numParticles(int n) {
     46        this->particles = n;
     47    }
     48    inline void materialTexture(const std::string& texture) {
     49        this->texture = texture;
     50    }
     51    inline void lifeSpan(float lifeSpan, float randomLifeSpan) {
     52        this->snowLife = lifeSpan;
     53        this->randomLife = randomLifeSpan;
     54    }
     55    inline void radius(float radius, float randomRadius) {
     56        this->snowRadius = radius;
     57        this->randomRadius = randomRadius;
     58    }
     59    inline void mass(float mass, float randomMass) {
     60        this->snowMass = mass;
     61        this->randomMass = randomMass;
     62    }
     63    inline void emissionRate(float emissionRate) {
     64        this->rate = emissionRate;
     65    }
     66    inline void emissionVelocity(float velocity, float randomVelocity) {
     67        this->velocity = velocity;
     68        this->randomVelocity = randomVelocity;
     69    }
     70    inline void size(float sizeX, float sizeY) {
     71        this->snowSize = Vector2D(sizeX, sizeY);
     72    }
     73    inline void coord(float x, float y, float z) {
     74        this->snowCoord = Vector(x, y, z);
     75    }
     76    inline void wind(int force) {
     77        this->snowWindForce = force;
     78    }
    5279
    53                 inline void setSnowOption(const std::string& option) {
    54                         /*if (option == "fade") this->snowFade = true;*/
    55                         if (option == "movesnow") this->snowMove = true;
    56                         if (option == "activate") this->snowActivate = true;
    57                 }
     80    inline void setSnowOption(const std::string& option) {
     81        /*if (option == "fade") this->snowFade = true;*/
     82        if (option == "movesnow")
     83            this->snowMove = true;
     84        if (option == "activate")
     85            this->snowActivate = true;
     86    }
    5887
    5988
    60         private:
    61                 int                             particles;
    62                 std::string                     texture;
    63                 float                           life, randomLife;
    64                 float                           snowRadius, randomRadius;
    65                 float                           snowMass, randomMass;
    66                 float                           rate;
    67                 float                           velocity, randomVelocity;
    68                 float                           angle, randomAngle;
    69                 float                           alpha;
    70                 Vector                          snowCoord;
    71                 Vector2D                        snowSize;
    72                 int                             snowWindForce;
     89private:
     90    int         particles;
     91    std::string       texture;
     92    float       snowLife, randomLife;
     93    float       snowRadius, randomRadius;
     94    float       snowMass, randomMass;
     95    float         rate;
     96    float         velocity, randomVelocity;
     97    float         angle, randomAngle;
     98    float         alpha;
     99    Vector        snowCoord;
     100    Vector2D      snowSize;
     101    int       snowWindForce;
    73102
    74                 bool                            snowMove;
    75                 bool                            snowActivate;
     103    bool        snowMove;
     104    bool        snowActivate;
    76105
    77                 PlaneEmitter*                   emitter;
     106    PlaneEmitter*     emitter;
    78107
    79                 static SpriteParticles*         snowParticles;
    80                 OrxSound::SoundSource           soundSource;
    81                 OrxSound::SoundBuffer*          windBuffer;
     108    static SpriteParticles*   snowParticles;
     109    OrxSound::SoundSource   soundSource;
     110    OrxSound::SoundBuffer*    windBuffer;
    82111
    83112};
  • trunk/src/lib/graphics/effects/volfog_effect.cc

    r8362 r8495  
    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
     
    2121#include "state.h"
    2222
     23#include "glincl.h"
     24//#include "shell_command.h"
    2325
    2426#define GLX_GLXEXT_PROTOTYPES
     
    4951CREATE_FACTORY(VolFogEffect, CL_VOLFOG_EFFECT);
    5052
    51 VolFogEffect::VolFogEffect(const TiXmlElement* root)
    52 {
    53         this->setClassID(CL_VOLFOG_EFFECT, "VolFogEffect");
     53VolFogEffect::VolFogEffect(const TiXmlElement* root) {
     54    this->setClassID(CL_VOLFOG_EFFECT, "VolFogEffect");
    5455
    55         if (root != NULL)
    56                 this->loadParams(root);
     56    if (root != NULL)
     57        this->loadParams(root);
    5758
    58         // Initialize Effect
    59         this->init();
     59    // Initialize Effect
     60    this->init();
    6061
    61         // Activate Effect
    62         this->activate();
     62    // Activate Effect
     63    this->activate();
    6364}
    6465
    6566
    66 VolFogEffect::~VolFogEffect()
    67 {
    68         this->deactivate();
     67VolFogEffect::~VolFogEffect() {
     68    this->deactivate();
    6969}
    7070
    71 void VolFogEffect::loadParams(const TiXmlElement* root)
    72 {
    73         WeatherEffect::loadParams(root);
     71void VolFogEffect::loadParams(const TiXmlElement* root) {
     72    WeatherEffect::loadParams(root);
    7473}
    7574
    76 bool VolFogEffect::init()
    77 {
    78         PRINTF(0)("Initalize VolFogEffect\n");
     75void VolFogEffect::init() {
     76    PRINTF(0)("Initalize VolFogEffect\n");
    7977
    80         // set fog mode
    81         GLenum fogMode  = GL_EXP;
     78    // set fog mode
     79    GLenum fogMode  = GL_EXP;
    8280
    83         // set fog density
    84         float  fogDensity  = 0.001f;
     81    // set fog density
     82    float  fogDensity  = 0.001f;
    8583
    86         // set fog near & far distance
    87         float fogStart = 0.0f;
    88         float fogEnd   = 1000.0f;
     84    // set fog near & far distance
     85    float fogStart = 0.0f;
     86    float fogEnd   = 1000.0f;
    8987
    90         // Set fog color
    91         float fogColor[4] = {0.6f,0.58f,0.79f,0.0f};
     88    // Set fog color
     89    float fogColor[4] = {0.6f,0.58f,0.79f,0.0f};
    9290
    9391
    94         glFogCoordfEXT       = (PFNGLFOGCOORDFEXTPROC)glXGetProcAddressARB((const GLubyte*)"glFogCoordfEXT");
    95         glFogCoordfvEXT      = (PFNGLFOGCOORDFVEXTPROC)glXGetProcAddressARB((const GLubyte*)"glFogCoordfvEXT");
    96         glFogCoorddEXT       = (PFNGLFOGCOORDDEXTPROC)glXGetProcAddressARB((const GLubyte*)"glFogCoorddEXT");
    97         glFogCoorddvEXT      = (PFNGLFOGCOORDDVEXTPROC)glXGetProcAddressARB((const GLubyte*)"glFogCoorddvEXT");
    98         glFogCoordPointerEXT = (PFNGLFOGCOORDPOINTEREXTPROC)glXGetProcAddressARB((const GLubyte*)"glFogCoordPointerEXT");
     92    glFogCoordfEXT       = (PFNGLFOGCOORDFEXTPROC)glXGetProcAddressARB((const GLubyte*)"glFogCoordfEXT");
     93    glFogCoordfvEXT      = (PFNGLFOGCOORDFVEXTPROC)glXGetProcAddressARB((const GLubyte*)"glFogCoordfvEXT");
     94    glFogCoorddEXT       = (PFNGLFOGCOORDDEXTPROC)glXGetProcAddressARB((const GLubyte*)"glFogCoorddEXT");
     95    glFogCoorddvEXT      = (PFNGLFOGCOORDDVEXTPROC)glXGetProcAddressARB((const GLubyte*)"glFogCoorddvEXT");
     96    glFogCoordPointerEXT = (PFNGLFOGCOORDPOINTEREXTPROC)glXGetProcAddressARB((const GLubyte*)"glFogCoordPointerEXT");
    9997
    100         // set the fog attributes
    101         glFogf (GL_FOG_START,  fogStart);
    102         glFogf (GL_FOG_END,    fogEnd);
    103         glFogfv(GL_FOG_COLOR,  fogColor);
    104         glFogi (GL_FOG_MODE,   fogMode);
    105         glFogf (GL_FOG_DENSITY,fogDensity);
    106         glFogi (GL_FOG_COORDINATE_SOURCE_EXT,GL_FOG_COORDINATE_EXT);
     98    // set the fog attributes
     99    glFogf (GL_FOG_START,  fogStart);
     100    glFogf (GL_FOG_END,    fogEnd);
     101    glFogfv(GL_FOG_COLOR,  fogColor);
     102    glFogi (GL_FOG_MODE,   fogMode);
     103    glFogf (GL_FOG_DENSITY,fogDensity);
     104    glFogi (GL_FOG_COORDINATE_SOURCE_EXT,GL_FOG_COORDINATE_EXT);
    107105
    108         // enable the fog
    109         glEnable(GL_FOG);
     106    // enable the fog
     107    glEnable(GL_FOG);
    110108
    111         if (glewInit() == GLEW_OK)
    112                 PRINTF(0)("glewInit OK\n");
    113         else
    114                 PRINTF(0)("glewInit failed\n");
     109    if (glewInit() == GLEW_OK)
     110        PRINTF(0)("glewInit OK\n");
     111    else
     112        PRINTF(0)("glewInit failed\n");
    115113
    116         if (glewGetExtension("GL_EXT_fog_coord"))
    117         {
    118                 PRINTF(0)("GL_EXT_fog_coord extension found\n");
    119                 return true;
    120         }
    121         else
    122         {
    123                 PRINTF(0)("GL_EXT_fog_coord extension NOT found\n");
    124                 return false;
    125         }
     114    if (glewGetExtension("GL_EXT_fog_coord"))
     115        PRINTF(0)("GL_EXT_fog_coord extension found\n");
    126116}
    127117
    128118
    129 bool VolFogEffect::activate()
    130 {
    131         PRINTF(0)("Activating VolFogEffect\n");
    132 
    133         return true;
     119void VolFogEffect::activate() {
     120    PRINTF(0)("Activating VolFogEffect\n");
    134121}
    135122
    136 bool VolFogEffect::deactivate()
    137 {
    138         PRINTF(0)("Deactivating VolFogEffect\n");
     123void VolFogEffect::deactivate() {
     124    PRINTF(0)("Deactivating VolFogEffect\n");
    139125
    140         glDisable(GL_FOG);
    141 
    142         return true;
     126    glDisable(GL_FOG);
    143127}
    144128
     
    147131* draws the effect, if needed
    148132*/
    149 void VolFogEffect::draw() const
    150 {
    151   glPushAttrib(GL_ENABLE_BIT);
    152   glClearColor(fogColor[0],fogColor[1],fogColor[2],0.0f);
    153         glShadeModel(GL_SMOOTH);
    154         glEnable(GL_DEPTH_TEST);
    155         glEnable(GL_CULL_FACE);
    156         glCullFace(GL_BACK);
     133void VolFogEffect::draw() const {
     134    glPushAttrib(GL_ENABLE_BIT);
     135    glClearColor(fogColor[0],fogColor[1],fogColor[2],0.0f);
     136    glShadeModel(GL_SMOOTH);
     137    glEnable(GL_DEPTH_TEST);
     138    glEnable(GL_CULL_FACE);
     139    glCullFace(GL_BACK);
    157140
    158         /* clear all pixels in colour buffer */
    159         glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
     141    /* clear all pixels in colour buffer */
     142    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    160143
    161         /* Enable blending */
    162         //glEnable(GL_BLEND);
    163         //glBlendFunc(GL_SRC_ALPHA, GL_DST_ALPHA);
     144    /* Enable blending */
     145    //glEnable(GL_BLEND);
     146    //glBlendFunc(GL_SRC_ALPHA, GL_DST_ALPHA);
    164147
    165         int i;
    166         glLoadIdentity();
     148    int i;
     149    glLoadIdentity();
    167150
    168151
    169         glBegin( GL_LINES );
    170                 glNormal3f(0,1,0);
    171                 for(i=-20;i<=20;i+=2)
    172                 {
    173                         float fog_c;
    174                         float diff[3];
     152    glBegin( GL_LINES );
     153    glNormal3f(0,1,0);
     154    for(i=-20;i<=20;i+=2) {
     155        float fog_c;
     156        float diff[3];
    175157
    176                         diff[0] = State::getCameraNode()->getAbsCoor().x - i;
    177                         diff[2] = State::getCameraNode()->getAbsCoor().z + 20;
    178                         diff[1] = State::getCameraNode()->getAbsCoor().y;
    179                         fog_c = 1.3f*sqrt(diff[0]*diff[0]+diff[1]*diff[1]+diff[2]*diff[2]);
    180                         glFogCoordfEXT(fog_c*2);
    181                         glVertex3f(i,0,-20);
     158        diff[0] = State::getCameraNode()->getAbsCoor().x - i;
     159        diff[2] = State::getCameraNode()->getAbsCoor().z + 20;
     160        diff[1] = State::getCameraNode()->getAbsCoor().y;
     161        fog_c = 1.3f*sqrt(diff[0]*diff[0]+diff[1]*diff[1]+diff[2]*diff[2]);
     162        glFogCoordfEXT(fog_c*2);
     163        glVertex3f(i,0,-20);
    182164
    183                         diff[0] = State::getCameraNode()->getAbsCoor().x - i;
    184                         diff[2] = State::getCameraNode()->getAbsCoor().z + 20;
    185                         diff[1] = State::getCameraNode()->getAbsCoor().y;
    186                         fog_c = 1.3f*sqrt(diff[0]*diff[0]+diff[1]*diff[1]+diff[2]*diff[2]);
    187                         glFogCoordfEXT(fog_c*2);
    188                         glVertex3f(i,0,20);
     165        diff[0] = State::getCameraNode()->getAbsCoor().x - i;
     166        diff[2] = State::getCameraNode()->getAbsCoor().z + 20;
     167        diff[1] = State::getCameraNode()->getAbsCoor().y;
     168        fog_c = 1.3f*sqrt(diff[0]*diff[0]+diff[1]*diff[1]+diff[2]*diff[2]);
     169        glFogCoordfEXT(fog_c*2);
     170        glVertex3f(i,0,20);
    189171
    190                         diff[0] = State::getCameraNode()->getAbsCoor().x - i;
    191                         diff[2] = State::getCameraNode()->getAbsCoor().z + 20;
    192                         diff[1] = State::getCameraNode()->getAbsCoor().y;
    193                         fog_c = 1.3f*sqrt(diff[0]*diff[0]+diff[1]*diff[1]+diff[2]*diff[2]);
    194                         glFogCoordfEXT(fog_c*2);
    195                         glVertex3f(-20,0,i);
     172        diff[0] = State::getCameraNode()->getAbsCoor().x - i;
     173        diff[2] = State::getCameraNode()->getAbsCoor().z + 20;
     174        diff[1] = State::getCameraNode()->getAbsCoor().y;
     175        fog_c = 1.3f*sqrt(diff[0]*diff[0]+diff[1]*diff[1]+diff[2]*diff[2]);
     176        glFogCoordfEXT(fog_c*2);
     177        glVertex3f(-20,0,i);
    196178
    197                         diff[0] = State::getCameraNode()->getAbsCoor().x - i;
    198                         diff[2] = State::getCameraNode()->getAbsCoor().z + 20;
    199                         diff[1] = State::getCameraNode()->getAbsCoor().y;
    200                         fog_c = 1.3f*sqrt(diff[0]*diff[0]+diff[1]*diff[1]+diff[2]*diff[2]);
    201                         glFogCoordfEXT(fog_c*2);
    202                         glVertex3f(20,0,i);
    203                 }
    204         glEnd();
     179        diff[0] = State::getCameraNode()->getAbsCoor().x - i;
     180        diff[2] = State::getCameraNode()->getAbsCoor().z + 20;
     181        diff[1] = State::getCameraNode()->getAbsCoor().y;
     182        fog_c = 1.3f*sqrt(diff[0]*diff[0]+diff[1]*diff[1]+diff[2]*diff[2]);
     183        glFogCoordfEXT(fog_c*2);
     184        glVertex3f(20,0,i);
     185    }
     186    glEnd();
    205187
    206   glPopAttrib();
     188    glPopAttrib();
    207189
    208190}
     
    212194* ticks the effect if there is any time dependancy
    213195*/
    214 void VolFogEffect::tick(float dt)
    215 {
    216 }
     196void VolFogEffect::tick(float dt) {}
  • trunk/src/lib/graphics/effects/volfog_effect.h

    r8362 r8495  
    1111#include "glincl.h"
    1212
    13 class VolFogEffect : public WeatherEffect
    14 {
    15         public:
    16                 VolFogEffect(const TiXmlElement* root = NULL);
    17                 virtual ~VolFogEffect();
     13class VolFogEffect : public WeatherEffect {
     14public:
     15    VolFogEffect(const TiXmlElement* root = NULL);
     16    virtual ~VolFogEffect();
    1817
    19                 virtual void loadParams(const TiXmlElement* root);
     18    virtual void loadParams(const TiXmlElement* root);
    2019
    21                 virtual bool init();
     20    virtual void init();
    2221
    23                 virtual bool activate();
    24                 virtual bool deactivate();
     22    virtual void activate();
     23    virtual void deactivate();
    2524
    26                 virtual void draw() const;
    27                 virtual void tick(float dt);
     25    virtual void draw() const;
     26    virtual void tick(float dt);
    2827
    29         private:
    30                 GLfloat fogColor[4];
     28private:
     29    GLfloat fogColor[4];
    3130
    3231};
  • trunk/src/lib/graphics/effects/weather_effect.cc

    r8316 r8495  
    5555 *  initializes the graphics effect
    5656 */
    57 bool WeatherEffect::init()
     57void WeatherEffect::init()
    5858{
    59   return true;
    6059}
    6160
  • trunk/src/lib/graphics/effects/weather_effect.h

    r7810 r8495  
    11/*!
    22 * @file weather_effect.h
    3  * 
     3 *
    44 */
    55
     
    1818    virtual void loadParams(const TiXmlElement* root);
    1919
    20     virtual bool init();
     20    virtual void init();
    2121
    22     virtual bool activate() = 0;
    23     virtual bool deactivate() = 0;
     22    virtual void activate() = 0;
     23    virtual void deactivate() = 0;
    2424
    2525    virtual void draw() const;
    2626    virtual void tick(float dt);
    2727
    28     inline bool isActivated() const { return this->bActivated; }
     28    inline  bool isActivated() const { return this->bActivated; }
    2929
    3030
  • trunk/src/lib/gui/qt/gui_control.cc

    r8316 r8495  
    286286        return -1;
    287287    }
     288
     289    return 0;
     290
    288291  }
    289292
  • trunk/src/lib/sound/sound_source.cc

    r8362 r8495  
    11/*
    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: Benjamin Grauer
    13         co-programmer: ...
     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: Benjamin Grauer
     13  co-programmer: ...
    1414*/
    1515
     
    8585    else
    8686      this->stop();
    87     return *this;
    8887  }
    8988
     
    190189      SoundEngine::checkError("Play Source", __LINE__);
    191190  }
    192 
    193 
    194   /**
    195   * @brief Plays and loops back a SoundSource
    196   */
    197   void SoundSource::loop()
    198   {
    199     if (this->buffer && this->retrieveSource())
    200     {
    201       if (this->bPlay)
    202         alSourceStop(this->sourceID);
    203 
     191 
     192   /**
     193   * @brief Plays back buffer on this Source with gain and looping possibility
     194   * @param buffer the buffer to play back on this Source
     195    */
     196  void SoundSource::play(const SoundBuffer* buffer, float gain, bool loop)
     197  {
     198    if (!this->retrieveSource())
     199    {
     200      PRINTF(3)("No more Free sources (You might consider raising the Source-Count).\n");
     201      return;
     202    }
     203
     204    alSourceStop(this->sourceID);
     205    alSourcei (this->sourceID, AL_BUFFER, buffer->getID());
     206   
     207    if (loop)
     208        alSourcei (this->sourceID, AL_LOOPING,  AL_TRUE);
     209    else
     210        alSourcei (this->sourceID, AL_LOOPING,  AL_FALSE);
     211   
     212    alSourcef (this->sourceID, AL_GAIN, gain);
     213
     214    alSourcePlay(this->sourceID);
     215
     216    if (unlikely(this->buffer != NULL))
    204217      alSourcei (this->sourceID, AL_BUFFER, this->buffer->getID());
    205       alSourcei (this->sourceID, AL_LOOPING,  AL_TRUE);
    206       alSourcef (this->sourceID, AL_GAIN, 1);
    207       alSourcePlay(this->sourceID);
    208 
    209       if (DEBUG_LEVEL >= 3)
    210         SoundEngine::checkError("Play Source", __LINE__);
    211       this->bPlay = true;
    212     }
    213   }
    214 
    215   /**
    216   * @brief Plays and loops buffer on this Source
    217   * @param buffer the buffer to play back on this Source
    218   */
    219   void SoundSource::loop(const SoundBuffer* buffer)
    220   {
    221     if (this->buffer && this->retrieveSource())
    222     {
    223       if (this->bPlay)
    224         alSourceStop(this->sourceID);
    225 
    226       alSourcei (this->sourceID, AL_BUFFER, this->buffer->getID());
    227       alSourcei (this->sourceID, AL_LOOPING,  AL_TRUE);
    228       alSourcef (this->sourceID, AL_GAIN, 1);
    229 
    230       alSourcePlay(this->sourceID);
    231 
    232       if (DEBUG_LEVEL >= 3)
    233         SoundEngine::checkError("Loop Source", __LINE__);
    234       this->bPlay = true;
    235     }
    236   }
    237 
    238 
    239   /**
    240   * @brief Plays and loops buffer on this Source with gain control
    241   * @param buffer the buffer to play back on this Source
    242   */
    243   void SoundSource::loop(const SoundBuffer* buffer, float gain)
    244   {
    245     if (this->buffer && this->retrieveSource())
    246     {
    247       if (this->bPlay)
    248         alSourceStop(this->sourceID);
    249 
    250       alSourcei (this->sourceID, AL_BUFFER, this->buffer->getID());
    251       alSourcei (this->sourceID, AL_LOOPING,  AL_TRUE);
    252       alSourcef (this->sourceID, AL_GAIN, gain);
    253 
    254       alSourcePlay(this->sourceID);
    255 
    256       if (DEBUG_LEVEL >= 3)
    257         SoundEngine::checkError("Loop Source", __LINE__);
    258       this->bPlay = true;
    259     }
    260   }
     218    this->bPlay = true;
     219
     220    if (DEBUG_LEVEL >= 3)
     221      SoundEngine::checkError("Play Source", __LINE__);
     222  }
    261223
    262224
     
    381343    }
    382344
    383     //  alSourcePlay(this->sourceID);
    384 
    385     //  if (DEBUG_LEVEL >= 3)
    386     //          SoundEngine::checkError("Loop Source", __LINE__);
    387     //  this->bPlay = true;
     345    //  alSourcePlay(this->sourceID);
     346
     347    //  if (DEBUG_LEVEL >= 3)
     348    //    SoundEngine::checkError("Loop Source", __LINE__);
     349    //  this->bPlay = true;
    388350    //}
    389351
  • trunk/src/lib/sound/sound_source.h

    r8255 r8495  
    3030                        void play(const SoundBuffer* buffer);
    3131                        void play(const SoundBuffer* buffer, float gain);
    32                         void loop();
    33                         void loop(const SoundBuffer* buffer);
    34                         void loop(const SoundBuffer* buffer, float gain);
     32      void play(const SoundBuffer* buffer, float gain, bool loop);   
     33
    3534                        void stop();
    3635                        void pause();
  • trunk/src/subprojects/benchmark.cc

    r5750 r8495  
    455455        }
    456456      printf("\n");
    457 
    458 
    459 
    460457    }
    461458
     459    return 0;
    462460}
    463461
  • trunk/src/util/kill_target.cc

    r7466 r8495  
    3131*/
    3232KillTarget::KillTarget (const TiXmlElement* root)
    33   : MissionGoal(root)
    34 {
    35   this->setClassID(CL_KILL_TARGET, "KillTarget");
     33        : MissionGoal(root) {
     34    this->setClassID(CL_KILL_TARGET, "KillTarget");
    3635
    37   if( root != NULL)
    38     this->loadParams(root);
     36    if( root != NULL)
     37        this->loadParams(root);
    3938}
    4039
     
    4342 * standard deconstructor
    4443*/
    45 KillTarget::~KillTarget ()
    46 {
    47 
     44KillTarget::~KillTarget () {
    4845}
    4946
    5047
    51 void KillTarget::loadParams(const TiXmlElement* root)
    52 {
    53   MissionGoal::loadParams(root);
     48void KillTarget::loadParams(const TiXmlElement* root) {
     49    MissionGoal::loadParams(root);
    5450
    55   LoadParam(root, "numberofkills", this, KillTarget, setNumberOfKills)
    56        .describe("sets the number of kills a target has to be killed");
    57   LoadParam(root, "targetclassid", this, KillTarget, setTargetClassID)
    58       .describe("sets the targets class id");
     51    LoadParam(root, "numberofkills", this, KillTarget, setNumberOfKills)
     52    .describe("sets the number of kills a target has to be killed");
     53    LoadParam(root, "targetclassid", this, KillTarget, setTargetClassID)
     54    .describe("sets the targets class id");
    5955}
    6056
    6157
    62 MissionState KillTarget::checkMissionGoal(float dt)
    63 {
     58MissionState KillTarget::checkMissionGoal(float dt) {}
    6459
    65 }
    66 
    67 
    68 
    69 
    70 
  • trunk/src/world_entities/effects/billboard.cc

    r8255 r8495  
    121121    return;
    122122
     123  glPushAttrib(GL_ENABLE_BIT);
     124  glDisable(GL_LIGHTING);
     125  glDisable(GL_FOG);
     126 
    123127  glPushMatrix();
    124128
     
    164168 
    165169  glPopMatrix();
     170 
     171  glPopAttrib();
    166172}
  • trunk/src/world_entities/space_ships/helicopter.cc

    r8408 r8495  
    107107  if (this->chopperBuffer != NULL)
    108108    ResourceManager::getInstance()->unload(this->chopperBuffer);
    109   this->chopperBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load("sound/chopper.wav", WAV);
     109  this->chopperBuffer = (OrxSound::SoundBuffer*)ResourceManager::getInstance()->load("sound/engine/chopper.wav", WAV);
    110110
    111111}
     
    219219  State::getCameraTargetNode()->setParentSoft(this->getWeaponManager().getFixedTarget());
    220220
    221   this->soundSource.loop(this->chopperBuffer, 0.8f);
    222   // PRINTF(0)( "Playing ChopperSound\n" );
     221  this->soundSource.play(this->chopperBuffer, 0.7f, true);
    223222}
    224223
Note: See TracChangeset for help on using the changeset viewer.