Alvaro Cassinelli
/
skinGames_forktest
just a test
Fork of scoreLight_Advanced by
rigidLoop.h@31:5f039cbddee8, 2012-09-23 (annotated)
- Committer:
- mbedalvaro
- Date:
- Sun Sep 23 10:11:43 2012 +0000
- Revision:
- 31:5f039cbddee8
- Parent:
- 30:d8af03f01cd4
- Child:
- 32:52273c3291fe
this is quite nice, but I am going to make a deep modification of the bouncing principle: instead of depending on the penetration, it will just be a factor over the speed (perfect elastic bouncing being factorElastic=1, and perfectly absorption=0);
Who changed what in which revision?
User | Revision | Line number | New 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 | 31:5f039cbddee8 | 11 | enum RigidLoopMode {SPOT_FOLLOWING, SPOT_GHOST, SPOT_PACMAN, SPOT_BOUNCING, SPOT_AIR_HOCKEY, SPOT_LORENTZ_FORCE, |
mbedalvaro | 31:5f039cbddee8 | 12 | SPOT_TEST, SPOT_TRACK, SPOT_TRACK_DOT, |
mbedalvaro | 31:5f039cbddee8 | 13 | EXPLOSION}; |
mbedalvaro | 1:a4050fee11f7 | 14 | |
mbedalvaro | 1:a4050fee11f7 | 15 | class rigidLoop : public soundSpot { |
mbedalvaro | 1:a4050fee11f7 | 16 | |
mbedalvaro | 1:a4050fee11f7 | 17 | public: |
mbedalvaro | 1:a4050fee11f7 | 18 | |
mbedalvaro | 1:a4050fee11f7 | 19 | // Constructor and destructor: |
mbedalvaro | 1:a4050fee11f7 | 20 | rigidLoop(); |
mbedalvaro | 1:a4050fee11f7 | 21 | ~rigidLoop(); |
mbedalvaro | 1:a4050fee11f7 | 22 | |
mbedalvaro | 1:a4050fee11f7 | 23 | // instantiation of the virtual methods of the base class (we don't need to append "virtual", but for clarity I do): |
mbedalvaro | 12:0de9cd2bced5 | 24 | void createBlob(int _id, RigidLoopMode _rigidBlobMode, vector2Df _initPos, vector2Df _initSpeed); |
mbedalvaro | 12:0de9cd2bced5 | 25 | 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 | 26 | virtual void update(vector2Df referencePos); // update dynamics of the mass loop |
mbedalvaro | 1:a4050fee11f7 | 27 | 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 | 28 | virtual void computeBoundingBox(); |
mbedalvaro | 1:a4050fee11f7 | 29 | virtual void sendDataSpecific(void); |
mbedalvaro | 24:4e52031a495b | 30 | virtual void speedFactor(float speedfactor); |
mbedalvaro | 31:5f039cbddee8 | 31 | |
mbedalvaro | 31:5f039cbddee8 | 32 | virtual void explosion(); // not very nice programming style, it should be a MODE instead or something like that. |
mbedalvaro | 31:5f039cbddee8 | 33 | virtual vector2Df getCenter(); |
mbedalvaro | 31:5f039cbddee8 | 34 | virtual void resetPositionSpeed() {centerMass.setInitialCondition(startCenter, startSpeed);}; |
mbedalvaro | 31:5f039cbddee8 | 35 | virtual void setPositionSpeed(vector2Df _pos, vector2Df _spe) {centerMass.setInitialCondition(_pos, _spe);}; |
mbedalvaro | 31:5f039cbddee8 | 36 | |
mbedalvaro | 31:5f039cbddee8 | 37 | |
mbedalvaro | 1:a4050fee11f7 | 38 | // methods that are new to this class (not in base class): |
mbedalvaro | 1:a4050fee11f7 | 39 | void initSizeBlob(int _numPoints); |
mbedalvaro | 1:a4050fee11f7 | 40 | void createLoopFromScafold(void); // this is much simpler than the elastic blob (here, we only need to add a central mass) |
mbedalvaro | 1:a4050fee11f7 | 41 | // void processLoopData(); // not needed, because the loop is rigid. |
mbedalvaro | 1:a4050fee11f7 | 42 | |
mbedalvaro | 1:a4050fee11f7 | 43 | RigidLoopMode updateMode; |
mbedalvaro | 1:a4050fee11f7 | 44 | |
mbedalvaro | 1:a4050fee11f7 | 45 | // 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 | 46 | // int numPoints; // this belongs to soundSpot base class |
mbedalvaro | 1:a4050fee11f7 | 47 | pointMass centerMass; // this is the center of the rigidLoop. Note that it can have mass or not, this will depend on the RigidLoopMode |
mbedalvaro | 1:a4050fee11f7 | 48 | |
mbedalvaro | 1:a4050fee11f7 | 49 | // The following are common to all blobs: |
mbedalvaro | 1:a4050fee11f7 | 50 | // float angleCorrectionForceLoop; |
mbedalvaro | 1:a4050fee11f7 | 51 | // vector2D recenteringVectorLoop; |
mbedalvaro | 1:a4050fee11f7 | 52 | // float angleRecenteringVector; // auxiliary variables for sending data (for the recenteringVectorLoop) |
mbedalvaro | 1:a4050fee11f7 | 53 | // float normRecenteringVector; |
mbedalvaro | 1:a4050fee11f7 | 54 | |
mbedalvaro | 1:a4050fee11f7 | 55 | // other modes: |
mbedalvaro | 1:a4050fee11f7 | 56 | bool slidingDirection; // for contour following |
mbedalvaro | 1:a4050fee11f7 | 57 | |
mbedalvaro | 1:a4050fee11f7 | 58 | // numeric parameters: |
mbedalvaro | 1:a4050fee11f7 | 59 | float saccadeRadius; |
mbedalvaro | 1:a4050fee11f7 | 60 | |
mbedalvaro | 7:0df17f3078bc | 61 | // THINGS FOR CONTOUR FOLLOWING: |
mbedalvaro | 7:0df17f3078bc | 62 | float saccadeRadius_initial; // this is for SEARCH MODE (remember initial radius) |
mbedalvaro | 7:0df17f3078bc | 63 | bool justSearched; |
mbedalvaro | 7:0df17f3078bc | 64 | |
mbedalvaro | 7:0df17f3078bc | 65 | |
mbedalvaro | 4:f9d364f10335 | 66 | float rotationAngle; // note: in the future, rotation would be done by the openGL-like renderer |
mbedalvaro | 4:f9d364f10335 | 67 | |
mbedalvaro | 1:a4050fee11f7 | 68 | float massCenter; |
mbedalvaro | 1:a4050fee11f7 | 69 | float dampMotionCenterMass; |
mbedalvaro | 25:74cb85b85fd2 | 70 | |
mbedalvaro | 21:bc9b9383f4b6 | 71 | |
mbedalvaro | 1:a4050fee11f7 | 72 | float speedContourFollowing; // this is given as a percentage of the radius of the circle |
mbedalvaro | 1:a4050fee11f7 | 73 | float factorBouncingForce; |
mbedalvaro | 1:a4050fee11f7 | 74 | }; |
mbedalvaro | 1:a4050fee11f7 | 75 | |
mbedalvaro | 1:a4050fee11f7 | 76 | #endif |