/* 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: * remartin * Co-authors: * ... * */ /** @file @author remartin @brief Asteroid belt with lots of parameters. Derived from asteroidField.lua Generates a ring of asteroids by calling SpicedAsteroidField multiple times. It's in the xy-plane at default, orientation can be changed with tiltAt (angle where it gets elevated/lowered the most) and TiltBy (angle at z-axis). This doesn't work very well and could probably implemented differently with relative coordinates (attach etc, stuff in WorldEntity). It is required to wait until all XML-arguments are set. That's why the actual generation happens when tick() gets called for the first time. */ #include "SpicedAsteroidBelt.h" #include "SpicedAsteroidField.h" #include #include "core/CoreIncludes.h" #include "core/XMLPort.h" #include "util/Math.h" namespace orxonox{ RegisterClass(SpicedAsteroidBelt); SpicedAsteroidBelt::SpicedAsteroidBelt(Context* context) : BaseObject(context) { RegisterObject(SpicedAsteroidBelt); // Default Values: this->count = 250; this->position = Vector3(0,0,0); this->segments = 30; this->minSize = 1; this->maxSize = 50; this->radius0 = 7190; this->radius1 = 7800; this->mDensity = 0.3; this->foggy = true; this->fogDensity = 0.5; this->tiltAt = 0.0; this->tiltBy = 0.0; } SpicedAsteroidBelt::~SpicedAsteroidBelt(){ } void SpicedAsteroidBelt::create(){ float myPi = math::pi; float width = fabs(this->radius1 - this->radius0); float radius = (this->radius1 + this->radius0) / 2.0f; int segmentCount = (int)roundf(this->count / this->segments); float dPhi = (2 * myPi) / this->segments; float dTheta = 4.0f*this->tiltBy/this->segments; float sepp = -this->tiltAt; float globi = (myPi/2.0f) + this->tiltBy; for(int s = 0; sgetContext()); field->setPosition(this->position + pos); field->setMinSize(this->minSize); field->setMaxSize(this->maxSize); field->setRadius(width); field->setCount(segmentCount); field->setFog(this->foggy); field->setMineralDensity(this->mDensity); field->setFogDensity(this->fogDensity); } } void SpicedAsteroidBelt::XMLPort(Element& xmlelement, XMLPort::Mode mode){ SUPER(SpicedAsteroidBelt, XMLPort, xmlelement, mode); XMLPortParam(SpicedAsteroidBelt, "count", setCount, getCount, xmlelement, mode); XMLPortParam(SpicedAsteroidBelt, "mDensity", setMineralDensity, getMineralDensity, xmlelement, mode); XMLPortParam(SpicedAsteroidBelt, "position", setPosition, getPosition, xmlelement, mode); XMLPortParam(SpicedAsteroidBelt, "segments", setSegments, getSegments, xmlelement, mode); XMLPortParam(SpicedAsteroidBelt, "maxSize", setMaxSize, getMaxSize, xmlelement, mode); XMLPortParam(SpicedAsteroidBelt, "minSize", setMinSize, getMinSize, xmlelement, mode); XMLPortParam(SpicedAsteroidBelt, "radius0", setRadius0, getRadius0, xmlelement, mode); XMLPortParam(SpicedAsteroidBelt, "radius1", setRadius1, getRadius1, xmlelement, mode); XMLPortParam(SpicedAsteroidBelt, "foggy", setFog, isFoggy, xmlelement, mode); XMLPortParam(SpicedAsteroidBelt, "fogDensity", setFogDensity, getFogDensity, xmlelement, mode); XMLPortParam(SpicedAsteroidBelt, "tiltAt", setTiltAt, getTiltAt, xmlelement, mode); XMLPortParam(SpicedAsteroidBelt, "tiltBy", setTiltBy, getTiltBy, xmlelement, mode); } void SpicedAsteroidBelt::tick(float dt){ this->create(); this->destroyLater(); } }