just a test

Dependencies:   mbed

Fork of scoreLight_Advanced by Alvaro Cassinelli

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?

UserRevisionLine numberNew contents of line
mbedalvaro 31:5f039cbddee8 1 /*
mbedalvaro 31:5f039cbddee8 2 * elasticLoop.h
mbedalvaro 31:5f039cbddee8 3 * laserBlobPure
mbedalvaro 31:5f039cbddee8 4 *
mbedalvaro 31:5f039cbddee8 5 * Created by CASSINELLI ALVARO on 5/20/11.
mbedalvaro 31:5f039cbddee8 6 * Copyright 2011 TOKYO UNIVERSITY. All rights reserved.
mbedalvaro 31:5f039cbddee8 7 *
mbedalvaro 31:5f039cbddee8 8 */
mbedalvaro 31:5f039cbddee8 9
mbedalvaro 31:5f039cbddee8 10 #ifndef ELASTIC_LOOP
mbedalvaro 31:5f039cbddee8 11 #define ELASTIC_LOOP
mbedalvaro 31:5f039cbddee8 12
mbedalvaro 31:5f039cbddee8 13 // Include the basic objects to create the loop
mbedalvaro 31:5f039cbddee8 14 #include "soundSpot.h"
mbedalvaro 31:5f039cbddee8 15 #include "classPointMass.h"
mbedalvaro 31:5f039cbddee8 16 #include "classSpring.h"
mbedalvaro 31:5f039cbddee8 17
mbedalvaro 31:5f039cbddee8 18 #include <vector>
mbedalvaro 31:5f039cbddee8 19 using namespace std;
mbedalvaro 31:5f039cbddee8 20
mbedalvaro 31:5f039cbddee8 21 //#define MAX_NUM_MASSES 50
mbedalvaro 31:5f039cbddee8 22 //#define PI 3.1415926
mbedalvaro 31:5f039cbddee8 23
mbedalvaro 31:5f039cbddee8 24 enum ElasticLoopMode {RELAX, CONTRACT, CONTRACT_CENTRAL, CONTRACT_CENTRAL_FAST, CONTOUR_FOLLOWING, CONTOUR_FOLLOWING_FAST, BOUNCING};
mbedalvaro 31:5f039cbddee8 25
mbedalvaro 31:5f039cbddee8 26 class elasticLoop : public soundSpot {
mbedalvaro 31:5f039cbddee8 27
mbedalvaro 31:5f039cbddee8 28 public:
mbedalvaro 31:5f039cbddee8 29
mbedalvaro 31:5f039cbddee8 30 // Constructor and destructor:
mbedalvaro 31:5f039cbddee8 31 elasticLoop();
mbedalvaro 39:7c54b6bca0e2 32 virtual ~elasticLoop();
mbedalvaro 31:5f039cbddee8 33
mbedalvaro 31:5f039cbddee8 34 // instantiation of the virtual methods of the base class (we don't need to append "virtual", but for clarity I do):
mbedalvaro 31:5f039cbddee8 35 void createBlob(int _id, ElasticLoopMode _elasticBlobMode, vector2Df _initPos, vector2Df _initSpeed);
mbedalvaro 31:5f039cbddee8 36 virtual void setRegionMotion(float mmix, float mmiy, float mmax, float mmay); // attention: initial position posX and posY should be inside this bounding box...
mbedalvaro 31:5f039cbddee8 37 virtual void update(vector2Df referencePos); // update dynamics of the mass loop
mbedalvaro 31:5f039cbddee8 38 virtual void draw(void); // draw the blob (renders on the laser trajectory object lsdTrajectory from the base class, using the openGL laser renderer - not yet done).
mbedalvaro 31:5f039cbddee8 39 virtual void computeBoundingBox();
mbedalvaro 31:5f039cbddee8 40 virtual void sendDataSpecific(void);
mbedalvaro 31:5f039cbddee8 41 // Some behaviour parameters:
mbedalvaro 33:43e8bc451ef0 42 virtual void setSpeed(float speed) {};// do nothing in the case of elastic loop for the time being...
mbedalvaro 33:43e8bc451ef0 43 virtual void setSize(float size) {}; // do nothing in the case of elastic loop for the time being...
mbedalvaro 31:5f039cbddee8 44 virtual void speedFactor(float speedfactor);
mbedalvaro 32:52273c3291fe 45 virtual void sizeFactor(float sizeFactor) {}; // do nothing in the case of elastic loop for the time being...
mbedalvaro 31:5f039cbddee8 46
mbedalvaro 31:5f039cbddee8 47 virtual void explosion() {}; // nothing for the time being
mbedalvaro 31:5f039cbddee8 48 virtual vector2Df getCenter() {}; // nothing for the time being
mbedalvaro 31:5f039cbddee8 49 virtual void resetPositionSpeed() {};// nothing for the time being
mbedalvaro 31:5f039cbddee8 50 virtual void setPositionSpeed(vector2Df _pos, vector2Df _spe) {};// nothing for the time being
mbedalvaro 31:5f039cbddee8 51
mbedalvaro 47:2312a8dc9658 52 virtual void showChildParameters();
mbedalvaro 46:90516893793a 53
mbedalvaro 31:5f039cbddee8 54 // methods that are new to this class (not in base class):
mbedalvaro 31:5f039cbddee8 55 void initSizeBlob(int _numMasses);
mbedalvaro 31:5f039cbddee8 56 void createLoopFromScafold(void);
mbedalvaro 31:5f039cbddee8 57 void processLoopData(); // process elastic loop data
mbedalvaro 31:5f039cbddee8 58
mbedalvaro 31:5f039cbddee8 59 // ====================== VARIABLES ======================
mbedalvaro 31:5f039cbddee8 60
mbedalvaro 31:5f039cbddee8 61 //ElasticLoopMode loopMode;
mbedalvaro 31:5f039cbddee8 62
mbedalvaro 31:5f039cbddee8 63 // The loop of masses with springs:
mbedalvaro 31:5f039cbddee8 64 int numMasses; // Number of particles in the elastic loop (this may or may not be equal to the number of points in the lsdTrajectory)
mbedalvaro 46:90516893793a 65 float integrationStepLoop;
mbedalvaro 31:5f039cbddee8 66 vector<pointMass> massesLoop;
mbedalvaro 31:5f039cbddee8 67 vector<spring> loopSpringArray;
mbedalvaro 31:5f039cbddee8 68 // NOTE: to save memory, we can drop hairVector (use lightForce instead, and then normalize it when required)
mbedalvaro 31:5f039cbddee8 69 vector<vector2Df> hairVector; // the perpendiculars to the loop
mbedalvaro 31:5f039cbddee8 70 vector<vector2Df> lightForce;
mbedalvaro 31:5f039cbddee8 71 //vector2D totalLightForce; // this belongs to the base class now
mbedalvaro 31:5f039cbddee8 72
mbedalvaro 31:5f039cbddee8 73 // For the central anchor point:
mbedalvaro 31:5f039cbddee8 74 pointMass anchorMass;
mbedalvaro 46:90516893793a 75 float integrationStepAnchor;
mbedalvaro 31:5f039cbddee8 76 vector<spring> centralSpringArray;
mbedalvaro 31:5f039cbddee8 77
mbedalvaro 31:5f039cbddee8 78 // Detail modes (could be in a struct)
mbedalvaro 31:5f039cbddee8 79 // Behaviour mode:
mbedalvaro 31:5f039cbddee8 80 bool pseudopodesMode;
mbedalvaro 31:5f039cbddee8 81 bool slidingDirection; // for contour following
mbedalvaro 31:5f039cbddee8 82 bool springForcesOnLoop;
mbedalvaro 31:5f039cbddee8 83 bool lightForcesOnLoop;
mbedalvaro 31:5f039cbddee8 84 bool forceBorderOnLoop;
mbedalvaro 31:5f039cbddee8 85 bool recenteringForceOnLoop;
mbedalvaro 31:5f039cbddee8 86 bool nuclearForceOnLoop;
mbedalvaro 31:5f039cbddee8 87 bool interParticleForceOnLoop;
mbedalvaro 31:5f039cbddee8 88 bool forceInternalPressureOnLoop;
mbedalvaro 31:5f039cbddee8 89 bool recenteringForceOnNucleus;
mbedalvaro 31:5f039cbddee8 90
mbedalvaro 31:5f039cbddee8 91 // Recentering vector (obtained by rotating the total light force by an arbitrary angle) for the anchor mass, and for each point in the loop
mbedalvaro 31:5f039cbddee8 92 // ex: if it is 180deg, then the blob just "bounces" on the zone transition; if it is 90, it does contour following...
mbedalvaro 31:5f039cbddee8 93
mbedalvaro 31:5f039cbddee8 94 // The following are common to all blobs:
mbedalvaro 31:5f039cbddee8 95 // float angleCorrectionForceLoop;
mbedalvaro 31:5f039cbddee8 96 // vector2D recenteringVectorLoop;
mbedalvaro 31:5f039cbddee8 97 // float angleRecenteringVector; // auxiliary variables for sending data (for the recenteringVectorLoop)
mbedalvaro 31:5f039cbddee8 98 // float normRecenteringVector;
mbedalvaro 31:5f039cbddee8 99
mbedalvaro 31:5f039cbddee8 100 float angleCorrectionForceNucleus;
mbedalvaro 31:5f039cbddee8 101 vector2Df recenteringVectorNucleus;
mbedalvaro 31:5f039cbddee8 102
mbedalvaro 31:5f039cbddee8 103 // Numeric parameters:
mbedalvaro 31:5f039cbddee8 104 float massLoopParticle;
mbedalvaro 31:5f039cbddee8 105 float dampMotionMassesLoop;
mbedalvaro 31:5f039cbddee8 106 float massAnchor;
mbedalvaro 31:5f039cbddee8 107 float dampMotionAnchorMass;
mbedalvaro 31:5f039cbddee8 108
mbedalvaro 31:5f039cbddee8 109 // initial size, position and center-mass speed of the elastic loop:
mbedalvaro 31:5f039cbddee8 110 float startRadius;
mbedalvaro 31:5f039cbddee8 111 //vector2D startCenter; // this belongs to the base class
mbedalvaro 31:5f039cbddee8 112 // vector2D startSpeed; // this belongs to base class
mbedalvaro 31:5f039cbddee8 113
mbedalvaro 31:5f039cbddee8 114 float interSpringK, interSpringRelax;
mbedalvaro 31:5f039cbddee8 115 float centralSpringK, centralSpringRelax;
mbedalvaro 31:5f039cbddee8 116 float factorLightForce;
mbedalvaro 31:5f039cbddee8 117 float factorRecenteringAnchorMass;
mbedalvaro 31:5f039cbddee8 118 float factorRecenteringLoopMass;
mbedalvaro 31:5f039cbddee8 119 float factorPressureLoopMass;
mbedalvaro 31:5f039cbddee8 120 float factorForceBorder;
mbedalvaro 31:5f039cbddee8 121 float interParticleRange, factorInterParticleForce; // zach like blob force
mbedalvaro 31:5f039cbddee8 122
mbedalvaro 31:5f039cbddee8 123 // SOUND SENDING MODES (specific to this kind of blob object):
mbedalvaro 31:5f039cbddee8 124 /*
mbedalvaro 31:5f039cbddee8 125 // (a) anchor mass data:
mbedalvaro 31:5f039cbddee8 126 bool sendingAnchorPosition;
mbedalvaro 31:5f039cbddee8 127 bool sendingAnchorForce; // this is the total force on the anchor mass, not just the recentering force
mbedalvaro 31:5f039cbddee8 128 bool sendingAnchorTouchWall;
mbedalvaro 31:5f039cbddee8 129 // (b) data from blob points:
mbedalvaro 31:5f039cbddee8 130 bool sendingLoopPositions;
mbedalvaro 31:5f039cbddee8 131 bool sendingLoopForces;// this is not just the forces from light, but all the forces in each particle
mbedalvaro 31:5f039cbddee8 132 bool sendingLoopForcesLight;
mbedalvaro 31:5f039cbddee8 133 bool sendingLoopRegions; // from this we can detect "hits"
mbedalvaro 31:5f039cbddee8 134 bool sendingLoopTouchWall;
mbedalvaro 31:5f039cbddee8 135 // (c) Blob geometry:
mbedalvaro 31:5f039cbddee8 136 bool sendingBlobArea;
mbedalvaro 31:5f039cbddee8 137 bool sendingBlobNormals;
mbedalvaro 31:5f039cbddee8 138 bool sendingBlobAngles; // redundant with sendingBlobNormals, but simplified (only angle of normal)
mbedalvaro 31:5f039cbddee8 139 */
mbedalvaro 31:5f039cbddee8 140
mbedalvaro 31:5f039cbddee8 141 };
mbedalvaro 31:5f039cbddee8 142
mbedalvaro 31:5f039cbddee8 143 #endif