Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8916 in orxonox.OLD for branches


Ignore:
Timestamp:
Jun 29, 2006, 6:13:47 PM (18 years ago)
Author:
stefalie
Message:

mountain_lake: fader gui works, fading also (but its a bit hacky)

Location:
branches/mountain_lake/src/world_entities/environments
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/mountain_lake/src/world_entities/environments/mapped_water.cc

    r8906 r8916  
    181181
    182182/**
    183  * @brief initialization of the shaders
     183 * @brief calculates the 4 verts of the water quad
    184184 */
    185185void MappedWater::calcVerts()
     
    211211  this->shader->deactivateShader();
    212212}
    213 
    214 void MappedWater::resetWaterColorR(float r)
    215 {
    216   this->resetWaterColor(r, this->waterColor.y, this->waterColor.z);
    217 }
    218 
    219 
    220 void MappedWater::resetWaterColorG(float g)
    221 {
    222   this->resetWaterColor(this->waterColor.x, g, this->waterColor.z);
    223 }
    224 
    225 
    226 void MappedWater::resetWaterColorB(float b)
    227 {
    228   this->resetWaterColor(this->waterColor.x, this->waterColor.y, b);
    229 }
    230 
    231 
    232213
    233214/**
     
    330311}
    331312
    332 
     313/**
     314 * @brief starts the slider gui that lets you edit all water parameters
     315 */
    333316void MappedWater::openGui()
    334317{
     
    337320    this->box = new OrxGui::GLGuiBox(OrxGui::Vertical);
    338321    {
    339       OrxGui::GLGuiBox* colorBox = new OrxGui::GLGuiBox(OrxGui::Horizontal);
     322      OrxGui::GLGuiBox* waterColorBox = new OrxGui::GLGuiBox(OrxGui::Horizontal);
    340323      {
    341         OrxGui::GLGuiInputLine* ColorText = new OrxGui::GLGuiInputLine();
    342         ColorText->setText("Color");
    343         colorBox->pack(ColorText);
     324        OrxGui::GLGuiInputLine* waterColorText = new OrxGui::GLGuiInputLine();
     325        waterColorText->setText("Color");
     326        waterColorBox->pack(waterColorText);
    344327
    345328        OrxGui::GLGuiSlider* waterColorR = new OrxGui::GLGuiSlider();
    346         waterColorR->setRange(0, 1.0);
     329        waterColorR->setRange(0, 1.0f);
    347330        waterColorR->setValue(this->waterColor.x);
     331        waterColorR->setStep(0.1f);
    348332        waterColorR->connect(SIGNAL(waterColorR, valueChanged), this, SLOT(MappedWater, resetWaterColorR));
    349         colorBox->pack(waterColorR);
     333        waterColorBox->pack(waterColorR);
    350334
    351335        OrxGui::GLGuiSlider* waterColorG = new OrxGui::GLGuiSlider();
    352         waterColorG->setRange(0, 1.0);
     336        waterColorG->setRange(0, 1.0f);
     337        waterColorR->setStep(0.1f);
    353338        waterColorG->setValue(this->waterColor.y);
    354339        waterColorG->connect(SIGNAL(waterColorG, valueChanged), this, SLOT(MappedWater, resetWaterColorG));
    355         colorBox->pack(waterColorG);
     340        waterColorBox->pack(waterColorG);
    356341
    357342        OrxGui::GLGuiSlider* waterColorB = new OrxGui::GLGuiSlider();
    358         waterColorB->setRange(0, 1.0);
     343        waterColorB->setRange(0, 1.0f);
     344        waterColorR->setStep(0.1f);
    359345        waterColorB->setValue(this->waterColor.z);
    360346        waterColorB->connect(SIGNAL(waterColorB, valueChanged), this, SLOT(MappedWater, resetWaterColorB));
    361         colorBox->pack(waterColorB);
     347        waterColorBox->pack(waterColorB);
    362348
    363349      }
    364       this->box->pack(colorBox);
     350      this->box->pack(waterColorBox);
     351
     352      OrxGui::GLGuiBox* waterUVBox = new OrxGui::GLGuiBox(OrxGui::Horizontal);
     353      {
     354        OrxGui::GLGuiInputLine* waterUVText = new OrxGui::GLGuiInputLine();
     355        waterUVText->setText("WaterUV");
     356        waterUVBox->pack(waterUVText);
     357
     358        OrxGui::GLGuiSlider* waterUV = new OrxGui::GLGuiSlider();
     359        waterUV->setRange(1, 20);
     360        waterUV->setValue(this->waterUV);
     361        waterUV->setStep(1);
     362        waterUV->connect(SIGNAL(waterUV, valueChanged), this, SLOT(MappedWater, setWaterUV));
     363        waterUVBox->pack(waterUV);
     364      }
     365      this->box->pack(waterUVBox);
     366
     367      OrxGui::GLGuiBox* waterFlowBox = new OrxGui::GLGuiBox(OrxGui::Horizontal);
     368      {
     369        OrxGui::GLGuiInputLine* waterFlowText = new OrxGui::GLGuiInputLine();
     370        waterFlowText->setText("WaterFlow");
     371        waterFlowBox->pack(waterFlowText);
     372
     373        OrxGui::GLGuiSlider* waterFlow = new OrxGui::GLGuiSlider();
     374        waterFlow->setRange(0.01f, 2);
     375        waterFlow->setValue(this->waterFlow);
     376        waterFlow->setStep(0.02f);
     377        waterFlow->connect(SIGNAL(waterFlow, valueChanged), this, SLOT(MappedWater, setWaterFlow));
     378        waterFlowBox->pack(waterFlow);
     379      }
     380      this->box->pack(waterFlowBox);
     381
     382      OrxGui::GLGuiBox* shineSizeBox = new OrxGui::GLGuiBox(OrxGui::Horizontal);
     383      {
     384        OrxGui::GLGuiInputLine* shineSizeText = new OrxGui::GLGuiInputLine();
     385        shineSizeText->setText("ShineSize");
     386        shineSizeBox->pack(shineSizeText);
     387
     388        OrxGui::GLGuiSlider* shineSize = new OrxGui::GLGuiSlider();
     389        shineSize->setRange(1, 128);
     390        shineSize->setValue(this->shineSize);
     391        shineSize->setStep(1);
     392        shineSize->connect(SIGNAL(shineSize, valueChanged), this, SLOT(MappedWater, resetShineSize));
     393        shineSizeBox->pack(shineSize);
     394      }
     395      this->box->pack(shineSizeBox);
     396
     397      OrxGui::GLGuiBox* shineStrengthBox = new OrxGui::GLGuiBox(OrxGui::Horizontal);
     398      {
     399        OrxGui::GLGuiInputLine* shineStrengthText = new OrxGui::GLGuiInputLine();
     400        shineStrengthText->setText("ShineStrength");
     401        shineStrengthBox->pack(shineStrengthText);
     402
     403        OrxGui::GLGuiSlider* shineStrength = new OrxGui::GLGuiSlider();
     404        shineStrength->setRange(0, 1);
     405        shineStrength->setValue(this->shineStrength);
     406        shineStrength->setStep(0.1f);
     407        shineStrength->connect(SIGNAL(shineStrength, valueChanged), this, SLOT(MappedWater, resetShineStrength));
     408        shineStrengthBox->pack(shineStrength);
     409      }
     410      this->box->pack(shineStrengthBox);
     411
     412      OrxGui::GLGuiBox* reflStrengthBox = new OrxGui::GLGuiBox(OrxGui::Horizontal);
     413      {
     414        OrxGui::GLGuiInputLine* reflStrengthText = new OrxGui::GLGuiInputLine();
     415        reflStrengthText->setText("ReflStrength");
     416        reflStrengthBox->pack(reflStrengthText);
     417
     418        OrxGui::GLGuiSlider* reflStrength = new OrxGui::GLGuiSlider();
     419        reflStrength->setRange(0, 1);
     420        reflStrength->setValue(this->reflStrength);
     421        reflStrength->setStep(0.1f);
     422        reflStrength->connect(SIGNAL(reflStrength, valueChanged), this, SLOT(MappedWater, resetReflStrength));
     423        reflStrengthBox->pack(reflStrength);
     424      }
     425      this->box->pack(reflStrengthBox);
     426
     427      OrxGui::GLGuiBox* refractionBox = new OrxGui::GLGuiBox(OrxGui::Horizontal);
     428      {
     429        OrxGui::GLGuiInputLine* refractionText = new OrxGui::GLGuiInputLine();
     430        refractionText->setText("Refraction");
     431        refractionBox->pack(refractionText);
     432
     433        OrxGui::GLGuiSlider* refraction = new OrxGui::GLGuiSlider();
     434        refraction->setRange(0.001f, 0.1f);
     435        refraction->setValue(this->refraction);
     436        refraction->setStep(0.004f);
     437        refraction->connect(SIGNAL(refraction, valueChanged), this, SLOT(MappedWater, resetRefraction));
     438        refractionBox->pack(refraction);
     439      }
     440      this->box->pack(refractionBox);
    365441
    366442    }
     
    374450}
    375451
    376 
     452/**
     453 * @brief closes the water gui
     454 */
    377455void MappedWater::closeGui()
    378456{
    379457  delete this->box;
    380458  this->box = NULL;
    381 
    382 }
    383 
     459}
    384460
    385461/**
     
    450526
    451527  // fading
    452   if(this->shineSize != this->newShineSize)
    453   {
    454     if(bFadeShineSize)
    455     {
    456       this->shineSizeFader = new tAnimation<MappedWater>(this, &MappedWater::resetShineSize);
    457       this->shineSizeFader->setInfinity(ANIM_INF_CONSTANT);
    458 
    459       this->shineSizeFader->addKeyFrame(this->shineSize, this->shineSizeFadeTime, ANIM_LINEAR);
    460       this->shineSizeFader->addKeyFrame(this->newShineSize, 0, ANIM_LINEAR);
    461 
    462       bFadeShineSize = false;
    463       this->shineSizeFader->replay();
    464     }
    465   }
    466 
    467   if(this->tempcounter == 100)
    468   {
    469     PRINTF(0)("\n\n\n\n\n\n///////////////////////test waterchangecolor/////////////////////\n\n\n\n\n\n");
    470     this->fadeShineSize(1, 10);
    471   }
     528  if(bFadeWaterUV)
     529  {
     530    this->waterUVFader = new tAnimation<MappedWater>(this, &MappedWater::setWaterUV);
     531    this->waterUVFader->setInfinity(ANIM_INF_CONSTANT);
     532
     533    this->waterUVFader->addKeyFrame(this->waterUV, this->waterUVFadeTime, ANIM_LINEAR);
     534    this->waterUVFader->addKeyFrame(this->newWaterUV, 0, ANIM_LINEAR);
     535
     536    bFadeWaterUV = false;
     537    this->waterUVFader->replay();
     538  }
     539
     540  if(bFadeWaterFlow)
     541  {
     542    this->waterFlowFader = new tAnimation<MappedWater>(this, &MappedWater::setWaterFlow);
     543    this->waterFlowFader->setInfinity(ANIM_INF_CONSTANT);
     544
     545    this->waterFlowFader->addKeyFrame(this->waterFlow, this->waterFlowFadeTime, ANIM_LINEAR);
     546    this->waterFlowFader->addKeyFrame(this->newWaterFlow, 0, ANIM_LINEAR);
     547
     548    bFadeWaterFlow = false;
     549    this->waterFlowFader->replay();
     550  }
     551
     552  if(bFadeShineSize)
     553  {
     554    this->shineSizeFader = new tAnimation<MappedWater>(this, &MappedWater::resetShineSize);
     555    this->shineSizeFader->setInfinity(ANIM_INF_CONSTANT);
     556
     557    this->shineSizeFader->addKeyFrame(this->shineSize, this->shineSizeFadeTime, ANIM_LINEAR);
     558    this->shineSizeFader->addKeyFrame(this->newShineSize, 0, ANIM_LINEAR);
     559
     560    bFadeShineSize = false;
     561    this->shineSizeFader->replay();
     562  }
     563
     564  if(bFadeShineStrength)
     565  {
     566    this->shineStrengthFader = new tAnimation<MappedWater>(this, &MappedWater::resetShineStrength);
     567    this->shineStrengthFader->setInfinity(ANIM_INF_CONSTANT);
     568
     569    this->shineStrengthFader->addKeyFrame(this->shineStrength, this->shineStrengthFadeTime, ANIM_LINEAR);
     570    this->shineStrengthFader->addKeyFrame(this->newShineStrength, 0, ANIM_LINEAR);
     571
     572    bFadeShineStrength = false;
     573    this->shineStrengthFader->replay();
     574  }
     575
     576  if(bFadeReflStrength)
     577  {
     578    this->reflStrengthFader = new tAnimation<MappedWater>(this, &MappedWater::resetReflStrength);
     579    this->reflStrengthFader->setInfinity(ANIM_INF_CONSTANT);
     580
     581    this->reflStrengthFader->addKeyFrame(this->reflStrength, this->reflStrengthFadeTime, ANIM_LINEAR);
     582    this->reflStrengthFader->addKeyFrame(this->newReflStrength, 0, ANIM_LINEAR);
     583
     584    bFadeReflStrength = false;
     585    this->reflStrengthFader->replay();
     586  }
     587
     588  if(bFadeRefraction)
     589  {
     590    this->refractionFader = new tAnimation<MappedWater>(this, &MappedWater::resetRefraction);
     591    this->refractionFader->setInfinity(ANIM_INF_CONSTANT);
     592
     593    this->refractionFader->addKeyFrame(this->refraction, this->refractionFadeTime, ANIM_LINEAR);
     594    this->refractionFader->addKeyFrame(this->newRefraction, 0, ANIM_LINEAR);
     595
     596    bFadeRefraction = false;
     597    this->refractionFader->replay();
     598  }
     599
     600
     601//   if(this->tempcounter == 300)
     602//   {
     603//     PRINTF(0)("\n\n\n\n\n\n///////////////////////test waterchangecolor/////////////////////\n\n\n\n\n\n");
     604//     this->fadeWaterUV(1, 10);
     605//   }
     606//   if(this->tempcounter == 100)
     607//   {
     608//     PRINTF(0)("\n\n\n\n\n\n///////////////////////test waterchangecolor/////////////////////\n\n\n\n\n\n");
     609//     this->fadeWaterFlow(1, 10);
     610//   }
    472611  //PRINTF(0)("counter %i/n", tempcounter);
    473612  tempcounter++;
  • branches/mountain_lake/src/world_entities/environments/mapped_water.h

    r8906 r8916  
    1 /*!
     1 /*!
    22 * @file mapped_water.h
    33 *  worldentity for flat, cool looking, mapped water
     
    6262  void setWaterAngle(float angle) { this->waterAngle = angle; }
    6363  void setWaterColor(float r, float g, float b) { this->waterColor = Vector(r,g,b); }
    64   void setWaterUV(float uv) { this->waterUV = uv; }
    65   void setWaterFlow(float flow) { this->waterFlow = flow; };
     64  void setWaterUV(float uv) { this->waterUV = uv; this->bFadeWaterUV = false; }
     65  void setWaterFlow(float flow) { this->waterFlow = flow; this->bFadeWaterFlow = false; }
    6666  void setNormalMapScale(float scale) { this->kNormalMapScale = scale; }
    67   void setShineSize(float shine) { this->shineSize = shine; this->newShineSize = shine; }
    68   void setShineStrength(float strength) { this->shineStrength = strength; }
    69   void setReflStrength(float strength) { this->reflStrength = strength; }
    70   void setRefraction(float refraction) { this->refraction = refraction; }
     67  void setShineSize(float shine) { this->shineSize = shine; this->bFadeShineSize = false; }
     68  void setShineStrength(float strength) { this->shineStrength = strength; this->bFadeShineStrength = false; }
     69  void setReflStrength(float strength) { this->reflStrength = strength; this->bFadeReflStrength = false; }
     70  void setRefraction(float refraction) { this->refraction = refraction; this->bFadeRefraction = false;}
    7171
    7272  // functions to change water parameters during runtime
     
    7878  void resetWaterAngle(float angle) { this->setWaterAngle(angle); this->calcVerts(); }
    7979  void resetWaterColor(float r, float g, float b);
    80   void resetWaterColorR(float r);
    81   void resetWaterColorG(float g);
    82   void resetWaterColorB(float b);
     80  void resetWaterColorR(float r) { this->resetWaterColor(r, this->waterColor.y, this->waterColor.z); }
     81  void resetWaterColorG(float g) { this->resetWaterColor(this->waterColor.x, g, this->waterColor.z); }
     82  void resetWaterColorB(float b) { this->resetWaterColor(this->waterColor.x, this->waterColor.y, b); }
    8383  void resetShineSize(float shine);
    8484  void resetShineStrength(float strength);
     
    8686  void resetRefraction(float refraction);
    8787
    88   // fade functions, hacky HACK
    89   void fadeWaterColor(float r, float g, float b, float time) {  }
    90   void fadeShineSize(float shine, float time) {this->newShineSize = shine; this->shineSizeFadeTime = time; }
    91   void fadeLightPos(float x, float y, float z, float time);
     88  // fading functions
     89  void fadeWaterUV(float uv, float time) { this->newWaterUV = uv; this->waterUVFadeTime = time; this->bFadeWaterUV = true; }
     90  void fadeWaterFlow(float flow, float time) { this->newWaterFlow = flow; this->waterFlowFadeTime = time; this->bFadeWaterFlow = true; }
     91  void fadeShineSize(float shine, float time) { this->newShineSize = shine; this->shineSizeFadeTime = time; this->bFadeShineSize = true; }
     92  void fadeShineStrength(float strength, float time) { this->newShineStrength = strength; this->shineStrengthFadeTime = time; this->bFadeShineStrength = true; }
     93  void fadeReflStrength(float strength, float time) { this->newReflStrength = strength; this->reflStrengthFadeTime = time; this->bFadeReflStrength = true; }
     94  void fadeRefraction(float refraction, float time) { this->newRefraction = refraction; this->refractionFadeTime = time; this->bFadeRefraction = true; }
    9295
    9396private:
     
    134137
    135138  // fading
     139  tAnimation<MappedWater>*      waterUVFader;
     140  float                         newWaterUV;
     141  float                         waterUVFadeTime;
     142  bool                          bFadeWaterUV ;
     143  tAnimation<MappedWater>*      waterFlowFader;
     144  float                         newWaterFlow;
     145  float                         waterFlowFadeTime;
     146  bool                          bFadeWaterFlow;
    136147  tAnimation<MappedWater>*      shineSizeFader;
    137148  float                         newShineSize;
    138149  float                         shineSizeFadeTime;
    139150  bool                          bFadeShineSize;
     151  tAnimation<MappedWater>*      shineStrengthFader;
     152  float                         newShineStrength;
     153  float                         shineStrengthFadeTime;
     154  bool                          bFadeShineStrength;
     155  tAnimation<MappedWater>*      reflStrengthFader;
     156  float                         newReflStrength;
     157  float                         reflStrengthFadeTime;
     158  bool                          bFadeReflStrength;
     159  tAnimation<MappedWater>*      refractionFader;
     160  float                         newRefraction;
     161  float                         refractionFadeTime;
     162  bool                          bFadeRefraction;
    140163
    141164  OrxGui::GLGuiBox*             box;
Note: See TracChangeset for help on using the changeset viewer.