Alvaro Cassinelli
/
skinGames_forktest
just a test
Fork of scoreLight_Advanced by
Diff: elasticLoop.cpp
- Revision:
- 18:d72935b13858
- Parent:
- 17:356ca5690a59
- Child:
- 19:228430f1350e
--- a/elasticLoop.cpp Sat Apr 28 09:33:49 2012 +0000 +++ b/elasticLoop.cpp Sat Apr 28 12:35:21 2012 +0000 @@ -38,6 +38,10 @@ // (3) initialize common variables for the elastic blob types: slidingDirection=true; // (will change when touching wall) + // Sending data: + sendingLoopPositions=true; + sendingBlobArea=true; + sendingOnlyWhenTouch=false; // send ALWAYS, regardless of the fact the blob is being touched or not. // (3) Initialize secondary variables depending on the blob type and mode: @@ -152,9 +156,59 @@ displaySensingBuffer.setDelayMirrors(2); // per-blob mirror delay (if things were well adjusted - in particular mirror waiting times, then this could be 0. break; - case CONTRACT_CENTRAL: + case CONTRACT_CENTRAL: + + sprintf(spotName,"contract_central"); + + //setColor(0x07);//0x04+0x02>>i); + setColor(0x04); + + // default (initial) shape: + startRadius=400; + bluePrint.buildCircularScafold(startRadius, vector2Dd(0,0), 50); //(float _radius, vector2Dd _pos,vector2D _vel, int _numScafoldPoints); + + // Numeric parameters for the simulated mechanical system: + massLoopParticle=0.3; + dampMotionMassesLoop=0.023;//0.17; + massAnchor=0.5; + dampMotionAnchorMass=0.001; + // Springs: + centralSpringK=0.3; + centralSpringRelax=startRadius; + interSpringK=0.54;//46; + interSpringRelax=30; + // for "zack-like" blob: + interParticleRange=100; + factorInterParticleForce=18.0; - // CUTE MOTION: make another mode? + searchActive=false; + pseudopodesMode=false; // this is for contour following. + + // Active/Inactive Forces: + springForcesOnLoop= true; + lightForcesOnLoop= true; + forceBorderOnLoop=false; + nuclearForceOnLoop=false;//true; + interParticleForceOnLoop=false; + forceInternalPressureOnLoop=false; // (when true, either constant force or calculated area using Green function or approximation by bounding box) + // Recentering vector: + angleCorrectionForceLoop=0;// in deg + recenteringForceOnLoop=false ; //true; !!!!!!!!!!!!!!! + angleCorrectionForceNucleus=0;// in deg + recenteringForceOnNucleus=false;//true; + + factorLightForce=5.3;//4.3; + factorRecenteringAnchorMass= 20.0/bluePrint.scafold.size(); + factorRecenteringLoopMass=0.045; + factorPressureLoopMass=1.5; + factorForceBorder=150; + + // per-blob mirror delay (if things were well adjusted - in particular mirror waiting times, then this could be 0. + //But in case of unique blobs, it may be interesting to accelerate display AND correct the delay by software): + displaySensingBuffer.setDelayMirrors(4); + +/* + // CUTE MOTION: make another mode? //setColor(0x07);//0x04+0x02>>i); setColor(0x04); @@ -197,58 +251,7 @@ factorRecenteringLoopMass=0.045; factorPressureLoopMass=1.5; factorForceBorder=150; - - -/* - sprintf(spotName,"contract_central"); - - //setColor(0x07);//0x04+0x02>>i); - setColor(0x04); - - // default (initial) shape: - startRadius=400; - bluePrint.buildCircularScafold(startRadius, vector2Dd(0,0), 50); //(float _radius, vector2Dd _pos,vector2D _vel, int _numScafoldPoints); - - // Numeric parameters for the simulated mechanical system: - massLoopParticle=0.3; - dampMotionMassesLoop=0.023;//0.17; - massAnchor=0.5; - dampMotionAnchorMass=0.001; - // Springs: - centralSpringK=0.3; - centralSpringRelax=startRadius; - interSpringK=0.54;//46; - interSpringRelax=30; - // for "zack-like" blob: - interParticleRange=100; - factorInterParticleForce=18.0; - - searchActive=false; - pseudopodesMode=false; // this is for contour following. - - // Active/Inactive Forces: - springForcesOnLoop= true; - lightForcesOnLoop= true; - forceBorderOnLoop=false; - nuclearForceOnLoop=false;//true; - interParticleForceOnLoop=false; - forceInternalPressureOnLoop=false; // (when true, either constant force or calculated area using Green function or approximation by bounding box) - // Recentering vector: - angleCorrectionForceLoop=0;// in deg - recenteringForceOnLoop=false ; //true; !!!!!!!!!!!!!!! - angleCorrectionForceNucleus=0;// in deg - recenteringForceOnNucleus=false;//true; - - factorLightForce=4.3;//3.0;//8.0; - factorRecenteringAnchorMass= 20.0/bluePrint.scafold.size(); - factorRecenteringLoopMass=0.045; - factorPressureLoopMass=1.5; - factorForceBorder=150; - - // per-blob mirror delay (if things were well adjusted - in particular mirror waiting times, then this could be 0. - //But in case of unique blobs, it may be interesting to accelerate display AND correct the delay by software): - displaySensingBuffer.setDelayMirrors(4); -*/ + */ break; case CONTOUR_FOLLOWING: @@ -701,7 +704,6 @@ // (2) Compute area: // (a) using Green method: - /* area=0; float dx; for (int i = 0; i < numMasses-1; i++){ @@ -710,7 +712,6 @@ } // to avoid computation problems: // if (area<=0) area=1; // or just norm: area CAN be negative! (a loop that is larger than the original blob...) - */ // (b) Compute approximate area from enclosing rectangle: computeBoundingBox(); @@ -749,15 +750,16 @@ myled2=1; // for tests... // First, set the top address of the message to the ID of the blob (not the name): - sprintf(auxstring, "%d", identifier); - sendMes.setTopAddress("0");//auxstring); + // sprintf(auxstring, "%d", identifier); + // sendMes.setTopAddress("0");//auxstring); // ===================== OSC ====================== if (sendOSC) { // (a) Anchor mass: - if (sendingAnchorPosition) { - sendMes.setSubAddress("/apos"); + if (sendingAnchorPosition) { + sprintf(auxstring, "/p %d",identifier); + sendMes.setSubAddress(auxstring); long x, y; //ATTENTION: parameters to setArgs should be long or unsigned long only (not int!!) x=(long)(anchorMass.pos.x); y=(long)(anchorMass.pos.y); @@ -783,7 +785,7 @@ #ifdef SEND_AS_POINTS long x, y; //ATTENTION: parameters to setArgs should be long or unsigned long only (not int!!) for (int i = 0; i < numMasses; i++) { - sprintf(auxstring, "/p%d", i); // auxstring read as "/p1", "/p2", ... + sprintf(auxstring, "/p %d", i); // auxstring read as "/p1", "/p2", ... sendMes.setSubAddress(auxstring); // ATTENTION: the host computer needs to know in advance how many points are in the loop (I did not implement "bundle" messages yet...) x=(long)(massesLoop[i].pos.x); y=(long)(massesLoop[i].pos.y); @@ -865,10 +867,11 @@ } // (c) Blob geometry: if (sendingBlobArea) { - sendMes.setSubAddress("/area"); + sendMes.setSubAddress("/a"); long x; //ATTENTION: parameters to setArgs should be long or unsigned long only (not int!!) - x=(long)(area);//approxArea); // area or approxArea - sendMes.setArgs( "i", &x); + // x=(long)(area);//approxArea); // area or approxArea + x=(long)(area>0? approxArea : -approxArea); + sendMes.setArgs( "i", &x); // ATTENTION: AREA CAN BE NEGATIVE!!! (does MAX handles this well? test this!) osc.sendOsc( &sendMes ); } if (sendingBlobNormals) {