Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 3420 in orxonox.OLD


Ignore:
Timestamp:
Feb 22, 2005, 8:14:18 PM (19 years ago)
Author:
bensch
Message:

orxonox/trunk: skysphere: some new functionality.
now size and texture can be set externaly, but also get a default value:
radius: 200.0
texture: "../data/pictures/sky-replace.jpg"

Location:
orxonox/trunk/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • orxonox/trunk/src/skysphere.cc

    r3419 r3420  
    5454Skysphere::~Skysphere()
    5555{
    56   delete sky;
     56  delete skyMaterial;
    5757  free(sphereObj);
    5858}
     
    6464void Skysphere::initialize(char* fileName)
    6565{
    66   sphereObj=gluNewQuadric();
    67   gluQuadricTexture(sphereObj,GL_TRUE);
    68   sky = new Material("Sky");
    69   sky->setDiffuseMap(fileName);
    70   sky->setIllum(3);
    71   sky->setAmbient(.5, .5, 1.0);
     66  this->sphereObj = gluNewQuadric();
     67  gluQuadricTexture(this->sphereObj, GL_TRUE);
     68  this->setRadius(250.0);
     69
     70  this->skyMaterial = new Material("Sky");
     71  this->setTexture(fileName);
     72  this->skyMaterial->setIllum(3);
     73  this->skyMaterial->setAmbient(.5, .5, 1.0);
     74}
     75
     76/**
     77   \brief sets the Radius of the Sphere.
     78   \param radius The Radius of The Sphere
     79*/
     80void Skysphere::setRadius(float radius)
     81{
     82  this->sphereRadius = radius;
     83}
     84
     85/**
     86   \brief Defines which texture should be loaded onto the skysphere.
     87   \param fileName The filename of the Texture
     88*/
     89void Skysphere::setTexture(char* fileName)
     90{
     91  this->skyMaterial->setDiffuseMap(fileName);
    7292}
    7393
     
    93113void Skysphere::draw()
    94114{
    95   sky->select();
     115  skyMaterial->select();
    96116  glPushMatrix();
    97117  glTranslatef(this->sphereCenter.x,this->sphereCenter.y,this->sphereCenter.z);
    98118 
    99   glRotatef(-30,1,0,0);
    100   glRotatef(95.0f,0.0f,0.0f,1.0f);
    101   glRotatef(-250.0f,0.0,1.0f,0.0f);
     119  glRotatef(-30, 1, 0, 0);
     120  glRotatef(95.0f, 0.0f, 0.0f, 1.0f);
     121  glRotatef(-250.0f, 0.0, 1.0f, 0.0f);
    102122 
    103   gluSphere(sphereObj,200.0f,20,20);
     123  gluSphere(sphereObj, sphereRadius, 20, 20);
    104124  glPopMatrix();
    105125}
  • orxonox/trunk/src/skysphere.h

    r3419 r3420  
    2424{
    2525 private:
    26   GLUquadricObj *sphereObj;
    27   Vector sphereCenter; //!< Center of the Skysphere
    28   Material *sky;       //!< A Material for the Sky
    29  
     26  GLUquadricObj *sphereObj; //!< A Placeholder for the SkySphere.
     27  Material *skyMaterial;    //!< A Material for the SkySphere.
     28  Vector sphereCenter;      //!< Center of the SkySphere.
     29  float sphereRadius;       //!< Radius of the SkySphere. This should match the frustum maximum range.
     30
    3031 public:
    3132  Skysphere();
    3233  Skysphere(char* fileName);
    3334  ~Skysphere();
     35
     36  void setRadius(float radius);
     37  void setTexture(char* fileName);
    3438
    3539  void updatePosition(Vector sphereCenter);
Note: See TracChangeset for help on using the changeset viewer.