Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7628 in orxonox.OLD


Ignore:
Timestamp:
May 16, 2006, 11:41:25 AM (18 years ago)
Author:
amaechler
Message:

branches/atmospheric_engine: Basic RainEffect working

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

Legend:

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

    r7523 r7628  
    7171bool FogEffect::activate()
    7272{
    73   PRINTF(0)( "Enabling Fog Effect, mode: %i, density: %f, start: %f, end: %f, color %f, %f, %f\n", this->fogMode, this->fogDensity, this->fogStart, this->fogEnd, this->colorVector.x, this->colorVector.y, this->colorVector.z);
     73  PRINTF(0)( "Enabling FogEffect, mode: %i, density: %f, start: %f, end: %f, color %f, %f, %f\n", this->fogMode, this->fogDensity, this->fogStart, this->fogEnd, this->colorVector.x, this->colorVector.y, this->colorVector.z);
    7474
    7575  glEnable(GL_FOG);
     
    9393bool FogEffect::deactivate()
    9494{
    95   PRINTF(0)("Deactivating Fog Effect\n");
     95  PRINTF(0)("Deactivating FogEffect\n");
    9696        glDisable(GL_FOG);
    9797}
  • branches/atmospheric_engine/src/lib/graphics/effects/rain_effect.cc

    r7577 r7628  
    1919
    2020#include "glincl.h"
     21#include "debug.h"
    2122
    22 // *****
    23 
    24 #include "material.h"
    2523#include "state.h"
    26 #include "shell_command.h"
     24#include "spark_particles.h"
     25#include "plane_emitter.h"
    2726
    2827#include "parser/tinyxml/tinyxml.h"
    29 #include <algorithm>
    30 #include "box_emitter.h"
    31 #include "spark_particles.h"
    3228
     29//SHELL_COMMAND(activate, RainEffect, activateRain);
     30//SHELL_COMMAND(deactivate, RainEffect, deactivateRain);
    3331
    3432using namespace std;
     
    4038  this->setClassID(CL_RAIN_EFFECT, "RainEffect");
    4139
    42   // BoxEmitter::BoxEmitter(const Vector& size, float emissionRate, float velocity, float angle)
    43 
    44 //         <name>RainEmitter</name>
    45 //         <rel-coor>-1200, 300, 0</rel-coor>
    46 //         <rel-dir>3.1412, 0, 0, 1</rel-dir>
    47 //         <spread>0,.3</spread>
    48 //         <emission-velocity>500,50</emission-velocity>
    49 //         <size>1000, 1000</size>
    50 //         <rate>5000</rate>
    51 
    52   this->emitter = new BoxEmitter(Vector(1000, 300, 100), 20000, 1000, M_2_PI);
    53   this->emitter->setRelCoor(100, 0, 0);
    54   // this->emitter->setParent(this);
    55   this->emitter->setSpread(0, 0.3);
    56 
    5740  if (root != NULL)
    5841    this->loadParams(root);
     42
     43  this->init();
    5944
    6045  this->activate();
     
    6651}
    6752
    68 
    6953void RainEffect::loadParams(const TiXmlElement* root)
    7054{
    71   WeatherEffect::loadParams(root);
     55        WeatherEffect::loadParams(root);
    7256
    73 //   LoadParam(root, "rel-coor", this, RainEffect, setRainMode);
    74 //
    75 //   LoadParam(root, "rate", this, RainEffect, setRainColor);
    76 //   LoadParam(root, "velocity", this, RainEffect, setRainColor);
    77 //   LoadParam(root, "angle", this, RainEffect, setRainColor);
    78 //
    79 //   LoadParam(root, "spread", this, RainEffect, setRainColor);
    80 
    81   // BoxEmitter::BoxEmitter(const Vector& size, float emissionRate, float velocity, float angle)
    82 
    83   this->emitter = new BoxEmitter(Vector(0, 1000, 0), 20000, 4000, 1);
    84   this->emitter->setRelCoor(0, 100, 0);
    85   // this->emitter->setParent(this);
    86   this->emitter->setSpread(0, 0.3);
    87 
    88 // LOAD_PARAM_START_CYCLE(root, element);
    89 //   {
    90 //     element->ToText();
    91 //     // PER-PARTICLE-ATTRIBUTES:
    92 //     LoadParam_CYCLE(element, "radius", this, ParticleSystem, setRadius)
    93 //     .describe("The Radius of each particle over time (TimeIndex [0-1], radius at TimeIndex, randomRadius at TimeIndex)");
    94 //
    95 //     LoadParam_CYCLE(element, "mass", this, ParticleSystem, setMass)
    96 //     .describe("The Mass of each particle over time (TimeIndex: [0-1], mass at TimeIndex, randomMass at TimeIndex)");
    97 //
    98 //     LoadParam_CYCLE(element, "color", this, ParticleSystem, setColor)
    99 //     .describe("The Color of each particle over time (TimeIndex: [0-1], red: [0-1], green: [0-1], blue: [0-1], alpha: [0-1])");
    100 //   }
    101 //   LOAD_PARAM_END_CYCLE(element);
    102 
     57        LoadParam(root, "coord", this, RainEffect, setRainCoord);
     58        LoadParam(root, "size", this, RainEffect, setRainSize);
     59        LoadParam(root, "rate", this, RainEffect, setRainRate);
     60        LoadParam(root, "velocity", this, RainEffect, setRainVelocity);
    10361}
    10462
     63
    10564bool RainEffect::init()
    106 {}
     65{
     66  this->emitter = new PlaneEmitter(this->rainSize);
     67}
     68
    10769
    10870SparkParticles* RainEffect::rainParticles = NULL;
     
    11072bool RainEffect::activate()
    11173{
    112 //   PRINTF(0)( "Enabling Rain Effect, mode: %i, density: %f, start: %f, end: %f, color %f, %f, %f\n", this->rainMode, this->rainDensity, this->rainStart, this->rainEnd, this->colorVector.x, this->colorVector.y, this->colorVector.z);
    113         PRINTF(0)("Activating Rain Effect\n");
     74        PRINTF(0)( "Activating RainEffect, coord: %f, %f, %f, size: %f, %f, rate: %f, velocity: %f\n", this->rainCoord.x, this->rainCoord.y, this->rainCoord.z, this->rainSize.x, this-> rainSize.y, this->rainRate, this->rainVelocity );
    11475
    11576        if (unlikely(RainEffect::rainParticles == NULL))
     
    12586                RainEffect::rainParticles->setColor(0.8, 0.8, 0.2, 0.3, 0.3);
    12687                RainEffect::rainParticles->setColor(1, 0.5, 0.5, 1, 0);
    127 
    128 //      <life-span>2,2</life-span>
    129 //      <radius>0, 0.05, 0.05</radius>
    130 //      <radius>1, 0.05, 0.05</radius>
    131 //      <mass>0,1, .05</mass>
    132 //      <color>0, 0, 0, 1, .3</color>
    133 //      <color>.5, .5, .5, 1, .2</color>
    134 //      <color>1,0.5, .5,1, .0</color>
    135 //      <precache>2</precache>
    136 //      <emitters>
    137 //       <PlaneEmitter>
    138 
    139 //       </PlaneEmitter>
    140 //      </emitters>
    141 
    14288        }
    14389
    14490        this->emitter->setSystem(RainEffect::rainParticles);
    145 //      this->size = 4.0;
    14691
    14792        RainEffect::rainParticles->debug();
    148 //      this->updateNode(0);
    149         this->emitter->setEmissionRate(5000.0);
    150         this->emitter->setEmissionVelocity(50.0);
    15193
    152 //      this->setHealth(200);
     94        this->emitter->setRelCoor(this->rainCoord);
    15395
     96        this->emitter->setEmissionRate(this->rainRate);
     97        this->emitter->setEmissionVelocity(-this->rainVelocity);
     98
     99        this->emitter->setSpread(0, .3);
    154100}
    155101
     
    157103bool RainEffect::deactivate()
    158104{
    159   PRINTF(0)("Deactivating Rain Effect\n");
     105  PRINTF(0)("Deactivating RainEffect\n");
    160106
    161107  this->emitter->setSystem(NULL);
    162  // this->lifeCycle = 0.0;
    163  // this->toList(OM_NULL);
    164 
    165 //  GarbageCollector::getInstance()->collect(this);
    166 //  this->toList(OM_DEAD);
    167 
    168108}
    169 
    170 void RainEffect::draw() const
    171 {
    172 //  Particle* drawPart = ParticleSystem::particles;
    173 
    174 //   glDepthMask(GL_FALSE);
    175 //   glPushAttrib(GL_ENABLE_BIT);
    176 //
    177 //   glDisable(GL_LIGHTING);
    178 //   glDisable(GL_TEXTURE_2D);
    179 //
    180 //   glEnable(GL_LINE_SMOOTH);
    181 //   glEnable(GL_BLEND);
    182 //   glBlendFunc(GL_SRC_ALPHA, GL_DST_ALPHA);
    183 //
    184 //   glLineWidth(2.0);
    185 //   glBegin(GL_LINES);
    186 //   while (likely(drawPart != NULL))
    187 //   {
    188 //   //    printf("%f %f %f %f\n", drawPart->color[0], drawPart->color[1], drawPart->color[2], drawPart->color[3]);
    189 //     glColor4fv(drawPart->color);
    190 //     glVertex3f(drawPart->position.x,  drawPart->position.y,  drawPart->position.z);
    191 //     glVertex3f(drawPart->position.x - drawPart->velocity.x * drawPart->radius,
    192 //                drawPart->position.y - drawPart->velocity.y * drawPart->radius,
    193 //                drawPart->position.z - drawPart->velocity.z * drawPart->radius);
    194 //     drawPart = drawPart->next;
    195 //   }
    196 //   glEnd();
    197 //
    198 //   glDepthMask(GL_TRUE);
    199 //   glPopAttrib();
    200 }
  • branches/atmospheric_engine/src/lib/graphics/effects/rain_effect.h

    r7577 r7628  
    77
    88#include "vector.h"
     9#include "vector2D.h"
     10
    911#include "particle_system.h"
    10 //#include "material.h"
    1112
    1213class SparkParticles;
    13 class ParticleEmitter;
     14class PlainEmitter;
    1415
    1516#include "weather_effect.h"
     
    2930    virtual bool deactivate();
    3031
    31     virtual void draw() const;
    32 
    33 //     inline void setRainMode(const std::string& mode) { this->rainMode = this->stringToRainMode(mode); }
    34 //     inline void setRainDensity(float density) { this->rainDensity = density; }
    35 //     inline void setRainRange(float start, float end) { this->rainStart = start; this->rainEnd = end; }
    36 //     inline void setRainColor(float r, float g, float b) { this->colorVector = Vector(r, g, b); }
     32    inline void setRainCoord(float x, float y, float z) { this->rainCoord = Vector(x, y, z); }
     33    inline void setRainSize(float x, float y) { this->rainSize = Vector2D(x, y); }
     34    inline void setRainRate(float rate) { this->rainRate = rate;}
     35    inline void setRainVelocity(float velocity) { this->rainVelocity = velocity; }
    3736
    3837  private:
     
    4039    ParticleEmitter*                  emitter;
    4140
    42 //     GLfloat                 rainDensity;
    43 //     GLfloat                 rainStart;
    44 //     GLfloat                 rainEnd;
    45 //     Vector                  colorVector;
     41    Vector                            rainCoord;
     42    Vector2D                          rainSize;
     43    GLfloat                           rainRate;
     44    GLfloat                           rainVelocity;
    4645};
    4746
  • branches/atmospheric_engine/src/lib/graphics/effects/snow_effect.cc

    r7576 r7628  
    4141
    4242  this->init();
    43  
     43
    4444  this->activate();
    4545}
     
    7373bool SnowEffect::activate()
    7474{
    75   PRINTF(0)("Activating Snow Effect\n");
     75  PRINTF(0)("Activating SnowEffect\n");
    7676 
    7777  SnowEffect::snowParticles = new SpriteParticles(10000);
     
    101101bool SnowEffect::deactivate()
    102102{
    103   PRINTF(0)("Deactivating Snow Effect\n");
     103  PRINTF(0)("Deactivating SnowEffect\n");
    104104 
    105105  this->emitter->setSystem(NULL);
Note: See TracChangeset for help on using the changeset viewer.