Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/gui/src/orxonox/objects/worldentities/Billboard.cc @ 2961

Last change on this file since 2961 was 2848, checked in by rgrieder, 16 years ago

Exported showsGraphics, etc. to a new class named GameMode in the core.

  • Property svn:eol-style set to native
File size: 3.7 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 *      Fabian 'x3n' Landau
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29#include "OrxonoxStableHeaders.h"
30#include "Billboard.h"
31
32#include <OgreBillboardSet.h>
33
34#include "core/CoreIncludes.h"
35#include "core/XMLPort.h"
36#include "core/GameMode.h"
37#include "objects/Scene.h"
38
39namespace orxonox
40{
41    CreateFactory(Billboard);
42
43    Billboard::Billboard(BaseObject* creator) : StaticEntity(creator)
44    {
45        RegisterObject(Billboard);
46
47        this->material_ = "";
48        this->colour_ = ColourValue::White;
49
50        this->registerVariables();
51    }
52
53    Billboard::~Billboard()
54    {
55        if (this->isInitialized())
56        {
57            if (this->isInitialized() && this->billboard_.getBillboardSet())
58                this->detachOgreObject(this->billboard_.getBillboardSet());
59        }
60    }
61
62    void Billboard::XMLPort(Element& xmlelement, XMLPort::Mode mode)
63    {
64        SUPER(Billboard, XMLPort, xmlelement, mode);
65
66        XMLPortParam(Billboard, "material", setMaterial, getMaterial, xmlelement, mode);
67        XMLPortParam(Billboard, "colour",   setColour,   getColour,   xmlelement, mode).defaultValues(ColourValue::White);
68    }
69
70    void Billboard::registerVariables()
71    {
72        registerVariable(this->material_, variableDirection::toclient, new NetworkCallback<Billboard>(this, &Billboard::changedMaterial));
73        registerVariable(this->colour_,   variableDirection::toclient, new NetworkCallback<Billboard>(this, &Billboard::changedColour));
74    }
75
76    void Billboard::changedMaterial()
77    {
78        if (this->material_ == "")
79            return;
80
81        if (!this->billboard_.getBillboardSet())
82        {
83            if (this->getScene() && GameMode::showsGraphics())
84            {
85                this->billboard_.setBillboardSet(this->getScene()->getSceneManager(), this->material_, this->colour_, 1);
86                if (this->billboard_.getBillboardSet())
87                     this->attachOgreObject(this->billboard_.getBillboardSet());
88                this->billboard_.setVisible(this->isVisible());
89            }
90        }
91        else
92            this->billboard_.setMaterial(this->material_);
93    }
94
95    void Billboard::changedColour()
96    {
97        if (!this->billboard_.getBillboardSet())
98        {
99/*
100            if (this->getScene() && GameMode::showsGraphics() && (this->material_ != ""))
101            {
102                this->billboard_.setBillboardSet(this->getScene()->getSceneManager(), this->material_, this->colour_, 1);
103                if (this->billboard_.getBillboardSet())
104                    this->attachOgreObject(this->billboard_.getBillboardSet());
105                this->billboard_.setVisible(this->isVisible());
106            }
107*/
108        }
109        else
110            this->billboard_.setColour(this->colour_);
111    }
112
113    void Billboard::changedVisibility()
114    {
115        SUPER(Billboard, changedVisibility);
116
117        this->billboard_.setVisible(this->isVisible());
118    }
119}
Note: See TracBrowser for help on using the repository browser.