Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

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

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

removed lag at first explosion

File size: 2.9 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
54
55        void ExplosionPart::XMLPort(Element& xmlelement, XMLPort::Mode mode)
56        {
57                SUPER(ExplosionPart, XMLPort, xmlelement, mode);
58
59                XMLPortParam(ExplosionPart, "mesh", setMesh, getMesh, xmlelement, mode);
60                XMLPortParam(ExplosionPart, "effect", setEffect, getEffect, xmlelement, mode);
61
62
63        }
64
65
66        void ExplosionPart::Explode()
67        {
68                orxout() << "Explode" << endl;
69
70                orxout() << getMesh() << endl;
71                orxout() << getEffect() << endl;
72
73                this->model_->setVisible(true);
74
75                //this->explosionEntity_->setSyncMode(0);
76
77                //this->model_->setSyncMode(0);
78
79                this->particleInterface_ = new ParticleInterface(this->getScene()->getSceneManager(), effect_, this->LOD_);
80
81                this->model_->attachOgreObject(this->particleInterface_->getParticleSystem());
82
83               
84
85                this->explosionEntity_->setVelocity(Vector3(rnd(-1, 1), rnd(-1, 1), rnd(-1, 1))*rnd(50,100));
86        this->explosionEntity_->setAngularVelocity(Vector3(rnd(-1, 1), rnd(-1, 1), rnd(-1, 1)).normalisedCopy() * Degree(400).valueRadians());
87        this->explosionEntity_->setScale(4);
88
89        this->explosionEntity_->attach(model_);
90
91        this->attach(explosionEntity_);
92
93        }
94
95
96
97
98        void ExplosionPart::setMesh(const std::string& newString)
99        {
100                this->mesh_ = newString;
101                this->model_->setMeshSource(mesh_);
102                this->model_->setVisible(false);
103                orxout() << newString << endl;
104        }
105
106        void ExplosionPart::setEffect(const std::string& newString)
107        {
108                this->effect_ = newString;
109        }
110
111        std::string& ExplosionPart::getMesh()
112        { return this->mesh_; }
113
114        std::string& ExplosionPart::getEffect()
115        { return this->effect_; }
116
117
118}
Note: See TracBrowser for help on using the repository browser.