Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/toonshader/src/orxonox/tools/BillboardSet.cc @ 7870

Last change on this file since 7870 was 2896, checked in by landauf, 16 years ago

Merged gui branch back to trunk.

I did 2 small changes in IngameManager.cc on line 777 and 888 (yes, really), because const_reverse_iterator strangely doesn't work on MinGW.

  • Property svn:eol-style set to native
File size: 5.1 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 "BillboardSet.h"
31
32#include <sstream>
33#include <cassert>
34
35#include <OgreSceneManager.h>
36#include <OgreBillboardSet.h>
37#include <OgreBillboard.h>
38
39#include "core/GameMode.h"
40#include "util/Convert.h"
41#include "util/String.h"
42
43namespace orxonox
44{
45    unsigned int BillboardSet::billboardSetCounter_s = 0;
46
47    BillboardSet::BillboardSet()
48    {
49        this->billboardSet_ = 0;
50    }
51
52    BillboardSet::~BillboardSet()
53    {
54        this->destroyBillboardSet();
55    }
56
57    void BillboardSet::setBillboardSet(Ogre::SceneManager* scenemanager, const std::string& file, int count)
58    {
59        this->setBillboardSet(scenemanager, file, Vector3::ZERO, count);
60    }
61
62    void BillboardSet::setBillboardSet(Ogre::SceneManager* scenemanager, const std::string& file, const ColourValue& colour, int count)
63    {
64        this->setBillboardSet(scenemanager, file, colour, Vector3::ZERO, count);
65    }
66
67    void BillboardSet::setBillboardSet(Ogre::SceneManager* scenemanager, const std::string& file, const Vector3& position, int count)
68    {
69        assert(scenemanager);
70        this->destroyBillboardSet();
71
72        try
73        {
74            if (GameMode::showsGraphics())
75            {
76                this->billboardSet_ = scenemanager->createBillboardSet("Billboard" + convertToString(BillboardSet::billboardSetCounter_s++), count);
77                this->billboardSet_->createBillboard(position);
78                this->billboardSet_->setMaterialName(file);
79            }
80        }
81        catch (...)
82        {
83            COUT(1) << "Error: Couln't load billboard \"" << file << "\"" << std::endl;
84            this->billboardSet_ = 0;
85        }
86
87        this->scenemanager_ = scenemanager;
88    }
89
90    void BillboardSet::setBillboardSet(Ogre::SceneManager* scenemanager, const std::string& file, const ColourValue& colour, const Vector3& position, int count)
91    {
92        assert(scenemanager);
93        this->destroyBillboardSet();
94
95        try
96        {
97            if (GameMode::showsGraphics())
98            {
99                this->billboardSet_ = scenemanager->createBillboardSet("Billboard" + convertToString(BillboardSet::billboardSetCounter_s++), count);
100                this->billboardSet_->createBillboard(position, colour);
101                this->billboardSet_->setMaterialName(file);
102            }
103        }
104        catch (...)
105        {
106            COUT(1) << "Error: Couln't load billboard \"" << file << "\"" << std::endl;
107            this->billboardSet_ = 0;
108        }
109
110        this->scenemanager_ = scenemanager;
111    }
112
113    void BillboardSet::destroyBillboardSet()
114    {
115        if (this->billboardSet_ && this->scenemanager_)
116            this->scenemanager_->destroyBillboardSet(this->billboardSet_);
117        this->billboardSet_ = 0;
118    }
119
120    const std::string& BillboardSet::getName() const
121    {
122        if (this->billboardSet_)
123            return this->billboardSet_->getName();
124        else
125            return BLANKSTRING;
126    }
127
128    void BillboardSet::setVisible(bool visible)
129    {
130        if (this->billboardSet_)
131            this->billboardSet_->setVisible(visible);
132    }
133
134    bool BillboardSet::getVisible() const
135    {
136        if (this->billboardSet_)
137            return this->billboardSet_->getVisible();
138        else
139            return false;
140    }
141
142    void BillboardSet::setColour(const ColourValue& colour)
143    {
144        if (this->billboardSet_)
145        {
146            for (int i = 0; i < this->billboardSet_->getNumBillboards(); ++i)
147                this->billboardSet_->getBillboard(i)->setColour(colour);
148        }
149    }
150
151    const ColourValue& BillboardSet::getColour() const
152    {
153        if (this->billboardSet_ && this->billboardSet_->getNumBillboards() > 0)
154        {
155            return this->billboardSet_->getBillboard(0)->getColour();
156        }
157        else
158            return ColourValue::White;
159    }
160
161    void BillboardSet::setMaterial(const std::string& material)
162    {
163        if (this->billboardSet_)
164            this->billboardSet_->setMaterialName(material);
165    }
166
167    const std::string& BillboardSet::getMaterial() const
168    {
169        if (this->billboardSet_)
170            return this->billboardSet_->getMaterialName();
171        else
172            return BLANKSTRING;
173    }
174}
Note: See TracBrowser for help on using the repository browser.