Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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


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

orxonox/trunk: some simple implementation of a SkyBox

File:
1 copied

Legend:

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

    r3794 r3796  
    2727
    2828
    29 #include "skysphere.h"
     29#include "skybox.h"
    3030#include "stdincl.h"
    3131
    3232#include "material.h"
    3333#include "vector.h"
     34#include "resource_manager.h"
     35#include "model.h"
    3436//#include "world_entity.h"
    3537
     
    3840
    3941/**
    40    \brief Constructs a SkySphere and takes fileName as a map.
    41    \param fileName the file to take as input for the skysphere
     42   \brief Constructs a SkyBox and takes fileName as a map.
     43   \param fileName the file to take as input for the SkyBox
    4244*/
    43 Skysphere::Skysphere(char* fileName)
     45SkyBox::SkyBox(char* fileName)
    4446{
    45   if (fileName == NULL)
    46     this->initialize("../data/pictures/sky-replace.jpg");
    47   else
    48     this->initialize(fileName);
     47  this->setClassName("SkyBox");
     48
     49
     50  this->model = (Model*)ResourceManager::getInstance()->load("cube", PRIM, RP_LEVEL);
     51  this->setMode(PNODE_MOVEMENT);
     52
     53  this->setSize(1900.0);
     54
     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
    4961}
    5062
     
    5365   \brief default destructor
    5466*/
    55 Skysphere::~Skysphere()
     67SkyBox::~SkyBox()
    5668{
    57   PRINTF(3)("Deleting the SkySphere\n");
    58   delete this->skyMaterial;
    59   free(this->sphereObj);
    60 }
    61 
    62 /**
    63    \brief initializes the Skysphere.
    64    \param fileName the file to take as input for the skysphere
    65 */
    66 void Skysphere::initialize(char* fileName)
    67 {
    68   PRINTF(1)("initializing the Skysphere with Material %s.\n", fileName);
    69   this->sphereObj = gluNewQuadric();
    70   this->setMode(PNODE_MOVEMENT);
    71 
    72   gluQuadricTexture(this->sphereObj, GL_TRUE);
    73   this->setRadius(1900.0);
    74 
    75   this->skyMaterial = new Material("Sky");
    76   this->setTexture(fileName);
    77   this->skyMaterial->setIllum(3);
    78   this->skyMaterial->setAmbient(1.0, 1.0, 1.0);
     69  PRINTF(3)("Deleting the SkyBox\n");
     70  delete this->material;
    7971}
    8072
    8173
    8274/**
    83    \brief Defines which texture should be loaded onto the skysphere.
     75   \brief Defines which texture should be loaded onto the SkyBox.
    8476   \param fileName The filename of the Texture
    8577*/
    86 void Skysphere::setTexture(char* fileName)
     78void SkyBox::setTexture(char* fileName)
    8779{
    88   this->skyMaterial->setDiffuseMap(fileName);
     80  this->material->setDiffuseMap(fileName);
    8981}
    9082
    9183
    9284/**
    93    \brief draws the Skysphere
     85   \brief draws the SkyBox
    9486   
    9587   This part is normally precessed in the "Painting Phase".
    9688*/
    97 void Skysphere::draw()
     89void SkyBox::draw()
    9890{
    9991  glPushMatrix();
     
    10294  glTranslatef(r.x, r.y, r.z);
    10395
    104   //glRotatef(-30, 1, 0, 0);
    105   //glRotatef(95.0f, 0.0f, 0.0f, 1.0f);
    106   //glRotatef(-250.0f, 0.0, 1.0f, 0.0f);
    107  
    108   skyMaterial->select();
    109   gluSphere(this->sphereObj, this->sphereRadius, 20, 20);
     96  this->material->select();
     97
     98  this->model->draw();
     99
    110100  glPopMatrix();
    111101}
     
    116106   \param radius The Radius of The Sphere
    117107*/
    118 void Skysphere::setRadius(float radius)
     108void SkyBox::setSize(float size)
    119109{
    120   this->sphereRadius = radius;
     110  this->size = size;
    121111}
Note: See TracChangeset for help on using the changeset viewer.