Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6768 in orxonox.OLD


Ignore:
Timestamp:
Jan 26, 2006, 1:13:10 PM (18 years ago)
Author:
patrick
Message:

network: the fog effect working and loadable

Location:
branches/network/src/lib/graphics/effects
Files:
4 edited

Legend:

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

    r6752 r6768  
    2222#include "factory.h"
    2323
     24#include "glincl.h"
     25
     26
    2427
    2528using namespace std;
    2629
    27 CREATE_FACTORY(FogEffect, CL_LIGHT);
     30CREATE_FACTORY(FogEffect, CL_FOG_EFFECT);
    2831
    2932
     
    3538 FogEffect::FogEffect(const TiXmlElement* root)
    3639{
     40
     41  this->fogMode = GL_EXP2;
     42  this->fogDensity = 0.001f;
     43  this->fogStart = 10.0f;
     44  this->fogEnd = 1000.0f;
     45
    3746
    3847  if (root != NULL)
     
    5564  GraphicsEffect::loadParams(root);
    5665
    57 //   LoadParam(root, "diffuse-color", this, FogEffect, setDiffuseColor)
    58 //       .describe("sets the diffuse color of the FogEffect (red [0-1], green [0-1], blue [0-1])");
     66   LoadParam(root, "fog-effect", this, FogEffect, setFogMode)
     67       .describe("sets the the fog mode {GL_LINEAR, GL_EXP, GL_EXP2}");
     68
     69   LoadParam(root, "fog-density", this, FogEffect, setFogDensity)
     70       .describe("sets the the fog density of the exponentionl functions");
     71
     72   LoadParam(root, "fog-range", this, FogEffect, setFogRange)
     73       .describe("sets the the range of the linear functions");
    5974}
    6075
     
    7287bool FogEffect::activate()
    7388{
    74 /*  glEnable(GL_FOG);
     89  PRINTF(4)( "Enabling Fog Effect, mode: %i, density: %f, start: %f, end: %f\n", this->fogMode, this->fogDensity,
     90             this->fogStart, this->fogEnd);
     91
     92  glEnable(GL_FOG);
    7593  {
    76     GLfloat fogColor[4] = {0.5, 0.5, 1.0};
     94    GLfloat fogColor[4] = {0.5, 0.5, 0.5, 1.0};
    7795
    78     GLint fogMode = GL_EXP;
    79     glFogi(GL_FOG_MODE, fogMode);
     96    glFogi(GL_FOG_MODE, this->fogMode);
    8097    glFogfv(GL_FOG_COLOR, fogColor);
    81     gfFogf(GL_FOG_DENSITY, 0.35f);
     98    glFogf(GL_FOG_DENSITY, this->fogDensity);
     99    glHint(GL_FOG_HINT, GL_DONT_CARE);
     100    glFogf(GL_FOG_START, this->fogStart);
     101    glFogf(GL_FOG_END, this->fogEnd);
    82102
    83 
    84   }*/
     103    //glFogi(GL_FOG_COORDINATE_SOURCE, GL_FOG_COORDINATE);
     104  }
     105  glClearColor(0.5, 0.5, 0.5, 1.0);
    85106}
    86107
     
    90111 */
    91112bool FogEffect::deactivate()
    92 {}
     113{
     114  glDisable(GL_FOG);
     115}
     116
     117
     118/**
     119 * converts a gl mode char to a GLint
     120 * @param mode the mode character
     121 */
     122GLint FogEffect::charToFogMode(const char* mode)
     123{
     124  if( !strcmp( "GL_LINEAR", mode))
     125    return GL_LINEAR;
     126  else if( !strcmp("GL_EXP", mode))
     127    return GL_EXP;
     128  else if(!strcmp("GL_EXP2", mode) )
     129    return GL_EXP2;
     130  else
     131    return -1;
     132}
     133
  • branches/network/src/lib/graphics/effects/fog_effect.h

    r6741 r6768  
    2424    virtual bool activate();
    2525    virtual bool deactivate();
     26
     27    void setFogMode(const char* mode) { this->fogMode = this->charToFogMode(mode); }
     28    void setFogDensity(float density) { this->fogDensity = density; }
     29    void setFogRange(float start, float end) { this->fogStart = start; this->fogEnd = end; }
     30
     31
     32  private:
     33    GLint charToFogMode(const char* mode);
     34
     35
     36  private:
     37    GLint                   fogMode;
     38    GLfloat                 fogDensity;
     39    GLfloat                 fogStart;
     40    GLfloat                 fogEnd;
    2641};
    2742
  • branches/network/src/lib/graphics/effects/graphics_effect.cc

    r6741 r6768  
    1313### File Specific:
    1414   main-programmer: Patrick Boenzli
    15    co-programmer: ...
    1615*/
    1716
     
    2120#include "graphics_effect.h"
    2221
     22#include "graphics_engine.h"
    2323#include "load_param.h"
    2424
     
    3535GraphicsEffect::GraphicsEffect(const TiXmlElement* root)
    3636{
     37  this->bActivated = false;
     38
     39  this->bActivated = GraphicsEngine::getInstance()->loadGraphicsEffect(this);
    3740
    3841  if (root != NULL)
     
    4548 */
    4649GraphicsEffect::~GraphicsEffect()
    47 {}
     50{
     51  if( this->bActivated)
     52    GraphicsEngine::getInstance()->unloadGraphicsEffect(this);
     53}
    4854
    4955
  • branches/network/src/lib/graphics/effects/graphics_effect.h

    r6741 r6768  
    2424    virtual bool activate() = 0;
    2525    virtual bool deactivate() = 0;
     26
     27    inline bool isActivated() { return this->bActivated; }
     28
     29
     30  protected:
     31    bool              bActivated;
    2632};
    2733
Note: See TracChangeset for help on using the changeset viewer.