Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 8918 in orxonox.OLD for branches


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

mountain_lake: waterHeight fading works

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

    r8916 r8918  
    2121#include "t_animation.h"
    2222#include "math.h"
    23 
    2423#include "glgui.h"
    25 
    26 
    2724#include "shell_command.h"
    2825
     
    5653  this->calcVerts();
    5754
    58   tempcounter = 0;
     55  // init gui
    5956  this->box = NULL;
    6057}
     
    10097  this->move = 0;
    10198  this->move2 = this->move * this->kNormalMapScale;
     99
     100  // initalize fading bools
     101  this->bFadeWaterHeight = false;
     102  this->bFadeWaterUV = false;
     103  this->bFadeWaterFlow = false;
     104  this->bFadeShineSize = false;
     105  this->bFadeShineStrength = false;
     106  this->bFadeReflStrength = false;
     107  this->bFadeRefraction = false;
     108
     109  this->tempcounter = 0;
    102110}
    103111
     
    323331      {
    324332        OrxGui::GLGuiInputLine* waterColorText = new OrxGui::GLGuiInputLine();
    325         waterColorText->setText("Color");
     333        waterColorText->setText("WaterColor");
    326334        waterColorBox->pack(waterColorText);
    327335
     
    335343        OrxGui::GLGuiSlider* waterColorG = new OrxGui::GLGuiSlider();
    336344        waterColorG->setRange(0, 1.0f);
    337         waterColorR->setStep(0.1f);
     345        waterColorG->setStep(0.1f);
    338346        waterColorG->setValue(this->waterColor.y);
    339347        waterColorG->connect(SIGNAL(waterColorG, valueChanged), this, SLOT(MappedWater, resetWaterColorG));
     
    342350        OrxGui::GLGuiSlider* waterColorB = new OrxGui::GLGuiSlider();
    343351        waterColorB->setRange(0, 1.0f);
    344         waterColorR->setStep(0.1f);
     352        waterColorB->setStep(0.1f);
    345353        waterColorB->setValue(this->waterColor.z);
    346354        waterColorB->connect(SIGNAL(waterColorB, valueChanged), this, SLOT(MappedWater, resetWaterColorB));
    347355        waterColorBox->pack(waterColorB);
    348 
    349356      }
    350357      this->box->pack(waterColorBox);
     
    440447      this->box->pack(refractionBox);
    441448
     449      OrxGui::GLGuiBox* lightPosBox = new OrxGui::GLGuiBox(OrxGui::Horizontal);
     450      {
     451        OrxGui::GLGuiInputLine* lightPosText = new OrxGui::GLGuiInputLine();
     452        lightPosText->setText("LightPos");
     453        lightPosBox->pack(lightPosText);
     454
     455        OrxGui::GLGuiSlider* lightPosX = new OrxGui::GLGuiSlider();
     456        lightPosX->setRange(-600, 600);
     457        lightPosX->setValue(this->lightPos.x);
     458        lightPosX->setStep(15);
     459        lightPosX->connect(SIGNAL(lightPosX, valueChanged), this, SLOT(MappedWater, resetLightPosX));
     460        lightPosBox->pack(lightPosX);
     461
     462        OrxGui::GLGuiSlider* lightPosY = new OrxGui::GLGuiSlider();
     463        lightPosY->setRange(-600, 600);
     464        lightPosY->setStep(15);
     465        lightPosY->setValue(this->lightPos.y);
     466        lightPosY->connect(SIGNAL(lightPosY, valueChanged), this, SLOT(MappedWater, resetLightPosY));
     467        lightPosBox->pack(lightPosY);
     468
     469        OrxGui::GLGuiSlider* lightPosZ = new OrxGui::GLGuiSlider();
     470        lightPosZ->setRange(-600, 600);
     471        lightPosZ->setStep(15);
     472        lightPosZ->setValue(this->lightPos.z);
     473        lightPosZ->connect(SIGNAL(lightPosZ, valueChanged), this, SLOT(MappedWater, resetLightPosZ));
     474        lightPosBox->pack(lightPosZ);
     475      }
     476      this->box->pack(lightPosBox);
     477
     478      OrxGui::GLGuiBox* waterHeightBox = new OrxGui::GLGuiBox(OrxGui::Horizontal);
     479      {
     480        OrxGui::GLGuiInputLine* waterHeightText = new OrxGui::GLGuiInputLine();
     481        waterHeightText->setText("WaterHeight");
     482        waterHeightBox->pack(waterHeightText);
     483
     484        OrxGui::GLGuiSlider* waterHeight = new OrxGui::GLGuiSlider();
     485        waterHeight->setRange(-500, 500);
     486        waterHeight->setValue(this->waterHeight);
     487        waterHeight->setStep(10);
     488        waterHeight->connect(SIGNAL(waterHeight, valueChanged), this, SLOT(MappedWater, setWaterHeight));
     489        waterHeightBox->pack(waterHeight);
     490      }
     491      this->box->pack(waterHeightBox);
    442492    }
     493
    443494    this->box->showAll();
    444495    this->box->setAbsCoor2D(300, 40);
     
    446497    OrxGui::GLGuiHandler::getInstance()->activateCursor();
    447498  }
    448 
    449 
    450499}
    451500
     
    598647  }
    599648
     649  if(bFadeWaterHeight)
     650  {
     651    this->waterHeightFader = new tAnimation<MappedWater>(this, &MappedWater::setWaterHeight);
     652    this->waterHeightFader->setInfinity(ANIM_INF_CONSTANT);
     653
     654    this->waterHeightFader->addKeyFrame(this->waterHeight, this->waterHeightFadeTime, ANIM_LINEAR);
     655    this->waterHeightFader->addKeyFrame(this->newWaterHeight, 0, ANIM_LINEAR);
     656
     657    bFadeWaterHeight = false;
     658    this->waterHeightFader->replay();
     659  }
     660
    600661
    601662//   if(this->tempcounter == 300)
     
    604665//     this->fadeWaterUV(1, 10);
    605666//   }
    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 //   }
     667  if(this->tempcounter == 100)
     668  {
     669    PRINTF(0)("\n\n\n\n\n\n///////////////////////test waterchangecolor/////////////////////\n\n\n\n\n\n");
     670    this->fadeWaterHeight(0, 15);
     671  }
    611672  //PRINTF(0)("counter %i/n", tempcounter);
    612673  tempcounter++;
  • branches/mountain_lake/src/world_entities/environments/mapped_water.h

    r8916 r8918  
    5050  void deactivateRefraction();
    5151
    52 
     52  // slider gui to edit water params during gameplay
    5353  void openGui();
    5454  void closeGui();
    55 
    56 
    5755
    5856  // functions to set parameters for the water, usually they're called through loadparam
    5957  void setLightPos(float x, float y, float z) { this->lightPos = Vector(x,y,z); }
    6058  void setWaterPos(float x, float y, float z) { this->waterHeight = y; this->waterVerts[0] = x; this->waterVerts[1] = z; }
     59  void setWaterHeight(float y) { this->waterHeight = y;  }
    6160  void setWaterSize(float x, float z) { this->xWidth = x; this->zWidth = z; }
    6261  void setWaterAngle(float angle) { this->waterAngle = angle; }
    6362  void setWaterColor(float r, float g, float b) { this->waterColor = Vector(r,g,b); }
    64   void setWaterUV(float uv) { this->waterUV = uv; this->bFadeWaterUV = false; }
    65   void setWaterFlow(float flow) { this->waterFlow = flow; this->bFadeWaterFlow = false; }
     63  void setWaterUV(float uv) { this->waterUV = uv; }
     64  void setWaterFlow(float flow) { this->waterFlow = flow; }
    6665  void setNormalMapScale(float scale) { this->kNormalMapScale = scale; }
    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;}
     66  void setShineSize(float shine) { this->shineSize = shine; }
     67  void setShineStrength(float strength) { this->shineStrength = strength; }
     68  void setReflStrength(float strength) { this->reflStrength = strength; }
     69  void setRefraction(float refraction) { this->refraction = refraction; }
    7170
    7271  // functions to change water parameters during runtime
     
    7473  // don't reset kNormalMapScale (because it won't change anything)
    7574  void resetLightPos(float x, float y, float z);
     75  void resetLightPosX(float x) { this->resetLightPos(x, this->lightPos.y, this->lightPos.z); }
     76  void resetLightPosY(float y) { this->resetLightPos(this->lightPos.x, y, this->lightPos.z); }
     77  void resetLightPosZ(float z) { this->resetLightPos(this->lightPos.x, this->lightPos.y, z); }
    7678  void resetWaterPos(float x, float y, float z) { this->setWaterPos(x, y, z); this->calcVerts(); }
    7779  void resetWaterSize(float x, float z) { this->setWaterSize(x, z); this->calcVerts(); }
     
    9395  void fadeReflStrength(float strength, float time) { this->newReflStrength = strength; this->reflStrengthFadeTime = time; this->bFadeReflStrength = true; }
    9496  void fadeRefraction(float refraction, float time) { this->newRefraction = refraction; this->refractionFadeTime = time; this->bFadeRefraction = true; }
     97  void fadeWaterHeight(float y, float time) { this->newWaterHeight = y; this->waterHeightFadeTime = time; this->bFadeWaterHeight = true; }
    9598
    9699private:
     
    101104
    102105private:
    103   Material            mat;
    104   Shader*             shader;
     106  Material                  mat;
     107  Shader*                   shader;
     108  OrxGui::GLGuiBox*         box;
    105109
    106110  // water size and position
    107   float               waterHeight;            //!< position of the water
    108   float               waterVerts[8];          //!< coords of the 4 vertexes of the water quad
    109   float               xWidth, zWidth;         //!< size of the water quad
    110   float               waterAngle;             //!< defines how much the water will be turned around the point waterPos
     111  float                     waterHeight;            //!< position of the water
     112  float                     waterVerts[8];          //!< coords of the 4 vertexes of the water quad
     113  float                     xWidth, zWidth;         //!< size of the water quad
     114  float                     waterAngle;             //!< defines how much the water will be turned around the point waterPos
    111115
    112116  // values for texture size, scale, texture coords
    113   float               move;
    114   float               move2;
    115   float               waterUV;                //!< size of the waves
    116   float               waterFlow;              //!< speed of the water
    117   float               normalUV;
    118   float               kNormalMapScale;
    119   int                 textureSize;            //!< height and width of the texture
     117  float                     move;
     118  float                     move2;
     119  float                     waterUV;                //!< size of the waves
     120  float                     waterFlow;              //!< speed of the water
     121  float                     normalUV;
     122  float                     kNormalMapScale;
     123  int                       textureSize;            //!< height and width of the texture
    120124
    121125  // values for the uniforms
    122   Vector              waterColor;             //!< color of the water
    123   Vector              lightPos;               //!< position of the light that is used to render the reflection
    124   float               shineSize;              //!< the bigger the value, the smaller the specular reflection point
    125   float               shineStrength;
    126   float               reflStrength;
    127   float               refraction;
     126  Vector                    waterColor;             //!< color of the water
     127  Vector                    lightPos;               //!< position of the light that is used to render the reflection
     128  float                     shineSize;              //!< the bigger the value, the smaller the specular reflection point
     129  float                     shineStrength;
     130  float                     reflStrength;
     131  float                     refraction;
    128132
    129133  // uniforms
    130   Shader::Uniform*    cam_uni;                //!< uniform that is used for the camera position
    131   Shader::Uniform*    light_uni;              //!< uniform that is used for the light position
    132   Shader::Uniform*    color_uni;              //!< uniform that is used for the watercolor
    133   Shader::Uniform*    shineSize_uni;          //!< uniform that is used for the specular shininessd of the water
    134   Shader::Uniform*    shineStrength_uni;      //!< uniform that is used for the strenght of the specular reflection
    135   Shader::Uniform*    reflStrength_uni;       //!< uniform that is used for the strength of the reflection
    136   Shader::Uniform*    refr_uni;               //!< uniform that is used for the strength of the refraction
     134  Shader::Uniform*          cam_uni;                //!< uniform that is used for the camera position
     135  Shader::Uniform*          light_uni;              //!< uniform that is used for the light position
     136  Shader::Uniform*          color_uni;              //!< uniform that is used for the watercolor
     137  Shader::Uniform*          shineSize_uni;          //!< uniform that is used for the specular shininessd of the water
     138  Shader::Uniform*          shineStrength_uni;      //!< uniform that is used for the strenght of the specular reflection
     139  Shader::Uniform*          reflStrength_uni;       //!< uniform that is used for the strength of the reflection
     140  Shader::Uniform*          refr_uni;               //!< uniform that is used for the strength of the refraction
    137141
    138142  // 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;
    147   tAnimation<MappedWater>*      shineSizeFader;
    148   float                         newShineSize;
    149   float                         shineSizeFadeTime;
    150   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;
    163 
    164   OrxGui::GLGuiBox*             box;
     143  tAnimation<MappedWater>*  waterUVFader;
     144  float                     newWaterUV;
     145  float                     waterUVFadeTime;
     146  bool                      bFadeWaterUV ;
     147  tAnimation<MappedWater>*  waterFlowFader;
     148  float                     newWaterFlow;
     149  float                     waterFlowFadeTime;
     150  bool                      bFadeWaterFlow;
     151  tAnimation<MappedWater>*  shineSizeFader;
     152  float                     newShineSize;
     153  float                     shineSizeFadeTime;
     154  bool                      bFadeShineSize;
     155  tAnimation<MappedWater>*  shineStrengthFader;
     156  float                     newShineStrength;
     157  float                     shineStrengthFadeTime;
     158  bool                      bFadeShineStrength;
     159  tAnimation<MappedWater>*  reflStrengthFader;
     160  float                     newReflStrength;
     161  float                     reflStrengthFadeTime;
     162  bool                      bFadeReflStrength;
     163  tAnimation<MappedWater>*  refractionFader;
     164  float                     newRefraction;
     165  float                     refractionFadeTime;
     166  bool                      bFadeRefraction;
     167  tAnimation<MappedWater>*  waterHeightFader;
     168  float                     newWaterHeight;
     169  float                     waterHeightFadeTime;
     170  bool                      bFadeWaterHeight;
    165171
    166172  int tempcounter;
Note: See TracChangeset for help on using the changeset viewer.