Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Changeset 4734 in orxonox.OLD for orxonox/trunk/src/lib/graphics/light.cc


Ignore:
Timestamp:
Jun 29, 2005, 3:05:47 PM (20 years ago)
Author:
bensch
Message:

orxonox/trunk: light loadable

File:
1 edited

Legend:

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

    r4597 r4734  
    2323#include "vector.h"
    2424#include "debug.h"
     25#include "tinyxml.h"
     26#include "load_param.h"
     27#include "factory.h"
    2528
    2629using namespace std;
    2730
     31CREATE_FACTORY(Light);
     32
    2833//! Definition of the Lights
    29 int lightsV[] = {GL_LIGHT0, GL_LIGHT1, GL_LIGHT2, GL_LIGHT3, GL_LIGHT4, GL_LIGHT5, GL_LIGHT6, GL_LIGHT7};
     34int lightsV[] =
     35{
     36                  GL_LIGHT0,
     37                  GL_LIGHT1,
     38                  GL_LIGHT2,
     39                  GL_LIGHT3,
     40                  GL_LIGHT4,
     41                  GL_LIGHT5,
     42                  GL_LIGHT6,
     43                  GL_LIGHT7
     44};
    3045
    3146
     
    3449*/
    3550Light::Light(int lightNumber)
     51{
     52  this->init(lightNumber);
     53}
     54
     55/**
     56 * \param root The XML-element to load the Light from
     57 */
     58 Light::Light(const TiXmlElement* root)
     59{
     60  this->init(1);
     61  this->loadParams(root);
     62}
     63
     64/**
     65   \brief destroys a Light
     66*/
     67Light::~Light(void)
     68{
     69  glDisable(lightsV[this->lightNumber]);
     70}
     71
     72/**
     73 * \brief initializes a Light
     74 */
     75void Light::init(int lightNumber)
    3676{
    3777  this->setClassID(CL_LIGHT, "Light");
     
    4686  // set values (defaults)
    4787  this->lightNumber = lightNumber;
    48   this->setPosition(0.0, 0.0, 0.0);
     88  this->setPosition(0,0,0);
    4989  this->setDiffuseColor(1.0, 1.0, 1.0);
    5090  this->setSpecularColor(1.0, 1.0, 1.0);
    5191}
    5292
    53 
    54 /**
    55    \brief destroys a Light
    56 */
    57 Light::~Light(void)
    58 {
    59   glDisable(lightsV[this->lightNumber]);
    60 }
    61 
     93/**
     94 * \param root The XML-element to load the Light from
     95 */
     96void Light::loadParams(const TiXmlElement* root)
     97{
     98  static_cast<PNode*>(this)->loadParams(root);
     99
     100  LoadParam<Light>(root, "diffuse-color", this, &Light::setDiffuseColor)
     101      .describe("sets the diffuse color of the Light (red [0-1], green [0-1], blue [0-1])");
     102
     103  LoadParam<Light>(root, "specular-color", this, &Light::setSpecularColor)
     104      .describe("sets the specular color of the Light (red [0-1], green [0-1], blue [0-1])");
     105
     106  LoadParam<Light>(root, "spot-direction", this, &Light::setSpotDirection)
     107      .describe("sets the Direction of the Spot");
     108
     109  LoadParam<Light>(root, "spot-cutoff", this, &Light::setSpotCutoff)
     110      .describe("the cuttoff of the Spotlight");
     111}
    62112
    63113/**
     
    66116   \todo patrick: is it ok to set a Light Position even if it is derived from p_node??
    67117*/
    68 void Light::setPosition(Vector position)
     118void Light::setPosition(const Vector& position)
    69119{
    70120  this->lightPosition[0] = position.x;
     
    107157}
    108158
    109 
    110159/**
    111160   \brief sets an emitting Specular color of this Light
     
    147196   \param direction The direction of the Spot Light.
    148197*/
    149 void Light::setSpotDirection(Vector direction)
     198void Light::setSpotDirection(const Vector& direction)
    150199{
    151200  this->spotDirection[0] = direction.x;
Note: See TracChangeset for help on using the changeset viewer.