Changeset 11732 for code/branches/Presentation_HS17_merge
- Timestamp:
- Feb 11, 2018, 6:04:01 PM (7 years ago)
- Location:
- code/branches/Presentation_HS17_merge/src/modules/asteroidmining
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/Presentation_HS17_merge/src/modules/asteroidmining/AsteroidMinable.cc
r11667 r11732 85 85 #include "core/EventIncludes.h" 86 86 #include "network/NetworkFunction.h" 87 #include "util/Convert.h" 87 88 #include "util/Math.h" 88 89 … … 152 153 // Add Model, random one of the 6 shapes 153 154 Model* hull = new Model(this->context); 154 char meshThingy[] = ""; 155 sprintf(meshThingy, "ast%.0f.mesh", round(5*rnd())+1); 156 hull->setMeshSource(meshThingy); 155 hull->setMeshSource("ast" + multi_cast<std::string>(1 + (int)rnd(0, 6)) + ".mesh"); 157 156 hull->setScale(this->size); 158 157 this->attach(hull); … … 233 232 PickupSpawner* thingy = new PickupSpawner(this->context); 234 233 235 char tname[] = ""; // can-t overwrite strings easily in C (strcat etc.)234 std::string tname; 236 235 if(this->size <= 5){ 237 strcat(tname, "smallmunitionpickup");236 tname = "smallmunitionpickup"; 238 237 }else if(this->size <= 20){ 239 strcat(tname, "mediummunitionpickup");238 tname = "mediummunitionpickup"; 240 239 }else{ 241 strcat(tname, "hugemunitionpickup");240 tname = "hugemunitionpickup"; 242 241 } 243 242 thingy->setPickupTemplateName(tname); … … 260 259 int num = round(rnd()*(massRem-1)) + 1; // random number of children, at least one 261 260 if(num > 10){num = 10;} // no max function in C? 262 int masses[num]; // Masses of the asteroids261 std::vector<int> masses(num); // Masses of the asteroids 263 262 // orxout() << "SpawnChildren(): Passed basic stuff. num = " << num << "; massRem(total) = "<< massRem << endl; 264 263 massRem = massRem-num; // mass must be at least one, add later. 265 264 266 265 // Randomnised spawning points for the new asteroids 267 float phi[num];268 float theta[num];266 std::vector<float> phi(num); 267 std::vector<float> theta(num); 269 268 270 269 // Discusting C stuff -> use that to initialise dynamic array values to 0. 271 for(int twat = 0; twat<num; ++twat){masses[twat] = 0; phi[twat] = 0.0; theta[twat] = 0.0;} 270 for(int twat = 0; twat<num; ++twat) 271 { 272 masses[twat] = 0; 273 phi[twat] = 0.0f; 274 theta[twat] = 0.0f; 275 } 272 276 273 277 float piG = 3.1415927410125732421875; //pi; // Math.pi ist statisch oder so. … … 310 314 if(massRem>0){ 311 315 int c = massRem; 312 float probDensity[c];316 std::vector<float> probDensity(c); 313 317 314 318 int a = round(massRem/num); … … 405 409 // } 406 410 } 407 408 // @brief Just for testing. Don-t work anyways.409 void AsteroidMinable::printArrayString(float thingy[]){ // Don-t work!410 411 orxout() << "[" ; //<< endl;412 char frag[] = "";413 int len = (int)(sizeof(thingy)/sizeof(thingy[0]));414 for(int m = 0; m< (len-2); ++m){415 sprintf(frag, "%.5f, ", thingy[m]);416 orxout() << frag << endl;//std::flush;417 }418 sprintf(frag, "%.5f]", thingy[len-1]);419 orxout() << frag << endl; // Just print it here! No ugly passing.420 }421 422 // @brief Just for testing. Don-t work anyways.423 void AsteroidMinable::printArrayString(int thingy[]){424 425 orxout() << "[" ; //<< endl;426 char frag[] = "";427 int len = (int)(sizeof(thingy)/sizeof(thingy[0]));428 for(int m = 0; m< (len-2); ++m){429 sprintf(frag, "%.0i, ", thingy[m]);430 orxout() << frag << endl;//std::flush;431 printf("TEst");432 }433 434 sprintf(frag, "%.0i]", thingy[len-1]); // last element435 orxout() << frag << endl; // Just print it here! No ugly passing.436 }437 438 // void AsteroidMinable::printArrayString(int thingy[]){439 // char res[] = "[";440 // //strcat(res, "[");441 // char frag[] = "";442 443 // int len = (int)(sizeof(thingy)/sizeof(thingy[0]));444 // for(int m = 0; m< (len-1); ++m){445 // sprintf(frag, "%.0i, ", thingy[m]);446 // strcat(res, frag);447 // }448 // sprintf(frag, "%.0i]", thingy[len]);449 // strcat(res, frag); // last element450 451 // orxout() << res << endl; // Just print it here! No ugly passing.452 453 // // static char result[(sizeof(res)/sizeof("")] = res; // define as static, would get deleted otherwise.454 // // char *result = malloc(sizeof(res)/sizeof("") + 1);455 // // *result = res;456 // // return result;457 // }458 459 411 } -
code/branches/Presentation_HS17_merge/src/modules/asteroidmining/AsteroidMinable.h
r11731 r11732 137 137 virtual void spawnChildren(); 138 138 139 // @brief Just for testing. Don-t work anyways.140 void printArrayString(float thingy[]);141 // @brief Just for testing. Don-t work anyways.142 void printArrayString(int thingy[]);143 144 139 }; // tolua_export 145 140 } // tolua_export -
code/branches/Presentation_HS17_merge/src/modules/asteroidmining/SpicedAsteroidBelt.cc
r11667 r11732 100 100 int segmentCount = round(this->count / this->segments); 101 101 102 SpicedAsteroidField* af[this->segments];103 (void)af[0]; // avoid nasty compiler warning104 105 102 float dPhi = (2 * myPi) / this->segments; 106 103 float dTheta = 4.0*this->tiltBy/this->segments; … … 117 114 118 115 Vector3* pos = new Vector3(radius*cos(sepp)*sin(globi), radius*sin(sepp)*sin(globi), radius*cos(globi)); 119 af[s] =new SpicedAsteroidField(this->context, this->position + *pos, this->minSize, this->maxSize, width, segmentCount, this->foggy, this->mDensity, this->fogDensity);116 new SpicedAsteroidField(this->context, this->position + *pos, this->minSize, this->maxSize, width, segmentCount, this->foggy, this->mDensity, this->fogDensity); 120 117 121 118 }
Note: See TracChangeset
for help on using the changeset viewer.