Changeset 11664 for code/branches/AsteroidMining_HS17/src/modules/asteroidmining/SpicedAsteroidField.cc
- Timestamp:
- Dec 11, 2017, 6:05:17 PM (6 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/AsteroidMining_HS17/src/modules/asteroidmining/SpicedAsteroidField.cc
r11646 r11664 27 27 */ 28 28 29 /* 29 /** 30 30 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 42 33 43 34 … … 60 51 #include "util/Math.h" 61 52 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" 71 54 72 55 73 //#include "../pickup/pickup ..... pickupable 74 #include "../objects/collisionshapes/SphereCollisionShape.h" 75 #include "../../orxonox/graphics/Model.h" 56 namespace orxonox{ 76 57 77 78 79 80 81 82 namespace orxonox83 {84 58 RegisterClass(SpicedAsteroidField); 85 59 86 60 SpicedAsteroidField::SpicedAsteroidField(Context* context) : Pawn(context) { 87 61 88 // Da auch noetig? Wegen set in XML-Code?89 62 RegisterObject(SpicedAsteroidField); 63 this->context = context; 90 64 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; 92 72 this->foggy = true; 93 73 this->fogDensity = 0.5; 94 this->count = 0;95 74 96 // Old from Pawn97 75 this->registerVariables(); 76 } 98 77 78 SpicedAsteroidField::SpicedAsteroidField(Context* c, Vector3 p, int minS, int maxS, int w, int count, bool f, float mD, float fD): Pawn(c){ 99 79 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 103 91 } 92 104 93 105 94 SpicedAsteroidField::~SpicedAsteroidField(){ … … 115 104 116 105 Vector3* relPos; 106 117 107 118 108 for(int gertrud = 0; gertrud<count; ++gertrud){ … … 131 121 a->toggleDropStuff(spiced); 132 122 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 } 157 135 } 158 136 } 159 137 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 164 142 XMLPortParam(SpicedAsteroidField, "count", setCount, getCount, xmlelement, mode); 165 143 XMLPortParam(SpicedAsteroidField, "mDensity", setMineralDensity, getMineralDensity, xmlelement, mode); … … 174 152 175 153 154 void SpicedAsteroidField::XMLEventPort(Element& xmlelement, XMLPort::Mode mode){ 176 155 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);183 156 } 184 157 185 void SpicedAsteroidField::registerVariables() 186 { 158 void SpicedAsteroidField::registerVariables(){ 187 159 188 160 registerVariable(this->count, VariableDirection::ToClient); … … 195 167 registerVariable(this->fogDensity, VariableDirection::ToClient); 196 168 197 198 169 } 199 170 … … 201 172 202 173 this->create(); 203 // orxout() << "SpicedAsteroidField is done. " << endl;204 205 174 this->bAlive_ = false; 206 175 this->destroyLater(); 207 176 } 208 177 209 210 211 212 213 178 } 214 215 // --[[ fog generator216 // generates fog217 // posX, posY, posZ - position in space218 // size - size of billboard219 // brightness - [0,1] fog brightness220 // --]]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 // end235 236 // --[[ asteroid field generator237 // generates asteroid field238 // posX, posY, posZ - position in space239 // minSize, maxSize - size boundaries of each asteroid240 // radius - size of the cube around position in space241 // count - number of asteroids242 // fog - enable fog 0/1243 // --]]244 // function asteroidField(posX, posY, posZ, minSize, maxSize, radius, count, fog)245 // for i = 1, count, 1 do246 // size = (math.random() * (maxSize - minSize)) + minSize247 // pX = (2 * math.random() * radius) - radius + posX248 // pY = (2 * math.random() * radius) - radius + posY249 // pZ = (2 * math.random() * radius) - radius + posZ250 // 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 then275 // generateFog(pX, pY, pZ, radius*0.04, 0.2)276 // end277 // end278 // end279 280 281 // --[[ asteroid belt generator282 // generates asteroid belt283 // posX, posY, posZ - position in space284 // yaw, pitch - rotation285 // minSize, maxSize - size boundaries of each asteroid286 // radius0, radius1 - inner/outer radius287 // count - number of asteroids288 // fog - enable fog 0/1289 // --]]290 // function asteroidBelt(centerX, centerY, centerZ, yaw, pitch, segments, minSize, maxSize, radius0, radius1, count, fog)291 // dPhi = (2 * math.pi) / segments292 // width = math.abs(radius1 - radius0)293 // radius = (radius1 + radius0) / 2294 // segmentCount = count / segments295 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 do308 // asteroidField((radius * math.cos(i * dPhi)),309 // (radius * math.sin(i * dPhi)),310 // 0, minSize, maxSize, width, segmentCount, fog)311 // end312 313 // print("</attached>")314 // print("</StaticEntity>")315 // end
Note: See TracChangeset
for help on using the changeset viewer.