Changeset 618 for code/branches/FICN/src/orxonox/Flocking.h
- Timestamp:
- Dec 18, 2007, 4:47:58 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/FICN/src/orxonox/Flocking.h
r609 r618 5 5 #define Flocking_Class 6 6 7 #include <Ogre.h>7 // #include <Ogre.h> 8 8 #include <OgreVector3.h> 9 9 … … 19 19 20 20 public: 21 Ogre::Vector3 location; //locationvector of the element22 Ogre::Vector3 speed; //speedvector of the element23 Ogre::Vector3 acceleration; //accelerationvector of the element24 bool movable; //movability of the element, (false) gives the possiblity that an object can`t be moved by flocking but still gets into the calculation25 static int const SEPERATIONDISTANCE = 300; //detectionradius of seperation26 static int const ALIGNMENTDISTANCE = 300; //detectionradius of alignment27 static int const COHESIONDISTANCE = 5000; //detectionradius of cohesion28 static int const ANZELEMENTS = 9; //number of elements21 Ogre::Vector3 location; //!< locationvector of the element 22 Ogre::Vector3 speed; //!< speedvector of the element 23 Ogre::Vector3 acceleration; //!< accelerationvector of the element 24 bool movable; //!< movability of the element, (false) gives the possiblity that an object can`t be moved by flocking but still gets into the calculation 25 static int const SEPERATIONDISTANCE = 300; //!< detectionradius of seperation 26 static int const ALIGNMENTDISTANCE = 300; //!< detectionradius of alignment 27 static int const COHESIONDISTANCE = 5000; //!< detectionradius of cohesion 28 static int const ANZELEMENTS = 9; //!< number of elements 29 29 30 // default constructor30 //! default constructor 31 31 Element() { 32 acceleration = (0,0,0);33 speed = (0,0,0);34 location = (0,0,0);32 acceleration = Ogre::Vector3(0,0,0); 33 speed = Ogre::Vector3(0,0,0); 34 location = Ogre::Vector3(0,0,0); 35 35 movable = true; 36 36 } 37 37 38 //constructor 38 /** constructor 39 * @param location_ sets locationvector of the element 40 * @param speed_ sets speedvector of the element 41 * @param acceleration_ sets accelerationvector of the element 42 * @param movable_ sets movability of the element 43 */ 39 44 Element(Ogre::Vector3 location_, Ogre::Vector3 speed_, Ogre::Vector3 acceleration_, bool movable_) { 40 45 acceleration = acceleration_; … … 44 49 } 45 50 46 // function to chance values of an element51 //! function to chance values of an element 47 52 void setValues(Ogre::Vector3 location_, Ogre::Vector3 speed_, Ogre::Vector3 acceleration_, bool movable_) { 48 53 acceleration = acceleration_; … … 52 57 } 53 58 54 //calculates the distance between the element and an other point given by temp 55 float getDistance(Element temp) { 56 Ogre::Vector3 distance = temp.location-location; 59 /** calculates the distance between the element and an other point given by temp 60 * @param e remote object to calculate distance to 61 */ 62 float getDistance(Element e) { 63 Ogre::Vector3 distance = e.location - location; 57 64 return distance.length(); 58 65 } 59 66 60 // updates the data of an element67 //! updates the data of an element 61 68 void update(Element arrayOfElements[]) { 62 69 if (this->movable == true) {calculateAcceleration(arrayOfElements);} //if element is movable, calculate acceleration 63 70 } 64 71 65 // calculates the new acceleration of an element72 //! calculates the new acceleration of an element 66 73 void calculateAcceleration(Element arrayOfElements[]) { 67 74 acceleration = separation(arrayOfElements) + alignment(arrayOfElements) + cohesion(arrayOfElements); //acceleration consisting of flocking-functions 68 75 } 69 76 70 // separation-function (keep elements separated, avoid crashs)77 //! separation-function (keep elements separated, avoid crashs) 71 78 Ogre::Vector3 separation(Element arrayOfElements[]) { 72 79 using namespace Ogre; … … 94 101 } 95 102 96 // alignment-function (lead elements to the same heading)103 //! alignment-function (lead elements to the same heading) 97 104 Ogre::Vector3 alignment(Element arrayOfElements[]) { 98 105 using namespace Ogre; … … 113 120 } 114 121 115 // cohseion-function (keep elements close to each other)122 //! cohseion-function (keep elements close to each other) 116 123 Ogre::Vector3 cohesion(Element arrayOfElements[]) { 117 124 using namespace Ogre;
Note: See TracChangeset
for help on using the changeset viewer.