- Timestamp:
- May 24, 2011, 12:28:31 AM (13 years ago)
- File:
-
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
code/branches/environment2/src/orxonox/graphics/GodrayShader.cc
r8497 r8557 30 30 @file 31 31 32 @brief Implementation of the G lobalGodrayShader class.32 @brief Implementation of the GodrayShader class. 33 33 */ 34 34 35 #include "GlobalGodrayShader.h" 35 36 #include "GodrayShader.h" 36 37 37 38 #include "util/Exception.h" … … 41 42 namespace orxonox 42 43 { 43 CreateFactory(G lobalGodrayShader);44 CreateFactory(GodrayShader); 44 45 45 G lobalGodrayShader::GlobalGodrayShader(BaseObject* creator) : BaseObject(creator), globalShader_(creator)46 GodrayShader::GodrayShader(BaseObject* creator) : BaseObject(creator), globalShader_(creator) 46 47 { 47 RegisterObject(G lobalGodrayShader);48 RegisterObject(GodrayShader); 48 49 49 if (!this->getScene()) 50 ThrowException(AbortLoading, "Can't create GlobalGodrayShader, no scene given."); 51 // if (!this->getScene()->getSceneManager()) 52 // ThrowException(AbortLoading, "Can't create GlobalGodrayShader, no scene manager given."); 53 50 // Default parameters are initialized 51 this->sunPosition_ = Vector3::Zero; 52 this->sunColor_ = ColourValue::White; 54 53 this->skyColor_ = ColourValue::Black; 55 this->exposure_ = 1.0f; 54 this->exposure_ = 1.0f; 56 55 this->decay_ = 0.1f; 57 56 this->density_ = 0.7f; 58 57 59 //// Init //// 58 // Godrays.compositor is getting initialized 59 this->globalShader_.getMutableShader().setCompositorName("Godrays"); 60 this->compositor_ = this->globalShader_.getMutableShader().getMutableCompositorInstance(); 60 61 } 61 62 62 G lobalGodrayShader::~GlobalGodrayShader()63 GodrayShader::~GodrayShader() 63 64 { 64 65 this->setVisible(false); 65 66 } 66 67 67 void G lobalGodrayShader::tick(float dt)68 void GodrayShader::tick(float dt) 68 69 { 69 // To-Do 70 if(this->isVisible()) 71 { 72 73 //Reset sunPosition in the compositor instance every tick 74 this->compositor_->getTechnique()->getTargetPass(2) 75 } 70 76 } 71 77 72 void G lobalGodrayShader::XMLPort(Element& xmlelement, XMLPort::Mode mode)78 void GodrayShader::XMLPort(Element& xmlelement, XMLPort::Mode mode) 73 79 { 74 SUPER(G lobalGodrayShader, XMLPort, xmlelement, mode);80 SUPER(GodrayShader, XMLPort, xmlelement, mode); 75 81 76 XMLPortParamTemplate(G lobalGodrayShader, "sunPosition", setSunPosition, getSunPosition, xmlelement, mode, const Vector3&);77 XMLPortParamTemplate(G lobalGodrayShader, "skyColor", setSkyColor, getSkyColor, xmlelement, mode, const ColourValue&);78 XMLPortParamVariable(G lobalGodrayShader, "exposure", exposure_, xmlelement, mode);79 XMLPortParamVariable(G lobalGodrayShader, "decay", decay_, xmlelement, mode);80 XMLPortParamVariable(G lobalGodrayShader, "density", density_, xmlelement, mode);82 XMLPortParamTemplate(GodrayShader, "sunColor", setSunColor, getSunColor, xmlelement, mode, const ColourValue&); 83 XMLPortParamTemplate(GodrayShader, "skyColor", setSkyColor, getSkyColor, xmlelement, mode, const ColourValue&); 84 XMLPortParamVariable(GodrayShader, "exposure", exposure_, xmlelement, mode); 85 XMLPortParamVariable(GodrayShader, "decay", decay_, xmlelement, mode); 86 XMLPortParamVariable(GodrayShader, "density", density_, xmlelement, mode); 81 87 } 82 88 83 void GlobalGodrayShader::setSunPosition(const Vector3& position) 89 void GodrayShader::setWorldEntity(WorldEntity* worldEntity) 90 { 91 this->worldEntity_ = worldEntity; 92 this->setSunPosition(worldEntity->getWorldPosition()); 93 } 94 95 void GodrayShader::setSunPosition(const Vector3& position) 84 96 { 85 97 this->sunPosition_ = position; 86 98 } 87 void G lobalGodrayShader::setSkyColor(const ColourValue& color)99 void GodrayShader::setSunColor(const ColourValue& color) 88 100 { 89 101 this->skyColor_ = color; 90 102 } 91 const Vector3& GlobalGodrayShader::getSunPosition() const 103 void GodrayShader::setSkyColor(const ColourValue& color) 104 { 105 this->skyColor_ = color; 106 } 107 const Vector3& GodrayShader::getSunPosition() const 92 108 { 93 109 return this->sunPosition_; 94 110 } 95 const ColourValue& GlobalGodrayShader::getSkyColor() const 111 const ColourValue& GodrayShader::getSunColor() const 112 { 113 return this->sunColor_; 114 } 115 const ColourValue& GodrayShader::getSkyColor() const 96 116 { 97 117 return this->skyColor_; 98 118 } 99 119 100 void G lobalGodrayShader::changedVisibility()120 void GodrayShader::changedVisibility() 101 121 { 102 SUPER(G lobalGodrayShader, changedVisibility);122 SUPER(GodrayShader, changedVisibility); 103 123 104 124 this->globalShader_.setVisible(this->isVisible());
Note: See TracChangeset
for help on using the changeset viewer.