Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/archive/environment2/src/orxonox/graphics/GodrayShader.cc @ 12373

Last change on this file since 12373 was 8557, checked in by marwegma, 14 years ago

Godrays: Safety commit. 90017 N8

File size: 3.8 KB
Line 
1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *                    > www.orxonox.net <
4 *
5 *
6 *   License notice:
7 *
8 *   This program is free software; you can redistribute it and/or
9 *   modify it under the terms of the GNU General Public License
10 *   as published by the Free Software Foundation; either version 2
11 *   of the License, or (at your option) any later version.
12 *
13 *   This program is distributed in the hope that it will be useful,
14 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
15 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 *   GNU General Public License for more details.
17 *
18 *   You should have received a copy of the GNU General Public License
19 *   along with this program; if not, write to the Free Software
20 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21 *
22 *   Author:
23 *      Markus 'atok' Wegmann
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29/**
30 @file
31 
32 @brief Implementation of the GodrayShader class.
33 */
34
35
36#include "GodrayShader.h"
37
38#include "util/Exception.h"
39#include "core/CoreIncludes.h"
40#include "core/XMLPort.h"
41
42namespace orxonox
43{
44    CreateFactory(GodrayShader);
45   
46    GodrayShader::GodrayShader(BaseObject* creator) : BaseObject(creator), globalShader_(creator)
47    {
48        RegisterObject(GodrayShader);
49       
50        // Default parameters are initialized
51        this->sunPosition_ = Vector3::Zero;
52        this->sunColor_ = ColourValue::White;
53        this->skyColor_ = ColourValue::Black;
54        this->exposure_ = 1.0f; 
55        this->decay_ = 0.1f;
56        this->density_ = 0.7f;
57       
58        // Godrays.compositor is getting initialized
59        this->globalShader_.getMutableShader().setCompositorName("Godrays");
60        this->compositor_ = this->globalShader_.getMutableShader().getMutableCompositorInstance();
61    }
62   
63    GodrayShader::~GodrayShader()
64    {
65        this->setVisible(false);
66    }
67   
68    void GodrayShader::tick(float dt)
69    {
70        if(this->isVisible())
71        {
72           
73            //Reset sunPosition in the compositor instance every tick
74            this->compositor_->getTechnique()->getTargetPass(2)
75        }
76    }
77   
78    void GodrayShader::XMLPort(Element& xmlelement, XMLPort::Mode mode)
79    {
80        SUPER(GodrayShader, XMLPort, xmlelement, mode);
81       
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);
87    }
88   
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)
96    {
97        this->sunPosition_ = position;
98    }
99    void GodrayShader::setSunColor(const ColourValue& color)
100    {
101        this->skyColor_ = color;
102    }
103    void GodrayShader::setSkyColor(const ColourValue& color)
104    {
105        this->skyColor_ = color;
106    }
107    const Vector3& GodrayShader::getSunPosition() const
108    {
109        return this->sunPosition_;
110    }
111    const ColourValue& GodrayShader::getSunColor() const
112    {
113        return this->sunColor_;
114    }
115    const ColourValue& GodrayShader::getSkyColor() const
116    {
117        return this->skyColor_;
118    }
119   
120    void GodrayShader::changedVisibility()
121    {
122        SUPER(GodrayShader, changedVisibility);
123       
124        this->globalShader_.setVisible(this->isVisible());
125    }
126}
Note: See TracBrowser for help on using the repository browser.