just a test

Dependencies:   mbed

Fork of scoreLight_Advanced by Alvaro Cassinelli

Committer:
mbedalvaro
Date:
Tue Dec 02 04:28:42 2014 +0000
Revision:
48:7633d8e7b0d3
Parent:
47:2312a8dc9658
this is the working version of the skin games sowtware (aka, scorelight but with pre-determined "games")

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbedalvaro 1:a4050fee11f7 1 #ifndef RIGID_LOOP
mbedalvaro 1:a4050fee11f7 2 #define RIGID_LOOP
mbedalvaro 1:a4050fee11f7 3
mbedalvaro 1:a4050fee11f7 4 // Include the basic objects to create the loop
mbedalvaro 1:a4050fee11f7 5 #include "soundSpot.h"
mbedalvaro 1:a4050fee11f7 6 #include "classPointMass.h" // this may be used to move the center of the RIGID loop in dynamically "real" ways
mbedalvaro 1:a4050fee11f7 7 #include "classSpring.h" // same remark than above
mbedalvaro 1:a4050fee11f7 8
mbedalvaro 1:a4050fee11f7 9 using namespace std;
mbedalvaro 1:a4050fee11f7 10
mbedalvaro 32:52273c3291fe 11 enum RigidLoopMode {SPOT_FOLLOWING, SPOT_GHOST, SPOT_PACMAN, SPOT_AIR_HOCKEY, SPOT_LORENTZ_FORCE,
mbedalvaro 32:52273c3291fe 12 SPOT_BOUNCING, SPOT_BOUNCING_FACTOR,
mbedalvaro 31:5f039cbddee8 13 SPOT_TEST, SPOT_TRACK, SPOT_TRACK_DOT,
mbedalvaro 31:5f039cbddee8 14 EXPLOSION};
mbedalvaro 1:a4050fee11f7 15
mbedalvaro 1:a4050fee11f7 16 class rigidLoop : public soundSpot {
mbedalvaro 1:a4050fee11f7 17
mbedalvaro 1:a4050fee11f7 18 public:
mbedalvaro 1:a4050fee11f7 19
mbedalvaro 1:a4050fee11f7 20 // Constructor and destructor:
mbedalvaro 1:a4050fee11f7 21 rigidLoop();
mbedalvaro 39:7c54b6bca0e2 22 virtual ~rigidLoop();
mbedalvaro 1:a4050fee11f7 23
mbedalvaro 1:a4050fee11f7 24 // instantiation of the virtual methods of the base class (we don't need to append "virtual", but for clarity I do):
mbedalvaro 12:0de9cd2bced5 25 void createBlob(int _id, RigidLoopMode _rigidBlobMode, vector2Df _initPos, vector2Df _initSpeed);
mbedalvaro 12:0de9cd2bced5 26 virtual void setRegionMotion(float mmix, float mmiy, float mmax, float mmay); // attention: initial position posX and posY should be inside this bounding box...
mbedalvaro 31:5f039cbddee8 27 virtual void update(vector2Df referencePos); // update dynamics of the mass loop
mbedalvaro 1:a4050fee11f7 28 virtual void draw(void); // draw the blob (renders on the laser trajectory object lsdTrajectory from the base class, using the openGL laser renderer - not yet done).
mbedalvaro 1:a4050fee11f7 29 virtual void computeBoundingBox();
mbedalvaro 1:a4050fee11f7 30 virtual void sendDataSpecific(void);
mbedalvaro 33:43e8bc451ef0 31 virtual void setSpeed(float speed);
mbedalvaro 33:43e8bc451ef0 32 virtual void setSize(float size);
mbedalvaro 24:4e52031a495b 33 virtual void speedFactor(float speedfactor);
mbedalvaro 32:52273c3291fe 34 virtual void sizeFactor(float sizeFactor);
mbedalvaro 31:5f039cbddee8 35
mbedalvaro 31:5f039cbddee8 36 virtual void explosion(); // not very nice programming style, it should be a MODE instead or something like that.
mbedalvaro 31:5f039cbddee8 37 virtual vector2Df getCenter();
mbedalvaro 31:5f039cbddee8 38 virtual void resetPositionSpeed() {centerMass.setInitialCondition(startCenter, startSpeed);};
mbedalvaro 31:5f039cbddee8 39 virtual void setPositionSpeed(vector2Df _pos, vector2Df _spe) {centerMass.setInitialCondition(_pos, _spe);};
mbedalvaro 31:5f039cbddee8 40
mbedalvaro 47:2312a8dc9658 41 virtual void showChildParameters();
mbedalvaro 31:5f039cbddee8 42
mbedalvaro 1:a4050fee11f7 43 // methods that are new to this class (not in base class):
mbedalvaro 1:a4050fee11f7 44 void initSizeBlob(int _numPoints);
mbedalvaro 1:a4050fee11f7 45 void createLoopFromScafold(void); // this is much simpler than the elastic blob (here, we only need to add a central mass)
mbedalvaro 1:a4050fee11f7 46 // void processLoopData(); // not needed, because the loop is rigid.
mbedalvaro 1:a4050fee11f7 47
mbedalvaro 1:a4050fee11f7 48 RigidLoopMode updateMode;
mbedalvaro 1:a4050fee11f7 49
mbedalvaro 1:a4050fee11f7 50 // The number of points in the loop (in this case, is just the number of points in the scaffold, as well as the number of points in the lsdTrajectory)
mbedalvaro 12:0de9cd2bced5 51 // int numPoints; // this belongs to soundSpot base class
mbedalvaro 1:a4050fee11f7 52 pointMass centerMass; // this is the center of the rigidLoop. Note that it can have mass or not, this will depend on the RigidLoopMode
mbedalvaro 46:90516893793a 53 float integrationStep;
mbedalvaro 1:a4050fee11f7 54
mbedalvaro 1:a4050fee11f7 55 // The following are common to all blobs:
mbedalvaro 1:a4050fee11f7 56 // float angleCorrectionForceLoop;
mbedalvaro 1:a4050fee11f7 57 // vector2D recenteringVectorLoop;
mbedalvaro 1:a4050fee11f7 58 // float angleRecenteringVector; // auxiliary variables for sending data (for the recenteringVectorLoop)
mbedalvaro 1:a4050fee11f7 59 // float normRecenteringVector;
mbedalvaro 1:a4050fee11f7 60
mbedalvaro 1:a4050fee11f7 61 // other modes:
mbedalvaro 1:a4050fee11f7 62 bool slidingDirection; // for contour following
mbedalvaro 1:a4050fee11f7 63
mbedalvaro 1:a4050fee11f7 64 // numeric parameters:
mbedalvaro 1:a4050fee11f7 65 float saccadeRadius;
mbedalvaro 1:a4050fee11f7 66
mbedalvaro 7:0df17f3078bc 67 // THINGS FOR CONTOUR FOLLOWING:
mbedalvaro 7:0df17f3078bc 68 float saccadeRadius_initial; // this is for SEARCH MODE (remember initial radius)
mbedalvaro 7:0df17f3078bc 69 bool justSearched;
mbedalvaro 7:0df17f3078bc 70
mbedalvaro 7:0df17f3078bc 71
mbedalvaro 4:f9d364f10335 72 float rotationAngle; // note: in the future, rotation would be done by the openGL-like renderer
mbedalvaro 4:f9d364f10335 73
mbedalvaro 1:a4050fee11f7 74 float massCenter;
mbedalvaro 1:a4050fee11f7 75 float dampMotionCenterMass;
mbedalvaro 25:74cb85b85fd2 76
mbedalvaro 21:bc9b9383f4b6 77
mbedalvaro 1:a4050fee11f7 78 float speedContourFollowing; // this is given as a percentage of the radius of the circle
mbedalvaro 32:52273c3291fe 79 float factorBouncingForce; // spring force when penetrating on dark zone (used by SPOT_BOUNCING)
mbedalvaro 32:52273c3291fe 80 float factorAbsorptionShock; // factor speed damping when bouncing on dark zone (used in SPOT_BOUNCING_FACTOR)
mbedalvaro 1:a4050fee11f7 81 };
mbedalvaro 1:a4050fee11f7 82
mbedalvaro 1:a4050fee11f7 83 #endif