Changeset 8557
- Timestamp:
- May 24, 2011, 12:28:31 AM (14 years ago)
- Location:
- code/branches/environment2
- Files:
-
- 2 added
- 6 edited
- 2 moved
Legend:
- Unmodified
- Added
- Removed
-
code/branches/environment2/src/libraries/tools/Shader.h
r8079 r8557 89 89 inline Ogre::SceneManager* getSceneManager() const 90 90 { return this->scenemanager_; } 91 91 92 /// Returns the compositor instance. Normally used for manually modifiying compositor parameters, when mt-type conversatio. 93 inline Ogre::CompositorInstance* getMutableCompositorInstance() 94 { return this->compositorInstance_; } 95 92 96 virtual void cameraChanged(Ogre::Viewport* viewport, Ogre::Camera* oldCamera); 93 97 98 void setParameter(size_t technique, size_t pass, const std::string& parameter, int value); 94 99 void setParameter(size_t technique, size_t pass, const std::string& parameter, float value); 95 void setParameter(size_t technique, size_t pass, const std::string& parameter, int value);96 100 97 101 virtual void notifyMaterialRender(Ogre::uint32 pass_id, Ogre::MaterialPtr& materialPtr); -
code/branches/environment2/src/orxonox/OrxonoxPrereqs.h
r8435 r8557 111 111 class FadingBillboard; 112 112 class GlobalShader; 113 class G lobalGodrayShader;113 class GodrayShader; 114 114 class Light; 115 115 class Model; -
code/branches/environment2/src/orxonox/graphics/CMakeLists.txt
r8435 r8557 4 4 FadingBillboard.cc 5 5 GlobalShader.cc 6 G lobalGodrayShader.cc6 GodrayShader.cc 7 7 MeshLodInformation.cc 8 8 Model.cc … … 10 10 ParticleEmitter.cc 11 11 ParticleSpawner.cc 12 WorldEntityShader.cc 12 13 COMPILATION_BEGIN GraphicsCompilation.cc 13 14 Backlight.cc -
code/branches/environment2/src/orxonox/graphics/GlobalShader.h
r8079 r8557 50 50 inline const Shader& getShader() const 51 51 { return this->shader_; } 52 53 inline Shader& getMutableShader() 54 { return this->shader_; } 52 55 53 56 private: -
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()); -
code/branches/environment2/src/orxonox/graphics/GodrayShader.h
r8497 r8557 31 31 @file 32 32 33 @brief Header of the G lobalGodrayShader class.33 @brief Header of the GodrayShader class. 34 34 */ 35 35 36 36 37 #ifndef _G lobalGodrayShader_H__38 #define _G lobalGodrayShader_H__37 #ifndef _GodrayShader_H__ 38 #define _GodrayShader_H__ 39 39 40 40 #include "OrxonoxPrereqs.h" 41 42 #include <OgreCompositorInstance.h> 41 43 42 44 #include "tools/interfaces/Tickable.h" 43 45 #include "core/BaseObject.h" 44 46 #include "util/Math.h" 47 #include "WorldEntity.h" 45 48 #include "GlobalShader.h" 46 49 … … 52 55 53 56 */ 54 class _OrxonoxExport G lobalGodrayShader : public BaseObject, public Tickable57 class _OrxonoxExport GodrayShader : public BaseObject, public Tickable 55 58 { 56 59 public: 57 G lobalGodrayShader(BaseObject* creator);58 virtual ~G lobalGodrayShader();60 GodrayShader(BaseObject* creator); 61 virtual ~GodrayShader(); 59 62 60 63 virtual void tick(float dt); 64 65 virtual void updateParameters(); 61 66 62 67 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 63 68 64 69 virtual void changedVisibility(); 70 71 void setWorldEntity(WorldEntity* worldEntity); 65 72 66 73 inline const GlobalShader& getGlobalShader() const … … 68 75 69 76 void setSunPosition(const Vector3& position); 77 void setSunColor(const ColourValue& color); 70 78 void setSkyColor(const ColourValue& color); 71 79 const Vector3& getSunPosition() const; 80 const ColourValue& getSunColor() const; 72 81 const ColourValue& getSkyColor() const; 73 82 74 83 private: 75 84 85 WorldEntity* worldEntity_; 76 86 GlobalShader globalShader_; 77 87 Ogre::CompositorInstance* compositor_; 78 88 Vector3 sunPosition_; 89 ColourValue sunColor_; 79 90 ColourValue skyColor_; 80 91 float exposure_; … … 84 95 } 85 96 86 #endif /* _G lobalGodrayShader_H__ */97 #endif /* _GodrayShader_H__ */ -
code/branches/environment2/src/orxonox/worldentities/WorldEntity.cc
r7937 r8557 177 177 // Attached collision shapes 178 178 XMLPortObject(WorldEntity, CollisionShape, "collisionShapes", attachCollisionShape, getAttachedCollisionShape, xmlelement, mode); 179 // Attach WorldEntityShaders that depend on WorldEntity data (e.g. position). -- TODO -- Extend to WorldEntityShader. 180 XMLPortObject(WorldEntity, GodrayShader, "shaders", attachShader, getAttachedObject, xmlelement, mode); 179 181 } 180 182 … … 510 512 return 0; 511 513 } 514 515 void WorldEntity::attachShader(GodrayShader* object) 516 { 517 object->setWorldEntity(object); 518 519 this->shaders_.insert(object); 520 } 521 void WorldEntity::detachShader(GodrayShader* object) 522 { 523 std::set<WorldEntity*>::iterator it = this->children_.find(object); 524 this->shaders_.erase(it); 525 526 } 527 GodrayShader* WorldEntity::getAttachedShader(unsigned int index) 528 { 529 unsigned int i = 0; 530 for (std::set<WorldEntity*>::const_iterator it = this->children_.begin(); it != this->children_.end(); ++it) 531 { 532 if (i == index) 533 return (*it); 534 ++i; 535 } 536 return 0; 537 } 512 538 513 539 //! Attaches an Ogre::SceneNode to this WorldEntity. -
code/branches/environment2/src/orxonox/worldentities/WorldEntity.h
r7910 r8557 199 199 void attachToNode(Ogre::SceneNode* node); 200 200 void detachFromNode(Ogre::SceneNode* node); 201 202 void attachShader(GodrayShader* object); 203 void detachShader(GodrayShader* object); 204 GodrayShader* getAttachedShader(unsigned int index); 205 inline const std::set<WorldEntity*>& getAttachedShaders() const 206 { return this->shaders_; } 201 207 202 208 inline void setDeleteWithParent(bool value) … … 234 240 unsigned int parentID_; 235 241 std::set<WorldEntity*> children_; 242 std::set<WorldEntity*> shaders_; 236 243 bool bDeleteWithParent_; 237 244
Note: See TracChangeset
for help on using the changeset viewer.