Index: code/branches/AsteroidMining_HS17/src/modules/asteroidmining/SpicedAsteroidField.cc
===================================================================
--- code/branches/AsteroidMining_HS17/src/modules/asteroidmining/SpicedAsteroidField.cc	(revision 11615)
+++ code/branches/AsteroidMining_HS17/src/modules/asteroidmining/SpicedAsteroidField.cc	(revision 11640)
@@ -31,7 +31,14 @@
 *
 *
-*<OFFEN Describe
+*<OFFEN Describe 
+Math from asteroidField.lua used. 
 *
 *
+
+
+DESCRIPTION
+o Andere: Simpel wie in asteroidField.lua, oder einfach Asteroiden, die nichts abwerfen?
+--> Letzteres scheint passender, simpler. 
+
 
 */
@@ -77,5 +84,5 @@
     RegisterClass(SpicedAsteroidField);
 
-    SpicedAsteroidField::SpicedAsteroidField(Context* context) {
+    SpicedAsteroidField::SpicedAsteroidField(Context* context) : Pawn(context) {
 
         // Da auch noetig? Wegen set in XML-Code?
@@ -83,14 +90,14 @@
 
         this->context = context;
-        this->initialised = false;
-
-        //Noetig, damit nicht sofort zerstoert?
-        this->setCollisionType(WorldEntity::CollisionType::Dynamic);
+        this->foggy = true; 
+        this->fogDensity = 0.5;
 
         // Old from Pawn
         this->registerVariables();
 
-        orxout() << "AsteroidMining:: Pseudo-Konstruktor passiert!" << endl;
-
+
+        // this->create();
+        this->bAlive_ = false;
+        this->destroyLater();
     }
 
@@ -101,12 +108,57 @@
     void SpicedAsteroidField::create(){
 
-
-
-
+        int size;
+        int pX;
+        int pY;
+        int pZ;
+
+        Vector3* relPos; 
+
+        for(int gertrud = 0; gertrud<count; ++gertrud){
+
+            AsteroidMinable* a = new AsteroidMinable(this->context);
+
+            size = round(rnd()*(this->maxSize - this->minSize)) + this->minSize;
+            a->setSize(size);
+
+            pX = round(rnd()*2*this->radius) - radius;
+            pY = round(rnd()*2*this->radius) - radius;
+            pZ = round(rnd()*2*this->radius) - radius;
+            relPos = new Vector3(pX, pY, pZ);
+            a->setPosition(this->position + *relPos);
+
+            bool spiced = (rnd() < (this->mDensity)); // does drop pickups etc. 
+            a->toggleDropStuff(spiced);
+
+            // @TODO: Fox Fog stuff, error due to billbord
+
+//             Billboard* bb;
+//             if(this->foggy && mod(gertrud, 5) == 0){
+//                 bb = new Billboard(this->context);
+//                 bb->setPosition(this-position + *relPos);
+//                 bb->setMaterial("Smoke/Smoke");
+//                 bb->setScale(size); // tricky?
+
+//                 bb->setColour(ColourValue(this-fogDensity, this->fogDensity, this->fogDensity)); // 4rd argument = transparency?
+                
+// //     print("<Billboard ")
+// //         print("position = \"")
+// //             print(posX) print(",")
+// //             print(posY) print(",")
+// //             print(posZ) print("\" ")
+// //         print("colour=\"")
+// //             print(brightness) print(",")
+// //             print(brightness) print(",")
+// //             print(brightness) print("\" ")
+// //         print("material=\"Smoke/Smoke\" scale=")
+// //         print(size)
+// //     print(" />")
+//             }
+        }
     }
 
     void SpicedAsteroidField::XMLPort(Element& xmlelement, XMLPort::Mode mode)
     {
-        SUPER(SpicedAsteroidField, XMLPort, xmlelement, mode);
+        // SUPER(SpicedAsteroidField, XMLPort, xmlelement, mode);
         //        XMLPortParam(PickupSpawner, "pickup", setPickupTemplateName, getPickupTemplateName, xmlelement, mode);
         XMLPortParam(SpicedAsteroidField, "count", setCount, getCount, xmlelement, mode);
@@ -117,5 +169,5 @@
         XMLPortParam(SpicedAsteroidField, "radius", setRadius, getRadius, xmlelement, mode);
         XMLPortParam(SpicedAsteroidField, "foggy", setFog, isFoggy, xmlelement, mode);
-
+        XMLPortParam(SpicedAsteroidField, "fogDensity", setFogDensity, getFogDensity, xmlelement, mode);
 
     }
@@ -126,5 +178,5 @@
     void SpicedAsteroidField::XMLEventPort(Element& xmlelement, XMLPort::Mode mode)
     {
-        SUPER(SpicedAsteroidField, XMLEventPort, xmlelement, mode);
+        // SUPER(SpicedAsteroidField, XMLEventPort, xmlelement, mode);
 
         XMLPortEventState(SpicedAsteroidField, BaseObject, "vulnerability", setVulnerable, xmlelement, mode);
@@ -133,30 +185,22 @@
     void SpicedAsteroidField::registerVariables()
     {
-        // registerVariable(this->bAlive_,            VariableDirection::ToClient);
-        // registerVariable(this->bVulnerable_,       VariableDirection::ToClient);
-        // registerVariable(this->health_,            VariableDirection::ToClient);
-        // registerVariable(this->maxHealth_,         VariableDirection::ToClient);
-
-        registerVariable(this->size, VariableDirection::ToClient);
-        registerVariable(this->generateSmaller, VariableDirection::ToClient);
-
-        registerVariable(this->initialised, VariableDirection::ToClient);
-        //registerVariable(this->context, VariableDirection::ToClient); // can't link that since it's a context
-
-
-            //         float size;
-            // bool generateSmaller;
-            // bool initialised;
-
-            // Context* context;
-    }
-
-    void SpicedAsteroidField::tick(float dt)
-    {
+
+        registerVariable(this->count, VariableDirection::ToClient);
+        registerVariable(this->mDensity, VariableDirection::ToClient);
+        registerVariable(this->position, VariableDirection::ToClient);
+        registerVariable(this->maxSize, VariableDirection::ToClient);
+        registerVariable(this->minSize, VariableDirection::ToClient);
+        registerVariable(this->radius, VariableDirection::ToClient);
+        registerVariable(this->foggy, VariableDirection::ToClient);
+        registerVariable(this->fogDensity, VariableDirection::ToClient);
+
+
+    }
+
+    void SpicedAsteroidField::tick(float dt){
 
         this->create();
-        this->~SpicedAsteroidField(); // seems dangerous. Necessary for efficiency? 
-
-
+        this->bAlive_ = false;
+        this->destroyLater();
     }
 
@@ -166,2 +210,104 @@
 
 }
+
+// --[[ fog generator
+// generates fog
+//     posX, posY, posZ - position in space
+//     size - size of billboard
+//     brightness - [0,1] fog brightness
+// --]]
+// function generateFog(posX, posY, posZ, size, brightness)
+//     print("<Billboard ")
+//         print("position = \"")
+//             print(posX) print(",")
+//             print(posY) print(",")
+//             print(posZ) print("\" ")
+//         print("colour=\"")
+//             print(brightness) print(",")
+//             print(brightness) print(",")
+//             print(brightness) print("\" ")
+//         print("material=\"Smoke/Smoke\" scale=")
+//         print(size)
+//     print(" />")
+// end
+
+// --[[ asteroid field generator
+// generates asteroid field
+//     posX, posY, posZ - position in space
+//     minSize, maxSize - size boundaries of each asteroid
+//     radius - size of the cube around position in space
+//     count - number of asteroids
+//     fog - enable fog 0/1
+// --]]
+// function asteroidField(posX, posY, posZ, minSize, maxSize, radius, count, fog)
+//     for i = 1, count, 1 do
+//         size = (math.random() * (maxSize - minSize)) + minSize
+//         pX = (2 * math.random() * radius) - radius + posX
+//         pY = (2 * math.random() * radius) - radius + posY
+//         pZ = (2 * math.random() * radius) - radius + posZ
+//         print("<StaticEntity ")
+
+//         print("position = \"")
+//         print(pX) print(",")
+//         print(pY) print(",")
+//         print(pZ) print("\" ")
+
+//         print("scale = \"") print(size) print("\" ")
+
+//         print("collisionType = static linearDamping = 0.8 angularDamping = 1 ")
+//         print("collisiondamage = 1000 enablecollisiondamage = true>")
+
+//         print("<attached>")
+//             print("<Model mass=\"") print(size * 10) print("\" ")
+//             print("mesh=\"ast") print(math.mod(i,6) + 1) print(".mesh\" />")
+//         print("</attached>")
+
+//         print("<collisionShapes> ")
+//             print("<SphereCollisionShape radius=\"")
+//             print(size * 2.5) print("\" />")
+//         print("</collisionShapes>")
+
+//         print("</StaticEntity>")
+
+//         if fog == 1 and i % 5 == 0 then
+//             generateFog(pX, pY, pZ, radius*0.04, 0.2)
+//         end
+//     end
+// end
+
+
+// --[[ asteroid belt generator
+// generates asteroid belt
+//     posX, posY, posZ - position in space
+//     yaw, pitch - rotation
+//     minSize, maxSize - size boundaries of each asteroid
+//     radius0, radius1 - inner/outer radius
+//     count - number of asteroids
+//     fog - enable fog 0/1
+// --]]
+// function asteroidBelt(centerX, centerY, centerZ, yaw, pitch, segments, minSize, maxSize, radius0, radius1, count, fog)
+//     dPhi = (2 * math.pi) / segments
+//     width = math.abs(radius1 - radius0)
+//     radius = (radius1 + radius0) / 2
+//     segmentCount = count / segments
+
+//     print("<StaticEntity collisionType=static yaw=") print(yaw)
+//     print(" pitch=") print(pitch)
+
+//     print(" position = \"")
+//         print(centerX) print(",")
+//         print(centerY) print(",")
+//         print(centerZ) print("\"")
+//     print(">")
+
+//     print("<attached>")
+
+//     for i = 0, segments - 1, 1 do
+//         asteroidField((radius * math.cos(i * dPhi)),
+//                     (radius * math.sin(i * dPhi)),
+//                     0, minSize, maxSize, width, segmentCount, fog)
+//     end
+
+//     print("</attached>")
+//     print("</StaticEntity>")
+// end
