Changeset 11667 for code/branches
- Timestamp:
- Dec 12, 2017, 8:29:52 PM (7 years ago)
- Location:
- code/branches/AsteroidMining_HS17
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/AsteroidMining_HS17/data/levels/AsteroidFarming.oxw
r11664 r11667 62 62 63 63 <!-- Drone pickup --> 64 65 64 <PickupSpawner pickup=dronepickup position="-25,100,-125" triggerDistance="10" respawnTime="30" maxSpawnedItems="10" /> 66 65 … … 99 98 100 99 101 <!-- ---AsteroidMinable --->100 <!-- AsteroidMinable --> 102 101 <AsteroidMinable size=15 position="0,-500,0" /> 103 102 <AsteroidMinable size=5 position="100,-500,100" /> … … 105 104 <AsteroidMinable size=30 position="-100, -500, -100" velocity= "0, -30, 0"/> 106 105 107 <!-- -SpicedAsteroidField -->108 <SpicedAsteroidField count=30 mDensity= 0.5 maxSize=40 minSize=1 position="5000, 0, 0" radius=1000 velocity=" -100,0,0"/>106 <!-- SpicedAsteroidField --> 107 <SpicedAsteroidField count=30 mDensity= 0.5 maxSize=40 minSize=1 position="5000, 0, 0" radius=1000 velocity="0,0,0"/> 109 108 110 109 111 110 <!-- Asteroid Belt with a planet --> 112 <SpicedAsteroidBelt position="-15000,0,0" mDensity=0.3 yaw=90 pitch=90 roll=90 segments=30 minSize=1 maxSize=50 radius0=7190 radius1 = 7800 count=250/> 111 112 <SpicedAsteroidBelt position="-15000,0,0" mDensity=0.3 segments=50 minSize=1 maxSize=50 radius0=7190 radius1 = 7800 count=250 tiltBy=0.5 tiltAt=0/> 113 113 <Planet 114 114 position="-15000,0,0" … … 139 139 140 140 141 142 141 </Scene> 143 142 </Level> -
code/branches/AsteroidMining_HS17/src/modules/asteroidmining/AsteroidMinable.cc
r11664 r11667 29 29 /* 30 30 31 @file AsteroidMinable.cc 32 33 * 34 * 35 * An asteroid which can be destroyed. Some smaller asteroids are created and a pickup 36 * spawns. 37 * 38 * 39 * 40 41 */ 42 43 /* 44 Veraenderungstagebuch 45 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 46 47 48 KNACKPUNKTE: 49 o Super-XML-Argumente werden nicht richtig geparst (Velocity, Pitch, Yaw etc. ) 50 51 52 OFFEN: 53 54 o Add custom pickup 'resources'. Weird template stuff -> Problems setting 'size' and other properties? setNumber of Resources. 55 --> PickupTemplateName_ in PickupSpawner ist ein string. Wird via getBaseClassIdentifier ausgelesen, daraus wird ein Pickupable fabriziert. 56 --> MunitionPickup erbt von Pickup erbt von collectiblePickup erbt von Pickupable 57 ----> im MineralsPickup die isPickedUp()-Methode überschreiben? 58 --> data_extern/images/effects: PNG's für die Pickups und GUI-Dinger. 31 @file 32 @author remartin 33 @brief An asteroid which can be destroyed. Some smaller asteroids are created and a pickup spawns. 34 35 HANDBUCH: 36 o Die Collision Shape kann nur im Konstruktor hinzugefügt werden. Die XML-Argumente werden aber erst nach dem Konstruktor gesetzt. 37 Darum wird hier beim ersten Aufruf der tick()-Methode via putStuff() ein komplett neuer Asteroid generiert und der alte zerstört. 38 o im Level-File includes/pickups.oxi importieren. 39 40 OFFEN/Weiterentwicklung: 41 o @TODO Add resource pickups. 42 --> data_extern/images/effects: PNG's für die Pickups 59 43 --> https://www.orxonox.net/jenkins/view/Management/job/orxonox_doxygen_trunk/javadoc/group___pickup.html 60 44 61 o Anfangsgeschwindigkeit fuers Asteroidenfeld62 45 o Density doesn't add up to 1... 63 o set collisionDamage? Just for static entities? 64 65 o Dokumentieren mit @brief? 66 o unregister -empty- asteroids from radar. (or turn them green or whatever) 46 o Does collision damage work properly 67 47 o Add sound effect (crunching etc. ) (No sound in space...) 68 48 o Explosion parts 69 49 70 HANDBUCH: 71 o im Level-File includes/pickups.oxi importieren. 72 o Bei der XML-Variante wird beim ersten Aufruf der Tick-Methode ein neuer Asteroid generiert, 73 damit die Groesse der Collision Shape korrekt initialisiert wird. 74 75 FREMDANPASSUNGEN: 50 ANDERORTS VERÄNDERTE SACHEN: 76 51 Pickup-Zeug: 77 o Pickup.h: Zugriffsänderung createSpawner52 o Pickup.h: createSpawner() neu public statt private 78 53 o PickupSpawner.h: Zugriffsrechte setPickupTemplateName() und setMaxSpawnedItems() 79 o PickupSpawner.h: In Tick() zwei Testbedingungen eingef uegt.54 o PickupSpawner.h: In Tick() zwei Testbedingungen eingefügt. 80 55 o Pawn.h: Attribut acceptsPickups_ inklusive get/set. 81 56 82 57 ERLEGTE FEHLER: 83 o Rand() geht bis zu riesigen Nummern! 84 o Pickupgenerierung: vgl. Fremdanpassungen. 85 o Minimalbegrenzung fuer Masse vergessen. 86 o Dynamische Definition -> putStuff-Methode, Werte noch nicht durchgesickert. 87 o Error-Nachricht: Einfach Argumente leer lassen. 88 o Pickups: setMaxSpawned funktioniert nicht -> Bastelloesung: Auf 2 statt eins setzen, erstes wird wohl direkt zerstoert. 89 o setHealth: Wird mit Max verwurstelt, war 0. 90 o Position nicht gesetzt -> alles im Ursprung, Kollision -> fliegt davon. 91 o nimmt zuviel Schaden. -> wird mit maxHealth verwurstelt -> einfach auch setzen. 92 93 o Groessenabhaengige Collison shape: Umweg ueber zweiten Konstruktor. 94 o Absturz beim Asteroidengenerieren: Health war auf 0 gesetzt! Wurde nur bei der xml-Variante definiert. 58 o Grössenabhängige Collision Shape -> putStuff-Methode, Werte noch nicht durchgesickert. 59 o setHealth: maxHealth() des pawns setzen! 95 60 o Asteroiden fressen Pickups: Argument in Pawn, Test darauf in Tick() von PickupSpawner. 96 o Man kann keine Arrays der Groesse 0 initialisieren, aber auch nicht per IF 2x definieren.97 61 o i++ einfach ganz verhindern, ++i stattdessen. 98 o Discusting mixup with array length, accessing element a[len]... 99 o unitialised mass value -> obese asteroid, physics bug. 100 62 o Velocity didn-t get passed properly through the 2nd constructor. Used get/set instead. 63 o Rand() geht bis zu riesigen Nummern! rnd() ist zwischen 0 und 1 101 64 102 65 NOTIZEN: 103 o SUPER entspricht ueberladen, andere Argumente der Methode.66 o SUPER 104 67 o Warnungsverhinderung anderswo: (void)pickedUp; // To avoid compiler warning. 105 106 Was ist das? friend class Pickupable; 68 o friend class Pickupable; 107 69 108 70 … … 150 112 this->acceptsPickups_ = false; 151 113 152 //Noetig, damit nicht sofort zerstoert?153 114 this->setCollisionType(WorldEntity::CollisionType::Dynamic); 154 115 this->enableCollisionCallback(); 155 116 156 157 117 // Old from Pawn 158 118 this->registerVariables(); 159 119 160 120 this->initialised = false; 161 162 121 } 163 122 164 123 // @brief Use this constructor with care. Mainly used internally, arguments are passed directly. 165 AsteroidMinable::AsteroidMinable(Context* c, float size, Vector3 position, Vector3 v,bool dropStuff) : Pawn(c){124 AsteroidMinable::AsteroidMinable(Context* c, float size, Vector3 position, bool dropStuff) : Pawn(c){ 166 125 167 126 RegisterObject(AsteroidMinable); … … 172 131 this->setRadarObjectShape(RadarViewable::Shape::Dot); 173 132 }else{ 174 // Somehow remove from radar? 133 // Somehow remove from radar? (all pawns get registered automatically... ) 134 this->setRadarObjectColour(ColourValue(0.663f, 0.663f, 0.663f, 1.0f)); 135 this->setRadarObjectShape(RadarViewable::Shape::Dot); 175 136 } 176 137 … … 184 145 185 146 this->setPosition(position); 186 this->setVelocity(v);187 147 //this->roll = rand()*5; //etwas Drehung. Richtige Variable? 188 148 189 149 this->setCollisionType(WorldEntity::CollisionType::Dynamic); 190 150 this->enableCollisionCallback(); 191 192 151 193 152 // Add Model, random one of the 6 shapes … … 214 173 } 215 174 216 // @brief Helper method. Create a new asteroid to have an appropriate size for the collision shape etc.175 // @brief Helper method. 217 176 void AsteroidMinable::putStuff(){ 218 177 219 // Just create a new asteroid to avoid Collision shape scale problems etc. 220 AsteroidMinable* reborn = new AsteroidMinable(this->context, this->size, this->getPosition(), this->getVelocity(), this->dropStuff); 178 AsteroidMinable* reborn = new AsteroidMinable(this->context, this->size, this->getPosition(), this->dropStuff); 179 reborn->setVelocity(this->getVelocity()); 180 // reborn->setAngularVelocity(this->getAngularVelocity()); // Add all other stuff, too? 221 181 (void)reborn; // avoid compiler warning 182 222 183 this->bAlive_ = false; 223 184 this->destroyLater(); … … 258 219 } 259 220 260 void AsteroidMinable::death(){ // ueberschreibt das Zeugin Pawn221 void AsteroidMinable::death(){ // @brief Überschreibt die Methode in Pawn 261 222 262 223 // just copied that from somewhere else. … … 268 229 269 230 270 // Pickups which can be harvested. 231 // Pickups which can be harvested. It's munition at the moment, could be changed/extended. 271 232 if(dropStuff){ 272 233 PickupSpawner* thingy = new PickupSpawner(this->context); 273 // OFFEN: more precise size relation in custom resource pickup. 234 274 235 char tname[] = ""; // can-t overwrite strings easily in C (strcat etc.) 275 236 if(this->size <= 5){ … … 291 252 } 292 253 293 294 void AsteroidMinable::spawnChildren(){// Spawn smaller Children 254 // @brief If the option generateSmaller is enabled, individual fragments are added with this method. 255 void AsteroidMinable::spawnChildren(){ 295 256 296 257 if (this->size <=1){return;} // Absicherung trivialer Fall … … 298 259 int massRem = this->size-1; //some mass is lost 299 260 int num = round(rnd()*(massRem-1)) + 1; // random number of children, at least one 300 if(num > 10){num = 10;} // no max function in C! 301 int masses[num]; // Masses of the asteroids, at least one. 302 261 if(num > 10){num = 10;} // no max function in C? 262 int masses[num]; // Masses of the asteroids 303 263 // orxout() << "SpawnChildren(): Passed basic stuff. num = " << num << "; massRem(total) = "<< massRem << endl; 304 305 massRem = massRem-num; // mass is at least one, add again below. 264 massRem = massRem-num; // mass must be at least one, add later. 306 265 307 266 // Randomnised spawning points for the new asteroids … … 348 307 //orxout() << "SpawnChildren(): Passed angle stuff. " << endl; 349 308 350 // 'Triangular', discrete probability "density" with max at the expected value massRem/num at a. a+b = c351 if(massRem>0){ // Required to avoid array of size 0 or access problems309 // Triangular, discrete probability "density" with max at the average value massRem/num. 50% chance to be below that. 310 if(massRem>0){ 352 311 int c = massRem; 353 312 float probDensity[c]; … … 372 331 373 332 // Distributing the mass to individual asteroids 374 int result; 375 float rVal; // between 0 and 1376 float probSum; 333 int result; 334 float rVal; // between 0 and 1 335 float probSum; // summing up until rval is reached. 377 336 for(int trav = 0; trav<num; ++trav){ 378 result = 0; // reset379 rVal = rnd(); // between 0 and 1337 result = 0; 338 rVal = rnd(); 380 339 probSum = probDensity[0]; 381 340 382 while(rVal>probSum && result<massRem){// Not yet found && there-s smth left to distribute (Incrementing onceinside!)341 while(rVal>probSum && result<massRem){// Not yet found && there-s smth left to distribute (Incrementing inside!) 383 342 if(result<(massRem-2)){probSum = probSum + probDensity[result+1];} // avoid logical/acess error 384 343 ++result; 385 344 } 386 345 346 masses[trav] = 1 +result; // Fragments have mass of at least one. 387 347 massRem = massRem-result; 388 masses[trav] = 1 +result; // Fragments have mass of at least one. 348 389 349 } 390 350 }else{ … … 404 364 } 405 365 406 AsteroidMinable* child = new AsteroidMinable(this->context, masses[fisch], this->getPosition() + *pos, this->getVelocity(), this->dropStuff); 366 AsteroidMinable* child = new AsteroidMinable(this->context, masses[fisch], this->getPosition() + *pos, this->dropStuff); 367 child->setVelocity(this->getVelocity()); 407 368 408 369 if(child == nullptr){ … … 414 375 } 415 376 416 377 // @brief overloading that to prevent asteroids from taking damage from each other (domino effect etc. ) 417 378 void AsteroidMinable::hit(Pawn* originator, const Vector3& force, const btCollisionShape* cs, float damage, float healthdamage, float shielddamage){ 418 379 419 orxout() << "AsteroidMining::Hit(Variante 1) Dings aufgerufen. " << endl; 420 421 // Kollision mit anderem Asteroid oder Pickup verhindern. In diesem Fall einfach nichts tun. 422 // Wird staending aufgerufen -> Rechenleistung? 380 // orxout() << "AsteroidMining::Hit(Variante 1) Dings aufgerufen. " << endl; 423 381 if(orxonox_cast<AsteroidMinable*>(originator) || orxonox_cast<Pickup*>(originator)){return;} 424 382 this->damage(damage, healthdamage, shielddamage, originator, cs); 425 383 this->setVelocity(this->getVelocity() + force); 426 427 428 384 429 385 // if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator))// && (!this->getController() || !this->getController()->getGodMode()) ) … … 434 390 } 435 391 392 // @brief overloading that to prevent asteroids from taking damage from each other (domino effect etc. ) 436 393 void AsteroidMinable::hit(Pawn* originator, btManifoldPoint& contactpoint, const btCollisionShape* cs, float damage, float healthdamage, float shielddamage){ 437 394 438 395 //orxout() << "AsteroidMining::Hit(Variante 2) Dings aufgerufen. " << endl; 439 // Kollision mit anderem Asteroid oder Pickup (OFFEN: evtl. Spawner oder irgendwas?) verhindern. In diesem Fall einfach nichts tun.440 // Wird staending aufgerufen -> Rechenleistung?441 396 if(orxonox_cast<AsteroidMinable*>(originator) || orxonox_cast<Pickup*>(originator)){return;} 442 443 //orxout() << "Schaden. HP: " << this->health_ << " Dmg: " << damage << " hDmg: " << healthdamage << " sDmg: " << shielddamage << endl;444 445 397 this->damage(damage, healthdamage, shielddamage, originator, cs); 446 447 448 449 398 450 399 // if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator))// && (!this->getController() || !this->getController()->getGodMode()) ) -
code/branches/AsteroidMining_HS17/src/modules/asteroidmining/AsteroidMinable.h
r11664 r11667 29 29 30 30 /** 31 @file AsteroidMinable.h32 31 32 @file 33 @author remartin 34 @brief An asteroid which can be destroyed. Some smaller asteroids are created and a pickup spawns. 35 36 HANDBUCH: 37 o Die Collision Shape kann nur im Konstruktor hinzugefügt werden. Die XML-Argumente werden aber erst nach dem Konstruktor gesetzt. 38 Darum wird hier beim ersten Aufruf der tick()-Methode via putStuff() ein komplett neuer Asteroid generiert und der alte zerstört. 39 o im Level-File includes/pickups.oxi importieren. 40 41 OFFEN/Weiterentwicklung: 42 o @TODO Add resource pickups. 43 --> data_extern/images/effects: PNG's für die Pickups 44 --> https://www.orxonox.net/jenkins/view/Management/job/orxonox_doxygen_trunk/javadoc/group___pickup.html 45 46 o Density doesn't add up to 1... 47 o Does collision damage work properly 48 o Add sound effect (crunching etc. ) (No sound in space...) 49 o Explosion parts 50 51 ANDERORTS VERÄNDERTE SACHEN: 52 Pickup-Zeug: 53 o Pickup.h: createSpawner() neu public statt private 54 o PickupSpawner.h: Zugriffsrechte setPickupTemplateName() und setMaxSpawnedItems() 55 o PickupSpawner.h: In Tick() zwei Testbedingungen eingefügt. 56 o Pawn.h: Attribut acceptsPickups_ inklusive get/set. 57 58 ERLEGTE FEHLER: 59 o Grössenabhängige Collision Shape -> putStuff-Methode, Werte noch nicht durchgesickert. 60 o setHealth: maxHealth() des pawns setzen! 61 o Asteroiden fressen Pickups: Argument in Pawn, Test darauf in Tick() von PickupSpawner. 62 o i++ einfach ganz verhindern, ++i stattdessen. 63 o Velocity didn-t get passed properly through the 2nd constructor. Used get/set instead. 64 o Rand() geht bis zu riesigen Nummern! rnd() ist zwischen 0 und 1 65 66 NOTIZEN: 67 o SUPER 68 o Warnungsverhinderung anderswo: (void)pickedUp; // To avoid compiler warning. 69 o friend class Pickupable; 33 70 34 71 */ … … 48 85 #include "../../orxonox/worldentities/pawns/Pawn.h" 49 86 50 namespace orxonox 51 { 87 namespace orxonox{ 52 88 53 89 … … 55 91 56 92 public: 57 AsteroidMinable(Context* context);// @brief This constructor is for XML access only! 58 AsteroidMinable(Context* c, float size, Vector3 position, Vector3 velocity, bool dS);// @brief Call this Constructor from other C-files. 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); 59 97 60 98 virtual ~AsteroidMinable(); … … 63 101 virtual void tick(float dt) override; 64 102 65 // @brief Overwrite to prevet 'self-collision' of generated stuff103 // @brief overloading that to prevent asteroids from taking damage from each other (domino effect etc. ) 66 104 virtual void hit(Pawn* originator, const Vector3& force, const btCollisionShape* cs, float damage, float healthdamage = 0.0f, float shielddamage = 0.0f); 67 105 virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, const btCollisionShape* cs, float damage, float healthdamage = 0.0f, float shielddamage = 0.0f); … … 80 118 Context* context; 81 119 82 int size; 83 bool generateSmaller; 84 bool dropStuff; 120 int size; //!< Implies health and type of dropped pickups 121 bool generateSmaller; //!< Whether this asteroid leaves fragments 122 bool dropStuff; //!< Whether this asteroid yields valuable stuff 85 123 86 bool initialised; 87 124 // @brief Überschreibt die Methode in Pawn 88 125 virtual void death(); 89 126 127 private: 90 128 129 bool initialised; //!< Used in relation to the constructor detour described above 91 130 92 private:93 131 void registerVariables(); 132 133 // @brief Helper method. 134 virtual void putStuff(); 135 136 // @brief If the option generateSmaller is enabled, individual fragments are added with this method. 94 137 virtual void spawnChildren(); 95 virtual void putStuff();96 138 97 139 // @brief Just for testing. Don-t work anyways. 98 140 void printArrayString(float thingy[]); 99 141 // @brief Just for testing. Don-t work anyways. 100 void printArrayString(int thingy[]);// Just for testing 101 102 103 104 142 void printArrayString(int thingy[]); 105 143 106 144 }; // tolua_export -
code/branches/AsteroidMining_HS17/src/modules/asteroidmining/SpicedAsteroidBelt.cc
r11665 r11667 29 29 /** 30 30 31 @file SpicedAsteroidBelt.cc 31 @file 32 @author remartin 32 33 @brief Asteroid belt with lots of parameters. Derived from asteroidField.lua 33 34 35 Generates a ring of asteroids by calling SpicedAsteroidField multiple times. 36 It's in the xy-plane at default, orientation can be changed with tiltAt 37 (angle where it gets elevated/lowered the most) and TiltBy (angle at z-axis). 38 This doesn't work very well and could probably implemented differently with 39 relative coordinates (attach etc, stuff in WorldEntity). 34 40 41 It is required to wait until all XML-arguments are set. That's why the actual 42 generation happens when tick() gets called for the first time. 43 35 44 */ 36 45 … … 64 73 this->count = 250; 65 74 this->position = Vector3(0,0,0); 66 // this->yaw = 0;67 // this->pitch = 0;68 75 this->segments = 30; 69 76 this->minSize = 1; … … 75 82 this->fogDensity = 0.5; 76 83 77 // Old from Pawn 84 this->tiltAt = 0.0; 85 this->tiltBy = 0.0; 86 78 87 this->registerVariables(); 79 88 … … 87 96 88 97 float myPi = 3.1415927410125732421875; //pi; // Math.pi ist statisch oder so. 89 float dPhi = (2 * myPi) / segments; 90 float width = radius1 - radius0; if(width<0){width = -width;} // predefined abs? 91 float radius = (radius1 + radius0) / 2.0; 92 int segmentCount = round(count / segments); 98 float width = this->radius1 - this->radius0; if(width<0){width = -width;} // predefined abs? 99 float radius = (this->radius1 + this->radius0) / 2.0; 100 int segmentCount = round(this->count / this->segments); 93 101 94 SpicedAsteroidField* af[ segments];102 SpicedAsteroidField* af[this->segments]; 95 103 (void)af[0]; // avoid nasty compiler warning 96 104 105 float dPhi = (2 * myPi) / this->segments; 106 float dTheta = 4.0*this->tiltBy/this->segments; 107 float sepp = -this->tiltAt; 108 float globi = (myPi/2.0) + this->tiltBy; 109 97 110 for(int s = 0; s<segments; ++s){ 98 Vector3* pos = new Vector3(radius*cos(s*dPhi), radius*sin(s*dPhi),0); 111 sepp = sepp + dPhi; 112 if(s<segments/2){ 113 globi = globi - dTheta; 114 }else{ 115 globi = globi + dTheta; 116 } 117 118 Vector3* pos = new Vector3(radius*cos(sepp)*sin(globi), radius*sin(sepp)*sin(globi), radius*cos(globi)); 99 119 af[s] = new SpicedAsteroidField(this->context, this->position + *pos, this->minSize, this->maxSize, width, segmentCount, this->foggy, this->mDensity, this->fogDensity); 120 100 121 } 101 122 … … 109 130 XMLPortParam(SpicedAsteroidBelt, "mDensity", setMineralDensity, getMineralDensity, xmlelement, mode); 110 131 XMLPortParam(SpicedAsteroidBelt, "position", setPosition, getPosition, xmlelement, mode); 111 // XMLPortParam(SpicedAsteroidBelt, "yaw", setYaw, getYaw, xmlelement, mode);112 // XMLPortParam(SpicedAsteroidBelt, "pitch", setPitch, getPitch, xmlelement, mode);113 132 XMLPortParam(SpicedAsteroidBelt, "segments", setSegments, getSegments, xmlelement, mode); 114 133 … … 119 138 XMLPortParam(SpicedAsteroidBelt, "foggy", setFog, isFoggy, xmlelement, mode); 120 139 XMLPortParam(SpicedAsteroidBelt, "fogDensity", setFogDensity, getFogDensity, xmlelement, mode); 140 141 XMLPortParam(SpicedAsteroidBelt, "tiltAt", setTiltAt, getTiltAt, xmlelement, mode); 142 XMLPortParam(SpicedAsteroidBelt, "tiltBy", setTiltBy, getTiltBy, xmlelement, mode); 121 143 122 144 } … … 131 153 registerVariable(this->mDensity, VariableDirection::ToClient); 132 154 registerVariable(this->position, VariableDirection::ToClient); 133 // registerVariable(this->yaw, VariableDirection::ToClient);134 // registerVariable(this->pitch, VariableDirection::ToClient);135 155 registerVariable(this->segments, VariableDirection::ToClient); 136 156 … … 141 161 registerVariable(this->foggy, VariableDirection::ToClient); 142 162 registerVariable(this->fogDensity, VariableDirection::ToClient); 163 164 registerVariable(this->tiltAt, VariableDirection::ToClient); 165 registerVariable(this->tiltBy, VariableDirection::ToClient); 143 166 144 167 } -
code/branches/AsteroidMining_HS17/src/modules/asteroidmining/SpicedAsteroidBelt.h
r11665 r11667 23 23 * Fabian 'x3n' Landau 24 24 * Co-authors: 25 * ...26 25 * 27 26 */ … … 29 28 /** 30 29 31 @file SpicedAsteroidBelt.h 30 @file 31 @author remartin 32 32 @brief Asteroid belt with lots of parameters. Derived from asteroidField.lua 33 33 34 Generates a ring of asteroids by calling SpicedAsteroidField multiple times. 35 It's in the xy-plane at default, orientation can be changed with tiltAt 36 (angle where it gets elevated/lowered the most) and TiltBy (angle at z-axis). 37 This doesn't work very well and could probably implemented differently with 38 relative coordinates (attach etc, stuff in WorldEntity). 34 39 40 It is required to wait until all XML-arguments are set. That's why the actual 41 generation happens when tick() gets called for the first time. 42 35 43 */ 36 44 … … 72 80 inline Vector3 getPosition(){return this->position;} 73 81 74 // inline void setYaw(float y){this->yaw = y;}75 // inline float getYaw(){return this->yaw;}76 77 // inline void setPitch(float p){this->pitch = p;}78 // inline float getPitch(){return this->pitch;}79 80 82 inline void setSegments(int s){this->segments = s;} 81 83 inline int getSegments(){return this->segments;} … … 99 101 inline float getFogDensity(){return this->fogDensity;} 100 102 103 inline void setTiltAt(float ta){this->tiltAt = ta;} 104 inline void setTiltBy(float tb){this->tiltBy = tb;} 105 inline float getTiltAt(){return this->tiltAt;} 106 inline float getTiltBy(){return this->tiltBy;} 107 101 108 102 109 protected: … … 104 111 Context* context; 105 112 106 float count; 107 float mDensity; // Mineral density,between 0 and 1;113 float count; //!< Approximate number of asteroids 114 float mDensity; //!< Approximate commonness of asteroids that yield stuff, value between 0 and 1; 108 115 109 116 Vector3 position; 110 117 111 // float yaw; 112 // float pitch; 113 int segments; 118 int segments; //!< Number of asteroidFields that get generated. 114 119 115 int maxSize; 116 int minSize; 120 int maxSize; //!< Most obese asteroid possible 121 int minSize; //!< Most meagre asteroid possible 117 122 118 float radius0; 119 float radius1; 123 float radius0; //!< Inner radius 124 float radius1; //!< Outer radius 120 125 121 bool foggy; 126 bool foggy; //!< Whether there's fog arount the asteroids 122 127 float fogDensity; 123 128 124 virtual void create(); 129 float tiltAt; //!< Orientation: Angle where it gets elevated/lowered the most 130 float tiltBy; //!< angle at z-axis 125 131 126 132 private: 127 133 void registerVariables(); 134 135 virtual void create(); 128 136 129 137 }; // tolua_export -
code/branches/AsteroidMining_HS17/src/modules/asteroidmining/SpicedAsteroidField.cc
r11664 r11667 29 29 /** 30 30 31 @file SpicedAsteroidField.cc 31 @file 32 @author remartin 32 33 @brief Asteroid field with lots of parameters. Derived from asteroidField.lua 33 34 34 35 Generates a bunch of asteroids that may contain some stuff. 36 It is required to wait until all XML-arguments are set. That's why the actual 37 generation happens when tick() gets called for the first time. 38 35 39 */ 36 40 … … 105 109 Vector3* relPos; 106 110 107 108 111 for(int gertrud = 0; gertrud<count; ++gertrud){ 109 112 … … 111 114 112 115 size = round(rnd()*(this->maxSize - this->minSize)) + this->minSize; 113 a->setSize(size); 116 a->setSize(size); 117 114 118 pX = round(rnd()*2*this->radius) - radius; 115 119 pY = round(rnd()*2*this->radius) - radius; … … 118 122 a->setPosition(this->position + *relPos); 119 123 120 bool spiced = (rnd() < (this->mDensity)); // does drop pickups etc.124 bool spiced = (rnd() < (this->mDensity)); // Whether the asteroid does drop pickups etc. 121 125 a->toggleDropStuff(spiced); 122 123 // A problem124 a->setVelocity(this->getVelocity());125 126 126 // Fog is iplemented with billboards. 127 a->setVelocity(this->getVelocity()); 128 129 // Fog is iplemented with billboards (as in asteroidField.lua, that bloke had the idea) 127 130 Billboard* bb; 128 131 if(this->foggy && mod(gertrud, 5) == 0){ -
code/branches/AsteroidMining_HS17/src/modules/asteroidmining/SpicedAsteroidField.h
r11664 r11667 23 23 * Fabian 'x3n' Landau 24 24 * Co-authors: 25 * ...26 25 * 27 26 */ … … 29 28 /** 30 29 31 @file SpicedAsteroidField.h 30 @file 31 @author remartin 32 32 @brief Asteroid field with lots of parameters. Derived from asteroidField.lua 33 33 34 34 Generates a bunch of asteroids that may contain some stuff. 35 It is required to wait until all XML-arguments are set. That's why the actual 36 generation happens when tick() gets called for the first time. 37 35 38 */ 36 39 … … 91 94 Context* context; 92 95 93 float count; 94 float mDensity; // Mineral density, between 0 and 1;96 float count; //!< Number of asteroids generated 97 float mDensity; //!< Mineral density, between 0 and 1; 95 98 96 Vector3 position; 99 Vector3 position; //!< The center 97 100 98 int maxSize; 99 int minSize; 101 int maxSize; //!< Upper bound to asteroid size 102 int minSize; //!< Lower bound to asteroid size 100 103 101 float radius; 102 bool foggy; 104 float radius; //!< Asteroids can appear within a sphere. 105 bool foggy; //!< Whether there's fog 103 106 float fogDensity; 104 105 virtual void create();106 107 107 108 108 … … 110 110 void registerVariables(); 111 111 112 virtual void create(); 113 114 112 115 }; // tolua_export 113 116 } // tolua_export
Note: See TracChangeset
for help on using the changeset viewer.