Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
Apr 13, 2005, 7:38:52 PM (20 years ago)
Author:
bensch
Message:

orxonox/trunk: SkyBox even better,

world-entity implements a draw function of its own

some other minor stuff

File:
1 edited

Legend:

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

    r3801 r3803  
    4646{
    4747  this->setClassName("SkyBox");
    48 
    49   this->model = NULL;
    50 
    51   this->setMode(PNODE_MOVEMENT);
    52 
    53   this->setSize(1900.0);
    54   this->rebuild();
    55 
    5648  this->material = new Material*[6];
    5749  for (int i = 0; i <6; i++)
     
    6153      this->material[i]->setAmbient(1.0, 1.0, 1.0);
    6254    }
     55  this->setMode(PNODE_MOVEMENT);
     56
     57
     58
     59  this->setSize(1900.0);
     60  this->rebuild();
    6361}
    6462
     
    7674}
    7775
    78 
     76/**
     77   \brief sets A set of textures when just giving a Name and an extension:
     78
     79   usage: give this function an argument like
     80   setTexture("skybox", "jpg");
     81   and it will convert this to
     82   setTextures("skybox_top.jpg", "skybox_bottom.jpg", "skybox_left.jpg",
     83               "skybox_right.jpg", "skybox_front.jpg", "skybox_back.jpg");
     84*/
     85void SkyBox::setTexture(const char* name, const char* extension)
     86{
     87  char* top    = new char[strlen(name)+strlen(extension)+ 6];
     88  char* bottom = new char[strlen(name)+strlen(extension)+ 9];
     89  char* left   = new char[strlen(name)+strlen(extension)+ 7];
     90  char* right  = new char[strlen(name)+strlen(extension)+ 8];
     91  char* front  = new char[strlen(name)+strlen(extension)+ 8];
     92  char* back   = new char[strlen(name)+strlen(extension)+ 7];
     93
     94  sprintf(top, "%s_top.%s", name, extension);
     95  sprintf(bottom, "%s_bottom.%s", name, extension);
     96  sprintf(left, "%s_left.%s", name, extension);
     97  sprintf(right, "%s_right.%s", name, extension);
     98  sprintf(front, "%s_front.%s", name, extension);
     99  sprintf(back, "%s_back.%s", name, extension);
     100 
     101  this->setTextures(top, bottom, left, right, front, back);
     102
     103  delete []top;
     104  delete []bottom;
     105  delete []left;
     106  delete []right;
     107  delete []front;
     108  delete []back;
     109}
     110
     111/**
     112   \brief Defines which textures should be loaded onto the SkyBox.
     113   \param top the top texture.
     114   \param bottom the bottom texture.
     115   \param left the left texture.
     116   \param right the right texture.
     117   \param front the front texture.
     118   \param back the back texture.
     119*/
     120void SkyBox::setTextures(const char* top, const char* bottom, const char* left, const char* right, const char* front, const char* back)
     121{
     122  this->material[0]->setDiffuseMap(top);
     123  this->material[1]->setDiffuseMap(bottom);
     124  this->material[2]->setDiffuseMap(left);
     125  this->material[3]->setDiffuseMap(right);
     126  this->material[4]->setDiffuseMap(front);
     127  this->material[5]->setDiffuseMap(back);
     128}
     129
     130/**
     131   \brief sets the Radius of the Sphere.
     132   \param radius The Radius of The Sphere
     133*/
     134void SkyBox::setSize(float size)
     135{
     136  this->size = size;
     137}
     138
     139/**
     140   \brief rebuilds the SkyBox
     141   
     142   this must be done, when changing the Size of the Skybox (runtime-efficency)
     143*/
    79144void SkyBox::rebuild()
    80145{
     
    144209  model->addUseMtl(material[5]);
    145210  model->addFace (4, 3, 7,13,21, 1,1,22, 3,3,23, 5,14,24);
    146 }
    147 
    148 /**
    149    \brief Defines which texture should be loaded onto the SkyBox.
    150    \param fileName The filename of the Texture
    151 */
    152 void SkyBox::setTexture(char* top, char* bottom, char* left, char* right, char* front, char* back)
    153 {
    154   this->material[0]->setDiffuseMap(top);
    155   this->material[1]->setDiffuseMap(bottom);
    156   this->material[2]->setDiffuseMap(left);
    157   this->material[3]->setDiffuseMap(right);
    158   this->material[4]->setDiffuseMap(front);
    159   this->material[5]->setDiffuseMap(back);
    160 }
    161 
    162 
    163 /**
    164    \brief draws the SkyBox
    165    
    166    This part is normally precessed in the "Painting Phase".
    167 */
    168 void SkyBox::draw()
    169 {
    170   glPushMatrix();
    171   glMatrixMode(GL_MODELVIEW);
    172   Vector r = this->getAbsCoor();
    173   glTranslatef(r.x, r.y, r.z);
    174 
    175   this->material[1]->select();
    176 
    177   this->model->draw();
    178 
    179   glPopMatrix();
    180 }
    181 
    182 
    183 /**
    184    \brief sets the Radius of the Sphere.
    185    \param radius The Radius of The Sphere
    186 */
    187 void SkyBox::setSize(float size)
    188 {
    189   this->size = size;
    190 }
     211 
     212  model->finalize();
     213}
Note: See TracChangeset for help on using the changeset viewer.