Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/environment2/src/orxonox/graphics/GodrayShader.cc @ 8557

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

Godrays: Safety commit. 90017 N8

File size: 3.8 KB
RevLine 
[8435]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 
[8557]32 @brief Implementation of the GodrayShader class.
[8435]33 */
34
35
[8557]36#include "GodrayShader.h"
37
[8435]38#include "util/Exception.h"
39#include "core/CoreIncludes.h"
40#include "core/XMLPort.h"
41
42namespace orxonox
43{
[8557]44    CreateFactory(GodrayShader);
[8435]45   
[8557]46    GodrayShader::GodrayShader(BaseObject* creator) : BaseObject(creator), globalShader_(creator)
[8435]47    {
[8557]48        RegisterObject(GodrayShader);
[8435]49       
[8557]50        // Default parameters are initialized
51        this->sunPosition_ = Vector3::Zero;
52        this->sunColor_ = ColourValue::White;
[8497]53        this->skyColor_ = ColourValue::Black;
[8557]54        this->exposure_ = 1.0f; 
[8491]55        this->decay_ = 0.1f;
56        this->density_ = 0.7f;
[8497]57       
[8557]58        // Godrays.compositor is getting initialized
59        this->globalShader_.getMutableShader().setCompositorName("Godrays");
60        this->compositor_ = this->globalShader_.getMutableShader().getMutableCompositorInstance();
[8435]61    }
62   
[8557]63    GodrayShader::~GodrayShader()
[8435]64    {
[8491]65        this->setVisible(false);
[8435]66    }
67   
[8557]68    void GodrayShader::tick(float dt)
[8491]69    {
[8557]70        if(this->isVisible())
71        {
72           
73            //Reset sunPosition in the compositor instance every tick
74            this->compositor_->getTechnique()->getTargetPass(2)
75        }
[8491]76    }
77   
[8557]78    void GodrayShader::XMLPort(Element& xmlelement, XMLPort::Mode mode)
[8435]79    {
[8557]80        SUPER(GodrayShader, XMLPort, xmlelement, mode);
[8435]81       
[8557]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);
[8435]87    }
[8491]88   
[8557]89    void GodrayShader::setWorldEntity(WorldEntity* worldEntity)
[8491]90    {
[8557]91        this->worldEntity_ = worldEntity;
92        this->setSunPosition(worldEntity->getWorldPosition());
93    }
94   
95    void GodrayShader::setSunPosition(const Vector3& position)
96    {
[8497]97        this->sunPosition_ = position;
[8491]98    }
[8557]99    void GodrayShader::setSunColor(const ColourValue& color)
[8491]100    {
[8497]101        this->skyColor_ = color;
[8491]102    }
[8557]103    void GodrayShader::setSkyColor(const ColourValue& color)
[8491]104    {
[8557]105        this->skyColor_ = color;
106    }
107    const Vector3& GodrayShader::getSunPosition() const
108    {
[8497]109        return this->sunPosition_;
[8491]110    }
[8557]111    const ColourValue& GodrayShader::getSunColor() const
[8491]112    {
[8557]113        return this->sunColor_;
114    }
115    const ColourValue& GodrayShader::getSkyColor() const
116    {
[8497]117        return this->skyColor_;
[8491]118    }
119   
[8557]120    void GodrayShader::changedVisibility()
[8491]121    {
[8557]122        SUPER(GodrayShader, changedVisibility);
[8491]123       
124        this->globalShader_.setVisible(this->isVisible());
125    }
[8435]126}
Note: See TracBrowser for help on using the repository browser.