Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3803 in orxonox.OLD


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

orxonox/trunk: SkyBox even better,

world-entity implements a draw function of its own

some other minor stuff

Location:
orxonox/trunk/src
Files:
7 edited

Legend:

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

    r3790 r3803  
    326326   \param dMap the Name of the Image to Use
    327327*/
    328 void Material::setDiffuseMap(char* dMap)
     328void Material::setDiffuseMap(const char* dMap)
    329329{
    330330  PRINTF(4)("setting Diffuse Map %s\n", dMap);
     
    342342   \todo implement this
    343343*/
    344 void Material::setAmbientMap(char* aMap)
     344void Material::setAmbientMap(const char* aMap)
    345345{
    346346  SDL_Surface* ambientMap;
     
    353353   \todo implement this
    354354*/
    355 void Material::setSpecularMap(char* sMap)
     355void Material::setSpecularMap(const char* sMap)
    356356{
    357357  SDL_Surface* specularMap;
     
    364364   \todo implemet this
    365365*/
    366 void Material::setBump(char* bump)
    367 {
    368 
    369 }
     366void Material::setBump(const char* bump)
     367{
     368
     369}
  • orxonox/trunk/src/lib/graphics/importer/material.h

    r3790 r3803  
    4848  void addTexturePath(char* pathName);
    4949 // MAPPING //
    50   void setDiffuseMap(char* dMap);
    51   void setAmbientMap(char* aMap);
    52   void setSpecularMap(char* sMap);
    53   void setBump(char* bump);
     50  void setDiffuseMap(const char* dMap);
     51  void setAmbientMap(const char* aMap);
     52  void setSpecularMap(const char* sMap);
     53  void setBump(const char* bump);
    5454
    5555 private:
  • orxonox/trunk/src/story_entities/world.cc

    r3801 r3803  
    3030#include "environment.h"
    3131#include "skysphere.h"
     32#include "skybox.h"
    3233#include "satellite.h"
    3334#include "terrain.h"
     
    327328
    328329            // Create SkySphere
    329             this->skySphere = new Skysphere("../data/pictures/sky-replace.jpg");
    330             this->skySphere->setName("SkySphere");
    331             this->localCamera->addChild(this->skySphere);
    332             this->spawn(this->skySphere);
     330            //      this->skySphere = new Skysphere("../data/pictures/sky-replace.jpg");
     331            //      this->skySphere->setName("SkySphere");
     332            //      this->localCamera->addChild(this->skySphere);
     333            //      this->spawn(this->skySphere);
     334            skyBox = new SkyBox();
     335            this->spawn(skyBox);
    333336
    334337            /*monitor progress*/
  • orxonox/trunk/src/story_entities/world.h

    r3795 r3803  
    2020class GLMenuImageScreen;
    2121class Skysphere;
     22class SkyBox;
    2223class LightManager;
    2324class Terrain;
     
    109110  Camera* localCamera;                //!< The current Camera
    110111  Skysphere* skySphere;               //!< The Environmental Heaven of orxonox \todo insert this to environment insted
     112  SkyBox* skyBox;
    111113  LightManager* lightMan;             //!< The Lights of the Level
    112114  Terrain* terrain;                   //!< The Terrain of the World.
  • 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}
  • orxonox/trunk/src/world_entities/skybox.h

    r3801 r3803  
    2626
    2727  void setSize(float size);
    28   void setTexture(char* top, char* bottom, char* left, char* right, char* front, char* back);
    29 
    30   virtual void draw();
     28  void setTexture(const char* name, const char* extension);
     29  void setTextures(const char* top, const char* bottom, const char* left, const char* right, const char* front, const char* back);
    3130
    3231 private:
    3332  void rebuild();
     33 
    3434
    3535  Material **material;    //!< A Material for the Skybox.
  • orxonox/trunk/src/world_entities/world_entity.cc

    r3755 r3803  
    1919
    2020#include "world_entity.h"
    21 #include "objModel.h"
     21#include "model.h"
    2222#include "list.h"
     23#include "vector.h"
    2324
    2425//#include "stdincl.h"
     
    4142  this->setClassName ("WorldEntity");
    4243  this->bDraw = true;
    43   //this->model = NULL;
     44  this->model = NULL;
    4445  //  collisioncluster = NULL;
    4546}
     
    171172   Handle all stuff that should update with time inside this method (movement, animation, etc.)
    172173*/
    173 inline void WorldEntity::tick(float time)
     174void WorldEntity::tick(float time)
    174175{
    175176}
     
    181182   This is a central function of an entity: call it to let the entity painted to the screen. Just override this function with whatever you want to be drawn.
    182183*/
    183 inline void WorldEntity::draw()
    184 {}
     184void WorldEntity::draw()
     185{
     186  glMatrixMode(GL_MODELVIEW);
     187  glPushMatrix();
     188  float matrix[4][4];
     189 
     190  /* translate */
     191  glTranslatef (this->getAbsCoor ().x,
     192                this->getAbsCoor ().y,
     193                this->getAbsCoor ().z);
     194  /* rotate */
     195  this->getAbsDir ().matrix (matrix);
     196  glMultMatrixf((float*)matrix);
     197
     198  if (this->model)
     199    this->model->draw();
     200  glPopMatrix();
     201}
    185202
    186203
Note: See TracChangeset for help on using the changeset viewer.