Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/tutorial/src/orxonox/objects/RotatingProjectile.cc @ 1215

Last change on this file since 1215 was 862, checked in by landauf, 17 years ago

tutorial

File size: 2.7 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
30#include "core/CoreIncludes.h"
31#include <OgreBillboard.h>
32#include "RotatingProjectile.h"
33
34namespace orxonox
35{
36    CreateFactory(RotatingProjectile);
37
38    RotatingProjectile::RotatingProjectile()
39    {
40        RegisterObject(RotatingProjectile);
41
42        this->time_ = 0;
43
44        this->rotatingBillboard1_.setBillboardSet("Examples/Flare", ColourValue(1.0, 1.0, 0.5), 1);
45        this->rotatingBillboard2_.setBillboardSet("Examples/Flare", ColourValue(1.0, 1.0, 0.5), 1);
46
47        this->rotatingNode1_ = this->getNode()->createChildSceneNode(this->getName() + "rotating1", Vector3(0, 50, 0));
48        this->rotatingNode2_ = this->getNode()->createChildSceneNode(this->getName() + "rotating2", Vector3(0, -50, 0));
49        this->rotatingNode1_->attachObject(this->rotatingBillboard1_.getBillboardSet());
50        this->rotatingNode2_->attachObject(this->rotatingBillboard2_.getBillboardSet());
51        this->rotatingNode1_->scale(0.7, 0.7, 0.7);
52        this->rotatingNode2_->scale(0.7, 0.7, 0.7);
53
54        this->setConfigValues();
55    }
56
57    RotatingProjectile::~RotatingProjectile()
58    {
59    }
60
61    void RotatingProjectile::setConfigValues()
62    {
63        SetConfigValue(colour_, ColourValue(1.0, 0.0, 0.0));
64
65        this->rotatingBillboard1_.getBillboardSet()->getBillboard(0)->setColour(this->colour_);
66        this->rotatingBillboard2_.getBillboardSet()->getBillboard(0)->setColour(this->colour_);
67    }
68
69    void RotatingProjectile::tick(float dt)
70    {
71        Projectile::tick(dt);
72
73        this->time_ += dt;
74
75        this->rotatingNode1_->setPosition(0, 50 * sin(this->time_ * 20), 50 * cos(this->time_ * 20));
76        this->rotatingNode2_->setPosition(0, -50 * sin(this->time_ * 20), -50 * cos(this->time_ * 20));
77    }
78}
Note: See TracBrowser for help on using the repository browser.