just a test

Dependencies:   mbed

Fork of scoreLight_Advanced by Alvaro Cassinelli

Committer:
mbedalvaro
Date:
Mon Mar 31 10:57:35 2014 +0000
Revision:
44:46e25fa1669b
Parent:
33:43e8bc451ef0
Child:
46:90516893793a
This new version works pretty well, even if the following blob is not as nice as in elasticLoop_OSC. New: fraction rendering / first point wait solved (more regular rendering) / better delay calibration.

Who changed what in which revision?

UserRevisionLine numberNew 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 15:56a0bf424e8d 52 void sendConfData(); // send OSC data for all the blobs
mbedalvaro 15:56a0bf424e8d 53
mbedalvaro 15:56a0bf424e8d 54 void computeBoundingBox();
mbedalvaro 15:56a0bf424e8d 55
mbedalvaro 30:d8af03f01cd4 56 // ========= Template spots from which to create multi-spot configurations: =====================
mbedalvaro 30:d8af03f01cd4 57 void addOneElasticLoopRelax(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(0,0));
mbedalvaro 30:d8af03f01cd4 58 void addOneElasticLoopContract(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(0,0));
mbedalvaro 30:d8af03f01cd4 59 void addOneElasticLoopContractCentral(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(0,0));
mbedalvaro 30:d8af03f01cd4 60 void addOneElasticLoopContractCentralFast(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(0,0));
mbedalvaro 30:d8af03f01cd4 61 void addOneElasticContourFollowing(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(0,0));
mbedalvaro 30:d8af03f01cd4 62 void addOneElasticContourFollowingFAST(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(0,0));
mbedalvaro 30:d8af03f01cd4 63 void addOneElasticBouncing(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(1,1));
mbedalvaro 15:56a0bf424e8d 64
mbedalvaro 30:d8af03f01cd4 65 void addOneRigidLoopBouncing(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(2,2));
mbedalvaro 31:5f039cbddee8 66 void addOneRigidLoopBouncingGravity(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(2,2));
mbedalvaro 30:d8af03f01cd4 67 void addOneRigidLoopLorentz(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(2,2));
mbedalvaro 30:d8af03f01cd4 68 void addOneRigidLoopAirHockey(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(0,0));
mbedalvaro 30:d8af03f01cd4 69 void addOneRigidLoopFollowing(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(0,0));
mbedalvaro 30:d8af03f01cd4 70 void addOneRigidLoopTest(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(0,0));
mbedalvaro 30:d8af03f01cd4 71 void addOneRigidTrackingSpot(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(0,0));
mbedalvaro 31:5f039cbddee8 72 void addOneRigidTrackingSpotDot(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(0,0));
mbedalvaro 30:d8af03f01cd4 73 void addOneRigidLoopPacman(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(0,0));
mbedalvaro 30:d8af03f01cd4 74 void addOneRigidLoopGhost(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(0,0));
mbedalvaro 15:56a0bf424e8d 75
mbedalvaro 15:56a0bf424e8d 76 //========== Variables =============
mbedalvaro 30:d8af03f01cd4 77 configType myConfigType;
mbedalvaro 30:d8af03f01cd4 78
mbedalvaro 15:56a0bf424e8d 79 // 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 80 // BUT ATTENTION when clearing the vector: instantiated objects must be DELETED before.
mbedalvaro 15:56a0bf424e8d 81 vector<soundSpot*> blobArray;
mbedalvaro 15:56a0bf424e8d 82 int numBlobs;// this is just equal to blobArray.size()
mbedalvaro 0:345b3bc7a0ea 83 };
mbedalvaro 0:345b3bc7a0ea 84
mbedalvaro 0:345b3bc7a0ea 85
mbedalvaro 0:345b3bc7a0ea 86 #endif