- Timestamp:
- Jun 29, 2006, 6:53:35 PM (18 years ago)
- 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 21 21 #include "t_animation.h" 22 22 #include "math.h" 23 24 23 #include "glgui.h" 25 26 27 24 #include "shell_command.h" 28 25 … … 56 53 this->calcVerts(); 57 54 58 tempcounter = 0;55 // init gui 59 56 this->box = NULL; 60 57 } … … 100 97 this->move = 0; 101 98 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; 102 110 } 103 111 … … 323 331 { 324 332 OrxGui::GLGuiInputLine* waterColorText = new OrxGui::GLGuiInputLine(); 325 waterColorText->setText(" Color");333 waterColorText->setText("WaterColor"); 326 334 waterColorBox->pack(waterColorText); 327 335 … … 335 343 OrxGui::GLGuiSlider* waterColorG = new OrxGui::GLGuiSlider(); 336 344 waterColorG->setRange(0, 1.0f); 337 waterColor R->setStep(0.1f);345 waterColorG->setStep(0.1f); 338 346 waterColorG->setValue(this->waterColor.y); 339 347 waterColorG->connect(SIGNAL(waterColorG, valueChanged), this, SLOT(MappedWater, resetWaterColorG)); … … 342 350 OrxGui::GLGuiSlider* waterColorB = new OrxGui::GLGuiSlider(); 343 351 waterColorB->setRange(0, 1.0f); 344 waterColor R->setStep(0.1f);352 waterColorB->setStep(0.1f); 345 353 waterColorB->setValue(this->waterColor.z); 346 354 waterColorB->connect(SIGNAL(waterColorB, valueChanged), this, SLOT(MappedWater, resetWaterColorB)); 347 355 waterColorBox->pack(waterColorB); 348 349 356 } 350 357 this->box->pack(waterColorBox); … … 440 447 this->box->pack(refractionBox); 441 448 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); 442 492 } 493 443 494 this->box->showAll(); 444 495 this->box->setAbsCoor2D(300, 40); … … 446 497 OrxGui::GLGuiHandler::getInstance()->activateCursor(); 447 498 } 448 449 450 499 } 451 500 … … 598 647 } 599 648 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 600 661 601 662 // if(this->tempcounter == 300) … … 604 665 // this->fadeWaterUV(1, 10); 605 666 // } 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 } 611 672 //PRINTF(0)("counter %i/n", tempcounter); 612 673 tempcounter++; -
branches/mountain_lake/src/world_entities/environments/mapped_water.h
r8916 r8918 50 50 void deactivateRefraction(); 51 51 52 52 // slider gui to edit water params during gameplay 53 53 void openGui(); 54 54 void closeGui(); 55 56 57 55 58 56 // functions to set parameters for the water, usually they're called through loadparam 59 57 void setLightPos(float x, float y, float z) { this->lightPos = Vector(x,y,z); } 60 58 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; } 61 60 void setWaterSize(float x, float z) { this->xWidth = x; this->zWidth = z; } 62 61 void setWaterAngle(float angle) { this->waterAngle = angle; } 63 62 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; } 66 65 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; } 71 70 72 71 // functions to change water parameters during runtime … … 74 73 // don't reset kNormalMapScale (because it won't change anything) 75 74 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); } 76 78 void resetWaterPos(float x, float y, float z) { this->setWaterPos(x, y, z); this->calcVerts(); } 77 79 void resetWaterSize(float x, float z) { this->setWaterSize(x, z); this->calcVerts(); } … … 93 95 void fadeReflStrength(float strength, float time) { this->newReflStrength = strength; this->reflStrengthFadeTime = time; this->bFadeReflStrength = true; } 94 96 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; } 95 98 96 99 private: … … 101 104 102 105 private: 103 Material mat; 104 Shader* shader; 106 Material mat; 107 Shader* shader; 108 OrxGui::GLGuiBox* box; 105 109 106 110 // water size and position 107 float waterHeight; //!< position of the water108 float waterVerts[8]; //!< coords of the 4 vertexes of the water quad109 float xWidth, zWidth; //!< size of the water quad110 float waterAngle; //!< defines how much the water will be turned around the point waterPos111 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 111 115 112 116 // values for texture size, scale, texture coords 113 float move;114 float move2;115 float waterUV; //!< size of the waves116 float waterFlow; //!< speed of the water117 float normalUV;118 float kNormalMapScale;119 int textureSize; //!< height and width of the texture117 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 120 124 121 125 // values for the uniforms 122 Vector waterColor; //!< color of the water123 Vector lightPos; //!< position of the light that is used to render the reflection124 float shineSize; //!< the bigger the value, the smaller the specular reflection point125 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; 128 132 129 133 // uniforms 130 Shader::Uniform* cam_uni; //!< uniform that is used for the camera position131 Shader::Uniform* light_uni; //!< uniform that is used for the light position132 Shader::Uniform* color_uni; //!< uniform that is used for the watercolor133 Shader::Uniform* shineSize_uni; //!< uniform that is used for the specular shininessd of the water134 Shader::Uniform* shineStrength_uni; //!< uniform that is used for the strenght of the specular reflection135 Shader::Uniform* reflStrength_uni; //!< uniform that is used for the strength of the reflection136 Shader::Uniform* refr_uni; //!< uniform that is used for the strength of the refraction134 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 137 141 138 142 // 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; 165 171 166 172 int tempcounter;
Note: See TracChangeset
for help on using the changeset viewer.