Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 6467 in orxonox.OLD for trunk/src


Ignore:
Timestamp:
Jan 11, 2006, 11:46:52 AM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: Texture loading with GL_TEXTURE_* in ResourceManager and Material

Location:
trunk/src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/lib/graphics/importer/grid.cc

    r6458 r6467  
    3333  this->_sizeX = sizeX;
    3434  this->_sizeY = sizeY;
    35   this->_gridSpacingX = sizeX / rows;
    36   this->_gridSpacingY = sizeY / columns;
     35  this->_gridSpacingX = sizeX / (float)rows;
     36  this->_gridSpacingY = sizeY / (float)columns;
    3737}
    3838
     
    5353    for (unsigned int j = 1; j < this->_columns-1; j++)
    5454    {
    55      Vector test(
    56           (this->vertex(i*_columns+j).y + this->vertex((i-1)*_columns+j).y - this->vertex((i+1)*_columns+j).y ) /maxHeight,
    57           1.0,
    58           (this->vertex(i*_columns+j).y - this->vertex(i*_columns+j-1).y + this->vertex(i*_columns+j+1).y)/maxHeight
    59                 );
     55/*
     56      Vector test( this->_gridSpacingX/(this->vertex(i*_columns+j).y - this->vertex(i*_columns+j-1).y) +
     57          this->_gridSpacingX/(this->vertex(i*_columns+j+1).y - this->vertex(i*_columns+j).y)
     58          ,
     59      _gridSpacingX,
     60      this->_gridSpacingY/(this->vertex(i*_columns+j).y - this->vertex((i-1)*_columns+j).y) +
     61          this->_gridSpacingX/(this->vertex((i+1)*_columns+j).y - this->vertex(i*_columns+j).y)
     62                 );*/
     63
     64
     65
     66      Vector test  (
     67          (-this->vertex(i*_columns+j-1).y - this->vertex(i*_columns+j+1).y)/maxHeight,
     68            1.0,
     69            (-this->vertex((i-1)*_columns+j).y - this->vertex((i+1)*_columns+j).y)/maxHeight
     70          );
     71
     72
     73//      Vector test(
     74//           (this->vertex(i*_columns+j).y + this->vertex((i-1)*_columns+j).y - this->vertex((i+1)*_columns+j).y ) /maxHeight,
     75//           1.0,
     76//           (this->vertex(i*_columns+j).y - this->vertex(i*_columns+j-1).y + this->vertex(i*_columns+j+1).y)/maxHeight
     77//                 );
    6078      this->normal( i*_columns+j) = test.getNormalized();
    6179    }
  • trunk/src/lib/graphics/importer/material.cc

    r6295 r6467  
    274274 * @param dMap the Name of the Image to Use
    275275*/
    276 void Material::setDiffuseMap(const char* dMap)
     276void Material::setDiffuseMap(const char* dMap, GLenum target)
    277277{
    278278  PRINTF(5)("setting Diffuse Map %s\n", dMap);
     
    283283  //! @todo Textures from .mtl-file need special care.
    284284  if (dMap!= NULL)
    285     this->diffuseTexture = (Texture*)ResourceManager::getInstance()->load(dMap, IMAGE, RP_GAME);
     285    this->diffuseTexture = (Texture*)ResourceManager::getInstance()->load(dMap, IMAGE, RP_GAME, (void*)&target);
    286286  else
    287287    this->diffuseTexture = NULL;
     
    293293   @todo implement this
    294294*/
    295 void Material::setAmbientMap(const char* aMap)
     295void Material::setAmbientMap(const char* aMap, GLenum target)
    296296{
    297297  SDL_Surface* ambientMap;
     
    304304   @todo implement this
    305305*/
    306 void Material::setSpecularMap(const char* sMap)
     306void Material::setSpecularMap(const char* sMap, GLenum target)
    307307{
    308308  SDL_Surface* specularMap;
  • trunk/src/lib/graphics/importer/material.h

    r5866 r6467  
    4444
    4545 // MAPPING //
    46   void setDiffuseMap(const char* dMap);
    47   void setAmbientMap(const char* aMap);
    48   void setSpecularMap(const char* sMap);
     46  void setDiffuseMap(const char* dMap, GLenum target = GL_TEXTURE_2D);
     47  void setAmbientMap(const char* aMap, GLenum target = GL_TEXTURE_2D);
     48  void setSpecularMap(const char* sMap, GLenum target = GL_TEXTURE_2D);
    4949  void setBump(const char* bump);
    5050
  • trunk/src/util/loading/resource_manager.cc

    r6222 r6467  
    407407#ifndef NO_TEXTURES
    408408        case IMAGE:
     409          if (param1 != NULL)
     410            tmpResource->texTarget = *(GLenum*)param1;
     411          else
     412            tmpResource->texTarget = GL_TEXTURE_2D;
    409413          if(isFile(fullName))
    410414            {
     
    422426                    {
    423427                      PRINTF(4)("Image %s resides to %s\n", fileName, imgName);
    424                       tmpResource->pointer = new Texture(imgName);
     428                      tmpResource->pointer = new Texture(imgName, tmpResource->texTarget);
    425429                      delete[] imgName;
    426430                      break;
     
    666670                  match = true;
    667671#endif /* NO_SHADERS */
     672#ifndef NO_TEXTURES
     673              case IMAGE:
     674                if (!param1)
     675                {
     676                  if ((*resource)->texTarget == GL_TEXTURE_2D)
     677                    match = true;
     678                }
     679                else if ((*resource)->texTarget ==  *(GLenum*)param1)
     680                  match = true;
     681#endif /* NO_TEXTURES */
    668682            default:
    669683              match = true;
  • trunk/src/util/loading/resource_manager.h

    r6222 r6467  
    8181  unsigned int      ttfSize;           //!< the size of the ttf-font (TTF)
    8282#endif /* NO_TEXT */
     83#ifndef NO_TEXTURES
     84  GLenum            texTarget;
     85#endif /* NO_TEXTURES */
    8386};
    8487
  • trunk/src/world_entities/environments/water.cc

    r6458 r6467  
    2323#include "material.h"
    2424
     25#include "resource_manager.h"
     26#include "shader.h"
     27
     28
    2529using namespace std;
    2630
     
    4347  this->rebuildGrid();
    4448  this->waterMaterial = new Material();
     49  this->waterShader = (Shader*)ResourceManager::getInstance()->load("shaders/water.vert", SHADER, RP_GAME, (void*)"shaders/water.frag");
     50
    4551}
    4652
     
    97103void Water::draw() const
    98104{
    99   this->waterMaterial->select();
     105  this->waterShader->activateShader();
     106//  this->waterMaterial->select();
    100107  WorldEntity::draw();
     108  Shader::deactivateShader();
    101109}
    102110
     
    109117    {
    110118      this->grid->height(i,j) = this->height*sin(((float)i/(float)this->grid->rows() *phase)+
    111           this->height*cos((float)j/(float)this->grid->columns()) * phase);
     119          this->height*cos((float)j/(float)this->grid->columns()) * phase * 2.0);
    112120    }
    113121  }
  • trunk/src/world_entities/environments/water.h

    r6458 r6467  
    1616class Material;
    1717class Grid;
     18class Shader;
    1819
    1920//! A Class to handle a WaterEffects
     
    3738    Grid*           grid;            //!< The water-surface-model to render with
    3839    Material*       waterMaterial;
     40    Shader*         waterShader;
    3941    float           height;          //!< The hight of the Water
    4042
Note: See TracChangeset for help on using the changeset viewer.