Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

Ignore:
Timestamp:
Dec 11, 2017, 6:05:17 PM (6 years ago)
Author:
remartin
Message:

SpicedAsteroidBelt erstellt, kosmetische Veränderungen. Offener Punkt um velocity, ansonsten fehlt nur noch das dokumentieren.

File:
1 edited

Legend:

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

    r11646 r11664  
    2727 */
    2828
    29 /*
     29/**
    3030
    31 *
    32 *
    33 *<OFFEN Describe
    34 Math from asteroidField.lua used.
    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.
     31    @file SpicedAsteroidField.cc
     32    @brief Asteroid field with lots of parameters. Derived from asteroidField.lua
    4233
    4334
     
    6051#include "util/Math.h"
    6152
    62 // #include "infos/PlayerInfo.h"
    63 // #include "controllers/Controller.h"
    64 // #include "gametypes/Gametype.h"
    65 // #include "graphics/ParticleSpawner.h"
    66 // #include "worldentities/ExplosionChunk.h"
    67 // #include "worldentities/ExplosionPart.h"
    68 
    69 // #include "core/object/ObjectListIterator.h"
    70 // #include "controllers/FormationController.h"
     53#include "../../orxonox/graphics/Billboard.h"
    7154
    7255
    73 //#include "../pickup/pickup ..... pickupable
    74 #include "../objects/collisionshapes/SphereCollisionShape.h"
    75 #include "../../orxonox/graphics/Model.h"
     56namespace orxonox{
    7657
    77 
    78 
    79 
    80 
    81 
    82 namespace orxonox
    83 {
    8458    RegisterClass(SpicedAsteroidField);
    8559
    8660    SpicedAsteroidField::SpicedAsteroidField(Context* context) : Pawn(context) {
    8761
    88         // Da auch noetig? Wegen set in XML-Code?
    8962        RegisterObject(SpicedAsteroidField);
     63        this->context = context;
    9064
    91         this->context = context;
     65        // Default Values:
     66        this->count = 30;
     67        this->mDensity = 0.5;
     68        this->position = Vector3(0,0,0);
     69        this->maxSize = 40;
     70        this->minSize = 1;
     71        this->radius = 1000;
    9272        this->foggy = true;
    9373        this->fogDensity = 0.5;
    94         this->count = 0;
    9574
    96         // Old from Pawn
    9775        this->registerVariables();
     76    }
    9877
     78    SpicedAsteroidField::SpicedAsteroidField(Context* c, Vector3 p, int minS, int maxS, int w, int count, bool f, float mD, float fD): Pawn(c){
    9979
    100         // this->create();
    101         this->bAlive_ = false;
    102         this->destroyLater();
     80        this->context = c;
     81        this->position = p;
     82        this->minSize = minS;
     83        this->maxSize = maxS;
     84        this->radius = w;
     85        this->count = count;
     86        this->foggy = f;
     87
     88        this->mDensity = mD;
     89        this->fogDensity = fD;
     90
    10391    }
     92
    10493
    10594    SpicedAsteroidField::~SpicedAsteroidField(){
     
    115104
    116105        Vector3* relPos;
     106
    117107
    118108        for(int gertrud = 0; gertrud<count; ++gertrud){
     
    131121            a->toggleDropStuff(spiced);
    132122
    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 //             }
     123            // A problem
     124            a->setVelocity(this->getVelocity());
     125           
     126            // Fog is iplemented with billboards.
     127            Billboard* bb;
     128            if(this->foggy && mod(gertrud, 5) == 0){
     129                bb = new Billboard(this->context);
     130                bb->setPosition(this->position + *relPos);
     131                bb->setMaterial("Smoke/Smoke");
     132                bb->setScale(size);
     133                bb->setColour(ColourValue(this->fogDensity, this->fogDensity, this->fogDensity));   
     134            }
    157135        }
    158136    }
    159137
    160     void SpicedAsteroidField::XMLPort(Element& xmlelement, XMLPort::Mode mode)
    161     {
    162         // SUPER(SpicedAsteroidField, XMLPort, xmlelement, mode);
    163         //        XMLPortParam(PickupSpawner, "pickup", setPickupTemplateName, getPickupTemplateName, xmlelement, mode);
     138    void SpicedAsteroidField::XMLPort(Element& xmlelement, XMLPort::Mode mode){
     139
     140        SUPER(SpicedAsteroidField, XMLPort, xmlelement, mode);
     141
    164142        XMLPortParam(SpicedAsteroidField, "count", setCount, getCount, xmlelement, mode);
    165143        XMLPortParam(SpicedAsteroidField, "mDensity", setMineralDensity, getMineralDensity, xmlelement, mode);
     
    174152
    175153
     154    void SpicedAsteroidField::XMLEventPort(Element& xmlelement, XMLPort::Mode mode){
    176155
    177 
    178     void SpicedAsteroidField::XMLEventPort(Element& xmlelement, XMLPort::Mode mode)
    179     {
    180         // SUPER(SpicedAsteroidField, XMLEventPort, xmlelement, mode);
    181 
    182         XMLPortEventState(SpicedAsteroidField, BaseObject, "vulnerability", setVulnerable, xmlelement, mode);
    183156    }
    184157
    185     void SpicedAsteroidField::registerVariables()
    186     {
     158    void SpicedAsteroidField::registerVariables(){
    187159
    188160        registerVariable(this->count, VariableDirection::ToClient);
     
    195167        registerVariable(this->fogDensity, VariableDirection::ToClient);
    196168
    197 
    198169    }
    199170
     
    201172
    202173        this->create();
    203         // orxout() << "SpicedAsteroidField is done. " << endl;
    204 
    205174        this->bAlive_ = false;
    206175        this->destroyLater();
    207176    }
    208177
    209 
    210 
    211 
    212 
    213178}
    214 
    215 // --[[ fog generator
    216 // generates fog
    217 //     posX, posY, posZ - position in space
    218 //     size - size of billboard
    219 //     brightness - [0,1] fog brightness
    220 // --]]
    221 // function generateFog(posX, posY, posZ, size, brightness)
    222 //     print("<Billboard ")
    223 //         print("position = \"")
    224 //             print(posX) print(",")
    225 //             print(posY) print(",")
    226 //             print(posZ) print("\" ")
    227 //         print("colour=\"")
    228 //             print(brightness) print(",")
    229 //             print(brightness) print(",")
    230 //             print(brightness) print("\" ")
    231 //         print("material=\"Smoke/Smoke\" scale=")
    232 //         print(size)
    233 //     print(" />")
    234 // end
    235 
    236 // --[[ asteroid field generator
    237 // generates asteroid field
    238 //     posX, posY, posZ - position in space
    239 //     minSize, maxSize - size boundaries of each asteroid
    240 //     radius - size of the cube around position in space
    241 //     count - number of asteroids
    242 //     fog - enable fog 0/1
    243 // --]]
    244 // function asteroidField(posX, posY, posZ, minSize, maxSize, radius, count, fog)
    245 //     for i = 1, count, 1 do
    246 //         size = (math.random() * (maxSize - minSize)) + minSize
    247 //         pX = (2 * math.random() * radius) - radius + posX
    248 //         pY = (2 * math.random() * radius) - radius + posY
    249 //         pZ = (2 * math.random() * radius) - radius + posZ
    250 //         print("<StaticEntity ")
    251 
    252 //         print("position = \"")
    253 //         print(pX) print(",")
    254 //         print(pY) print(",")
    255 //         print(pZ) print("\" ")
    256 
    257 //         print("scale = \"") print(size) print("\" ")
    258 
    259 //         print("collisionType = static linearDamping = 0.8 angularDamping = 1 ")
    260 //         print("collisiondamage = 1000 enablecollisiondamage = true>")
    261 
    262 //         print("<attached>")
    263 //             print("<Model mass=\"") print(size * 10) print("\" ")
    264 //             print("mesh=\"ast") print(math.mod(i,6) + 1) print(".mesh\" />")
    265 //         print("</attached>")
    266 
    267 //         print("<collisionShapes> ")
    268 //             print("<SphereCollisionShape radius=\"")
    269 //             print(size * 2.5) print("\" />")
    270 //         print("</collisionShapes>")
    271 
    272 //         print("</StaticEntity>")
    273 
    274 //         if fog == 1 and i % 5 == 0 then
    275 //             generateFog(pX, pY, pZ, radius*0.04, 0.2)
    276 //         end
    277 //     end
    278 // end
    279 
    280 
    281 // --[[ asteroid belt generator
    282 // generates asteroid belt
    283 //     posX, posY, posZ - position in space
    284 //     yaw, pitch - rotation
    285 //     minSize, maxSize - size boundaries of each asteroid
    286 //     radius0, radius1 - inner/outer radius
    287 //     count - number of asteroids
    288 //     fog - enable fog 0/1
    289 // --]]
    290 // function asteroidBelt(centerX, centerY, centerZ, yaw, pitch, segments, minSize, maxSize, radius0, radius1, count, fog)
    291 //     dPhi = (2 * math.pi) / segments
    292 //     width = math.abs(radius1 - radius0)
    293 //     radius = (radius1 + radius0) / 2
    294 //     segmentCount = count / segments
    295 
    296 //     print("<StaticEntity collisionType=static yaw=") print(yaw)
    297 //     print(" pitch=") print(pitch)
    298 
    299 //     print(" position = \"")
    300 //         print(centerX) print(",")
    301 //         print(centerY) print(",")
    302 //         print(centerZ) print("\"")
    303 //     print(">")
    304 
    305 //     print("<attached>")
    306 
    307 //     for i = 0, segments - 1, 1 do
    308 //         asteroidField((radius * math.cos(i * dPhi)),
    309 //                     (radius * math.sin(i * dPhi)),
    310 //                     0, minSize, maxSize, width, segmentCount, fog)
    311 //     end
    312 
    313 //     print("</attached>")
    314 //     print("</StaticEntity>")
    315 // end
Note: See TracChangeset for help on using the changeset viewer.