just a test

Dependencies:   mbed

Fork of scoreLight_Advanced by Alvaro Cassinelli

Committer:
mbedalvaro
Date:
Fri Sep 21 10:02:35 2012 +0000
Revision:
30:d8af03f01cd4
Parent:
28:44b7b6e35548
Child:
31:5f039cbddee8
first commit. Not yet functional. Added ghost and pacman game modes, but the behaviour of these "rigid spots" is not implemented yet

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 30:d8af03f01cd4 16 BOUNCING_SPOTS, LORENTZ_SPOTS, FOLLOWING_SPOTS,
mbedalvaro 30:d8af03f01cd4 17 AIR_HOCKEY_GAME, CIRCULAR_PONG_GAME, VERTICAL_PINBALL_GAME, PAC_MAN_GAME};
mbedalvaro 30:d8af03f01cd4 18
mbedalvaro 0:345b3bc7a0ea 19 class blobConfig {
mbedalvaro 15:56a0bf424e8d 20 public:
mbedalvaro 15:56a0bf424e8d 21
mbedalvaro 15:56a0bf424e8d 22 //========== Methods =============
mbedalvaro 15:56a0bf424e8d 23 blobConfig(); // overaloded constructor
mbedalvaro 30:d8af03f01cd4 24 blobConfig(configType cftype, unsigned char numspots=1) { initConfig(cftype, numspots);}; // overaloded constructor with parameters
mbedalvaro 15:56a0bf424e8d 25 ~blobConfig();
mbedalvaro 15:56a0bf424e8d 26
mbedalvaro 30:d8af03f01cd4 27 void initConfig(configType myConfigType, unsigned char numblobs=1);
mbedalvaro 30:d8af03f01cd4 28
mbedalvaro 15:56a0bf424e8d 29 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 30
mbedalvaro 15:56a0bf424e8d 31 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 32 void allAlive();
mbedalvaro 15:56a0bf424e8d 33
mbedalvaro 15:56a0bf424e8d 34 void allStandBy(); //NO update, but rendering may be done (they are "frozen" in their positions)
mbedalvaro 15:56a0bf424e8d 35 void allResume();
mbedalvaro 15:56a0bf424e8d 36
mbedalvaro 15:56a0bf424e8d 37 void allInvisible(); // blobs are invisible, but they may continue to evolve (call to update)
mbedalvaro 15:56a0bf424e8d 38 void allVisible();
mbedalvaro 25:74cb85b85fd2 39
mbedalvaro 25:74cb85b85fd2 40 void allSetColor(unsigned char c);
mbedalvaro 25:74cb85b85fd2 41
mbedalvaro 15:56a0bf424e8d 42 void update(); // update dynamics
mbedalvaro 15:56a0bf424e8d 43 void draw(); // draw in the LaserSensingTrajectory object (lsdTrajectory) of each blob, using the openGL laser rendering (not yet done).
mbedalvaro 15:56a0bf424e8d 44
mbedalvaro 15:56a0bf424e8d 45 void sendConfData(); // send OSC data for all the blobs
mbedalvaro 15:56a0bf424e8d 46
mbedalvaro 15:56a0bf424e8d 47 void computeBoundingBox();
mbedalvaro 15:56a0bf424e8d 48
mbedalvaro 30:d8af03f01cd4 49 // ========= Template spots from which to create multi-spot configurations: =====================
mbedalvaro 30:d8af03f01cd4 50 void addOneElasticLoopRelax(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(0,0));
mbedalvaro 30:d8af03f01cd4 51 void addOneElasticLoopContract(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(0,0));
mbedalvaro 30:d8af03f01cd4 52 void addOneElasticLoopContractCentral(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(0,0));
mbedalvaro 30:d8af03f01cd4 53 void addOneElasticLoopContractCentralFast(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(0,0));
mbedalvaro 30:d8af03f01cd4 54 void addOneElasticContourFollowing(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(0,0));
mbedalvaro 30:d8af03f01cd4 55 void addOneElasticContourFollowingFAST(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(0,0));
mbedalvaro 30:d8af03f01cd4 56 void addOneElasticBouncing(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(1,1));
mbedalvaro 15:56a0bf424e8d 57
mbedalvaro 30:d8af03f01cd4 58 void addOneRigidLoopBouncing(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(2,2));
mbedalvaro 30:d8af03f01cd4 59 void addOneRigidLoopLorentz(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(2,2));
mbedalvaro 30:d8af03f01cd4 60 void addOneRigidLoopAirHockey(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(0,0));
mbedalvaro 30:d8af03f01cd4 61 void addOneRigidLoopFollowing(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(0,0));
mbedalvaro 30:d8af03f01cd4 62 void addOneRigidLoopTest(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(0,0));
mbedalvaro 30:d8af03f01cd4 63 void addOneRigidTrackingSpot(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(0,0));
mbedalvaro 30:d8af03f01cd4 64 void addOneRigidLoopPacman(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(0,0));
mbedalvaro 30:d8af03f01cd4 65 void addOneRigidLoopGhost(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(0,0));
mbedalvaro 15:56a0bf424e8d 66
mbedalvaro 15:56a0bf424e8d 67 //========== Variables =============
mbedalvaro 30:d8af03f01cd4 68 configType myConfigType;
mbedalvaro 30:d8af03f01cd4 69
mbedalvaro 15:56a0bf424e8d 70 // 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 71 // BUT ATTENTION when clearing the vector: instantiated objects must be DELETED before.
mbedalvaro 15:56a0bf424e8d 72 vector<soundSpot*> blobArray;
mbedalvaro 15:56a0bf424e8d 73 int numBlobs;// this is just equal to blobArray.size()
mbedalvaro 0:345b3bc7a0ea 74 };
mbedalvaro 0:345b3bc7a0ea 75
mbedalvaro 0:345b3bc7a0ea 76
mbedalvaro 0:345b3bc7a0ea 77 #endif