Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 12, 2017, 8:29:52 PM (7 years ago)
Author:
remartin
Message:

Added tilting for the spicedAsteroidBelt. Finished commenting, polish up. Done.

Location:
code/branches/AsteroidMining_HS17/src/modules/asteroidmining
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • code/branches/AsteroidMining_HS17/src/modules/asteroidmining/AsteroidMinable.cc

    r11664 r11667  
    2929/*
    3030
    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
     35HANDBUCH:
     36o 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.
     38o im Level-File includes/pickups.oxi importieren.
     39
     40OFFEN/Weiterentwicklung:
     41o @TODO Add resource pickups.
     42--> data_extern/images/effects: PNG's für die Pickups
    5943--> https://www.orxonox.net/jenkins/view/Management/job/orxonox_doxygen_trunk/javadoc/group___pickup.html
    6044
    61 o Anfangsgeschwindigkeit fuers Asteroidenfeld
    6245o 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)
     46o Does collision damage work properly
    6747o Add sound effect (crunching etc. ) (No sound in space...)
    6848o Explosion parts
    6949
    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:
     50ANDERORTS VERÄNDERTE SACHEN:
    7651Pickup-Zeug:
    77 o Pickup.h: Zugriffsänderung createSpawner
     52o Pickup.h: createSpawner() neu public statt private
    7853o PickupSpawner.h: Zugriffsrechte setPickupTemplateName() und setMaxSpawnedItems()
    79 o PickupSpawner.h: In Tick() zwei Testbedingungen eingefuegt.
     54o PickupSpawner.h: In Tick() zwei Testbedingungen eingefügt.
    8055o Pawn.h: Attribut acceptsPickups_ inklusive get/set.
    8156
    8257ERLEGTE 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.
     58o Grössenabhängige Collision Shape -> putStuff-Methode, Werte noch nicht durchgesickert.
     59o setHealth: maxHealth() des pawns setzen!
    9560o 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.
    9761o 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 
     62o Velocity didn-t get passed properly through the 2nd constructor. Used get/set instead.
     63o Rand() geht bis zu riesigen Nummern! rnd() ist zwischen 0 und 1
    10164
    10265NOTIZEN:
    103 o SUPER entspricht ueberladen, andere Argumente der Methode.
     66o SUPER
    10467o Warnungsverhinderung anderswo: (void)pickedUp; // To avoid compiler warning.
    105 
    106 Was ist das?         friend class Pickupable;
     68o friend class Pickupable;
    10769
    10870
     
    150112        this->acceptsPickups_ = false;
    151113
    152         //Noetig, damit nicht sofort zerstoert?
    153114        this->setCollisionType(WorldEntity::CollisionType::Dynamic);
    154115        this->enableCollisionCallback();
    155116
    156 
    157117        // Old from Pawn
    158118        this->registerVariables();
    159119
    160120        this->initialised = false;
    161 
    162121    }
    163122
    164123    // @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){
    166125
    167126        RegisterObject(AsteroidMinable);
     
    172131            this->setRadarObjectShape(RadarViewable::Shape::Dot);
    173132        }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);
    175136        }
    176137
     
    184145
    185146        this->setPosition(position);
    186         this->setVelocity(v);
    187147        //this->roll = rand()*5; //etwas Drehung. Richtige Variable?
    188148
    189149        this->setCollisionType(WorldEntity::CollisionType::Dynamic);
    190150        this->enableCollisionCallback();
    191 
    192151
    193152        // Add Model, random one of the 6 shapes
     
    214173    }
    215174
    216     // @brief Helper method. Create a new asteroid to have an appropriate size for the collision shape etc.
     175    // @brief Helper method.
    217176    void AsteroidMinable::putStuff(){
    218177
    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?
    221181        (void)reborn; // avoid compiler warning
     182
    222183        this->bAlive_ = false;
    223184        this->destroyLater();
     
    258219    }
    259220
    260     void AsteroidMinable::death(){ // ueberschreibt das Zeug in Pawn
     221    void AsteroidMinable::death(){ // @brief Überschreibt die Methode in Pawn
    261222
    262223        // just copied that from somewhere else.
     
    268229
    269230
    270         // Pickups which can be harvested.
     231        // Pickups which can be harvested. It's munition at the moment, could be changed/extended.
    271232        if(dropStuff){
    272233            PickupSpawner* thingy = new PickupSpawner(this->context);
    273             // OFFEN: more precise size relation in custom resource pickup.
     234
    274235            char tname[] = ""; // can-t overwrite strings easily in C (strcat etc.)
    275236            if(this->size <= 5){
     
    291252    }
    292253
    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(){
    295256
    296257    if (this->size <=1){return;} // Absicherung trivialer Fall
     
    298259    int massRem = this->size-1; //some mass is lost
    299260    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
    303263    // 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. 
    306265
    307266    // Randomnised spawning points for the new asteroids
     
    348307    //orxout() << "SpawnChildren(): Passed angle stuff. " << endl;
    349308
    350     // 'Triangular', discrete probability "density" with max at the expected value massRem/num at a. a+b = c
    351     if(massRem>0){ // Required to avoid array of size 0 or access problems
     309    // Triangular, discrete probability "density" with max at the average value massRem/num. 50% chance to be below that.
     310    if(massRem>0){
    352311        int c = massRem;
    353312        float probDensity[c];
     
    372331
    373332        // Distributing the mass to individual asteroids
    374         int result;
    375         float rVal;// between 0 and 1
    376         float probSum;
     333        int result; 
     334        float rVal; // between 0 and 1
     335        float probSum; // summing up until rval is reached.
    377336        for(int trav = 0; trav<num; ++trav){
    378             result = 0;// reset
    379             rVal = rnd();// between 0 and 1
     337            result = 0;
     338            rVal = rnd(); 
    380339            probSum = probDensity[0];
    381340
    382             while(rVal>probSum && result<massRem){// Not yet found && there-s smth left to distribute (Incrementing once inside!)
     341            while(rVal>probSum && result<massRem){// Not yet found && there-s smth left to distribute (Incrementing inside!)
    383342                if(result<(massRem-2)){probSum = probSum + probDensity[result+1];} // avoid logical/acess error
    384343                ++result;
    385344            }
    386345
     346            masses[trav] = 1 +result; // Fragments have mass of at least one.
    387347            massRem = massRem-result;
    388             masses[trav] = 1 +result; // Fragments have mass of at least one.
     348
    389349        }
    390350    }else{
     
    404364        }
    405365       
    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());
    407368
    408369        if(child == nullptr){
     
    414375}
    415376
    416 
     377// @brief overloading that to prevent asteroids from taking damage from each other (domino effect etc. )
    417378    void AsteroidMinable::hit(Pawn* originator, const Vector3& force, const btCollisionShape* cs, float damage, float healthdamage, float shielddamage){
    418379
    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;
    423381        if(orxonox_cast<AsteroidMinable*>(originator) || orxonox_cast<Pickup*>(originator)){return;}
    424382        this->damage(damage, healthdamage, shielddamage, originator, cs);
    425383        this->setVelocity(this->getVelocity() + force);
    426 
    427 
    428384
    429385        // if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator))// && (!this->getController() || !this->getController()->getGodMode()) )
     
    434390    }
    435391
     392// @brief overloading that to prevent asteroids from taking damage from each other (domino effect etc. )
    436393    void AsteroidMinable::hit(Pawn* originator, btManifoldPoint& contactpoint, const btCollisionShape* cs, float damage, float healthdamage, float shielddamage){
    437394
    438395        //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?
    441396        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 
    445397        this->damage(damage, healthdamage, shielddamage, originator, cs);
    446 
    447 
    448 
    449398
    450399        // if (this->getGametype() && this->getGametype()->allowPawnHit(this, originator))// && (!this->getController() || !this->getController()->getGodMode()) )
  • code/branches/AsteroidMining_HS17/src/modules/asteroidmining/AsteroidMinable.h

    r11664 r11667  
    2929
    3030/**
    31     @file AsteroidMinable.h
    3231
     32    @file
     33    @author remartin
     34    @brief An asteroid which can be destroyed. Some smaller asteroids are created and a pickup spawns.
     35
     36HANDBUCH:
     37o 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.
     39o im Level-File includes/pickups.oxi importieren.
     40
     41OFFEN/Weiterentwicklung:
     42o @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
     46o Density doesn't add up to 1...
     47o Does collision damage work properly
     48o Add sound effect (crunching etc. ) (No sound in space...)
     49o Explosion parts
     50
     51ANDERORTS VERÄNDERTE SACHEN:
     52Pickup-Zeug:
     53o Pickup.h: createSpawner() neu public statt private
     54o PickupSpawner.h: Zugriffsrechte setPickupTemplateName() und setMaxSpawnedItems()
     55o PickupSpawner.h: In Tick() zwei Testbedingungen eingefügt.
     56o Pawn.h: Attribut acceptsPickups_ inklusive get/set.
     57
     58ERLEGTE FEHLER:
     59o Grössenabhängige Collision Shape -> putStuff-Methode, Werte noch nicht durchgesickert.
     60o setHealth: maxHealth() des pawns setzen!
     61o Asteroiden fressen Pickups: Argument in Pawn, Test darauf in Tick() von PickupSpawner.
     62o i++ einfach ganz verhindern, ++i stattdessen.
     63o Velocity didn-t get passed properly through the 2nd constructor. Used get/set instead.
     64o Rand() geht bis zu riesigen Nummern! rnd() ist zwischen 0 und 1
     65
     66NOTIZEN:
     67o SUPER
     68o Warnungsverhinderung anderswo: (void)pickedUp; // To avoid compiler warning.
     69o friend class Pickupable;
    3370
    3471*/
     
    4885#include "../../orxonox/worldentities/pawns/Pawn.h"
    4986
    50 namespace orxonox
    51 {
     87namespace orxonox{
    5288
    5389
     
    5591
    5692        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);
    5997
    6098            virtual ~AsteroidMinable();
     
    63101            virtual void tick(float dt) override;
    64102
    65             // @brief Overwrite to prevet 'self-collision' of generated stuff
     103            // @brief overloading that to prevent asteroids from taking damage from each other (domino effect etc. )
    66104            virtual void hit(Pawn* originator, const Vector3& force, const btCollisionShape* cs, float damage, float healthdamage = 0.0f, float shielddamage = 0.0f);
    67105            virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, const btCollisionShape* cs, float damage, float healthdamage = 0.0f, float shielddamage = 0.0f);
     
    80118            Context* context;
    81119
    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
    85123
    86             bool initialised;
    87 
     124            // @brief Überschreibt die Methode in Pawn
    88125            virtual void death();
    89126
     127        private:
    90128
     129            bool initialised; //!< Used in relation to the constructor detour described above
    91130
    92         private:
    93131            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.
    94137            virtual void spawnChildren();
    95             virtual void putStuff();
    96138
    97139            // @brief Just for testing. Don-t work anyways.
    98140            void printArrayString(float thingy[]);
    99141            // @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[]);
    105143
    106144    }; // tolua_export
  • code/branches/AsteroidMining_HS17/src/modules/asteroidmining/SpicedAsteroidBelt.cc

    r11665 r11667  
    2929/**
    3030
    31     @file SpicedAsteroidBelt.cc
     31    @file
     32    @author remartin
    3233    @brief Asteroid belt with lots of parameters. Derived from asteroidField.lua
    3334
     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).
    3440
     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   
    3544*/
    3645
     
    6473        this->count = 250;
    6574        this->position = Vector3(0,0,0);
    66         // this->yaw = 0;
    67         // this->pitch = 0;
    6875        this->segments = 30;
    6976        this->minSize = 1;
     
    7582        this->fogDensity = 0.5;
    7683
    77         // Old from Pawn
     84        this->tiltAt = 0.0;
     85        this->tiltBy = 0.0; 
     86
    7887        this->registerVariables();
    7988
     
    8796
    8897        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);
    93101
    94         SpicedAsteroidField* af[segments];
     102        SpicedAsteroidField* af[this->segments];
    95103        (void)af[0]; // avoid nasty compiler warning
    96104
     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
    97110        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));
    99119            af[s] = new SpicedAsteroidField(this->context, this->position + *pos, this->minSize, this->maxSize, width, segmentCount, this->foggy, this->mDensity, this->fogDensity);
     120           
    100121        }
    101122       
     
    109130        XMLPortParam(SpicedAsteroidBelt, "mDensity", setMineralDensity, getMineralDensity, xmlelement, mode);
    110131        XMLPortParam(SpicedAsteroidBelt, "position", setPosition, getPosition, xmlelement, mode);
    111         // XMLPortParam(SpicedAsteroidBelt, "yaw", setYaw, getYaw, xmlelement, mode);
    112         // XMLPortParam(SpicedAsteroidBelt, "pitch", setPitch, getPitch, xmlelement, mode);
    113132        XMLPortParam(SpicedAsteroidBelt, "segments", setSegments, getSegments, xmlelement, mode);
    114133
     
    119138        XMLPortParam(SpicedAsteroidBelt, "foggy", setFog, isFoggy, xmlelement, mode);
    120139        XMLPortParam(SpicedAsteroidBelt, "fogDensity", setFogDensity, getFogDensity, xmlelement, mode);
     140
     141        XMLPortParam(SpicedAsteroidBelt, "tiltAt", setTiltAt, getTiltAt, xmlelement, mode);
     142        XMLPortParam(SpicedAsteroidBelt, "tiltBy", setTiltBy, getTiltBy, xmlelement, mode);
    121143
    122144    }
     
    131153        registerVariable(this->mDensity, VariableDirection::ToClient);
    132154        registerVariable(this->position, VariableDirection::ToClient);
    133         // registerVariable(this->yaw, VariableDirection::ToClient);
    134         // registerVariable(this->pitch, VariableDirection::ToClient);
    135155        registerVariable(this->segments, VariableDirection::ToClient);
    136156
     
    141161        registerVariable(this->foggy, VariableDirection::ToClient);
    142162        registerVariable(this->fogDensity, VariableDirection::ToClient);
     163
     164        registerVariable(this->tiltAt, VariableDirection::ToClient);
     165        registerVariable(this->tiltBy, VariableDirection::ToClient);
    143166
    144167    }
  • code/branches/AsteroidMining_HS17/src/modules/asteroidmining/SpicedAsteroidBelt.h

    r11665 r11667  
    2323 *      Fabian 'x3n' Landau
    2424 *   Co-authors:
    25  *      ...
    2625 *
    2726 */
     
    2928/**
    3029
    31     @file SpicedAsteroidBelt.h
     30    @file
     31    @author remartin
    3232    @brief Asteroid belt with lots of parameters. Derived from asteroidField.lua
    3333
     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).
    3439
     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   
    3543*/
    3644
     
    7280            inline Vector3 getPosition(){return this->position;}
    7381
    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 
    8082            inline void setSegments(int s){this->segments = s;}
    8183            inline int getSegments(){return this->segments;}
     
    99101            inline float getFogDensity(){return this->fogDensity;}
    100102
     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
    101108
    102109        protected:
     
    104111            Context* context;
    105112
    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;
    108115
    109116            Vector3 position;
    110117
    111             // float yaw;
    112             // float pitch;
    113             int segments;
     118            int segments; //!< Number of asteroidFields that get generated.
    114119           
    115             int maxSize;
    116             int minSize;
     120            int maxSize; //!< Most obese asteroid possible
     121            int minSize; //!< Most meagre asteroid possible
    117122
    118             float radius0;
    119             float radius1;
     123            float radius0; //!< Inner radius
     124            float radius1; //!< Outer radius
    120125
    121             bool foggy;
     126            bool foggy; //!< Whether there's fog arount the asteroids
    122127            float fogDensity;
    123128
    124             virtual void create();
     129            float tiltAt; //!< Orientation: Angle where it gets elevated/lowered the most
     130            float tiltBy; //!< angle at z-axis
    125131
    126132        private:
    127133            void registerVariables();
     134           
     135            virtual void create();
    128136
    129137    }; // tolua_export
  • code/branches/AsteroidMining_HS17/src/modules/asteroidmining/SpicedAsteroidField.cc

    r11664 r11667  
    2929/**
    3030
    31     @file SpicedAsteroidField.cc
     31    @file
     32    @author remartin
    3233    @brief Asteroid field with lots of parameters. Derived from asteroidField.lua
    3334
    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   
    3539*/
    3640
     
    105109        Vector3* relPos;
    106110
    107 
    108111        for(int gertrud = 0; gertrud<count; ++gertrud){
    109112
     
    111114
    112115            size = round(rnd()*(this->maxSize - this->minSize)) + this->minSize;
    113             a->setSize(size);
     116            a->setSize(size);
     117
    114118            pX = round(rnd()*2*this->radius) - radius;
    115119            pY = round(rnd()*2*this->radius) - radius;
     
    118122            a->setPosition(this->position + *relPos);
    119123
    120             bool spiced = (rnd() < (this->mDensity)); // does drop pickups etc.
     124            bool spiced = (rnd() < (this->mDensity)); // Whether the asteroid does drop pickups etc.
    121125            a->toggleDropStuff(spiced);
    122 
    123             // A problem
    124             a->setVelocity(this->getVelocity());
    125126           
    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)
    127130            Billboard* bb;
    128131            if(this->foggy && mod(gertrud, 5) == 0){
  • code/branches/AsteroidMining_HS17/src/modules/asteroidmining/SpicedAsteroidField.h

    r11664 r11667  
    2323 *      Fabian 'x3n' Landau
    2424 *   Co-authors:
    25  *      ...
    2625 *
    2726 */
     
    2928/**
    3029
    31     @file SpicedAsteroidField.h
     30    @file
     31    @author remartin
    3232    @brief Asteroid field with lots of parameters. Derived from asteroidField.lua
    3333
    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   
    3538*/
    3639
     
    9194            Context* context;
    9295
    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;
    9598
    96             Vector3 position;
     99            Vector3 position; //!< The center
    97100           
    98             int maxSize;
    99             int minSize;
     101            int maxSize; //!< Upper bound to asteroid size
     102            int minSize; //!< Lower bound to asteroid size
    100103
    101             float radius;
    102             bool foggy;
     104            float radius; //!< Asteroids can appear within a sphere.
     105            bool foggy; //!< Whether there's fog
    103106            float fogDensity;
    104 
    105             virtual void create();
    106 
    107107
    108108
     
    110110            void registerVariables();
    111111
     112            virtual void create();
     113
     114
    112115    }; // tolua_export
    113116} // tolua_export
Note: See TracChangeset for help on using the changeset viewer.