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