Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Jun 21, 2006, 9:00:01 AM (18 years ago)
Author:
hdavid
Message:

branches/atmospheric_engine: cloud animation works :)

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

Legend:

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

    r8636 r8663  
    2222
    2323#include "material.h"
    24 #include <math.h>
    2524#include "state.h"
    2625#include "p_node.h"
     
    4140{
    4241  this->setClassID(CL_CLOUD_EFFECT, "CloudEffect");
    43   //  this->toList(OM_ENVIRON);
    4442
    4543  this->init();
     
    4846    this->loadParams(root);
    4947
    50   //if(cloudActivate)
    51   this->activate();
     48  if(cloudActivate)
     49    this->activate();
    5250}
    5351
     
    6159{
    6260  PRINTF(0)("Initializing CloudEffect\n");
     61 
     62  this->offsetZ = 0;
     63  this->animationSpeed = 2;
    6364
    6465  noise3DTexSize = 64;
     
    7980               noise3DTexSize, noise3DTexSize, noise3DTexSize,
    8081               0, GL_RGBA, GL_UNSIGNED_BYTE, noise3DTexPtr);
    81 
    82 
    83   //cloudMaterial.setDiffuseMap("pictures/sky/cloud1.jpg", GL_TEXTURE_2D, 0);
    84 
    85   coor = 0;
    8682 
    8783  shader = new Shader(ResourceManager::getInstance()->getDataDir() + "/shaders/cloud.vert",
     
    106102  WeatherEffect::loadParams(root);
    107103
    108   // LoadParam(root, "speed", this, CloudEffect, setCloudAnimation);
    109   // LoadParam(root, "texture", this, CloudEffect, setCloudTexture);
    110   /*
     104  LoadParam(root, "speed", this, CloudEffect, setAnimationSpeed);
     105 
    111106  LOAD_PARAM_START_CYCLE(root, element);
    112107  {
    113   LoadParam_CYCLE(element, "option", this, CloudEffect, setCloudOption);
    114   }
    115   LOAD_PARAM_END_CYCLE(element);*/
     108    LoadParam_CYCLE(element, "option", this, CloudEffect, setCloudOption);
     109  }
     110  LOAD_PARAM_END_CYCLE(element);
    116111}
    117112
     
    121116  PRINTF(0)( "Activating\n");
    122117
    123   //  this->cloudActivate = true;
     118  this->cloudActivate = true;
    124119}
    125120
     
    128123  PRINTF(0)("Deactivating CloudEffect\n");
    129124
    130   //  this->cloudActivate = false;
     125  this->cloudActivate = false;
    131126}
    132127
    133128void CloudEffect::draw() const
    134129{
    135   //if (!this->cloudActivate)
    136   //  return;
     130  if (!this->cloudActivate)
     131    return;
     132 
    137133  glPushAttrib(GL_ENABLE_BIT);
    138134
     
    143139  glBindTexture(GL_TEXTURE_3D, noise3DTexName);
    144140
    145 
    146   //this->shader->activateShader();
    147 
    148   //glMatrixMode(GL_MODELVIEW);
    149   //glColor4f(1,1,1,1);
    150141  glPushMatrix();
    151   //glTranslatef(0,this->waterHeight,0);
    152 
    153   //cloudMaterial.unselect();
    154   //cloudMaterial.select();
    155142
    156143  this->shader->activateShader();
    157   //PRINTF(0)("coor: %f\n", coor);
    158   offset->set(coor, coor, coor);
    159 
    160   //glutSolidTeapot(1);
     144  offset->set(0.0f, 0.0f, offsetZ);
    161145
    162146
     
    173157  this->shader->deactivateShader();
    174158
    175   //cloudMaterial.unselect();
    176 
    177159  glPopMatrix();
    178 
    179160  glPopAttrib();
    180161
     
    183164void CloudEffect::tick (float dt)
    184165{
    185   //if (!this->cloudActivate)
    186   //  return;
    187   coor += 10;
     166  if (!this->cloudActivate)
     167    return;
     168  this->offsetZ += 0.05 * dt * this->animationSpeed;
    188169}
    189170
  • branches/atmospheric_engine/src/lib/graphics/effects/cloud_effect.h

    r8636 r8663  
    5252    this->deactivate();
    5353  }
     54  inline void setCloudOption(const std::string& option)
     55  {
     56    if (option == "activate")
     57      this->cloudActivate = true;
     58  }
     59  inline void setAnimationSpeed(float speed)
     60  {
     61    this->animationSpeed = speed;
     62  }
    5463
    5564  virtual void draw() const;
     
    6372  void normalize3(double v[3]);
    6473
    65   /*inline void setCloudOption(const std::string& option) {
    66       if (option == "activate")
    67   this->cloudActivate = true;
    68   }*/
     74private:
    6975
    70 
    71 private:
    72   //void initialize(char* fileName);
    73 
    74   //bool        cloudActivate;
     76  bool        cloudActivate;
     77  float       animationSpeed;
    7578
    7679  // Material                 cloudMaterial;
    7780  Shader*                 shader;
    7881  Shader::Uniform*        offset;
    79  
    80   float coor;
     82
     83  float offsetZ;
    8184
    8285  int noise3DTexSize;
Note: See TracChangeset for help on using the changeset viewer.