Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Fork of scoreLight_Advanced by
blobConfig.h
00001 #ifndef blobConf_h 00002 #define blobConf_h 00003 00004 // include all kind of spots classes (childs of soundSpot) 00005 #include "elasticLoop.h" 00006 #include "rigidLoop.h" 00007 #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 00008 00009 #include <vector> 00010 //#include <deque>; // using a deque instead of a vector can have advantanges in terms of memory (deque can handle fragmented memory), BUT IS SLOWER. 00011 using namespace std; 00012 00013 // 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 00014 // method cannot be just "update all the blobs": 00015 enum configType {ONE_ELASTIC_FOLLOWING, ONE_ELASTIC_MOUTH, ONE_ELASTIC_MOUTH_SMALL, 00016 ONE_TRACKING_SPOT, ONE_TRACKING_SPOT_DOT, 00017 BOUNCING_SPOTS, LORENTZ_SPOTS, FOLLOWING_SPOTS, 00018 AIR_HOCKEY_GAME, CIRCULAR_PONG_GAME, FISH_NET_GAME, VERTICAL_PINBALL_GAME, PAC_MAN_GAME, 00019 RAIN_MODE}; 00020 00021 class blobConfig { 00022 public: 00023 00024 //========== Methods ============= 00025 blobConfig(); // overaloded constructor 00026 blobConfig(configType cftype, unsigned char numspots=1) { initConfig(cftype, numspots);}; // overaloded constructor with parameters 00027 ~blobConfig(); 00028 00029 void initConfig(configType myConfigType, int numblobs=1); 00030 00031 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()). 00032 00033 void processSensedData(); 00034 00035 void allKill(); // this put all the blobs in "dead" mode, meaning that neither rendering nor update is done (but they are not deleted). 00036 void allAlive(); 00037 00038 void allStandBy(); //NO update, but rendering may be done (they are "frozen" in their positions) 00039 void allResume(); 00040 00041 void allInvisible(); // blobs are invisible, but they may continue to evolve (call to update) 00042 void allVisible(); 00043 00044 void allSetColor(unsigned char c); 00045 void allSetGreen(unsigned char c); 00046 void allSetBlue(unsigned char c); 00047 void randomizeAllColors(); 00048 00049 void update(); // update dynamics 00050 void draw(); // draw in the LaserSensingTrajectory object (lsdTrajectory) of each blob, using the openGL laser rendering (not yet done). 00051 00052 void printParameters(); // on serial port (for calibration) 00053 00054 void sendConfData(); // send OSC data for all the blobs 00055 00056 void computeBoundingBox(); 00057 00058 // ========= Template spots from which to create multi-spot configurations: ===================== 00059 void addOneElasticLoopRelax(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(0,0)); 00060 void addOneElasticLoopContract(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(0,0)); 00061 void addOneElasticLoopContractCentral(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(0,0)); 00062 void addOneElasticLoopContractCentralFast(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(0,0)); 00063 void addOneElasticContourFollowing(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(0,0)); 00064 void addOneElasticContourFollowingFAST(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(0,0)); 00065 void addOneElasticBouncing(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(1,1)); 00066 00067 void addOneRigidLoopBouncing(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(2,2)); 00068 void addOneRigidLoopBouncingGravity(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(2,2)); 00069 void addOneRigidLoopLorentz(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(2,2)); 00070 void addOneRigidLoopAirHockey(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(0,0)); 00071 void addOneRigidLoopFollowing(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(0,0)); 00072 void addOneRigidLoopTest(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(0,0)); 00073 void addOneRigidTrackingSpot(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(0,0)); 00074 void addOneRigidTrackingSpotDot(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(0,0)); 00075 void addOneRigidLoopPacman(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(0,0)); 00076 void addOneRigidLoopGhost(vector2Df initpos=vector2Df(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_Y), vector2Df initspeed=vector2Df(0,0)); 00077 00078 //========== Variables ============= 00079 configType myConfigType; 00080 00081 // 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) 00082 // BUT ATTENTION when clearing the vector: instantiated objects must be DELETED before. 00083 vector<soundSpot*> blobArray; 00084 int numBlobs;// this is just equal to blobArray.size() 00085 }; 00086 00087 00088 #endif
Generated on Tue Jul 12 2022 18:50:26 by
1.7.2
