Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7982 in orxonox.OLD for branches/water/src


Ignore:
Timestamp:
May 30, 2006, 3:30:47 PM (19 years ago)
Author:
stefalie
Message:

branches/water: light!

Location:
branches/water/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • branches/water/src/lib/graphics/importer/material.cc

    r7788 r7982  
    107107  if (unlikely(this == Material::selectedMaterial))
    108108      return true;
     109  else if (likely(Material::selectedMaterial != NULL))
     110  {
     111  Material::unselect();
     112//     for(unsigned int i = 0; i < Material::selectedMaterial->textures.size(); ++i)
     113//     {
     114//         glActiveTexture(Material::glTextureArbs[i]);
     115//         glBindTexture(GL_TEXTURE_2D, 0);
     116//         glDisable(GL_TEXTURE_2D);
     117//     }
     118  }
    109119
    110120
     
    137147  else if (this->illumModel >= 2)
    138148    glShadeModel(GL_SMOOTH);
    139 
    140   if (likely(Material::selectedMaterial != NULL))
    141   {
    142     for(unsigned int i = 0; i < Material::selectedMaterial->textures.size(); ++i)
    143     {
    144         glActiveTexture(Material::glTextureArbs[i]);
    145         glBindTexture(GL_TEXTURE_2D, 0);
    146         glDisable(GL_TEXTURE_2D);
    147     }
    148   }
    149149
    150150  for(unsigned int i = 0; i < this->textures.size(); ++i)
     
    172172}
    173173
     174void Material::unselect()
     175{
     176  Material::selectedMaterial = NULL;
     177    for(unsigned int i = 0; i < 8; ++i)
     178    {
     179        glActiveTexture(Material::glTextureArbs[i]);
     180        glBindTexture(GL_TEXTURE_2D, 0);
     181        glDisable(GL_TEXTURE_2D);
     182    }
     183}
     184
    174185/**
    175186 *  Sets the Material Illumination Model.
  • branches/water/src/lib/graphics/importer/material.h

    r7788 r7982  
    3232
    3333    bool select () const;
     34    static void unselect();
    3435
    3536    void setIllum (int illum);
  • branches/water/src/lib/graphics/shader.h

    r7835 r7982  
    2323  {
    2424  public:
    25     Uniform(const Shader* shader, const std::string& location) { glGetUniformLocationARB(shader->getProgram(), location.c_str()) ; }
    26     Uniform(const Shader& shader, const std::string& location) { glGetUniformLocation(shader.getProgram(), location.c_str()) ; };
    27     Uniform(GLhandleARB shaderProgram, const std::string& location) { glGetUniformLocation(shaderProgram, location.c_str()) ; };
     25    Uniform(const Shader* shader, const std::string& location) { this->uniform = glGetUniformLocationARB(shader->getProgram(), location.c_str()) ; }
     26    Uniform(const Shader& shader, const std::string& location) { this->uniform = glGetUniformLocation(shader.getProgram(), location.c_str()) ; };
     27    Uniform(GLhandleARB shaderProgram, const std::string& location) { this->uniform = glGetUniformLocation(shaderProgram, location.c_str()) ; };
    2828
    2929    void set(float v0) const { glUniform1f(this->uniform, v0); }
  • branches/water/src/world_entities/environments/mapped_water.cc

    r7832 r7982  
    3939  mat.setDiffuseMap("pictures/dudvmap.bmp", GL_TEXTURE_2D, 0);
    4040  // load refraction texture
    41   mat.setDiffuseMap("pictures/sky-replace.jpg", 1);
     41 // mat.setDiffuseMap("pictures/sky-replace.jpg", 1);
    4242  // load normal map
    4343  mat.setDiffuseMap("pictures/normalmap.bmp", GL_TEXTURE_2D, 2);
     
    123123  // HACK
    124124
    125   glDisable(GL_BLEND);
    126125  //glActiveTexture(GL_TEXTURE0);
    127126  //glBindTexture(GL_TEXTURE_2D, this->texture);
    128 
     127  mat.unselect();
    129128  mat.select();
    130   glBindTexture(GL_TEXTURE_2D, this->mat.getDiffuseTexture(0));
     129  //glBindTexture(GL_TEXTURE_2D, this->mat.getDiffuseTexture(0));
    131130
    132131
     
    134133  this->shader->activateShader();
    135134  GLint uniform;
     135  Shader::Uniform* uni;
    136136
    137137  // Set the variable "reflection" to correspond to the first texture unit
    138   uniform = glGetUniformLocationARB(shader->getProgram(), "reflection");
    139   glUniform1iARB(uniform, 0); //second paramter is the texture unit
     138  uni = new Shader::Uniform (shader, "reflection");
     139  uni->set(0);
     140  //uniform = glGetUniformLocationARB(shader->getProgram(), "reflection");
     141  //glUniform1iARB(uniform, 0); //second paramter is the texture unit
    140142
    141143  // Set the variable "refraction" to correspond to the second texture unit
    142   uniform = glGetUniformLocationARB(shader->getProgram(), "refraction");
    143   glUniform1iARB(uniform, 1);
     144 // uni = new Shader::Uniform (shader, "refraction");
     145 // uni->set(1);
     146  //uniform = glGetUniformLocationARB(shader->getProgram(), "refraction");
     147  //glUniform1iARB(uniform, 1);
    144148
    145149  // Set the variable "normalMap" to correspond to the third texture unit
    146   uniform = glGetUniformLocationARB(shader->getProgram(), "normalMap");
    147   glUniform1iARB(uniform, 2);
     150  uni = new Shader::Uniform (shader, "normalMap");
     151  uni->set(2);
     152  //uniform = glGetUniformLocationARB(shader->getProgram(), "normalMap");
     153  //glUniform1iARB(uniform, 2);
    148154
    149155  // Set the variable "dudvMap" to correspond to the fourth texture unit
    150   uniform = glGetUniformLocationARB(shader->getProgram(), "dudvMap");
    151   glUniform1iARB(uniform, 3);
     156  uni = new Shader::Uniform (shader, "dudvMap");
     157  uni->set(3);
     158  //uniform = glGetUniformLocationARB(shader->getProgram(), "dudvMap");
     159  //glUniform1iARB(uniform, 3);
    152160
    153161  // Set the variable "depthMap" to correspond to the fifth texture unit
    154   uniform = glGetUniformLocationARB(shader->getProgram(), "depthMap");
    155   glUniform1iARB(uniform, 4);
     162 // uni = new Shader::Uniform (shader, "depthMap");
     163 // uni->set(4);
     164  //uniform = glGetUniformLocationARB(shader->getProgram(), "depthMap");
     165  //glUniform1iARB(uniform, 4);
    156166  // FIXME we dont have a depthMap yet :-(
    157167
     
    177187
    178188
    179   float move2 = this->move * this->kNormalMapScale;
    180   float refrUV = this->g_WaterUV;
    181   float normalUV = this->g_WaterUV * this->kNormalMapScale;
     189
    182190
    183191
     
    219227
    220228
     229  Material::unselect();
     230
    221231  glPopMatrix();
    222232}
     
    225235{
    226236  this->move += this->g_WaterFlow = 0.004;
     237  this->move2 = this->move * this->kNormalMapScale;
     238  this->refrUV = this->g_WaterUV;
     239  this->normalUV = this->g_WaterUV * this->kNormalMapScale;
    227240}
    228241
  • branches/water/src/world_entities/environments/mapped_water.h

    r7823 r7982  
    4040    float           kNormalMapScale;
    4141    float           g_WaterFlow;
     42    float           move2;
     43    float           refrUV;
     44    float           normalUV;
    4245
    4346    int             textureSize;                //!< size of the texture
Note: See TracChangeset for help on using the changeset viewer.