/* * ORXONOX - the hottest 3D action shooter ever to exist * > www.orxonox.net < * * * License notice: * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * * Author: * Vedat Aydin * Co-authors: * ... * */ #include "ExplosionPart.h" #include "core/XMLPort.h" namespace orxonox { RegisterClass(ExplosionPart); ExplosionPart::ExplosionPart(Context* context) : MovableEntity(context) { RegisterObject(ExplosionPart); this->bStop_ = false; this->LOD_ = LODParticle::Normal; this->mesh_ = ""; this->effect_ = ""; this->model_= new Model(this->getContext()); this->particleInterface_= NULL; this->explosionEntity_ = new MovableEntity(this->getContext()); } void ExplosionPart::XMLPort(Element& xmlelement, XMLPort::Mode mode) { SUPER(ExplosionPart, XMLPort, xmlelement, mode); XMLPortParam(ExplosionPart, "mesh", setMesh, getMesh, xmlelement, mode); XMLPortParam(ExplosionPart, "effect", setEffect, getEffect, xmlelement, mode); } void ExplosionPart::Explode() { orxout() << "Explode" << endl; orxout() << getMesh() << endl; orxout() << getEffect() << endl; this->explosionEntity_->setSyncMode(0); this->model_->setSyncMode(0); this->particleInterface_ = new ParticleInterface(this->getScene()->getSceneManager(), effect_, this->LOD_); this->model_->attachOgreObject(this->particleInterface_->getParticleSystem()); this->model_->setMeshSource(mesh_); this->explosionEntity_->setVelocity(Vector3(rnd(-1, 1), rnd(-1, 1), rnd(-1, 1))*rnd(50,100)); this->explosionEntity_->setAngularVelocity(Vector3(rnd(-1, 1), rnd(-1, 1), rnd(-1, 1)).normalisedCopy() * Degree(400).valueRadians()); this->explosionEntity_->setScale(4); this->explosionEntity_->attach(model_); this->attach(explosionEntity_); } void ExplosionPart::setMesh(const std::string& newString) { this->mesh_ = newString; orxout() << newString << endl; } void ExplosionPart::setEffect(const std::string& newString) { this->effect_ = newString; } std::string& ExplosionPart::getMesh() { return this->mesh_; } std::string& ExplosionPart::getEffect() { return this->effect_; } }