Changeset 11640
- Timestamp:
- Dec 4, 2017, 4:38:17 PM (7 years ago)
- Location:
- code/branches/AsteroidMining_HS17
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/AsteroidMining_HS17/data/levels/AsteroidFarming.oxw
r11581 r11640 41 41 42 42 <!-- Asteroid Display: --> 43 43 <Model position="0, 0,40" yaw="90" pitch="-90" roll="0" scale="3" mesh="ast1.mesh" /> 44 44 <Model position="0, 20,40" yaw="90" pitch="-90" roll="0" scale="3" mesh="ast2.mesh" /> 45 45 <Model position="0, 40,40" yaw="90" pitch="-90" roll="0" scale="3" mesh="ast3.mesh" /> … … 77 77 </Pawn> 78 78 79 <!----Just a box with different mesh--> 79 80 <Pawn team=1 health=50 position="0,1000,0" direction="0,-1,0" collisionType=dynamic mass=100000 name=box RVName = "Globi Asteroid" > 80 81 <events> … … 94 95 95 96 <!-----AsteroidMinable ---> 96 97 97 <AsteroidMinable size=15 position="0,-500,0" /> 98 98 <AsteroidMinable size=5 position="100,-500,100" /> 99 99 <AsteroidMinable size=50 position="500,-500, 500" /> 100 <AsteroidMinable size=30 position="-100, -500, -100" velocity= "0, -30, 0"/> 100 101 101 102 <!--- SpicedAsteroidField ---> 103 <SpicedAsteroidField count=30 mDensity= 0.5 maxSize=40 minSize=1 position="5000, 0, 0" radius=1000/> 102 104 103 105 -
code/branches/AsteroidMining_HS17/src/modules/asteroidmining/AsteroidMinable.cc
r11618 r11640 43 43 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 44 44 45 FRAGEN:46 * Zeilen-Loeschung beim output47 * orxout()-Problem48 * dokumentieren mit @brief?49 * Warnumg aus Asteroidenzerstoerung50 51 45 52 46 KNACKPUNKTE: 53 47 54 55 48 OFFEN: 56 57 o Mass distribution -> weird for bigger asteroids58 --> more testing59 60 o SpicedAsteroidField fertigstellen, Mineraldichten-Parameter61 49 62 50 o Add custom pickup 'resources'. Weird template stuff -> Problems setting 'size' and other properties? setNumber of Resources. … … 65 53 ----> im MineralsPickup die isPickedUp()-Methode überschreiben? 66 54 --> data_extern/images/effects: PNG's für die Pickups und GUI-Dinger. 67 68 o inherit parent velocity 55 --> https://www.orxonox.net/jenkins/view/Management/job/orxonox_doxygen_trunk/javadoc/group___pickup.html 56 57 o Anfangsgeschwindigkeit fuers Asteroidenfeld 58 o Density doesn't add up to 1... 69 59 o set collisionDamage? Just for static entities? 60 o AsteroidBelt? 61 70 62 o Dokumentieren mit @brief? 71 63 o unregister -empty- asteroids from radar. (or turn them green or whatever) 64 o Add sound effect (crunching etc. ) (No sound in space...) 72 65 o Explosion parts 73 66 o custom HUD 67 74 68 75 69 HANDBUCH: … … 85 79 o Pawn.h: Attribut acceptsPickups_ inklusive get/set. 86 80 87 ERLEGT :81 ERLEGTE FEHLER: 88 82 o Rand() geht bis zu riesigen Nummern! 89 83 o Pickupgenerierung: vgl. Fremdanpassungen. … … 158 152 RegisterClass(AsteroidMinable); 159 153 160 161 // This constructor is for XML access only. 154 // @brief Standard constructor 162 155 AsteroidMinable::AsteroidMinable(Context* context) : Pawn(context){ 163 156 164 // Da auch noetig? Wegen set in XML-Code?165 157 RegisterObject(AsteroidMinable); 166 158 167 159 this->context = context; 168 160 this->initialised = false; 161 this->dropStuff = true; // Default 169 162 170 163 //Noetig, damit nicht sofort zerstoert? … … 178 171 } 179 172 180 // Call this one from other C-files. Takes arguments.181 AsteroidMinable::AsteroidMinable(Context* c, float size, Vector3 position ) : Pawn(c){173 // @brief Use this constructor with care. Mainly used internally, arguments are passed directly. 174 AsteroidMinable::AsteroidMinable(Context* c, float size, Vector3 position, Vector3 v, bool dropStuff) : Pawn(c){ 182 175 183 176 RegisterObject(AsteroidMinable); 184 177 185 // Old stuff from pawn 186 this->setRadarObjectColour(ColourValue(1.0f, 1.0f, 0.0f, 1.0f)); 187 this->setRadarObjectShape(RadarViewable::Shape::Dot); 178 // The radar is able to detect whether an asteroid contains resources.... 179 if(dropStuff){ 180 this->setRadarObjectColour(ColourValue(1.0f, 1.0f, 0.0f, 1.0f)); 181 this->setRadarObjectShape(RadarViewable::Shape::Dot); 182 }else{ 183 // Somehow remove from radar? 184 } 185 188 186 this->setCollisionType(WorldEntity::CollisionType::Dynamic); 189 190 187 this->enableCollisionCallback(); 191 188 192 189 // Default Values 193 this->generateSmaller = true;194 190 this->context = c; 195 191 this->size = size; 196 192 this->health_ = 15*size; 197 193 this->maxHealth_ = this->health_; 198 this->acceptsPickups_ = false; 194 this->acceptsPickups_ = false; 195 this->generateSmaller = true; 196 this->dropStuff = dropStuff; 199 197 200 198 this->setPosition(position); 199 this->setVelocity(v); // velocity = v; // The right one? 201 200 //this->roll = rand()*5; //etwas Drehung. richtige Variable 202 201 … … 228 227 229 228 } 230 229 // @brief Helper method. Create a new asteroid to have an appropriate size for the collision shape etc. 231 230 void AsteroidMinable::putStuff(){ 232 231 233 232 // Just create a new asteroid to avoid Collision shape scale problems etc. 234 AsteroidMinable* reborn = new AsteroidMinable(this->context, this->size, this->getPosition() );233 AsteroidMinable* reborn = new AsteroidMinable(this->context, this->size, this->getPosition(), this->getVelocity(), this->dropStuff); 235 234 reborn->toggleShattering(true); // mainly here to avoid 'unused' warning. 236 this->~AsteroidMinable(); // seems dangerous, yields warning. Necessary for efficiency? 235 this->bAlive_ = false; 236 this->destroyLater(); 237 //this->~AsteroidMinable(); // seems dangerous, yields warning. Necessary for efficiency? 237 238 238 239 } … … 276 277 } 277 278 278 void AsteroidMinable::setSize(float s){ 279 this->size = s; 280 } 281 282 float AsteroidMinable::getSize(){ 283 return this->size; 284 } 285 286 void AsteroidMinable::toggleShattering(bool b){ 287 this->generateSmaller = b; 288 } 279 289 280 290 281 … … 304 295 305 296 306 // Stuff that can be harvested. 307 PickupSpawner* thingy = new PickupSpawner(this->context); 308 // OFFEN: more precise size relation in custom resource pickup. 309 char tname[] = ""; // can-t overwrite strings easily in C (strcat etc.) 310 if(this->size <= 5){ 311 strcat(tname, "smallmunitionpickup"); 312 }else if(this->size <= 20){ 313 strcat(tname, "mediummunitionpickup"); 314 }else{ 315 strcat(tname, "hugemunitionpickup"); 316 } 317 thingy->setPickupTemplateName(tname); 318 thingy->setPosition(this->getPosition()); 319 thingy->setMaxSpawnedItems(1); // Would be default anyways 320 thingy->setRespawnTime(0.2f); 321 297 // Pickups which can be harvested. 298 if(dropStuff){ 299 PickupSpawner* thingy = new PickupSpawner(this->context); 300 // OFFEN: more precise size relation in custom resource pickup. 301 char tname[] = ""; // can-t overwrite strings easily in C (strcat etc.) 302 if(this->size <= 5){ 303 strcat(tname, "smallmunitionpickup"); 304 }else if(this->size <= 20){ 305 strcat(tname, "mediummunitionpickup"); 306 }else{ 307 strcat(tname, "hugemunitionpickup"); 308 } 309 thingy->setPickupTemplateName(tname); 310 thingy->setPosition(this->getPosition()); 311 thingy->setMaxSpawnedItems(1); // Would be default anyways 312 thingy->setRespawnTime(0.2f); 313 } 322 314 // orxout() << "AsteroidMining::Death(): Passed Pickup stuff!" << endl; 323 315 … … 339 331 if(num > 10){num = 10;} // no max function in C! 340 332 int masses[num]; // Masses of the asteroids, at least one. 341 orxout() << "SpawnChildren(): Passed basic stuff. num = " << num << "; massRem(total) = "<< massRem << endl;333 //orxout() << "SpawnChildren(): Passed basic stuff. num = " << num << "; massRem(total) = "<< massRem << endl; 342 334 343 335 massRem = massRem-num; // mass is at least one, add again below. … … 346 338 float phi[num] = {0.0}; // assuming that it gets initialised to 0. Add (= {0.0})? 347 339 float theta[num] = {0.0}; 348 float piG = pi; //ist statisch oder so.340 float piG = 3.1415927410125732421875; //pi; // Math.pi ist statisch oder so. 349 341 350 342 float d_p = 2*piG/num; … … 380 372 //orxout() << "SpawnChildren(): Phi: "; printArrayString(phi); 381 373 //orxout() << "SpawnChildren(): Theta: "; printArrayString(theta); 382 orxout() << "SpawnChildren(): Passed angle stuff. " << endl;383 384 // 'Triangular', discrete probability densitywith max at the expected value massRem/num at a. a+b = c374 //orxout() << "SpawnChildren(): Passed angle stuff. " << endl; 375 376 // 'Triangular', discrete probability "density" with max at the expected value massRem/num at a. a+b = c 385 377 if(massRem>0){ // Required to avoid array of size 0 or access problems 386 378 int c = massRem; … … 397 389 for(z = 0; z<b; ++z){probDensity[c-z] = (z+1)*dProbB;} // falling part 398 390 399 // Testing 400 for(int globi = 0; globi<c; ++globi){ 401 orxout() << "pDensity at [" << globi << "] is: " << probDensity[globi] << endl; 402 } 391 // // Just for testing: 392 // float sum = 0.0; 393 // for(int globi = 0; globi<c; ++globi){ 394 // orxout() << "pDensity at [" << globi << "] is: " << probDensity[globi] << endl; 395 // sum = sum+ probDensity[globi]; 396 // } 397 // orxout() << "Sum of densities should b 1, it is: " << sum << endl; 403 398 404 399 // Distributing the mass to individual asteroids … … 409 404 result = 0;// reset 410 405 rVal = rnd();// between 0 and 1 411 orxout() << "Random Value picked: " << rVal << endl;406 // orxout() << "Random Value picked: " << rVal << endl; 412 407 probSum = probDensity[0]; 413 408 //orxout() << "Sum at start: " << probSum << endl; 414 409 415 410 while(rVal>probSum && result<massRem){// Not yet found && there-s smth to distribute (Incrementing once inside!) 416 if(result<( num-2)){probSum = probSum+probDensity[result+1];} // avoid logical/acess error411 if(result<(massRem-2)){probSum = probSum + probDensity[result+1];} // avoid logical/acess error 417 412 ++result; 418 // orxout() << "Sum so far: " << probSum <<endl;413 // orxout() << "Sum so far: " << probSum << ". Just added " << probDensity[result+1] << endl; 419 414 } 420 415 421 416 massRem = massRem-result; 422 417 masses[trav] = 1 +result; // at least one 423 orxout() << "Mass chosen for child " << trav << " is: " << masses[trav] << endl;418 // orxout() << "Mass chosen for child " << trav << " is: " << masses[trav] << endl; 424 419 425 420 } … … 430 425 } 431 426 432 // orxout() << "SpawnChildren(): Masses: "; printArrayString(masses);433 orxout() << "SpawnChildren(): Passed mass stuff. " << endl;427 // orxout() << "SpawnChildren(): Masses: "; printArrayString(masses); 428 // orxout() << "SpawnChildren(): Passed mass stuff. " << endl; 434 429 435 430 // Creating the 'chlidren': … … 442 437 } 443 438 444 // orxout() << "Creating asteroid with mass " << masses[fisch] << " at relative postition " << *pos << endl;445 AsteroidMinable* child = new AsteroidMinable(this->context, masses[fisch], this->getPosition() + *pos );439 // orxout() << "Creating asteroid with mass " << masses[fisch] << " at relative postition " << *pos << endl; 440 AsteroidMinable* child = new AsteroidMinable(this->context, masses[fisch], this->getPosition() + *pos, this->getVelocity(), this->dropStuff); 446 441 447 442 if(child == nullptr){ … … 450 445 451 446 } 452 orxout() << "Leaving spawnChildren() method. " << endl;447 // orxout() << "Leaving spawnChildren() method. " << endl; 453 448 } 454 449 … … 458 453 orxout() << "AsteroidMining::Hit(Variante 1) Dings aufgerufen. " << endl; 459 454 460 // Kollision mit anderem Asteroid oder Pickup (OFFEN: evtl. Spawner oder irgendwas?)verhindern. In diesem Fall einfach nichts tun.455 // Kollision mit anderem Asteroid oder Pickup verhindern. In diesem Fall einfach nichts tun. 461 456 // Wird staending aufgerufen -> Rechenleistung? 462 457 if(orxonox_cast<AsteroidMinable*>(originator) || orxonox_cast<Pickup*>(originator)){return;} … … 496 491 } 497 492 493 // @brief Just for testing. Don-t work anyways. 498 494 void AsteroidMinable::printArrayString(float thingy[]){ // Don-t work! 499 495 … … 509 505 } 510 506 507 // @brief Just for testing. Don-t work anyways. 511 508 void AsteroidMinable::printArrayString(int thingy[]){ 512 509 … … 524 521 } 525 522 526 527 523 // void AsteroidMinable::printArrayString(int thingy[]){ 528 529 524 // char res[] = "["; 530 525 // //strcat(res, "["); … … 547 542 // } 548 543 549 550 551 //Pawn:552 // void Pawn::hit(Pawn* originator, const Vector3& force, const btCollisionShape* cs, float damage, float healthdamage, float shielddamage)553 // {554 // if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator) && (!this->getController() || !this->getController()->getGodMode()) )555 // {556 // this->damage(damage, healthdamage, shielddamage, originator, cs);557 // this->setVelocity(this->getVelocity() + force);558 // }559 // }560 561 // void Pawn::hit(Pawn* originator, btManifoldPoint& contactpoint, const btCollisionShape* cs, float damage, float healthdamage, float shielddamage)562 // {563 // if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator) && (!this->getController() || !this->getController()->getGodMode()) )564 // {565 // this->damage(damage, healthdamage, shielddamage, originator, cs);566 567 // if ( this->getController() )568 // this->getController()->hit(originator, contactpoint, damage); // changed to damage, why shielddamage?569 // }570 // }571 572 573 574 575 // /**576 // @brief577 // Virtual function that gets called when this object collides with another.578 // @param otherObject579 // The object this one has collided into.580 // @param ownCollisionShape581 // The collision shape of the other object582 // @param contactPoint583 // Contact point provided by Bullet. Holds more information and can me modified. See return value.584 // @return585 // Returning false means that no modification to the contactPoint has been made. Return true otherwise!586 // @note587 // Condition is that enableCollisionCallback() was called.588 // */589 // virtual inline bool collidesAgainst(WorldEntity* otherObject, const btCollisionShape* ownCollisionShape, btManifoldPoint& contactPoint)590 // { return false; } /* With false, Bullet assumes no modification to the collision objects. */591 592 // //! Enables the collidesAgainst(.) function. The object doesn't respond to collision otherwise!593 // inline void enableCollisionCallback()594 // { this->bCollisionCallbackActive_ = true; this->collisionCallbackActivityChanged(); }595 596 597 598 // //! Disables the collidesAgainst(.) function. @see enableCollisionCallback()599 // inline void disableCollisionCallback()600 // { this->bCollisionCallbackActive_ = false; this->collisionCallbackActivityChanged(); }601 602 603 // //! Tells whether there could be a collision callback via collidesAgainst(.)604 // inline bool isCollisionCallbackActive() const605 // { return this->bCollisionCallbackActive_; }606 607 // //! Enables or disables collision response (default is of course on)608 // inline void setCollisionResponse(bool value)609 // { this->bCollisionResponseActive_ = value; this->collisionResponseActivityChanged(); }610 611 612 // //! Tells whether there could be a collision response613 // inline bool hasCollisionResponse()614 // { return this->bCollisionResponseActive_; }615 616 617 544 } 618 619 620 621 622 623 /*624 void DronePickup::changedUsed(void)625 {626 SUPER(DronePickup, changedUsed);627 628 // If the pickup has transited to used.629 if(this->isUsed())630 {631 632 Pawn* pawn = this->carrierToPawnHelper();633 if(pawn == nullptr) // If the PickupCarrier is no Pawn, then this pickup is useless and therefore is destroyed.634 this->Pickupable::destroy();635 636 //Attach to pawn637 Drone* drone = new Drone(pawn->getContext()); // this is neccessary because the projectiles fired need a valid creator for the particlespawner (when colliding against something)638 drone->addTemplate(this->getDroneTemplate());639 640 Controller* controller = drone->getController();641 DroneController* droneController = orxonox_cast<DroneController*>(controller);642 if(droneController != nullptr)643 {644 droneController->setOwner(pawn);645 }646 647 Vector3 spawnPosition = pawn->getWorldPosition() + Vector3(30,0,-30);648 drone->setPosition(spawnPosition);649 650 // The pickup has been used up.651 this->setUsed(false);652 }653 else654 {655 // If either the pickup can only be used once or it is continuous and used up, it is destroyed upon setting it to unused.656 if(this->isOnce() || (this->isContinuous() ))657 {658 this->Pickupable::destroy();659 }660 }661 }662 */ -
code/branches/AsteroidMining_HS17/src/modules/asteroidmining/AsteroidMinable.h
r11618 r11640 41 41 #include "../../orxonox/worldentities/pawns/Pawn.h" 42 42 43 namespace orxonox // tolua_export43 namespace orxonox 44 44 { 45 45 46 46 47 // tolua_export 48 class _OrxonoxExport AsteroidMinable : public Pawn 49 { // tolua_export 47 class _OrxonoxExport AsteroidMinable : public Pawn{ 50 48 51 49 public: 52 50 AsteroidMinable(Context* context);// This constructor is for XML access only! 53 AsteroidMinable(Context* c, float size, Vector3 position );// Call this Constructor from other C-files.51 AsteroidMinable(Context* c, float size, Vector3 position, Vector3 velocity, bool dS);// Call this Constructor from other C-files. 54 52 55 53 virtual ~AsteroidMinable(); … … 62 60 virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, const btCollisionShape* cs, float damage, float healthdamage = 0.0f, float shielddamage = 0.0f); 63 61 62 inline void setSize(int s){this->size = s;} 63 inline int getSize(){return this->size;} 64 64 65 66 virtual void setSize(float f); 67 virtual float getSize(); 68 69 virtual void toggleShattering(bool b); 70 71 72 65 inline void toggleShattering(bool b){this->generateSmaller = b;} 66 inline void toggleDropStuff(bool b){this->dropStuff = b;} 73 67 74 68 75 69 protected: 76 // Da neue Argumente reinstellen77 //float asteroidVersion; // Bodenstrich-Konvention?,78 // Wert zwischen 1 und 6 (Spezialdinger?), die Mesh-Form79 float size;80 bool generateSmaller;81 bool initialised;82 70 83 71 Context* context; 84 72 73 int size; 74 bool generateSmaller; 75 bool dropStuff; 76 bool initialised; 77 85 78 virtual void death(); 86 virtual void putStuff();87 79 88 80 … … 91 83 void registerVariables(); 92 84 virtual void spawnChildren(); 85 virtual void putStuff(); 93 86 94 void printArrayString(float thingy[]);// Just for testing 87 // @brief Just for testing. Don-t work anyways. 88 void printArrayString(float thingy[]); 89 // @brief Just for testing. Don-t work anyways. 95 90 void printArrayString(int thingy[]);// Just for testing 96 91 -
code/branches/AsteroidMining_HS17/src/modules/asteroidmining/CMakeLists.txt
r11547 r11640 1 1 SET_SOURCE_FILES(PICKUP_SRC_FILES 2 2 AsteroidMinable.cc 3 SpicedAsteroidField.cc 3 4 ) 4 5 -
code/branches/AsteroidMining_HS17/src/modules/asteroidmining/SpicedAsteroidField.cc
r11615 r11640 31 31 * 32 32 * 33 *<OFFEN Describe 33 *<OFFEN Describe 34 Math from asteroidField.lua used. 34 35 * 35 36 * 37 38 39 DESCRIPTION 40 o Andere: Simpel wie in asteroidField.lua, oder einfach Asteroiden, die nichts abwerfen? 41 --> Letzteres scheint passender, simpler. 42 36 43 37 44 */ … … 77 84 RegisterClass(SpicedAsteroidField); 78 85 79 SpicedAsteroidField::SpicedAsteroidField(Context* context) {86 SpicedAsteroidField::SpicedAsteroidField(Context* context) : Pawn(context) { 80 87 81 88 // Da auch noetig? Wegen set in XML-Code? … … 83 90 84 91 this->context = context; 85 this->initialised = false; 86 87 //Noetig, damit nicht sofort zerstoert? 88 this->setCollisionType(WorldEntity::CollisionType::Dynamic); 92 this->foggy = true; 93 this->fogDensity = 0.5; 89 94 90 95 // Old from Pawn 91 96 this->registerVariables(); 92 97 93 orxout() << "AsteroidMining:: Pseudo-Konstruktor passiert!" << endl; 94 98 99 // this->create(); 100 this->bAlive_ = false; 101 this->destroyLater(); 95 102 } 96 103 … … 101 108 void SpicedAsteroidField::create(){ 102 109 103 104 105 110 int size; 111 int pX; 112 int pY; 113 int pZ; 114 115 Vector3* relPos; 116 117 for(int gertrud = 0; gertrud<count; ++gertrud){ 118 119 AsteroidMinable* a = new AsteroidMinable(this->context); 120 121 size = round(rnd()*(this->maxSize - this->minSize)) + this->minSize; 122 a->setSize(size); 123 124 pX = round(rnd()*2*this->radius) - radius; 125 pY = round(rnd()*2*this->radius) - radius; 126 pZ = round(rnd()*2*this->radius) - radius; 127 relPos = new Vector3(pX, pY, pZ); 128 a->setPosition(this->position + *relPos); 129 130 bool spiced = (rnd() < (this->mDensity)); // does drop pickups etc. 131 a->toggleDropStuff(spiced); 132 133 // @TODO: Fox Fog stuff, error due to billbord 134 135 // Billboard* bb; 136 // if(this->foggy && mod(gertrud, 5) == 0){ 137 // bb = new Billboard(this->context); 138 // bb->setPosition(this-position + *relPos); 139 // bb->setMaterial("Smoke/Smoke"); 140 // bb->setScale(size); // tricky? 141 142 // bb->setColour(ColourValue(this-fogDensity, this->fogDensity, this->fogDensity)); // 4rd argument = transparency? 143 144 // // print("<Billboard ") 145 // // print("position = \"") 146 // // print(posX) print(",") 147 // // print(posY) print(",") 148 // // print(posZ) print("\" ") 149 // // print("colour=\"") 150 // // print(brightness) print(",") 151 // // print(brightness) print(",") 152 // // print(brightness) print("\" ") 153 // // print("material=\"Smoke/Smoke\" scale=") 154 // // print(size) 155 // // print(" />") 156 // } 157 } 106 158 } 107 159 108 160 void SpicedAsteroidField::XMLPort(Element& xmlelement, XMLPort::Mode mode) 109 161 { 110 SUPER(SpicedAsteroidField, XMLPort, xmlelement, mode);162 // SUPER(SpicedAsteroidField, XMLPort, xmlelement, mode); 111 163 // XMLPortParam(PickupSpawner, "pickup", setPickupTemplateName, getPickupTemplateName, xmlelement, mode); 112 164 XMLPortParam(SpicedAsteroidField, "count", setCount, getCount, xmlelement, mode); … … 117 169 XMLPortParam(SpicedAsteroidField, "radius", setRadius, getRadius, xmlelement, mode); 118 170 XMLPortParam(SpicedAsteroidField, "foggy", setFog, isFoggy, xmlelement, mode); 119 171 XMLPortParam(SpicedAsteroidField, "fogDensity", setFogDensity, getFogDensity, xmlelement, mode); 120 172 121 173 } … … 126 178 void SpicedAsteroidField::XMLEventPort(Element& xmlelement, XMLPort::Mode mode) 127 179 { 128 SUPER(SpicedAsteroidField, XMLEventPort, xmlelement, mode);180 // SUPER(SpicedAsteroidField, XMLEventPort, xmlelement, mode); 129 181 130 182 XMLPortEventState(SpicedAsteroidField, BaseObject, "vulnerability", setVulnerable, xmlelement, mode); … … 133 185 void SpicedAsteroidField::registerVariables() 134 186 { 135 // registerVariable(this->bAlive_, VariableDirection::ToClient); 136 // registerVariable(this->bVulnerable_, VariableDirection::ToClient); 137 // registerVariable(this->health_, VariableDirection::ToClient); 138 // registerVariable(this->maxHealth_, VariableDirection::ToClient); 139 140 registerVariable(this->size, VariableDirection::ToClient); 141 registerVariable(this->generateSmaller, VariableDirection::ToClient); 142 143 registerVariable(this->initialised, VariableDirection::ToClient); 144 //registerVariable(this->context, VariableDirection::ToClient); // can't link that since it's a context 145 146 147 // float size; 148 // bool generateSmaller; 149 // bool initialised; 150 151 // Context* context; 152 } 153 154 void SpicedAsteroidField::tick(float dt) 155 { 187 188 registerVariable(this->count, VariableDirection::ToClient); 189 registerVariable(this->mDensity, VariableDirection::ToClient); 190 registerVariable(this->position, VariableDirection::ToClient); 191 registerVariable(this->maxSize, VariableDirection::ToClient); 192 registerVariable(this->minSize, VariableDirection::ToClient); 193 registerVariable(this->radius, VariableDirection::ToClient); 194 registerVariable(this->foggy, VariableDirection::ToClient); 195 registerVariable(this->fogDensity, VariableDirection::ToClient); 196 197 198 } 199 200 void SpicedAsteroidField::tick(float dt){ 156 201 157 202 this->create(); 158 this->~SpicedAsteroidField(); // seems dangerous. Necessary for efficiency? 159 160 203 this->bAlive_ = false; 204 this->destroyLater(); 161 205 } 162 206 … … 166 210 167 211 } 212 213 // --[[ fog generator 214 // generates fog 215 // posX, posY, posZ - position in space 216 // size - size of billboard 217 // brightness - [0,1] fog brightness 218 // --]] 219 // function generateFog(posX, posY, posZ, size, brightness) 220 // print("<Billboard ") 221 // print("position = \"") 222 // print(posX) print(",") 223 // print(posY) print(",") 224 // print(posZ) print("\" ") 225 // print("colour=\"") 226 // print(brightness) print(",") 227 // print(brightness) print(",") 228 // print(brightness) print("\" ") 229 // print("material=\"Smoke/Smoke\" scale=") 230 // print(size) 231 // print(" />") 232 // end 233 234 // --[[ asteroid field generator 235 // generates asteroid field 236 // posX, posY, posZ - position in space 237 // minSize, maxSize - size boundaries of each asteroid 238 // radius - size of the cube around position in space 239 // count - number of asteroids 240 // fog - enable fog 0/1 241 // --]] 242 // function asteroidField(posX, posY, posZ, minSize, maxSize, radius, count, fog) 243 // for i = 1, count, 1 do 244 // size = (math.random() * (maxSize - minSize)) + minSize 245 // pX = (2 * math.random() * radius) - radius + posX 246 // pY = (2 * math.random() * radius) - radius + posY 247 // pZ = (2 * math.random() * radius) - radius + posZ 248 // print("<StaticEntity ") 249 250 // print("position = \"") 251 // print(pX) print(",") 252 // print(pY) print(",") 253 // print(pZ) print("\" ") 254 255 // print("scale = \"") print(size) print("\" ") 256 257 // print("collisionType = static linearDamping = 0.8 angularDamping = 1 ") 258 // print("collisiondamage = 1000 enablecollisiondamage = true>") 259 260 // print("<attached>") 261 // print("<Model mass=\"") print(size * 10) print("\" ") 262 // print("mesh=\"ast") print(math.mod(i,6) + 1) print(".mesh\" />") 263 // print("</attached>") 264 265 // print("<collisionShapes> ") 266 // print("<SphereCollisionShape radius=\"") 267 // print(size * 2.5) print("\" />") 268 // print("</collisionShapes>") 269 270 // print("</StaticEntity>") 271 272 // if fog == 1 and i % 5 == 0 then 273 // generateFog(pX, pY, pZ, radius*0.04, 0.2) 274 // end 275 // end 276 // end 277 278 279 // --[[ asteroid belt generator 280 // generates asteroid belt 281 // posX, posY, posZ - position in space 282 // yaw, pitch - rotation 283 // minSize, maxSize - size boundaries of each asteroid 284 // radius0, radius1 - inner/outer radius 285 // count - number of asteroids 286 // fog - enable fog 0/1 287 // --]] 288 // function asteroidBelt(centerX, centerY, centerZ, yaw, pitch, segments, minSize, maxSize, radius0, radius1, count, fog) 289 // dPhi = (2 * math.pi) / segments 290 // width = math.abs(radius1 - radius0) 291 // radius = (radius1 + radius0) / 2 292 // segmentCount = count / segments 293 294 // print("<StaticEntity collisionType=static yaw=") print(yaw) 295 // print(" pitch=") print(pitch) 296 297 // print(" position = \"") 298 // print(centerX) print(",") 299 // print(centerY) print(",") 300 // print(centerZ) print("\"") 301 // print(">") 302 303 // print("<attached>") 304 305 // for i = 0, segments - 1, 1 do 306 // asteroidField((radius * math.cos(i * dPhi)), 307 // (radius * math.sin(i * dPhi)), 308 // 0, minSize, maxSize, width, segmentCount, fog) 309 // end 310 311 // print("</attached>") 312 // print("</StaticEntity>") 313 // end -
code/branches/AsteroidMining_HS17/src/modules/asteroidmining/SpicedAsteroidField.h
r11615 r11640 46 46 47 47 // tolua_export 48 class _OrxonoxExport SpicedAsteroidField 48 class _OrxonoxExport SpicedAsteroidField : public Pawn // need pawn to get tick for clean argument passing 49 49 { // tolua_export 50 50 … … 65 65 66 66 inline void setPosition(Vector3 v){this->position = v;} 67 inline Vector3 getPosition(){retur rn this->position;}67 inline Vector3 getPosition(){return this->position;} 68 68 69 69 inline void setMaxSize(int i){this->maxSize = i;} … … 79 79 inline bool isFoggy(){return this->foggy;} 80 80 81 inline void setFogDensity(float fd){this->fogDensity = fd;} 82 inline float getFogDensity(){return this->fogDensity;} 83 81 84 protected: 82 85 // Da neue Argumente reinstellen … … 87 90 88 91 Vector3 position; 89 bool initialised;90 92 Context* context; 93 91 94 int maxSize; 92 95 int minSize; … … 94 97 float radius; 95 98 bool foggy; 99 float fogDensity; 96 100 97 101 virtual void create();
Note: See TracChangeset
for help on using the changeset viewer.