![](/media/cache/profiles/68a15b5278e4f7c4c056df9d5f1d3b1f.jpg.50x50_q85.jpg)
save loops
blobConfig.h@0:df6fdd9b99f0, 2014-12-02 (annotated)
- Committer:
- mbedalvaro
- Date:
- Tue Dec 02 04:39:15 2014 +0000
- Revision:
- 0:df6fdd9b99f0
this new version of skinGames will have a function that stops scanning as the laser reaches the same position (i.e., loops) with a certain precision. It is for extracting contours for Takashita project. It can then save on a file or send on osc
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
mbedalvaro | 0:df6fdd9b99f0 | 1 | #ifndef blobConf_h |
mbedalvaro | 0:df6fdd9b99f0 | 2 | #define blobConf_h |
mbedalvaro | 0:df6fdd9b99f0 | 3 | |
mbedalvaro | 0:df6fdd9b99f0 | 4 | // include all kind of spots classes (childs of soundSpot) |
mbedalvaro | 0:df6fdd9b99f0 | 5 | #include "elasticLoop.h" |
mbedalvaro | 0:df6fdd9b99f0 | 6 | #include "rigidLoop.h" |
mbedalvaro | 0:df6fdd9b99f0 | 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:df6fdd9b99f0 | 8 | |
mbedalvaro | 0:df6fdd9b99f0 | 9 | #include <vector> |
mbedalvaro | 0:df6fdd9b99f0 | 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 | 0:df6fdd9b99f0 | 11 | using namespace std; |
mbedalvaro | 0:df6fdd9b99f0 | 12 | |
mbedalvaro | 0:df6fdd9b99f0 | 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 | 0:df6fdd9b99f0 | 14 | // method cannot be just "update all the blobs": |
mbedalvaro | 0:df6fdd9b99f0 | 15 | enum configType {ONE_ELASTIC_FOLLOWING, ONE_ELASTIC_MOUTH, ONE_ELASTIC_MOUTH_SMALL, |
mbedalvaro | 0:df6fdd9b99f0 | 16 | ONE_TRACKING_SPOT, ONE_TRACKING_SPOT_DOT, |
mbedalvaro | 0:df6fdd9b99f0 | 17 | BOUNCING_SPOTS, LORENTZ_SPOTS, FOLLOWING_SPOTS, |
mbedalvaro | 0:df6fdd9b99f0 | 18 | AIR_HOCKEY_GAME, CIRCULAR_PONG_GAME, FISH_NET_GAME, VERTICAL_PINBALL_GAME, PAC_MAN_GAME, |
mbedalvaro | 0:df6fdd9b99f0 | 19 | RAIN_MODE}; |
mbedalvaro | 0:df6fdd9b99f0 | 20 | |
mbedalvaro | 0:df6fdd9b99f0 | 21 | class blobConfig { |
mbedalvaro | 0:df6fdd9b99f0 | 22 | public: |
mbedalvaro | 0:df6fdd9b99f0 | 23 | |
mbedalvaro | 0:df6fdd9b99f0 | 24 | //========== Methods ============= |
mbedalvaro | 0:df6fdd9b99f0 | 25 | blobConfig(); // overaloded constructor |
mbedalvaro | 0:df6fdd9b99f0 | 26 | blobConfig(configType cftype, unsigned char numspots=1) { initConfig(cftype, numspots);}; // overaloded constructor with parameters |
mbedalvaro | 0:df6fdd9b99f0 | 27 | ~blobConfig(); |
mbedalvaro | 0:df6fdd9b99f0 | 28 | |
mbedalvaro | 0:df6fdd9b99f0 | 29 | void initConfig(configType myConfigType, int numblobs=1); |
mbedalvaro | 0:df6fdd9b99f0 | 30 | |
mbedalvaro | 0:df6fdd9b99f0 | 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 | 0:df6fdd9b99f0 | 32 | |
mbedalvaro | 0:df6fdd9b99f0 | 33 | void processSensedData(); |
mbedalvaro | 0:df6fdd9b99f0 | 34 | |
mbedalvaro | 0:df6fdd9b99f0 | 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 | 0:df6fdd9b99f0 | 36 | void allAlive(); |
mbedalvaro | 0:df6fdd9b99f0 | 37 | |
mbedalvaro | 0:df6fdd9b99f0 | 38 | void allStandBy(); //NO update, but rendering may be done (they are "frozen" in their positions) |
mbedalvaro | 0:df6fdd9b99f0 | 39 | void allResume(); |
mbedalvaro | 0:df6fdd9b99f0 | 40 | |
mbedalvaro | 0:df6fdd9b99f0 | 41 | void allInvisible(); // blobs are invisible, but they may continue to evolve (call to update) |
mbedalvaro | 0:df6fdd9b99f0 | 42 | void allVisible(); |
mbedalvaro | 0:df6fdd9b99f0 | 43 | |
mbedalvaro | 0:df6fdd9b99f0 | 44 | void allSetColor(unsigned char c); |
mbedalvaro | 0:df6fdd9b99f0 | 45 | void allSetGreen(unsigned char c); |
mbedalvaro | 0:df6fdd9b99f0 | 46 | void allSetBlue(unsigned char c); |
mbedalvaro | 0:df6fdd9b99f0 | 47 | void randomizeAllColors(); |
mbedalvaro | 0:df6fdd9b99f0 | 48 | |
mbedalvaro | 0:df6fdd9b99f0 | 49 | void update(); // update dynamics |
mbedalvaro | 0:df6fdd9b99f0 | 50 | void draw(); // draw in the LaserSensingTrajectory object (lsdTrajectory) of each blob, using the openGL laser rendering (not yet done). |
mbedalvaro | 0:df6fdd9b99f0 | 51 | |
mbedalvaro | 0:df6fdd9b99f0 | 52 | void printParameters(); // on serial port (for calibration) |
mbedalvaro | 0:df6fdd9b99f0 | 53 | |
mbedalvaro | 0:df6fdd9b99f0 | 54 | void sendConfData(); // send OSC data for all the blobs |
mbedalvaro | 0:df6fdd9b99f0 | 55 | |
mbedalvaro | 0:df6fdd9b99f0 | 56 | void computeBoundingBox(); |
mbedalvaro | 0:df6fdd9b99f0 | 57 | |
mbedalvaro | 0:df6fdd9b99f0 | 58 | // ========= Template spots from which to create multi-spot configurations: ===================== |
mbedalvaro | 0:df6fdd9b99f0 | 59 | void addOneElasticLoopRelax(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(0,0)); |
mbedalvaro | 0:df6fdd9b99f0 | 60 | void addOneElasticLoopContract(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(0,0)); |
mbedalvaro | 0:df6fdd9b99f0 | 61 | void addOneElasticLoopContractCentral(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(0,0)); |
mbedalvaro | 0:df6fdd9b99f0 | 62 | void addOneElasticLoopContractCentralFast(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(0,0)); |
mbedalvaro | 0:df6fdd9b99f0 | 63 | void addOneElasticContourFollowing(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(0,0)); |
mbedalvaro | 0:df6fdd9b99f0 | 64 | void addOneElasticContourFollowingFAST(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(0,0)); |
mbedalvaro | 0:df6fdd9b99f0 | 65 | void addOneElasticBouncing(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(1,1)); |
mbedalvaro | 0:df6fdd9b99f0 | 66 | |
mbedalvaro | 0:df6fdd9b99f0 | 67 | void addOneRigidLoopBouncing(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(2,2)); |
mbedalvaro | 0:df6fdd9b99f0 | 68 | void addOneRigidLoopBouncingGravity(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(2,2)); |
mbedalvaro | 0:df6fdd9b99f0 | 69 | void addOneRigidLoopLorentz(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(2,2)); |
mbedalvaro | 0:df6fdd9b99f0 | 70 | void addOneRigidLoopAirHockey(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(0,0)); |
mbedalvaro | 0:df6fdd9b99f0 | 71 | void addOneRigidLoopFollowing(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(0,0)); |
mbedalvaro | 0:df6fdd9b99f0 | 72 | void addOneRigidLoopTest(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(0,0)); |
mbedalvaro | 0:df6fdd9b99f0 | 73 | void addOneRigidTrackingSpot(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(0,0)); |
mbedalvaro | 0:df6fdd9b99f0 | 74 | void addOneRigidTrackingSpotDot(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(0,0)); |
mbedalvaro | 0:df6fdd9b99f0 | 75 | void addOneRigidLoopPacman(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(0,0)); |
mbedalvaro | 0:df6fdd9b99f0 | 76 | void addOneRigidLoopGhost(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(0,0)); |
mbedalvaro | 0:df6fdd9b99f0 | 77 | |
mbedalvaro | 0:df6fdd9b99f0 | 78 | //========== Variables ============= |
mbedalvaro | 0:df6fdd9b99f0 | 79 | configType myConfigType; |
mbedalvaro | 0:df6fdd9b99f0 | 80 | |
mbedalvaro | 0:df6fdd9b99f0 | 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 | 0:df6fdd9b99f0 | 82 | // BUT ATTENTION when clearing the vector: instantiated objects must be DELETED before. |
mbedalvaro | 0:df6fdd9b99f0 | 83 | vector<soundSpot*> blobArray; |
mbedalvaro | 0:df6fdd9b99f0 | 84 | int numBlobs;// this is just equal to blobArray.size() |
mbedalvaro | 0:df6fdd9b99f0 | 85 | }; |
mbedalvaro | 0:df6fdd9b99f0 | 86 | |
mbedalvaro | 0:df6fdd9b99f0 | 87 | |
mbedalvaro | 0:df6fdd9b99f0 | 88 | #endif |