Changeset 10996 for code/branches/cpp11_v2/src/orxonox
- Timestamp:
- Dec 30, 2015, 11:59:18 AM (9 years ago)
- Location:
- code/branches/cpp11_v2/src/orxonox/graphics
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/cpp11_v2/src/orxonox/graphics/Light.cc
r10774 r10996 44 44 45 45 // Be sure we don't do bad conversions 46 static_assert((int)Ogre::Light::LT_POINT == (int)Light:: Point, "check enum");47 static_assert((int)Ogre::Light::LT_DIRECTIONAL == (int)Light:: Directional, "check enum");48 static_assert((int)Ogre::Light::LT_SPOTLIGHT == (int)Light:: Spotlight, "check enum");46 static_assert((int)Ogre::Light::LT_POINT == (int)Light::Type::Point, "check enum"); 47 static_assert((int)Ogre::Light::LT_DIRECTIONAL == (int)Light::Type::Directional, "check enum"); 48 static_assert((int)Ogre::Light::LT_SPOTLIGHT == (int)Light::Type::Spotlight, "check enum"); 49 49 50 50 Light::Light(Context* context) : StaticEntity(context) … … 55 55 this->diffuse_ = ColourValue::White; 56 56 this->specular_ = ColourValue::White; 57 this->type_ = Light::Point;57 this->type_ = Type::Point; 58 58 this->attenuation_ = Vector4(100000, 1, 0, 0); 59 59 this->spotlightRange_ = Vector3(40.0f, 30.0f, 1.0f); … … 105 105 void Light::registerVariables() 106 106 { 107 registerVariable( (int&)this->type_,VariableDirection::ToClient, new NetworkCallback<Light>(this, &Light::updateType));107 registerVariable(this->type_, VariableDirection::ToClient, new NetworkCallback<Light>(this, &Light::updateType)); 108 108 registerVariable(this->diffuse_, VariableDirection::ToClient, new NetworkCallback<Light>(this, &Light::updateDiffuseColour)); 109 109 registerVariable(this->specular_, VariableDirection::ToClient, new NetworkCallback<Light>(this, &Light::updateSpecularColour)); … … 126 126 void Light::updateAttenuation() 127 127 { 128 if (this->light_ && this->type_ != Light::Directional)128 if (this->light_ && this->type_ != Type::Directional) 129 129 this->light_->setAttenuation(this->attenuation_.x, this->attenuation_.y, this->attenuation_.z, this->attenuation_.w); 130 130 } … … 132 132 void Light::updateSpotlightRange() 133 133 { 134 if (this->light_ && this->type_ == Light::Spotlight)134 if (this->light_ && this->type_ == Type::Spotlight) 135 135 this->light_->setSpotlightRange(Degree(this->spotlightRange_.x), Degree(this->spotlightRange_.y), this->spotlightRange_.z); 136 136 } … … 139 139 { 140 140 if (type == "point") 141 this->setType( Light::Point);141 this->setType(Type::Point); 142 142 else if (type == "directional") 143 this->setType( Light::Directional);143 this->setType(Type::Directional); 144 144 else if (type == "spotlight") 145 this->setType( Light::Spotlight);145 this->setType(Type::Spotlight); 146 146 else 147 this->setType( Light::Point);147 this->setType(Type::Point); 148 148 } 149 149 … … 152 152 switch (this->type_) 153 153 { 154 case Light::Directional:154 case Type::Directional: 155 155 return "directional"; 156 case Light::Spotlight:156 case Type::Spotlight: 157 157 return "spotlight"; 158 case Light::Point:158 case Type::Point: 159 159 default: 160 160 return "point"; … … 168 168 this->light_->setType(static_cast<Ogre::Light::LightTypes>(this->type_)); 169 169 170 if (this->type_ != Light::Directional)170 if (this->type_ != Type::Directional) 171 171 this->updateAttenuation(); 172 if (this->type_ == Light::Spotlight)172 if (this->type_ == Type::Spotlight) 173 173 this->updateSpotlightRange(); 174 174 } -
code/branches/cpp11_v2/src/orxonox/graphics/Light.h
r10817 r10996 42 42 { 43 43 public: 44 enum LightTypes// Copy from the Ogre enum44 enum class Type // Copy from the Ogre enum 45 45 { 46 46 /// Point light sources give off light equally in all directions, so require only position not direction … … 63 63 { return this->light_; } 64 64 65 inline void setType(Light:: LightTypestype)65 inline void setType(Light::Type type) 66 66 { this->type_ = type; this->updateType(); } 67 inline Light:: LightTypesgetType() const67 inline Light::Type getType() const 68 68 { return this->type_; } 69 69 … … 144 144 145 145 Ogre::Light* light_; 146 Light Typestype_;146 Light::Type type_; 147 147 ColourValue diffuse_; 148 148 ColourValue specular_;
Note: See TracChangeset
for help on using the changeset viewer.