Planet
navi homePPSaboutscreenshotsdownloaddevelopmentforum

source: code/branches/FICN/src/orxonox/Arrival.h @ 737

Last change on this file since 737 was 708, checked in by rgrieder, 17 years ago
  • added Vector2, Vector3, Matrix3, ColourValue, Quaternion and String to the misc folder as header files (each of them contains #include <string> … typedef std::string String , etc.)
  • please use String from now on by including <misc/String.h"
  • removed #include <OgreVector3.h", etc. from "CoreIncludes.h" (adjusted all source files)
  • adjusted all the source files (except network, that keeps <string> for the moment) (what a mess..)
  • moved usleep hack to misc/Sleep.h
  • relative include paths for files from other root directories (like misc, network, etc.) (but it stills writes "../Orxonox.h" when in folder orxonox/objects)
  • "OgreSceneManager.h" —> <OgreSceneManager.h>
  • included OrxonoxPrereqs in every file in folder orxonox
  • moved HUD and ParticleInterface to namespace orxonox
  • removed some using namespace Ogre/std when appropriate
  • I hope I haven't forgotten important points..
File size: 2.1 KB
Line 
1
2// Arrival Class
3
4
5#ifndef _Arrival_H__
6#define _Arrival_H__
7
8#include "misc/Vector3.h"
9#include "misc/Quaternion.h"
10
11namespace orxonox
12{
13  class Arrival
14  {
15  public:
16    Vector3 location;           //!< locationvector of the element
17    Vector3 speed;              //!< speedvector of the element
18    Vector3 acceleration;       //!< accelerationvector of the element
19    Vector3 target;             //!< target to arrive
20    int accelerationForwards;   //!< from steering-interface
21    int MaxSpeed;               //!< from steering-interface
22
23
24    Arrival() {
25      acceleration = (0,0,0);
26      speed = (0,0,0);
27      location = (0,0,0);
28      target = (0,0,0);
29    }
30
31    Arrival(Vector3 location_, Vector3 speed_, Vector3 acceleration_, Vector3 target_) {
32      acceleration = acceleration_;
33      speed = speed_;
34      location = location_;
35      target = target_;
36    }
37
38    void setValues(Vector3 location_, Vector3 speed_, Vector3 acceleration_, Vector3 target_) {
39      acceleration = acceleration_;
40      speed = speed_;
41      location = location_;
42      target = target_;
43    }
44
45    void setTarget(Vector3 target_) {
46      setValues(this->location, this->speed, this->acceleration, target_);
47    }
48
49    Vector3 getDirection() {
50      Vector3 direction = target-location;
51    }
52
53    double relativeDirectApproach() {
54      // Maxspeed / accelerationForwards = time needed to break with max acceleration
55      // 2*getDistance()length/(MaxSpeed/accelerationForwards)^2 = required acceleration to arrive at the target with speed = 0
56      return (accelerationForwards / (2*getDirection().length() / ((MaxSpeed/accelerationForwards)*(MaxSpeed/accelerationForwards))) );
57    }
58
59    void Approach() {
60      Quaternion rotation = Quaternion(0,0,0,0);
61      if (relativeDirectApproach() > 1)
62      {
63        float length = speed.length();
64        speed = (speed+getDirection());
65        speed.normalise();
66        speed = speed*length;
67        if (relativeDirectApproach() > 4)
68        {
69          //accelerate
70        }
71        else
72        {
73          // speed will stay constant
74        }
75      }
76      else {
77      }
78    }
79
80  };
81}
82
83#endif /* _Arrival_H__ */
Note: See TracBrowser for help on using the repository browser.