Changeset 9939 for code/trunk/src/modules/objects
- Timestamp:
- Dec 21, 2013, 11:16:54 PM (11 years ago)
- Location:
- code/trunk
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/trunk
- Property svn:mergeinfo changed
-
code/trunk/src/modules/objects/ForceField.cc
r9667 r9939 45 45 /*static*/ const std::string ForceField::modeSphere_s = "sphere"; 46 46 /*static*/ const std::string ForceField::modeInvertedSphere_s = "invertedSphere"; 47 48 /*static*/ const std::string ForceField::modeHomogen_s = "homogen"; 49 47 50 /*static*/ const std::string ForceField::modeNewtonianGravity_s = "newtonianGravity"; 48 51 /*static*/ const float ForceField::gravConstant_ = 6.673e-11; 49 52 /*static*/ const float ForceField::attenFactor_ = 1; 53 50 54 51 55 /** … … 89 93 XMLPortParam(ForceField, "length", setLength , getLength , xmlelement, mode).defaultValues(2000); 90 94 XMLPortParam(ForceField, "mode", setMode, getMode, xmlelement, mode); 95 XMLPortParam(ForceField, "forcedirection", setForceDirection, getForceDirection, xmlelement, mode).defaultValues(Vector3(0,-400,0)); 91 96 } 92 97 … … 196 201 } 197 202 } 203 else if(this->mode_ == forceFieldMode::homogen) 204 { 205 // Iterate over all objects that could possibly be affected by the ForceField. 206 for (ObjectList<MobileEntity>::iterator it = ObjectList<MobileEntity>::begin(); it != ObjectList<MobileEntity>::end(); ++it) 207 { 208 Vector3 distanceVector = it->getWorldPosition() - this->getWorldPosition(); 209 float distance = distanceVector.length(); 210 if (distance < this->radius_ && distance > this->massRadius_) 211 { 212 // Add a Acceleration in forceDirection_. 213 // Vector3(0,0,0) is the direction, where the force should work. 214 it->addAcceleration(forceDirection_ , Vector3(0,0,0)); 215 } 216 } 217 } 198 218 } 199 219 … … 214 234 else if(mode == ForceField::modeNewtonianGravity_s) 215 235 this->mode_ = forceFieldMode::newtonianGravity; 236 237 else if(mode == ForceField::modeHomogen_s) 238 this->mode_ = forceFieldMode::homogen; 239 216 240 else 217 241 { … … 239 263 case forceFieldMode::newtonianGravity: 240 264 return ForceField::modeNewtonianGravity_s; 265 266 case forceFieldMode::homogen: 267 return ForceField::modeHomogen_s; 268 241 269 default: 242 270 return ForceField::modeTube_s; -
code/trunk/src/modules/objects/ForceField.h
r9667 r9939 1 1 2 /* 2 3 * ORXONOX - the hottest 3D action shooter ever to exist … … 57 58 sphere, //!< The ForceField has a spherical shape. 58 59 invertedSphere, //!< The ForceField has a spherical shape but "inverted" behavior. 59 newtonianGravity //!< The ForceField imitates Newtonian gravitation for use in stellar bodies. 60 newtonianGravity, //!< The ForceField imitates Newtonian gravitation for use in stellar bodies. 61 homogen //!< Local homogenous Force field with changeable direction for the Space Station 60 62 }; 61 63 } … … 66 68 67 69 The following parameters can be set to specify the behavior of the ForceField. 70 - @b forcedirection The direction and the strength of the homogenous force field. Default is 0,-400,0. 68 71 - @b velocity The amount of force the ForceField excerts. Default is 100. 69 72 - @b diameter The diameter of the ForceField. Default is 500. … … 147 150 { return this->halfLength_*2; } 148 151 152 inline void setForceDirection(Vector3 forcedir) 153 { this->forceDirection_ = forcedir; } 154 155 inline Vector3 getForceDirection() 156 { return this->forceDirection_; } 157 158 149 159 void setMode(const std::string& mode); //!< Set the mode of the ForceField. 150 160 const std::string& getMode(void); //!< Get the mode of the ForceField. … … 156 166 static const std::string modeInvertedSphere_s; 157 167 static const std::string modeNewtonianGravity_s; 168 169 static const std::string modeHomogen_s; 158 170 159 171 float velocity_; //!< The velocity of the ForceField. … … 167 179 //! Attenuation factor for Newtonian ForceFields 168 180 static const float attenFactor_; 181 Vector3 forceDirection_; 169 182 }; 170 183 }
Note: See TracChangeset
for help on using the changeset viewer.