Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/explosionChunksHS15/src/orxonox/worldentities/ExplosionPart.cc @ 10752

Last change on this file since 10752 was 10752, checked in by vaydin, 8 years ago

Deleted previously created VaydinExplosion class, created ExplosionPart class

File size: 2.8 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 *      Vedat Aydin
24 *   Co-authors:
25 *      ...
26 *
27 */
28
29
30#include "ExplosionPart.h"
31#include "core/XMLPort.h"
32
33
34namespace orxonox
35{
36
37        RegisterClass(ExplosionPart);
38
39        ExplosionPart::ExplosionPart(Context* context) : MovableEntity(context)
40        {
41                RegisterObject(ExplosionPart);
42                this->bStop_ = false;
43        this->LOD_ = LODParticle::Normal;
44                this->mesh_ = "";
45                this->effect_ = "";
46                this->model_= new Model(this->getContext());
47                this->particleInterface_= NULL;
48                this->explosionEntity_ = new MovableEntity(this->getContext());
49
50        }
51
52
53        void ExplosionPart::XMLPort(Element& xmlelement, XMLPort::Mode mode)
54        {
55                SUPER(ExplosionPart, XMLPort, xmlelement, mode);
56
57                XMLPortParam(ExplosionPart, "mesh", setMesh, getMesh, xmlelement, mode);
58                XMLPortParam(ExplosionPart, "effect", setEffect, getEffect, xmlelement, mode);
59
60
61        }
62
63
64        void ExplosionPart::Explode()
65        {
66                orxout() << "Explode" << endl;
67
68                orxout() << getMesh() << endl;
69                orxout() << getEffect() << endl;
70
71                this->explosionEntity_->setSyncMode(0);
72
73                this->model_->setSyncMode(0);
74
75                this->particleInterface_ = new ParticleInterface(this->getScene()->getSceneManager(), effect_, this->LOD_);
76
77                this->model_->attachOgreObject(this->particleInterface_->getParticleSystem());
78
79                this->model_->setMeshSource(mesh_);
80
81                this->explosionEntity_->setVelocity(Vector3(rnd(-1, 1), rnd(-1, 1), rnd(-1, 1))*rnd(50,100));
82        this->explosionEntity_->setAngularVelocity(Vector3(rnd(-1, 1), rnd(-1, 1), rnd(-1, 1)).normalisedCopy() * Degree(400).valueRadians());
83        this->explosionEntity_->setScale(4);
84
85        this->explosionEntity_->attach(model_);
86
87        this->attach(explosionEntity_);
88
89        }
90
91
92
93
94        void ExplosionPart::setMesh(const std::string& newString)
95        {
96                this->mesh_ = newString;
97                orxout() << newString << endl;
98        }
99
100        void ExplosionPart::setEffect(const std::string& newString)
101        {
102                this->effect_ = newString;
103        }
104
105        std::string& ExplosionPart::getMesh()
106        { return this->mesh_; }
107
108        std::string& ExplosionPart::getEffect()
109        { return this->effect_; }
110
111
112}
Note: See TracBrowser for help on using the repository browser.