Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 7328 in orxonox.OLD for trunk/src/world_entities/skybox.cc


Ignore:
Timestamp:
Apr 17, 2006, 3:58:57 PM (18 years ago)
Author:
bensch
Message:

orxonox/trunk: sky is ok again

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/world_entities/skybox.cc

    r7230 r7328  
    121121
    122122/**
    123  *  sets A set of textures when just giving a Name and an extension:
    124 
    125    usage: give this function an argument like
    126    setTexture("skybox", "jpg");
    127    and it will convert this to
    128    setTextures("skybox_top.jpg", "skybox_bottom.jpg", "skybox_left.jpg",
    129                "skybox_right.jpg", "skybox_front.jpg", "skybox_back.jpg");
    130 */
     123 * @brief sets A set of textures when just giving a Name and an extension:
     124 * @param name the prefix of the Name
     125 * @param extension the file extension (jpg by default)
     126 * usage: give this function an argument like
     127 * setTexture("skybox", "jpg");
     128 * and it will convert this to
     129 * setTextures("skybox_negx.jpg", "skybox_posx.jpg", "skybox_negy.jpg",
     130 *             "skybox_posy.jpg", "skybox_negz.jpg", "skybox_posz.jpg");
     131 */
    131132void SkyBox::setTextureAndType(const std::string& name, const std::string& extension)
    132133{
    133   std::string top = name + "_top." + extension;
    134   std::string bottom = name + "_bottom." + extension;
    135   std::string left = name + "_left." + extension;
    136   std::string right = name + "_right." + extension;
    137   std::string front = name + "_front." + extension;
    138   std::string back = name + "_back." + extension;
    139 
    140   this->setTextures(top, bottom, left, right, front, back);
    141 }
    142 
    143 /**
    144  *  Defines which textures should be loaded onto the SkyBox.
    145  * @param top the top texture.
    146  * @param bottom the bottom texture.
    147  * @param left the left texture.
    148  * @param right the right texture.
    149  * @param front the front texture.
    150  * @param back the back texture.
    151 */
    152 void SkyBox::setTextures(const std::string& top, const std::string& bottom, const std::string& left,
    153                           const std::string& right, const std::string& front, const std::string& back)
    154 {
    155   this->material[0]->setDiffuseMap(top);
    156   this->material[1]->setDiffuseMap(bottom);
    157   this->material[2]->setDiffuseMap(left);
    158   this->material[3]->setDiffuseMap(right);
    159   this->material[4]->setDiffuseMap(front);
    160   this->material[5]->setDiffuseMap(back);
     134  std::string negX = name + "_negx." + extension;
     135  std::string posX = name + "_posx." + extension;
     136
     137  std::string negY = name + "_negy." + extension;
     138  std::string posY = name + "_posy." + extension;
     139
     140  std::string negZ = name + "_negz." + extension;
     141  std::string posZ = name + "_posz." + extension;
     142
     143  this->setTextures(negX, posX, negY, posY, negZ, posZ);
     144}
     145
     146/**
     147 * @brief Defines which textures should be loaded onto the SkyBox.
     148 * @param negX the top texture.
     149 * @param posX the bottom texture.
     150 * @param negY the left texture.
     151 * @param posY the right texture.
     152 * @param negZ the front texture.
     153 * @param posZ the back texture.
     154*/
     155void SkyBox::setTextures(const std::string& negX, const std::string& posX,
     156                         const std::string& negY, const std::string& posY,
     157                         const std::string& negZ, const std::string& posZ)
     158{
     159  this->material[0]->setDiffuseMap(negX);
     160  this->material[1]->setDiffuseMap(posX);
     161  this->material[2]->setDiffuseMap(negY);
     162  this->material[3]->setDiffuseMap(posY);
     163  this->material[4]->setDiffuseMap(negZ);
     164  this->material[5]->setDiffuseMap(posZ);
    161165  if (GLEW_EXT_texture_cube_map)
    162     this->loadCubeMapTextures(top, bottom, left, right, front, back);
    163 }
    164 
    165 void SkyBox::loadCubeMapTextures(const std::string& top, const std::string& bottom, const std::string& left,
    166                                   const std::string& right, const std::string& front, const std::string& back)
    167 {
    168   this->cubeTexture[0] = (Texture*)ResourceManager::getInstance()->load(top, RP_LEVEL, IMAGE, GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT);
    169   this->cubeTexture[1] = (Texture*)ResourceManager::getInstance()->load(bottom, RP_LEVEL, IMAGE, GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT);
    170   this->cubeTexture[2] = (Texture*)ResourceManager::getInstance()->load(left, RP_LEVEL, IMAGE, GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT);
    171   this->cubeTexture[3] = (Texture*)ResourceManager::getInstance()->load(right, RP_LEVEL, IMAGE, GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT);
    172   this->cubeTexture[4] = (Texture*)ResourceManager::getInstance()->load(front, RP_LEVEL, IMAGE, GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT);
    173   this->cubeTexture[5] = (Texture*)ResourceManager::getInstance()->load(back, RP_LEVEL, IMAGE, GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT);
     166    this->loadCubeMapTextures(negX, posX, negY, posY, negZ, posZ);
     167}
     168
     169void SkyBox::loadCubeMapTextures(const std::string& posY, const std::string& negY, const std::string& negZ,
     170                                  const std::string& posZ, const std::string& posX, const std::string& negX)
     171{
     172  this->cubeTexture[0] = (Texture*)ResourceManager::getInstance()->load(negX, RP_LEVEL, IMAGE, GL_TEXTURE_CUBE_MAP_NEGATIVE_X_EXT);
     173  this->cubeTexture[1] = (Texture*)ResourceManager::getInstance()->load(posX, RP_LEVEL, IMAGE, GL_TEXTURE_CUBE_MAP_POSITIVE_X_EXT);
     174
     175  this->cubeTexture[2] = (Texture*)ResourceManager::getInstance()->load(negY, RP_LEVEL, IMAGE, GL_TEXTURE_CUBE_MAP_NEGATIVE_Y_EXT);
     176  this->cubeTexture[3] = (Texture*)ResourceManager::getInstance()->load(posY, RP_LEVEL, IMAGE, GL_TEXTURE_CUBE_MAP_POSITIVE_Y_EXT);
     177
     178  this->cubeTexture[4] = (Texture*)ResourceManager::getInstance()->load(negZ, RP_LEVEL, IMAGE, GL_TEXTURE_CUBE_MAP_NEGATIVE_Z_EXT);
     179  this->cubeTexture[5] = (Texture*)ResourceManager::getInstance()->load(posZ, RP_LEVEL, IMAGE, GL_TEXTURE_CUBE_MAP_POSITIVE_Z_EXT);
    174180}
    175181
     
    269275
    270276  model->setMaterial(material[0]);
     277  model->addFace (4, VERTEX_TEXCOORD_NORMAL, 6,0,4, 0,1,4, 2,2,4, 4,3,4); // back
     278  model->setMaterial(material[1]);
     279  model->addFace (4, VERTEX_TEXCOORD_NORMAL, 1,0,5, 7,1,5, 5,2,5, 3,3,5); // front
     280  model->setMaterial(material[2]);
     281  model->addFace (4, VERTEX_TEXCOORD_NORMAL, 6,0,1, 7,1,1, 1,2,1, 0,3,1); // bottom
     282  model->setMaterial(material[3]);
    271283  model->addFace (4, VERTEX_TEXCOORD_NORMAL, 2,0,3, 3,1,3, 5,2,3, 4,3,3); // top
    272   model->setMaterial(material[1]);
    273   model->addFace (4, VERTEX_TEXCOORD_NORMAL, 6,0,1, 7,1,1, 1,2,1, 0,3,1); // bottom
    274   model->setMaterial(material[2]);
     284  model->setMaterial(material[4]);
    275285  model->addFace (4, VERTEX_TEXCOORD_NORMAL, 4,2,2, 5,3,2, 7,0,2, 6,1,2); // left
    276   model->setMaterial(material[3]);
     286  model->setMaterial(material[5]);
    277287  model->addFace (4, VERTEX_TEXCOORD_NORMAL, 0,0,0, 1,1,0, 3,2,0, 2,3,0); // right
    278   model->setMaterial(material[4]);
    279   model->addFace (4, VERTEX_TEXCOORD_NORMAL, 1,0,5, 7,1,5, 5,2,5, 3,3,5); // front
    280   model->setMaterial(material[5]);
    281   model->addFace (4, VERTEX_TEXCOORD_NORMAL, 6,0,4, 0,1,4, 2,2,4, 4,3,4); // back
    282288
    283289  model->finalize();
Note: See TracChangeset for help on using the changeset viewer.