[Orxonox-commit 7046] r11665 - code/branches/AsteroidMining_HS17/src/modules/asteroidmining
remartin at orxonox.net
remartin at orxonox.net
Mon Dec 11 18:06:20 CET 2017
Author: remartin
Date: 2017-12-11 18:06:20 +0100 (Mon, 11 Dec 2017)
New Revision: 11665
Added:
code/branches/AsteroidMining_HS17/src/modules/asteroidmining/SpicedAsteroidBelt.cc
code/branches/AsteroidMining_HS17/src/modules/asteroidmining/SpicedAsteroidBelt.h
Log:
Added: code/branches/AsteroidMining_HS17/src/modules/asteroidmining/SpicedAsteroidBelt.cc
===================================================================
--- code/branches/AsteroidMining_HS17/src/modules/asteroidmining/SpicedAsteroidBelt.cc (rev 0)
+++ code/branches/AsteroidMining_HS17/src/modules/asteroidmining/SpicedAsteroidBelt.cc 2017-12-11 17:06:20 UTC (rev 11665)
@@ -0,0 +1,156 @@
+
+ /* 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:
+ * Fabian 'x3n' Landau
+ * Co-authors:
+ * Simon Miescher
+ *
+ */
+
+/**
+
+ @file SpicedAsteroidBelt.cc
+ @brief Asteroid belt with lots of parameters. Derived from asteroidField.lua
+
+
+*/
+
+
+#include "../../orxonox/worldentities/pawns/Pawn.h"
+#include "../../orxonox/worldentities/WorldEntity.h"
+
+#include "SpicedAsteroidBelt.h"
+#include "SpicedAsteroidField.h"
+
+#include <algorithm>
+
+#include "core/CoreIncludes.h"
+#include "core/GameMode.h"
+#include "core/XMLPort.h"
+#include "core/EventIncludes.h"
+#include "network/NetworkFunction.h"
+#include "util/Math.h"
+
+namespace orxonox{
+
+ RegisterClass(SpicedAsteroidBelt);
+
+ SpicedAsteroidBelt::SpicedAsteroidBelt(Context* context) : Pawn(context) {
+
+ RegisterObject(SpicedAsteroidBelt);
+
+ this->context = context;
+
+ // Default Values:
+ this->count = 250;
+ this->position = Vector3(0,0,0);
+ // this->yaw = 0;
+ // this->pitch = 0;
+ this->segments = 30;
+ this->minSize = 1;
+ this->maxSize = 50;
+ this->radius0 = 7190;
+ this->radius1 = 7800;
+
+ this->mDensity = 0.3;
+ this->fogDensity = 0.5;
+
+ // Old from Pawn
+ this->registerVariables();
+
+ }
+
+ SpicedAsteroidBelt::~SpicedAsteroidBelt(){
+
+ }
+
+ void SpicedAsteroidBelt::create(){
+
+ float myPi = 3.1415927410125732421875; //pi; // Math.pi ist statisch oder so.
+ float dPhi = (2 * myPi) / segments;
+ float width = radius1 - radius0; if(width<0){width = -width;} // predefined abs?
+ float radius = (radius1 + radius0) / 2.0;
+ int segmentCount = round(count / segments);
+
+ SpicedAsteroidField* af[segments];
+ (void)af[0]; // avoid nasty compiler warning
+
+ for(int s = 0; s<segments; ++s){
+ Vector3* pos = new Vector3(radius*cos(s*dPhi), radius*sin(s*dPhi),0);
+ af[s] = new SpicedAsteroidField(this->context, this->position + *pos, this->minSize, this->maxSize, width, segmentCount, this->foggy, this->mDensity, 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, "yaw", setYaw, getYaw, xmlelement, mode);
+ // XMLPortParam(SpicedAsteroidBelt, "pitch", setPitch, getPitch, 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);
+
+ }
+
+ void SpicedAsteroidBelt::XMLEventPort(Element& xmlelement, XMLPort::Mode mode){
+
+ }
+
+ void SpicedAsteroidBelt::registerVariables(){
+
+ registerVariable(this->count, VariableDirection::ToClient);
+ registerVariable(this->mDensity, VariableDirection::ToClient);
+ registerVariable(this->position, VariableDirection::ToClient);
+ // registerVariable(this->yaw, VariableDirection::ToClient);
+ // registerVariable(this->pitch, VariableDirection::ToClient);
+ registerVariable(this->segments, VariableDirection::ToClient);
+
+ registerVariable(this->maxSize, VariableDirection::ToClient);
+ registerVariable(this->minSize, VariableDirection::ToClient);
+ registerVariable(this->radius0, VariableDirection::ToClient);
+ registerVariable(this->radius1, VariableDirection::ToClient);
+ registerVariable(this->foggy, VariableDirection::ToClient);
+ registerVariable(this->fogDensity, VariableDirection::ToClient);
+
+ }
+
+ void SpicedAsteroidBelt::tick(float dt){
+
+ this->create();
+ this->bAlive_ = false;
+ this->destroyLater();
+
+ }
+
+}
+
+
Added: code/branches/AsteroidMining_HS17/src/modules/asteroidmining/SpicedAsteroidBelt.h
===================================================================
--- code/branches/AsteroidMining_HS17/src/modules/asteroidmining/SpicedAsteroidBelt.h (rev 0)
+++ code/branches/AsteroidMining_HS17/src/modules/asteroidmining/SpicedAsteroidBelt.h 2017-12-11 17:06:20 UTC (rev 11665)
@@ -0,0 +1,132 @@
+/*
+ * 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:
+ * Fabian 'x3n' Landau
+ * Co-authors:
+ * ...
+ *
+ */
+
+/**
+
+ @file SpicedAsteroidBelt.h
+ @brief Asteroid belt with lots of parameters. Derived from asteroidField.lua
+
+
+*/
+
+
+#ifndef _SpicedAsteroidBelt_H__
+#define _SpicedAsteroidBelt_H__
+
+#include "OrxonoxPrereqs.h"
+
+#include <string>
+#include <vector>
+#include "worldentities/ControllableEntity.h"
+
+#include "../../orxonox/worldentities/pawns/Pawn.h"
+
+namespace orxonox // tolua_export
+{
+
+ // tolua_export
+ class _OrxonoxExport SpicedAsteroidBelt : public Pawn // need pawn to get tick for clean argument passing
+ { // tolua_export
+
+ public:
+ SpicedAsteroidBelt(Context* context);// This constructor is for XML access only!
+
+ virtual ~SpicedAsteroidBelt();
+ virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode);
+ virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode) override;
+ virtual void tick(float dt) override;
+
+
+ inline void setCount(float s){this->count = s;}
+ inline float getCount(){return this->count;}
+
+ inline void setMineralDensity(float d){this->mDensity = d;}
+ inline float getMineralDensity(){return this->mDensity;}
+
+ inline void setPosition(Vector3 v){this->position = v;}
+ inline Vector3 getPosition(){return this->position;}
+
+ // inline void setYaw(float y){this->yaw = y;}
+ // inline float getYaw(){return this->yaw;}
+
+ // inline void setPitch(float p){this->pitch = p;}
+ // inline float getPitch(){return this->pitch;}
+
+ inline void setSegments(int s){this->segments = s;}
+ inline int getSegments(){return this->segments;}
+
+ inline void setMaxSize(int i){this->maxSize = i;}
+ inline int getMaxSize(){return this->maxSize;}
+
+ inline void setMinSize(int i){this->minSize = i;}
+ inline int getMinSize(){return this->minSize;}
+
+ inline void setRadius0(float r0){this->radius0 = r0;}
+ inline int getRadius0(){return this->radius0;}
+
+ inline void setRadius1(float r1){this->radius1 = r1;}
+ inline int getRadius1(){return this->radius1;}
+
+ inline void setFog(bool f){this->foggy = f;}
+ inline bool isFoggy(){return this->foggy;}
+
+ inline void setFogDensity(float fd){this->fogDensity = fd;}
+ inline float getFogDensity(){return this->fogDensity;}
+
+
+ protected:
+
+ Context* context;
+
+ float count;
+ float mDensity; // Mineral density, between 0 and 1;
+
+ Vector3 position;
+
+ // float yaw;
+ // float pitch;
+ int segments;
+
+ int maxSize;
+ int minSize;
+
+ float radius0;
+ float radius1;
+
+ bool foggy;
+ float fogDensity;
+
+ virtual void create();
+
+ private:
+ void registerVariables();
+
+ }; // tolua_export
+} // tolua_export
+
+#endif /* _SpicedAsteroidBelt_H__ */
More information about the Orxonox-commit
mailing list