Alvaro Cassinelli
/
skinGames_forktest
just a test
Fork of scoreLight_Advanced by
blobConfig.h@48:7633d8e7b0d3, 2014-12-02 (annotated)
- 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?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbedalvaro | 0:345b3bc7a0ea | 1 | #ifndef blobConf_h |
mbedalvaro | 0:345b3bc7a0ea | 2 | #define blobConf_h |
mbedalvaro | 0:345b3bc7a0ea | 3 | |
mbedalvaro | 0:345b3bc7a0ea | 4 | // include all kind of spots classes (childs of soundSpot) |
mbedalvaro | 15:56a0bf424e8d | 5 | #include "elasticLoop.h" |
mbedalvaro | 1:a4050fee11f7 | 6 | #include "rigidLoop.h" |
mbedalvaro | 30:d8af03f01cd4 | 7 | #include "hardwareIO.h" // this is in fact only to get to know the initial position of the spots, as well as the mirror limits to set the bounding box for the blobs |
mbedalvaro | 0:345b3bc7a0ea | 8 | |
mbedalvaro | 11:62f7183a03e7 | 9 | #include <vector> |
mbedalvaro | 15:56a0bf424e8d | 10 | //#include <deque>; // using a deque instead of a vector can have advantanges in terms of memory (deque can handle fragmented memory), BUT IS SLOWER. |
mbedalvaro | 15:56a0bf424e8d | 11 | using namespace std; |
mbedalvaro | 11:62f7183a03e7 | 12 | |
mbedalvaro | 30:d8af03f01cd4 | 13 | // This is for the SKIN GAMES project, in which not only each blob object has behaviour of its own, but the blobs can interact in different ways; hence the update |
mbedalvaro | 30:d8af03f01cd4 | 14 | // method cannot be just "update all the blobs": |
mbedalvaro | 30:d8af03f01cd4 | 15 | enum configType {ONE_ELASTIC_FOLLOWING, ONE_ELASTIC_MOUTH, ONE_ELASTIC_MOUTH_SMALL, |
mbedalvaro | 31:5f039cbddee8 | 16 | ONE_TRACKING_SPOT, ONE_TRACKING_SPOT_DOT, |
mbedalvaro | 30:d8af03f01cd4 | 17 | BOUNCING_SPOTS, LORENTZ_SPOTS, FOLLOWING_SPOTS, |
mbedalvaro | 32:52273c3291fe | 18 | AIR_HOCKEY_GAME, CIRCULAR_PONG_GAME, FISH_NET_GAME, VERTICAL_PINBALL_GAME, PAC_MAN_GAME, |
mbedalvaro | 32:52273c3291fe | 19 | RAIN_MODE}; |
mbedalvaro | 30:d8af03f01cd4 | 20 | |
mbedalvaro | 0:345b3bc7a0ea | 21 | class blobConfig { |
mbedalvaro | 15:56a0bf424e8d | 22 | public: |
mbedalvaro | 15:56a0bf424e8d | 23 | |
mbedalvaro | 15:56a0bf424e8d | 24 | //========== Methods ============= |
mbedalvaro | 15:56a0bf424e8d | 25 | blobConfig(); // overaloded constructor |
mbedalvaro | 30:d8af03f01cd4 | 26 | blobConfig(configType cftype, unsigned char numspots=1) { initConfig(cftype, numspots);}; // overaloded constructor with parameters |
mbedalvaro | 15:56a0bf424e8d | 27 | ~blobConfig(); |
mbedalvaro | 15:56a0bf424e8d | 28 | |
mbedalvaro | 31:5f039cbddee8 | 29 | void initConfig(configType myConfigType, int numblobs=1); |
mbedalvaro | 30:d8af03f01cd4 | 30 | |
mbedalvaro | 15:56a0bf424e8d | 31 | void clearConfig(); // actually delete every element of the config (note: the blobArray is a vector of POINTERS, it is not enought to do blobArray.clear()). |
mbedalvaro | 15:56a0bf424e8d | 32 | |
mbedalvaro | 44:46e25fa1669b | 33 | void processSensedData(); |
mbedalvaro | 44:46e25fa1669b | 34 | |
mbedalvaro | 15:56a0bf424e8d | 35 | void allKill(); // this put all the blobs in "dead" mode, meaning that neither rendering nor update is done (but they are not deleted). |
mbedalvaro | 15:56a0bf424e8d | 36 | void allAlive(); |
mbedalvaro | 15:56a0bf424e8d | 37 | |
mbedalvaro | 15:56a0bf424e8d | 38 | void allStandBy(); //NO update, but rendering may be done (they are "frozen" in their positions) |
mbedalvaro | 15:56a0bf424e8d | 39 | void allResume(); |
mbedalvaro | 15:56a0bf424e8d | 40 | |
mbedalvaro | 15:56a0bf424e8d | 41 | void allInvisible(); // blobs are invisible, but they may continue to evolve (call to update) |
mbedalvaro | 15:56a0bf424e8d | 42 | void allVisible(); |
mbedalvaro | 25:74cb85b85fd2 | 43 | |
mbedalvaro | 25:74cb85b85fd2 | 44 | void allSetColor(unsigned char c); |
mbedalvaro | 32:52273c3291fe | 45 | void allSetGreen(unsigned char c); |
mbedalvaro | 32:52273c3291fe | 46 | void allSetBlue(unsigned char c); |
mbedalvaro | 33:43e8bc451ef0 | 47 | void randomizeAllColors(); |
mbedalvaro | 32:52273c3291fe | 48 | |
mbedalvaro | 15:56a0bf424e8d | 49 | void update(); // update dynamics |
mbedalvaro | 15:56a0bf424e8d | 50 | void draw(); // draw in the LaserSensingTrajectory object (lsdTrajectory) of each blob, using the openGL laser rendering (not yet done). |
mbedalvaro | 15:56a0bf424e8d | 51 | |
mbedalvaro | 47:2312a8dc9658 | 52 | void printParameters(); // on serial port (for calibration) |
mbedalvaro | 46:90516893793a | 53 | |
mbedalvaro | 15:56a0bf424e8d | 54 | void sendConfData(); // send OSC data for all the blobs |
mbedalvaro | 15:56a0bf424e8d | 55 | |
mbedalvaro | 15:56a0bf424e8d | 56 | void computeBoundingBox(); |
mbedalvaro | 15:56a0bf424e8d | 57 | |
mbedalvaro | 30:d8af03f01cd4 | 58 | // ========= Template spots from which to create multi-spot configurations: ===================== |
mbedalvaro | 30:d8af03f01cd4 | 59 | void addOneElasticLoopRelax(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(0,0)); |
mbedalvaro | 30:d8af03f01cd4 | 60 | void addOneElasticLoopContract(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(0,0)); |
mbedalvaro | 30:d8af03f01cd4 | 61 | void addOneElasticLoopContractCentral(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(0,0)); |
mbedalvaro | 30:d8af03f01cd4 | 62 | void addOneElasticLoopContractCentralFast(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(0,0)); |
mbedalvaro | 30:d8af03f01cd4 | 63 | void addOneElasticContourFollowing(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(0,0)); |
mbedalvaro | 30:d8af03f01cd4 | 64 | void addOneElasticContourFollowingFAST(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(0,0)); |
mbedalvaro | 30:d8af03f01cd4 | 65 | void addOneElasticBouncing(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(1,1)); |
mbedalvaro | 15:56a0bf424e8d | 66 | |
mbedalvaro | 30:d8af03f01cd4 | 67 | void addOneRigidLoopBouncing(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(2,2)); |
mbedalvaro | 31:5f039cbddee8 | 68 | void addOneRigidLoopBouncingGravity(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(2,2)); |
mbedalvaro | 30:d8af03f01cd4 | 69 | void addOneRigidLoopLorentz(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(2,2)); |
mbedalvaro | 30:d8af03f01cd4 | 70 | void addOneRigidLoopAirHockey(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(0,0)); |
mbedalvaro | 30:d8af03f01cd4 | 71 | void addOneRigidLoopFollowing(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(0,0)); |
mbedalvaro | 30:d8af03f01cd4 | 72 | void addOneRigidLoopTest(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(0,0)); |
mbedalvaro | 30:d8af03f01cd4 | 73 | void addOneRigidTrackingSpot(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(0,0)); |
mbedalvaro | 31:5f039cbddee8 | 74 | void addOneRigidTrackingSpotDot(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(0,0)); |
mbedalvaro | 30:d8af03f01cd4 | 75 | void addOneRigidLoopPacman(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(0,0)); |
mbedalvaro | 30:d8af03f01cd4 | 76 | void addOneRigidLoopGhost(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(0,0)); |
mbedalvaro | 15:56a0bf424e8d | 77 | |
mbedalvaro | 15:56a0bf424e8d | 78 | //========== Variables ============= |
mbedalvaro | 30:d8af03f01cd4 | 79 | configType myConfigType; |
mbedalvaro | 30:d8af03f01cd4 | 80 | |
mbedalvaro | 15:56a0bf424e8d | 81 | // I use an array (actually a vector) of POINTERS of polymorphic class soundSpot with virtual methods (this way we can access polymorphic methods - of children - with a pointer) |
mbedalvaro | 15:56a0bf424e8d | 82 | // BUT ATTENTION when clearing the vector: instantiated objects must be DELETED before. |
mbedalvaro | 15:56a0bf424e8d | 83 | vector<soundSpot*> blobArray; |
mbedalvaro | 15:56a0bf424e8d | 84 | int numBlobs;// this is just equal to blobArray.size() |
mbedalvaro | 0:345b3bc7a0ea | 85 | }; |
mbedalvaro | 0:345b3bc7a0ea | 86 | |
mbedalvaro | 0:345b3bc7a0ea | 87 | |
mbedalvaro | 0:345b3bc7a0ea | 88 | #endif |