Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/archive/tutorialHS08/src/orxonox/objects/RotatingProjectile.cc @ 10177

Last change on this file since 10177 was 1747, checked in by landauf, 16 years ago

merged core3 back to trunk

  • Property svn:eol-style set to native
File size: 3.3 KB
Line 
1/*
2 *   ORXONOX - the hottest 3D action shooter ever to exist
3 *
4 *
5 *   License notice:
6 *
7 *   This program is free software; you can redistribute it and/or
8 *   modify it under the terms of the GNU General Public License
9 *   as published by the Free Software Foundation; either version 2
10 *   of the License, or (at your option) any later version.
11 *
12 *   This program is distributed in the hope that it will be useful,
13 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
14 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 *   GNU General Public License for more details.
16 *
17 *   You should have received a copy of the GNU General Public License
18 *   along with this program; if not, write to the Free Software
19 *   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20 *
21 *   Author:
22 *      Fabian 'x3n' Landau
23 *   Co-authors:
24 *      ...
25 *
26 */
27
28#include "OrxonoxStableHeaders.h"
29#include "RotatingProjectile.h"
30
31#include "core/CoreIncludes.h"
32#include "core/ConfigValueIncludes.h"
33#include <OgreBillboard.h>
34
35namespace orxonox
36{
37    CreateFactory(RotatingProjectile);
38
39    RotatingProjectile::RotatingProjectile(SpaceShip* owner) : BillboardProjectile(owner)
40    {
41        RegisterObject(RotatingProjectile);
42
43        this->time_ = 0;
44
45        if (/*this->owner_*/true)
46        {
47            this->rotatingBillboard1_.setBillboardSet("Examples/Flare", ColourValue(1.0, 0.0, 0.0), 1);
48            this->rotatingBillboard2_.setBillboardSet("Examples/Flare", ColourValue(1.0, 0.0, 0.0), 1);
49
50            this->rotatingNode1_ = this->getNode()->createChildSceneNode(this->getName() + "rotating1", Vector3(0, 50, 0));
51            this->rotatingNode2_ = this->getNode()->createChildSceneNode(this->getName() + "rotating2", Vector3(0, -50, 0));
52            this->rotatingNode1_->attachObject(this->rotatingBillboard1_.getBillboardSet());
53            this->rotatingNode2_->attachObject(this->rotatingBillboard2_.getBillboardSet());
54            this->rotatingNode1_->scale(0.3, 0.3, 0.3);
55            this->rotatingNode2_->scale(0.3, 0.3, 0.3);
56        }
57
58        this->setConfigValues();
59    }
60
61    RotatingProjectile::~RotatingProjectile()
62    {
63    }
64
65    void RotatingProjectile::setConfigValues()
66    {
67        SetConfigValue(colour_, ColourValue(1.0, 0.0, 0.0)).callback(this, &RotatingProjectile::colourChanged);
68    }
69
70    void RotatingProjectile::colourChanged()
71    {
72        if (this->isInitialized())
73        {
74            this->rotatingBillboard1_.getBillboardSet()->getBillboard(0)->setColour(this->colour_);
75            this->rotatingBillboard2_.getBillboardSet()->getBillboard(0)->setColour(this->colour_);
76        }
77    }
78
79    void RotatingProjectile::tick(float dt)
80    {
81        if (this->isActive())
82        {
83            this->time_ += dt;
84
85            this->rotatingNode1_->setPosition(0, 50 * sin(this->time_ * 20), 50 * cos(this->time_ * 20));
86            this->rotatingNode2_->setPosition(0, -50 * sin(this->time_ * 20), -50 * cos(this->time_ * 20));
87        }
88
89        SUPER(RotatingProjectile, tick, dt);
90    }
91
92    void RotatingProjectile::changedVisibility()
93    {
94        SUPER(RotatingProjectile, changedVisibility);
95        this->rotatingBillboard1_.setVisible(this->isVisible());
96        this->rotatingBillboard2_.setVisible(this->isVisible());
97    }
98}
Note: See TracBrowser for help on using the repository browser.