Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Feb 14, 2009, 10:17:35 PM (15 years ago)
Author:
rgrieder
Message:

Merged presentation branch back to trunk.

Location:
code/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • code/trunk

  • code/trunk/src/orxonox/objects/worldentities/Light.h

    r2087 r2662  
    3131
    3232#include "OrxonoxPrereqs.h"
    33 #include "PositionableEntity.h"
     33#include "StaticEntity.h"
    3434
    3535#include <string>
     
    4040namespace orxonox
    4141{
    42     class _OrxonoxExport Light : public PositionableEntity
     42    class _OrxonoxExport Light : public StaticEntity
    4343    {
    4444        public:
     
    5454                { return this->light_; }
    5555
    56             const std::string& getName() const;
    57 
    5856            inline void setType(Ogre::Light::LightTypes type)
    59                 { this->type_ = type; this->changedType(); }
    60             Ogre::Light::LightTypes getType() const
     57                { this->type_ = type; this->updateType(); }
     58            inline Ogre::Light::LightTypes getType() const
    6159                { return this->type_; }
    6260
    63             void setDiffuseColour(const ColourValue& colour);
    64             const ColourValue& getDiffuseColour() const;
     61            inline void setDiffuseColour(const ColourValue& colour)
     62                { this->diffuse_ = colour; this->updateDiffuseColour(); }
     63            inline const ColourValue& getDiffuseColour() const
     64                { return this->diffuse_; }
    6565
    66             void setSpecularColour(const ColourValue& colour);
    67             const ColourValue& getSpecularColour() const;
     66            inline void setSpecularColour(const ColourValue& colour)
     67                { this->specular_ = colour; this->updateSpecularColour(); }
     68            inline const ColourValue& getSpecularColour() const
     69                { return this->specular_; }
    6870
    69             void setDirection(const Vector3& direction);
    70             const Vector3& getDirection() const;
     71            /**
     72                @brief Sets the attenuation parameters of the light source i.e. how it diminishes with distance.
     73
     74                @param attenuation.x range (The absolute upper range of the light in world units)
     75                @param attenuation.y constant (The constant factor in the attenuation formula: 1.0 means never attenuate, 0.0 is complete attenuation)
     76                @param attenuation.z linear (The linear factor in the attenuation formula: 1 means attenuate evenly over the distance)
     77                @param attenuation.w quadratic (The quadratic factor in the attenuation formula: adds a curvature to the attenuation formula)
     78
     79                Quote from the Ogre API:
     80                Lights normally get fainter the further they are away. Also, each light is given a maximum range beyond which it cannot affect any objects.
     81                Light attenuation is not applicable to directional lights since they have an infinite range and constant intensity.
     82                This follows a standard attenuation approach - see any good 3D text for the details of what they mean since i don't have room here!
     83
     84                Quote from the Ogre wiki:
     85                "Using these numbers, the light has 100% intensity at 0 distance, and
     86                trails off to near black at a distance equal to the Range. Keep in mind
     87                that most of the light falls in the first 20% of the range."
     88
     89                Range   Constant   Linear     Quadratic
     90                3250,     1.0,     0.0014,    0.000007
     91                600,      1.0,     0.007,     0.0002
     92                325,      1.0,     0.014,     0.0007
     93                200,      1.0,     0.022,     0.0019
     94                160,      1.0,     0.027,     0.0028
     95                100,      1.0,     0.045,     0.0075
     96                65,       1.0,     0.07,      0.017
     97                50,       1.0,     0.09,      0.032
     98                32,       1.0,     0.14,      0.07
     99                20,       1.0,     0.22,      0.20
     100                13,       1.0,     0.35,      0.44
     101                7,        1.0,     0.7,       1.8
     102            */
     103            inline void setAttenuation(const Vector4& attenuation)
     104                { this->attenuation_ = attenuation; this->updateAttenuation(); }
     105            inline const Vector4& getAttenuation() const
     106                { return this->attenuation_; }
     107
     108            /**
     109                @brief Sets the range of a spotlight, i.e. the angle of the inner and outer cones and the rate of falloff between them.
     110
     111                @param spotlightRange.x innerAngle (The angle covered by the bright inner cone)
     112                @param spotlightRange.x outerAngle (The angle covered by the outer cone)
     113                @param spotlightRange.x falloff (The rate of falloff between the inner and outer cones. 1.0 means a linear falloff, less means slower falloff, higher means faster falloff.)
     114            */
     115            inline void setSpotlightRange(const Vector3& spotlightRange)
     116                { this->spotlightRange_ = spotlightRange; this->updateSpotlightRange(); }
     117            inline const Vector3& getSpotlightRange() const
     118                { return this->spotlightRange_; }
    71119
    72120        private:
     
    74122            std::string getTypeString() const;
    75123
    76             void changedType();
     124            void updateType();
     125            void updateDiffuseColour();
     126            void updateSpecularColour();
     127            void updateAttenuation();
     128            void updateSpotlightRange();
    77129
    78             static unsigned int lightCounter_s;
    79130            Ogre::Light* light_;
    80131            Ogre::Light::LightTypes type_;
    81 
     132            ColourValue diffuse_;
     133            ColourValue specular_;
     134            Vector4 attenuation_;
     135            Vector3 spotlightRange_;
    82136    };
    83137}
Note: See TracChangeset for help on using the changeset viewer.