- Timestamp:
- Feb 12, 2018, 12:17:34 AM (7 years ago)
- Location:
- code/branches/Presentation_HS17_merge/src/modules/asteroidmining
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/Presentation_HS17_merge/src/modules/asteroidmining/AsteroidMinable.cc
r11738 r11739 115 115 } 116 116 117 void AsteroidMinable::setSize( int s)117 void AsteroidMinable::setSize(float s) 118 118 { 119 119 this->size = s; … … 214 214 if (this->size <=1){return;} // Absicherung trivialer Fall 215 215 216 int massRem = this->size-1; //some mass is lost217 int num = round(rnd()*(massRem-1)) + 1; // random number of children, at least one216 float massRem = (this->size-1); //some mass is lost 217 int num = (int)roundf(rnd(massRem-1)) + 1; // random number of children, at least one 218 218 if(num > 10){num = 10;} // no max function in C? 219 std::vector< int> masses(num); // Masses of the asteroids219 std::vector<float> masses(num); // Masses of the asteroids 220 220 // orxout() << "SpawnChildren(): Passed basic stuff. num = " << num << "; massRem(total) = "<< massRem << endl; 221 221 massRem = massRem-num; // mass must be at least one, add later. … … 228 228 for(int twat = 0; twat<num; ++twat) 229 229 { 230 masses[twat] = 0 ;230 masses[twat] = 0.0f; 231 231 phi[twat] = 0.0f; 232 232 theta[twat] = 0.0f; … … 236 236 float d_p = 2*piG/num; 237 237 float d_t = piG/num; 238 float p = d_p/2.0 ;239 float t = d_t/2.0 ;238 float p = d_p/2.0f; 239 float t = d_t/2.0f; 240 240 // float phiOffset = rnd()*2*pi; // Added everywhere to become independent of the coordinate system? 241 241 // float thetaOffset = rnd()*pi; … … 251 251 for(int it = 0; it<num; ++it){ 252 252 253 pos = mod((int)(rnd( )*num),num);253 pos = mod((int)(rnd((float)num)),num); 254 254 while(phi[pos] != 0.0){// find empty spot in array 255 255 pos = (int)mod(++pos, num); … … 257 257 phi[pos] = p + it*d_p;// set angle there 258 258 259 pos = mod((int)(rnd( )*num),num);259 pos = mod((int)(rnd((float)num)),num); 260 260 while(theta[pos] != 0.0){ 261 261 pos = (int)mod(++pos, num); … … 271 271 // Triangular, discrete probability "density" with max at the average value massRem/num. 50% chance to be below that. 272 272 if(massRem>0){ 273 int c = massRem;273 int c = (int)massRem; 274 274 std::vector<float> probDensity(c); 275 275 276 int a = round(massRem/num);276 int a = (int)roundf(massRem/num); 277 277 int b = c-a; 278 278 279 279 int z = 0; 280 float dProbA = 1.0 /(a*a + 3.0*a + 2.0); // one 'probability unit' for discrete ramp function. Gauss stuff.280 float dProbA = 1.0f/(a*a + 3.0f*a + 2.0f); // one 'probability unit' for discrete ramp function. Gauss stuff. 281 281 for(z = 0; z<a; ++z){probDensity[z] = (z+1)*dProbA; } // rising part 282 282 283 float dProbB = 1.0 /(b*b +3.0*b + 2.0);283 float dProbB = 1.0f/(b*b +3.0f*b + 2.0f); 284 284 for(z = 0; z<b; ++z){probDensity[c-1-z] = (z+1)*dProbB;} // falling part 285 285 … … 306 306 } 307 307 308 masses[trav] = 1 +result; // Fragments have mass of at least one.308 masses[trav] = 1.0f + result; // Fragments have mass of at least one. 309 309 massRem = massRem-result; 310 310 -
code/branches/Presentation_HS17_merge/src/modules/asteroidmining/AsteroidMinable.h
r11736 r11739 94 94 virtual void hit(Pawn* originator, btManifoldPoint& contactpoint, const btCollisionShape* cs, float damage, float healthdamage = 0.0f, float shielddamage = 0.0f); 95 95 96 void setSize( int s);97 inline int getSize(){return this->size;}96 void setSize(float s); 97 inline float getSize(){return this->size;} 98 98 99 99 inline void setShattering(bool b){this->generateSmaller = b;} … … 105 105 protected: 106 106 107 int size; //!< Implies health and type of dropped pickups107 float size; //!< Implies health and type of dropped pickups 108 108 bool generateSmaller; //!< Whether this asteroid leaves fragments 109 109 bool dropStuff; //!< Whether this asteroid yields valuable stuff -
code/branches/Presentation_HS17_merge/src/modules/asteroidmining/SpicedAsteroidBelt.cc
r11736 r11739 88 88 float myPi = 3.1415927410125732421875; //pi; // Math.pi ist statisch oder so. 89 89 float width = this->radius1 - this->radius0; if(width<0){width = -width;} // predefined abs? 90 float radius = (this->radius1 + this->radius0) / 2.0 ;91 int segmentCount = round(this->count / this->segments);90 float radius = (this->radius1 + this->radius0) / 2.0f; 91 int segmentCount = (int)roundf(this->count / this->segments); 92 92 93 93 float dPhi = (2 * myPi) / this->segments; 94 float dTheta = 4.0 *this->tiltBy/this->segments;94 float dTheta = 4.0f*this->tiltBy/this->segments; 95 95 float sepp = -this->tiltAt; 96 float globi = (myPi/2.0 ) + this->tiltBy;96 float globi = (myPi/2.0f) + this->tiltBy; 97 97 98 98 for(int s = 0; s<segments; ++s){ -
code/branches/Presentation_HS17_merge/src/modules/asteroidmining/SpicedAsteroidBelt.h
r11736 r11739 72 72 inline float getMineralDensity(){return this->mDensity;} 73 73 74 inline void setPosition( Vector3v){this->position = v;}75 inline Vector3getPosition(){return this->position;}74 inline void setPosition(const Vector3& v){this->position = v;} 75 inline const Vector3& getPosition(){return this->position;} 76 76 77 77 inline void setSegments(int s){this->segments = s;} 78 78 inline int getSegments(){return this->segments;} 79 79 80 inline void setMaxSize( int i){this->maxSize = i;}81 inline int getMaxSize(){return this->maxSize;}80 inline void setMaxSize(float i){this->maxSize = i;} 81 inline float getMaxSize(){return this->maxSize;} 82 82 83 inline void setMinSize( int i){this->minSize = i;}84 inline int getMinSize(){return this->minSize;}83 inline void setMinSize(float i){this->minSize = i;} 84 inline float getMinSize(){return this->minSize;} 85 85 86 86 inline void setRadius0(float r0){this->radius0 = r0;} 87 inline int getRadius0(){return this->radius0;}87 inline float getRadius0(){return this->radius0;} 88 88 89 89 inline void setRadius1(float r1){this->radius1 = r1;} 90 inline int getRadius1(){return this->radius1;}90 inline float getRadius1(){return this->radius1;} 91 91 92 92 inline void setFog(bool f){this->foggy = f;} … … 111 111 int segments; //!< Number of asteroidFields that get generated. 112 112 113 int maxSize; //!< Most obese asteroid possible114 int minSize; //!< Most meagre asteroid possible113 float maxSize; //!< Most obese asteroid possible 114 float minSize; //!< Most meagre asteroid possible 115 115 116 116 float radius0; //!< Inner radius -
code/branches/Presentation_HS17_merge/src/modules/asteroidmining/SpicedAsteroidField.cc
r11736 r11739 77 77 void SpicedAsteroidField::create(){ 78 78 79 int size;80 int pX;81 int pY;82 int pZ;79 float size; 80 float pX; 81 float pY; 82 float pZ; 83 83 84 84 for(int gertrud = 0; gertrud<count; ++gertrud){ … … 86 86 AsteroidMinable* a = new AsteroidMinable(this->getContext()); 87 87 88 size = round (rnd()*(this->maxSize - this->minSize)) + this->minSize;88 size = roundf(rnd(this->maxSize - this->minSize)) + this->minSize; 89 89 a->setSize(size); 90 90 91 pX = round (rnd()*2*this->radius) - radius;92 pY = round (rnd()*2*this->radius) - radius;93 pZ = round (rnd()*2*this->radius) - radius;91 pX = roundf(rnd(2*this->radius)) - radius; 92 pY = roundf(rnd(2*this->radius)) - radius; 93 pZ = roundf(rnd(2*this->radius)) - radius; 94 94 Vector3 relPos(pX, pY, pZ); 95 95 a->setPosition(this->position + relPos); -
code/branches/Presentation_HS17_merge/src/modules/asteroidmining/SpicedAsteroidField.h
r11736 r11739 60 60 virtual void tick(float dt) override; 61 61 62 inline void setCount( float s){this->count = s;}63 inline float getCount(){return this->count;}62 inline void setCount(int s){this->count = s;} 63 inline int getCount(){return this->count;} 64 64 65 65 inline void setMineralDensity(float d){this->mDensity = d;} 66 66 inline float getMineralDensity(){return this->mDensity;} 67 67 68 inline void setPosition( Vector3v){this->position = v;}69 inline Vector3getPosition(){return this->position;}68 inline void setPosition(const Vector3& v){this->position = v;} 69 inline const Vector3& getPosition(){return this->position;} 70 70 71 inline void setMaxSize( int i){this->maxSize = i;}72 inline int getMaxSize(){return this->maxSize;}71 inline void setMaxSize(float i){this->maxSize = i;} 72 inline float getMaxSize(){return this->maxSize;} 73 73 74 inline void setMinSize( int i){this->minSize = i;}75 inline int getMinSize(){return this->minSize;}74 inline void setMinSize(float i){this->minSize = i;} 75 inline float getMinSize(){return this->minSize;} 76 76 77 77 inline void setRadius(float r){this->radius = r;} 78 inline int getRadius(){return this->radius;}78 inline float getRadius(){return this->radius;} 79 79 80 80 inline void setFog(bool f){this->foggy = f;} … … 86 86 protected: 87 87 88 float count; //!< Number of asteroids generated88 int count; //!< Number of asteroids generated 89 89 float mDensity; //!< Mineral density, between 0 and 1; 90 90 91 91 Vector3 position; //!< The center 92 92 93 int maxSize; //!< Upper bound to asteroid size94 int minSize; //!< Lower bound to asteroid size93 float maxSize; //!< Upper bound to asteroid size 94 float minSize; //!< Lower bound to asteroid size 95 95 96 96 float radius; //!< Asteroids can appear within a sphere. 97 97 bool foggy; //!< Whether there's fog 98 float fogDensity; 98 float fogDensity; 99 99 100 100
Note: See TracChangeset
for help on using the changeset viewer.