Changeset 11736 for code/branches
- Timestamp:
- Feb 11, 2018, 10:31:46 PM (7 years ago)
- Location:
- code/branches/Presentation_HS17_merge/src/modules/asteroidmining
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/Presentation_HS17_merge/src/modules/asteroidmining/AsteroidMinable.cc
r11735 r11736 71 71 */ 72 72 73 74 #include "../../orxonox/worldentities/pawns/Pawn.h"75 #include "../../orxonox/worldentities/WorldEntity.h"76 77 73 #include "AsteroidMinable.h" 78 74 … … 82 78 #include "core/GameMode.h" 83 79 #include "core/XMLPort.h" 84 #include "core/EventIncludes.h"85 #include "network/NetworkFunction.h"86 80 #include "util/Convert.h" 87 81 #include "util/Math.h" 88 82 89 #include "../pickup/PickupSpawner.h" 90 #include "../pickup/Pickup.h" 91 92 #include "../objects/collisionshapes/SphereCollisionShape.h" 93 #include "../../orxonox/graphics/Model.h" 94 83 #include "pickup/PickupSpawner.h" 84 #include "pickup/Pickup.h" 85 86 #include "objects/collisionshapes/SphereCollisionShape.h" 87 #include "graphics/Model.h" 95 88 96 89 namespace orxonox{ … … 102 95 103 96 RegisterObject(AsteroidMinable); 104 this->context = context;105 97 106 98 // Default Values: 107 this->size = 1 0;99 this->size = 1; 108 100 this->dropStuff = true; 109 101 this->generateSmaller = true; 110 this->health_ = 15*size;111 this->maxHealth_ = this->health_;112 102 this->acceptsPickups_ = false; 113 103 … … 121 111 } 122 112 123 // @brief Use this constructor with care. Mainly used internally, arguments are passed directly. 124 AsteroidMinable::AsteroidMinable(Context* c, float size, Vector3 position, bool dropStuff) : Pawn(c){ 125 126 RegisterObject(AsteroidMinable); 113 AsteroidMinable::~AsteroidMinable(){ 114 115 } 116 117 void AsteroidMinable::setSize(int s) 118 { 119 this->size = s; 120 this->health_ = 15*size; 121 this->maxHealth_ = this->health_; 122 } 123 124 // @brief Helper method. 125 void AsteroidMinable::putStuff(){ 127 126 128 127 // The radar is able to detect whether an asteroid contains resources.... … … 136 135 } 137 136 138 this->context = c;139 this->size = size;140 this->health_ = 15*size;141 this->maxHealth_ = this->health_;142 this->acceptsPickups_ = false;143 this->generateSmaller = true;144 this->dropStuff = dropStuff;145 146 this->setPosition(position);147 //this->roll = rand()*5; //etwas Drehung. Richtige Variable?148 149 this->setCollisionType(WorldEntity::CollisionType::Dynamic);150 this->enableCollisionCallback();151 152 137 // Add Model, random one of the 6 shapes 153 Model* hull = new Model(this-> context);138 Model* hull = new Model(this->getContext()); 154 139 hull->setMeshSource("ast" + multi_cast<std::string>(1 + (int)rnd(0, 6)) + ".mesh"); 155 140 hull->setScale(this->size); … … 157 142 158 143 // Collision shape 159 SphereCollisionShape* cs = new SphereCollisionShape(this-> context);144 SphereCollisionShape* cs = new SphereCollisionShape(this->getContext()); 160 145 cs->setRadius((this->size)*2); //OFFEN: Feinabstimmung der Radien. 161 146 this->attachCollisionShape(cs); 162 147 163 this->registerVariables();164 165 148 this->initialised=true; 166 167 }168 169 AsteroidMinable::~AsteroidMinable(){170 171 }172 173 // @brief Helper method.174 void AsteroidMinable::putStuff(){175 176 AsteroidMinable* reborn = new AsteroidMinable(this->context, this->size, this->getPosition(), this->dropStuff);177 reborn->setVelocity(this->getVelocity());178 // reborn->setAngularVelocity(this->getAngularVelocity()); // Add all other stuff, too?179 180 this->bAlive_ = false;181 this->destroyLater();182 183 149 } 184 150 … … 188 154 189 155 XMLPortParam(AsteroidMinable, "size", setSize, getSize, xmlelement, mode); 190 XMLPortParam(AsteroidMinable, "generateSmaller", toggleShattering, doesShatter, xmlelement, mode); 191 XMLPortParam(AsteroidMinable, "dropStuff", toggleDropStuff, doesDropStuff, xmlelement, mode); 192 193 } 194 195 void AsteroidMinable::XMLEventPort(Element& xmlelement, XMLPort::Mode mode){ 196 197 SUPER(AsteroidMinable, XMLEventPort, xmlelement, mode); 156 XMLPortParam(AsteroidMinable, "generateSmaller", setShattering, doesShatter, xmlelement, mode); 157 XMLPortParam(AsteroidMinable, "dropStuff", setDropStuff, doesDropStuff, xmlelement, mode); 198 158 199 159 } … … 228 188 // Pickups which can be harvested. It's munition at the moment, could be changed/extended. 229 189 if(dropStuff){ 230 PickupSpawner* thingy = new PickupSpawner(this-> context);190 PickupSpawner* thingy = new PickupSpawner(this->getContext()); 231 191 232 192 std::string tname; … … 366 326 } 367 327 368 AsteroidMinable* child = new AsteroidMinable(this->context, masses[fisch], this->getPosition() + pos, this->dropStuff); 328 AsteroidMinable* child = new AsteroidMinable(this->getContext()); 329 child->setSize(masses[fisch]); 330 child->setPosition(this->getPosition() + pos); 369 331 child->setVelocity(this->getVelocity()); 370 332 child->setDropStuff(this->dropStuff); 371 333 } 372 334 // orxout() << "Leaving spawnChildren() method. " << endl; -
code/branches/Presentation_HS17_merge/src/modules/asteroidmining/AsteroidMinable.h
r11732 r11736 76 76 #include "AsteroidMiningPrereqs.h" 77 77 78 #include <string> 79 #include <vector> 80 #include "interfaces/PickupCarrier.h" 81 #include "interfaces/RadarViewable.h" 82 #include "worldentities/ControllableEntity.h" 83 #include "worldentities/ExplosionPart.h" 84 85 #include "../../orxonox/worldentities/pawns/Pawn.h" 78 #include "worldentities/pawns/Pawn.h" 86 79 87 80 namespace orxonox{ 88 81 89 82 90 class _AsteroidMiningExport AsteroidMinable : public Pawn{ 83 class _AsteroidMiningExport AsteroidMinable : public Pawn 84 { 85 public: 86 AsteroidMinable(Context* context); 87 virtual ~AsteroidMinable(); 91 88 92 public:93 // @brief This constructor is for XML access only!94 AsteroidMinable(Context* context);95 // @brief Call this Constructor from other C-files.96 AsteroidMinable(Context* c, float size, Vector3 position, bool dS);97 98 virtual ~AsteroidMinable();99 89 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 100 virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode) override;101 90 virtual void tick(float dt) override; 102 91 … … 105 94 virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, const btCollisionShape* cs, float damage, float healthdamage = 0.0f, float shielddamage = 0.0f); 106 95 107 inline void setSize(int s){this->size = s;}96 void setSize(int s); 108 97 inline int getSize(){return this->size;} 109 98 110 inline void toggleShattering(bool b){this->generateSmaller = b;}99 inline void setShattering(bool b){this->generateSmaller = b;} 111 100 inline bool doesShatter(){return this->generateSmaller;} 112 101 113 inline void toggleDropStuff(bool b){this->dropStuff = b;}102 inline void setDropStuff(bool b){this->dropStuff = b;} 114 103 inline bool doesDropStuff(){return this->dropStuff;} 115 104 116 105 protected: 117 118 Context* context;119 106 120 107 int size; //!< Implies health and type of dropped pickups -
code/branches/Presentation_HS17_merge/src/modules/asteroidmining/CMakeLists.txt
r11664 r11736 13 13 14 14 LINK_LIBRARIES 15 overlays16 15 orxonox 17 16 pickup -
code/branches/Presentation_HS17_merge/src/modules/asteroidmining/SpicedAsteroidBelt.cc
r11735 r11736 45 45 46 46 47 #include "../../orxonox/worldentities/pawns/Pawn.h"48 #include "../../orxonox/worldentities/WorldEntity.h"49 50 47 #include "SpicedAsteroidBelt.h" 51 48 #include "SpicedAsteroidField.h" … … 54 51 55 52 #include "core/CoreIncludes.h" 56 #include "core/GameMode.h"57 53 #include "core/XMLPort.h" 58 #include "core/EventIncludes.h"59 #include "network/NetworkFunction.h"60 54 #include "util/Math.h" 61 55 … … 64 58 RegisterClass(SpicedAsteroidBelt); 65 59 66 SpicedAsteroidBelt::SpicedAsteroidBelt(Context* context) : Pawn(context) {60 SpicedAsteroidBelt::SpicedAsteroidBelt(Context* context) : BaseObject(context) { 67 61 68 62 RegisterObject(SpicedAsteroidBelt); 69 70 this->context = context;71 63 72 64 // Default Values: … … 85 77 this->tiltAt = 0.0; 86 78 this->tiltBy = 0.0; 87 88 this->registerVariables();89 79 90 80 } … … 115 105 116 106 Vector3 pos(radius*cos(sepp)*sin(globi), radius*sin(sepp)*sin(globi), radius*cos(globi)); 117 new SpicedAsteroidField(this->context, this->position + pos, this->minSize, this->maxSize, width, segmentCount, this->foggy, this->mDensity, this->fogDensity); 118 107 108 SpicedAsteroidField* field = new SpicedAsteroidField(this->getContext()); 109 field->setPosition(this->position + pos); 110 field->setMinSize(this->minSize); 111 field->setMaxSize(this->maxSize); 112 field->setRadius(width); 113 field->setCount(segmentCount); 114 field->setFog(this->foggy); 115 field->setMineralDensity(this->mDensity); 116 field->setFogDensity(this->fogDensity); 119 117 } 120 121 118 } 122 119 … … 142 139 } 143 140 144 void SpicedAsteroidBelt::XMLEventPort(Element& xmlelement, XMLPort::Mode mode){145 146 }147 148 void SpicedAsteroidBelt::registerVariables(){149 150 registerVariable(this->count, VariableDirection::ToClient);151 registerVariable(this->mDensity, VariableDirection::ToClient);152 registerVariable(this->position, VariableDirection::ToClient);153 registerVariable(this->segments, VariableDirection::ToClient);154 155 registerVariable(this->maxSize, VariableDirection::ToClient);156 registerVariable(this->minSize, VariableDirection::ToClient);157 registerVariable(this->radius0, VariableDirection::ToClient);158 registerVariable(this->radius1, VariableDirection::ToClient);159 registerVariable(this->foggy, VariableDirection::ToClient);160 registerVariable(this->fogDensity, VariableDirection::ToClient);161 162 registerVariable(this->tiltAt, VariableDirection::ToClient);163 registerVariable(this->tiltBy, VariableDirection::ToClient);164 165 }166 167 141 void SpicedAsteroidBelt::tick(float dt){ 168 142 169 143 this->create(); 170 this->bAlive_ = false;171 144 this->destroyLater(); 172 145 -
code/branches/Presentation_HS17_merge/src/modules/asteroidmining/SpicedAsteroidBelt.h
r11731 r11736 49 49 #include "AsteroidMiningPrereqs.h" 50 50 51 #include <string> 52 #include <vector> 53 #include "worldentities/ControllableEntity.h" 54 55 #include "../../orxonox/worldentities/pawns/Pawn.h" 51 #include "core/BaseObject.h" 52 #include "tools/interfaces/Tickable.h" 56 53 57 54 namespace orxonox // tolua_export … … 59 56 60 57 // tolua_export 61 class _AsteroidMiningExport SpicedAsteroidBelt : public Pawn // need pawn to get tick for clean argument passing58 class _AsteroidMiningExport SpicedAsteroidBelt : public BaseObject, public Tickable 62 59 { // tolua_export 63 60 64 61 public: 65 62 SpicedAsteroidBelt(Context* context);// This constructor is for XML access only! 63 virtual ~SpicedAsteroidBelt(); 66 64 67 virtual ~SpicedAsteroidBelt();68 65 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 69 virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode) override;70 66 virtual void tick(float dt) override; 71 72 67 73 68 inline void setCount(float s){this->count = s;} … … 109 104 protected: 110 105 111 Context* context;112 113 106 float count; //!< Approximate number of asteroids 114 107 float mDensity; //!< Approximate commonness of asteroids that yield stuff, value between 0 and 1; … … 131 124 132 125 private: 133 void registerVariables();134 135 126 virtual void create(); 136 127 -
code/branches/Presentation_HS17_merge/src/modules/asteroidmining/SpicedAsteroidField.cc
r11735 r11736 40 40 41 41 42 #include "../../orxonox/worldentities/pawns/Pawn.h"43 #include "../../orxonox/worldentities/WorldEntity.h"44 45 42 #include "SpicedAsteroidField.h" 46 43 #include "AsteroidMinable.h" … … 49 46 50 47 #include "core/CoreIncludes.h" 51 #include "core/GameMode.h"52 48 #include "core/XMLPort.h" 53 #include "core/EventIncludes.h"54 #include "network/NetworkFunction.h"55 49 #include "util/Math.h" 56 50 57 #include " ../../orxonox/graphics/Billboard.h"51 #include "graphics/Billboard.h" 58 52 59 53 … … 62 56 RegisterClass(SpicedAsteroidField); 63 57 64 SpicedAsteroidField::SpicedAsteroidField(Context* context) : Pawn(context) {58 SpicedAsteroidField::SpicedAsteroidField(Context* context) : BaseObject(context) { 65 59 66 60 RegisterObject(SpicedAsteroidField); 67 this->context = context;68 61 69 62 // Default Values: … … 76 69 this->foggy = true; 77 70 this->fogDensity = 0.5; 78 79 this->registerVariables();80 71 } 81 82 SpicedAsteroidField::SpicedAsteroidField(Context* c, Vector3 p, int minS, int maxS, int w, int count, bool f, float mD, float fD): Pawn(c){83 84 this->context = c;85 this->position = p;86 this->minSize = minS;87 this->maxSize = maxS;88 this->radius = w;89 this->count = count;90 this->foggy = f;91 92 this->mDensity = mD;93 this->fogDensity = fD;94 95 }96 97 72 98 73 SpicedAsteroidField::~SpicedAsteroidField(){ … … 109 84 for(int gertrud = 0; gertrud<count; ++gertrud){ 110 85 111 AsteroidMinable* a = new AsteroidMinable(this-> context);86 AsteroidMinable* a = new AsteroidMinable(this->getContext()); 112 87 113 88 size = round(rnd()*(this->maxSize - this->minSize)) + this->minSize; … … 121 96 122 97 bool spiced = (rnd() < (this->mDensity)); // Whether the asteroid does drop pickups etc. 123 a->toggleDropStuff(spiced); 124 125 a->setVelocity(this->getVelocity()); 98 a->setDropStuff(spiced); 126 99 127 100 // Fog is iplemented with billboards (as in asteroidField.lua, that bloke had the idea) 128 101 if(this->foggy && mod(gertrud, 5) == 0){ 129 Billboard* bb = new Billboard(this-> context);102 Billboard* bb = new Billboard(this->getContext()); 130 103 bb->setPosition(this->position + relPos); 131 104 bb->setMaterial("Smoke/Smoke"); … … 151 124 } 152 125 153 154 void SpicedAsteroidField::XMLEventPort(Element& xmlelement, XMLPort::Mode mode){155 156 }157 158 void SpicedAsteroidField::registerVariables(){159 160 registerVariable(this->count, VariableDirection::ToClient);161 registerVariable(this->mDensity, VariableDirection::ToClient);162 registerVariable(this->position, VariableDirection::ToClient);163 registerVariable(this->maxSize, VariableDirection::ToClient);164 registerVariable(this->minSize, VariableDirection::ToClient);165 registerVariable(this->radius, VariableDirection::ToClient);166 registerVariable(this->foggy, VariableDirection::ToClient);167 registerVariable(this->fogDensity, VariableDirection::ToClient);168 169 }170 171 126 void SpicedAsteroidField::tick(float dt){ 172 127 173 128 this->create(); 174 this->bAlive_ = false;175 129 this->destroyLater(); 176 130 } -
code/branches/Presentation_HS17_merge/src/modules/asteroidmining/SpicedAsteroidField.h
r11731 r11736 43 43 #include "AsteroidMiningPrereqs.h" 44 44 45 #include <string> 46 #include <vector> 47 48 #include "worldentities/ControllableEntity.h" 49 #include "../../orxonox/worldentities/pawns/Pawn.h" 45 #include "core/BaseObject.h" 46 #include "tools/interfaces/Tickable.h" 50 47 51 48 namespace orxonox // tolua_export … … 53 50 54 51 // tolua_export 55 class _AsteroidMiningExport SpicedAsteroidField : public Pawn // need pawn to get tick for clean argument passing52 class _AsteroidMiningExport SpicedAsteroidField : public BaseObject, public Tickable 56 53 { // tolua_export 57 54 58 55 public: 59 SpicedAsteroidField(Context* context); // This constructor is for XML access only!60 SpicedAsteroidField(Context* c, Vector3 p, int minS, int maxS, int w, int count, bool f, float mD, float fD);56 SpicedAsteroidField(Context* context); 57 virtual ~SpicedAsteroidField(); 61 58 62 virtual ~SpicedAsteroidField();63 59 virtual void XMLPort(Element& xmlelement, XMLPort::Mode mode); 64 virtual void XMLEventPort(Element& xmlelement, XMLPort::Mode mode) override;65 60 virtual void tick(float dt) override; 66 67 61 68 62 inline void setCount(float s){this->count = s;} … … 92 86 protected: 93 87 94 Context* context;95 96 88 float count; //!< Number of asteroids generated 97 89 float mDensity; //!< Mineral density, between 0 and 1; … … 108 100 109 101 private: 110 void registerVariables();111 112 102 virtual void create(); 113 103
Note: See TracChangeset
for help on using the changeset viewer.