Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3801 in orxonox.OLD for orxonox/trunk/src/world_entities


Ignore:
Timestamp:
Apr 13, 2005, 6:54:35 PM (20 years ago)
Author:
bensch
Message:

orxonox/trunk: some more functionality to material
now it is possible to add an external Material, and it handles pointers instead of char-arrays

Location:
orxonox/trunk/src/world_entities
Files:
2 edited

Legend:

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

    r3796 r3801  
    4747  this->setClassName("SkyBox");
    4848
     49  this->model = NULL;
    4950
    50   this->model = (Model*)ResourceManager::getInstance()->load("cube", PRIM, RP_LEVEL);
    5151  this->setMode(PNODE_MOVEMENT);
    5252
    5353  this->setSize(1900.0);
     54  this->rebuild();
    5455
    55   this->material = new Material("Sky");
    56   if (fileName)
    57     this->setTexture(fileName);
    58   this->material->setIllum(3);
    59   this->material->setAmbient(1.0, 1.0, 1.0);
    60 
     56  this->material = new Material*[6];
     57  for (int i = 0; i <6; i++)
     58    {
     59      this->material[i] = new Material();
     60      this->material[i]->setIllum(3);
     61      this->material[i]->setAmbient(1.0, 1.0, 1.0);
     62    }
    6163}
    6264
     
    6769SkyBox::~SkyBox()
    6870{
    69   PRINTF(3)("Deleting the SkyBox\n");
    70   delete this->material;
     71  PRINTF(5)("Deleting the SkyBox\n");
     72 
     73  for (int i = 0; i < 6; i++)
     74    delete this->material[i];
     75  delete []this->material;
    7176}
    7277
     78
     79void SkyBox::rebuild()
     80{
     81  if (this->model)
     82    delete model;
     83  model = new Model();
     84
     85  model->addVertex (-0.5*size, -0.5*size, 0.5*size);
     86  model->addVertex (0.5*size, -0.5*size, 0.5*size);
     87  model->addVertex (-0.5*size, 0.5*size, 0.5*size);
     88  model->addVertex (0.5*size, 0.5*size, 0.5*size);
     89  model->addVertex (-0.5*size, 0.5*size, -0.5*size);
     90  model->addVertex (0.5*size, 0.5*size, -0.5*size);
     91  model->addVertex (-0.5*size, -0.5*size, -0.5*size);
     92  model->addVertex (0.5*size, -0.5*size, -0.5*size);
     93
     94  model->addVertexTexture (0.0, 0.0);
     95  model->addVertexTexture (1.0, 0.0);
     96  model->addVertexTexture (0.0, 1.0);
     97  model->addVertexTexture (1.0, 1.0);
     98  model->addVertexTexture (0.0, 2.0);
     99  model->addVertexTexture (1.0, 2.0);
     100  model->addVertexTexture (0.0, 3.0);
     101  model->addVertexTexture (1.0, 3.0);
     102  model->addVertexTexture (0.0, 4.0);
     103  model->addVertexTexture (1.0, 4.0);
     104  model->addVertexTexture (2.0, 0.0);
     105  model->addVertexTexture (2.0, 1.0);
     106  model->addVertexTexture (-1.0, 0.0);
     107  model->addVertexTexture (-1.0, 1.0);
     108
     109  model->addVertexNormal (0.0, 0.0, 1.0);
     110  model->addVertexNormal (0.0, 0.0, 1.0);
     111  model->addVertexNormal (0.0, 0.0, 1.0);
     112  model->addVertexNormal (0.0, 0.0, 1.0);
     113  model->addVertexNormal (0.0, 1.0, 0.0);
     114  model->addVertexNormal (0.0, 1.0, 0.0);
     115  model->addVertexNormal (0.0, 1.0, 0.0);
     116  model->addVertexNormal (0.0, 1.0, 0.0);
     117  model->addVertexNormal (0.0, 0.0, -1.0);
     118  model->addVertexNormal (0.0, 0.0, -1.0);
     119  model->addVertexNormal (0.0, 0.0, -1.0);
     120  model->addVertexNormal (0.0, 0.0, -1.0);
     121  model->addVertexNormal (0.0, -1.0, 0.0);
     122  model->addVertexNormal (0.0, -1.0, 0.0);
     123  model->addVertexNormal (0.0, -1.0, 0.0);
     124  model->addVertexNormal (0.0, -1.0, 0.0);
     125  model->addVertexNormal (1.0, 0.0, 0.0);
     126  model->addVertexNormal (1.0, 0.0, 0.0);
     127  model->addVertexNormal (1.0, 0.0, 0.0);
     128  model->addVertexNormal (1.0, 0.0, 0.0);
     129  model->addVertexNormal (-1.0, 0.0, 0.0);
     130  model->addVertexNormal (-1.0, 0.0, 0.0);
     131  model->addVertexNormal (-1.0, 0.0, 0.0);
     132  model->addVertexNormal (-1.0, 0.0, 0.0);
     133
     134  model->addUseMtl(material[0]);
     135  model->addFace (4, 3, 1,1,1, 2,2,2, 4,4,3, 3,3,4);
     136  model->addUseMtl(material[1]);
     137  model->addFace (4, 3, 3,3,5, 4,4,6, 6,6,7, 5,5,8);
     138  model->addUseMtl(material[2]);
     139  model->addFace (4, 3, 5,5,9, 6,6,10, 8,8,11, 7,7,12);
     140  model->addUseMtl(material[3]);
     141  model->addFace (4, 3, 7,7,13, 8,8,14, 2,10,15, 1,9,16);
     142  model->addUseMtl(material[4]);
     143  model->addFace (4, 3, 2,2,17, 8,11,18, 6,12,19, 4,4,20);
     144  model->addUseMtl(material[5]);
     145  model->addFace (4, 3, 7,13,21, 1,1,22, 3,3,23, 5,14,24);
     146}
    73147
    74148/**
     
    76150   \param fileName The filename of the Texture
    77151*/
    78 void SkyBox::setTexture(char* fileName)
     152void SkyBox::setTexture(char* top, char* bottom, char* left, char* right, char* front, char* back)
    79153{
    80   this->material->setDiffuseMap(fileName);
     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);
    81160}
    82161
     
    94173  glTranslatef(r.x, r.y, r.z);
    95174
    96   this->material->select();
     175  this->material[1]->select();
    97176
    98177  this->model->draw();
  • orxonox/trunk/src/world_entities/skybox.h

    r3796 r3801  
    2626
    2727  void setSize(float size);
    28   void setTexture(char* fileName);
     28  void setTexture(char* top, char* bottom, char* left, char* right, char* front, char* back);
    2929
    3030  virtual void draw();
    3131
    32  private:
    33   Material *material;    //!< A Material for the Skybox.
     32 private:
     33  void rebuild();
     34
     35  Material **material;    //!< A Material for the Skybox.
    3436  float size;       //!< Radius of the Skybox. This should match the frustum maximum range.
    3537   
Note: See TracChangeset for help on using the changeset viewer.