KoduActionMotion.h
Go to the documentation of this file.00001 #ifndef KODU_ACTION_MOTION_H_
00002 #define KODU_ACTION_MOTION_H_
00003
00004
00005
00006 #include <cmath>
00007
00008
00009 #include "DualCoding/BaseData.h"
00010 #include "DualCoding/DualCoding.h"
00011 #include "DualCoding/ShapeRoot.h"
00012
00013
00014 #include "Kodu/Primitives/KoduAction.h"
00015 #include "Kodu/Primitives/PerceptionSearch.h"
00016 #include "Kodu/Generators/KoduGenerators.h"
00017 #include "Kodu/Keepers/ObjectKeeper.h"
00018
00019 namespace Kodu {
00020
00021 class MotionCommand {
00022 public:
00023
00024 MotionCommand();
00025
00026
00027 MotionCommand(const ShapeRoot& kTarget, float fwdSpeed, float trnSpeed);
00028
00029
00030 MotionCommand(float fwdDist, float trnAngle, float fwdSpeed, float trnSpeed);
00031
00032
00033 MotionCommand(const ShapeRoot& kTarget, float fwdDist, float trnAngle,
00034 float fwdSpeed, float trnSpeed);
00035
00036 MotionCommand(float fwdDist, float trnAngle, float fwdSpeed, float trnSpeed, bool driven);
00037
00038
00039 MotionCommand(const MotionCommand&);
00040
00041
00042 ~MotionCommand();
00043
00044
00045 MotionCommand& operator=(const MotionCommand&);
00046
00047
00048 bool operator==(const MotionCommand&);
00049
00050
00051 bool operator!=(const MotionCommand&);
00052
00053
00054 float getForwardSpeed() const;
00055
00056
00057 float getTurnSpeed() const;
00058
00059
00060 float getDistanceToTravel() const;
00061
00062
00063 float getTurningAngle() const;
00064
00065
00066 bool isValid() const;
00067
00068
00069 bool targetObjectIsValid() const;
00070
00071 bool isDriven() const;
00072
00073
00074 const ShapeRoot& getTargetObject() const;
00075
00076 friend class KoduActionMotion;
00077 friend std::ostream& operator<<(std::ostream &os, const MotionCommand &cmd);
00078
00079 private:
00080 ShapeRoot targetObject;
00081 float dx;
00082 float da;
00083 float forwardSpeed;
00084 float turnSpeed;
00085 bool cmdDriven;
00086 };
00087
00088 std::ostream& operator<<(std::ostream &os, const MotionCommand &cmd);
00089
00090
00091 class KoduActionMotion : public KoduAction {
00092 public:
00093
00094 enum MotionType_t {
00095 MT_MOVE_WANDER = 1L << 0,
00096 MT_MOVE_FORWARD = 1L << 1,
00097 MT_MOVE_TOWARDS = 1L << 2,
00098 MT_EMPTY_MOTION_TYPE = 1L << 3,
00099 MT_TURN_DIRECTION = 1L << 4,
00100 MT_TURN_LEFT = 1L << 5,
00101 MT_TURN_RIGHT = 1L << 6,
00102 MT_MOVE_GAMEPAD = 1L << 7
00103 };
00104
00105
00106 enum MotionRate_t {
00107 MR_NORMAL = 1L << 0,
00108 MR_QUICKLY = 1L << 1,
00109 MR_SLOWLY = 1L << 2
00110 };
00111
00112
00113 KoduActionMotion(MotionType_t type, MotionRate_t rate, unsigned int motionMagCount);
00114
00115
00116 KoduActionMotion(Direction_t direction, MotionRate_t rate, unsigned int motionMagCount);
00117
00118
00119 KoduActionMotion(const KoduActionMotion& kAction);
00120
00121
00122 ~KoduActionMotion();
00123
00124
00125 KoduActionMotion& operator=(const KoduActionMotion& kAction);
00126
00127
00128 const MotionCommand getMotionCommand();
00129
00130
00131 MotionType_t getMotionType() const;
00132
00133
00134 bool motionTypeIsMove() const;
00135
00136
00137 bool motionTypeIsTurn() const;
00138
00139
00140 virtual void reinitialize();
00141
00142 private:
00143
00144 MotionType_t motionType;
00145
00146
00147 NumericGenerator angleGen;
00148
00149
00150 NumericGenerator distGen;
00151
00152
00153 Direction_t directionToFace;
00154 };
00155 }
00156
00157 #endif // KODU_ACTION_MOTION_H_