Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


Ignore:
Timestamp:
May 10, 2005, 12:06:20 AM (20 years ago)
Author:
bensch
Message:

orxonox/trunk: skyModel now gets unloaded/loaded for real. There was some danger, when loading a model into a WorldEntity not using the resourceManager. so this should not be done anymore.
maybe i will write a fix to the ResourceManager, enabling it, to also load pointers to user-space-defined Variables… we'll see

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

Legend:

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

    r4112 r4136  
    6666      PRINTF(0)("SkyBox is missing a proper 'MaterialSet'\n");
    6767    }
    68   if( this->model == NULL)
     68  if( this->skyModel == NULL)
    6969    {
    7070      PRINTF(0)("SkyBox model '%s' could not be loaded\n", string);
     
    7676{
    7777  this->setClassName("SkyBox");
     78  this->skyModel = NULL;
    7879  this->material = new Material*[6];
    79   for (int i = 0; i <6; i++)
     80  for (int i = 0; i < 6; i++)
    8081    {
    8182      this->material[i] = new Material();
     
    100101SkyBox::~SkyBox()
    101102{
    102   PRINTF(5)("Deleting the SkyBox\n");
     103  PRINTF(5)("Deleting SkyBox\n");
    103104  for (int i = 0; i < 6; i++)
    104105    delete this->material[i];
     
    179180  glTranslatef(r.x, r.y, r.z);
    180181
    181   this->model->draw();
     182  this->skyModel->draw();
    182183
    183184  glPopMatrix();
     
    192193void SkyBox::rebuild()
    193194{
    194   if (this->model)
    195     delete model;
    196   model = new Model();
    197 
    198   model->addVertex (-0.5*size, -0.5*size, 0.5*size); 
    199   model->addVertex (0.5*size, -0.5*size, 0.5*size);
    200   model->addVertex (-0.5*size, 0.5*size, 0.5*size);
    201   model->addVertex (0.5*size, 0.5*size, 0.5*size);
    202   model->addVertex (-0.5*size, 0.5*size, -0.5*size);
    203   model->addVertex (0.5*size, 0.5*size, -0.5*size);
    204   model->addVertex (-0.5*size, -0.5*size, -0.5*size);
    205   model->addVertex (0.5*size, -0.5*size, -0.5*size);
    206 
    207   model->addVertexTexture (0.0, 0.0);
    208   model->addVertexTexture (1.0, 0.0);
    209   model->addVertexTexture (1.0, 1.0);
    210   model->addVertexTexture (0.0, 1.0);
    211 
    212   model->addVertexNormal (0.0, 0.0, 1.0);
    213   model->addVertexNormal (0.0, 1.0, 0.0);
    214   model->addVertexNormal (0.0, 0.0, -1.0);
    215   model->addVertexNormal (0.0, -1.0, 0.0);
    216   model->addVertexNormal (1.0, 0.0, 0.0);
    217   model->addVertexNormal (-1.0, 0.0, 0.0);
    218 
    219   model->setMaterial(material[0]);
    220   model->addFace (4, VERTEX_TEXCOORD_NORMAL, 2,1,3, 3,2,3, 5,3,3, 4,0,3); // top
    221   model->setMaterial(material[1]);
    222   model->addFace (4, VERTEX_TEXCOORD_NORMAL, 6,3,1, 7,0,1, 1,1,1, 0,2,1); // bottom
    223   model->setMaterial(material[2]);
    224   model->addFace (4, VERTEX_TEXCOORD_NORMAL, 0,0,2, 1,1,2, 3,2,2, 2,3,2); // left
    225   model->setMaterial(material[3]);
    226   model->addFace (4, VERTEX_TEXCOORD_NORMAL, 4,2,0, 5,3,0, 7,0,0, 6,1,0); // right
    227   model->setMaterial(material[4]);
    228   model->addFace (4, VERTEX_TEXCOORD_NORMAL, 1,0,5, 7,1,5, 5,2,5, 3,3,6); // front
    229   model->setMaterial(material[5]);
    230   model->addFace (4, VERTEX_TEXCOORD_NORMAL, 6,0,4, 0,1,4, 2,2,4, 4,3,4); // back
     195  if (this->skyModel)
     196    delete skyModel;
     197  skyModel = new Model();
     198
     199  this->skyModel->addVertex (-0.5*size, -0.5*size, 0.5*size); 
     200  this->skyModel->addVertex (0.5*size, -0.5*size, 0.5*size);
     201  this->skyModel->addVertex (-0.5*size, 0.5*size, 0.5*size);
     202  this->skyModel->addVertex (0.5*size, 0.5*size, 0.5*size);
     203  this->skyModel->addVertex (-0.5*size, 0.5*size, -0.5*size);
     204  this->skyModel->addVertex (0.5*size, 0.5*size, -0.5*size);
     205  this->skyModel->addVertex (-0.5*size, -0.5*size, -0.5*size);
     206  this->skyModel->addVertex (0.5*size, -0.5*size, -0.5*size);
     207
     208  this->skyModel->addVertexTexture (0.0, 0.0);
     209  this->skyModel->addVertexTexture (1.0, 0.0);
     210  this->skyModel->addVertexTexture (1.0, 1.0);
     211  this->skyModel->addVertexTexture (0.0, 1.0);
     212
     213  this->skyModel->addVertexNormal (0.0, 0.0, 1.0);
     214  this->skyModel->addVertexNormal (0.0, 1.0, 0.0);
     215  this->skyModel->addVertexNormal (0.0, 0.0, -1.0);
     216  this->skyModel->addVertexNormal (0.0, -1.0, 0.0);
     217  this->skyModel->addVertexNormal (1.0, 0.0, 0.0);
     218  this->skyModel->addVertexNormal (-1.0, 0.0, 0.0);
     219
     220  this->skyModel->setMaterial(material[0]);
     221  this->skyModel->addFace (4, VERTEX_TEXCOORD_NORMAL, 2,1,3, 3,2,3, 5,3,3, 4,0,3); // top
     222  this->skyModel->setMaterial(material[1]);
     223  this->skyModel->addFace (4, VERTEX_TEXCOORD_NORMAL, 6,3,1, 7,0,1, 1,1,1, 0,2,1); // bottom
     224  this->skyModel->setMaterial(material[2]);
     225  this->skyModel->addFace (4, VERTEX_TEXCOORD_NORMAL, 0,0,2, 1,1,2, 3,2,2, 2,3,2); // left
     226  this->skyModel->setMaterial(material[3]);
     227  this->skyModel->addFace (4, VERTEX_TEXCOORD_NORMAL, 4,2,0, 5,3,0, 7,0,0, 6,1,0); // right
     228  this->skyModel->setMaterial(material[4]);
     229  this->skyModel->addFace (4, VERTEX_TEXCOORD_NORMAL, 1,0,5, 7,1,5, 5,2,5, 3,3,6); // front
     230  this->skyModel->setMaterial(material[5]);
     231  this->skyModel->addFace (4, VERTEX_TEXCOORD_NORMAL, 6,0,4, 0,1,4, 2,2,4, 4,3,4); // back
    231232 
    232   model->finalize();
    233 }
     233  this->skyModel->finalize();
     234}
  • orxonox/trunk/src/world_entities/skybox.h

    r4012 r4136  
    3939  void rebuild();
    4040
     41  Model* skyModel;        //!< A Model for the Sky. This must not be the same as the Model from WorldEntity, because it is not alocated through the ResourceManager.
    4142  Material **material;    //!< Materials for the SkyBox. sorted by number (0-5) top, bottom, left, right, front, back
    4243  float size;             //!< Size of the SkyBox. This should match the frustum maximum range.
  • orxonox/trunk/src/world_entities/terrain.cc

    r3677 r4136  
    7777void Terrain::init(void)
    7878{
    79    this->setClassName ("Terrain");
    80 
    81    this->objectList = 0;
     79  this->setClassName ("Terrain");
     80 
     81  this->objectList = 0;
    8282}
    8383
     
    9898  glMultMatrixf((float*)matrix);
    9999
    100   if (objectList)
    101     glCallList(objectList);
    102   else if (model)
    103     model->draw();
    104   //  this->model->draw();
     100  if (this->objectList)
     101    glCallList(this->objectList);
     102  else if (this->model)
     103    this->model->draw();
    105104  glPopMatrix();
    106105}
Note: See TracChangeset for help on using the changeset viewer.