Changeset 11667 for code/branches/AsteroidMining_HS17/src/modules/asteroidmining/SpicedAsteroidBelt.cc
- Timestamp:
- Dec 12, 2017, 8:29:52 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/AsteroidMining_HS17/src/modules/asteroidmining/SpicedAsteroidBelt.cc
r11665 r11667 29 29 /** 30 30 31 @file SpicedAsteroidBelt.cc 31 @file 32 @author remartin 32 33 @brief Asteroid belt with lots of parameters. Derived from asteroidField.lua 33 34 35 Generates a ring of asteroids by calling SpicedAsteroidField multiple times. 36 It's in the xy-plane at default, orientation can be changed with tiltAt 37 (angle where it gets elevated/lowered the most) and TiltBy (angle at z-axis). 38 This doesn't work very well and could probably implemented differently with 39 relative coordinates (attach etc, stuff in WorldEntity). 34 40 41 It is required to wait until all XML-arguments are set. That's why the actual 42 generation happens when tick() gets called for the first time. 43 35 44 */ 36 45 … … 64 73 this->count = 250; 65 74 this->position = Vector3(0,0,0); 66 // this->yaw = 0;67 // this->pitch = 0;68 75 this->segments = 30; 69 76 this->minSize = 1; … … 75 82 this->fogDensity = 0.5; 76 83 77 // Old from Pawn 84 this->tiltAt = 0.0; 85 this->tiltBy = 0.0; 86 78 87 this->registerVariables(); 79 88 … … 87 96 88 97 float myPi = 3.1415927410125732421875; //pi; // Math.pi ist statisch oder so. 89 float dPhi = (2 * myPi) / segments; 90 float width = radius1 - radius0; if(width<0){width = -width;} // predefined abs? 91 float radius = (radius1 + radius0) / 2.0; 92 int segmentCount = round(count / segments); 98 float width = this->radius1 - this->radius0; if(width<0){width = -width;} // predefined abs? 99 float radius = (this->radius1 + this->radius0) / 2.0; 100 int segmentCount = round(this->count / this->segments); 93 101 94 SpicedAsteroidField* af[ segments];102 SpicedAsteroidField* af[this->segments]; 95 103 (void)af[0]; // avoid nasty compiler warning 96 104 105 float dPhi = (2 * myPi) / this->segments; 106 float dTheta = 4.0*this->tiltBy/this->segments; 107 float sepp = -this->tiltAt; 108 float globi = (myPi/2.0) + this->tiltBy; 109 97 110 for(int s = 0; s<segments; ++s){ 98 Vector3* pos = new Vector3(radius*cos(s*dPhi), radius*sin(s*dPhi),0); 111 sepp = sepp + dPhi; 112 if(s<segments/2){ 113 globi = globi - dTheta; 114 }else{ 115 globi = globi + dTheta; 116 } 117 118 Vector3* pos = new Vector3(radius*cos(sepp)*sin(globi), radius*sin(sepp)*sin(globi), radius*cos(globi)); 99 119 af[s] = new SpicedAsteroidField(this->context, this->position + *pos, this->minSize, this->maxSize, width, segmentCount, this->foggy, this->mDensity, this->fogDensity); 120 100 121 } 101 122 … … 109 130 XMLPortParam(SpicedAsteroidBelt, "mDensity", setMineralDensity, getMineralDensity, xmlelement, mode); 110 131 XMLPortParam(SpicedAsteroidBelt, "position", setPosition, getPosition, xmlelement, mode); 111 // XMLPortParam(SpicedAsteroidBelt, "yaw", setYaw, getYaw, xmlelement, mode);112 // XMLPortParam(SpicedAsteroidBelt, "pitch", setPitch, getPitch, xmlelement, mode);113 132 XMLPortParam(SpicedAsteroidBelt, "segments", setSegments, getSegments, xmlelement, mode); 114 133 … … 119 138 XMLPortParam(SpicedAsteroidBelt, "foggy", setFog, isFoggy, xmlelement, mode); 120 139 XMLPortParam(SpicedAsteroidBelt, "fogDensity", setFogDensity, getFogDensity, xmlelement, mode); 140 141 XMLPortParam(SpicedAsteroidBelt, "tiltAt", setTiltAt, getTiltAt, xmlelement, mode); 142 XMLPortParam(SpicedAsteroidBelt, "tiltBy", setTiltBy, getTiltBy, xmlelement, mode); 121 143 122 144 } … … 131 153 registerVariable(this->mDensity, VariableDirection::ToClient); 132 154 registerVariable(this->position, VariableDirection::ToClient); 133 // registerVariable(this->yaw, VariableDirection::ToClient);134 // registerVariable(this->pitch, VariableDirection::ToClient);135 155 registerVariable(this->segments, VariableDirection::ToClient); 136 156 … … 141 161 registerVariable(this->foggy, VariableDirection::ToClient); 142 162 registerVariable(this->fogDensity, VariableDirection::ToClient); 163 164 registerVariable(this->tiltAt, VariableDirection::ToClient); 165 registerVariable(this->tiltBy, VariableDirection::ToClient); 143 166 144 167 }
Note: See TracChangeset
for help on using the changeset viewer.