Alvaro Cassinelli
/
skinGames_forktest
just a test
Fork of scoreLight_Advanced by
Diff: rigidLoop.cpp
- Revision:
- 24:4e52031a495b
- Parent:
- 22:d87317d7ca91
- Child:
- 25:74cb85b85fd2
--- a/rigidLoop.cpp Wed Jun 13 10:09:41 2012 +0000 +++ b/rigidLoop.cpp Mon Jun 18 08:00:57 2012 +0000 @@ -75,7 +75,7 @@ setColor(0x04); // default (initial) shape (the scafold belongs to the base class): - saccadeRadius=25; + saccadeRadius=40; bluePrint.buildCircularScafold(saccadeRadius, vector2Dd(0,0), 18); //(float _radius, vector2D _pos,vector2D _vel, int _numScafoldPoints); // Note: We may assume NO MASS for the center of the contour following loop. Adding mass may be interesting though (smooth motion). @@ -107,12 +107,12 @@ //setColor(0x07);//0x04+0x02>>i); setColor(0x04); - saccadeRadius=40+rand()%20; + saccadeRadius=65;//+rand()%20; // default (initial) shape (the scafold belongs to the base class): bluePrint.buildCircularScafold(saccadeRadius, vector2Dd(0,0), 18); //(float _radius, vector2D _pos,vector2D _vel, int _numScafoldPoints); // Numeric parameters for the simulated mechanical system: - massCenter=0.0008+0.000005*(rand()%100); + massCenter=0.0008;//+0.000005*(rand()%100); dampMotionCenterMass=0.00045;//0.00015;//00003; factorBouncingForce=0.0018; // this is because we will use a force on the central mass @@ -164,6 +164,17 @@ pointMass::setWallLimits(mmix+10, mmiy+10, mmax-10, mmay-10); } +void rigidLoop::speedFactor(float speedfactor) { + // in case of spot following: + speedContourFollowing*=speedfactor; + + // in case of bouncing, there are many ways to change the speed (play with the mass, damping or the bouncing force). + //centerMass.mass/=speedfactor;//0.0008;//+0.000005*(rand()%100); + centerMass.dampMotion/=speedfactor;//0.00045;//0.00015;//00003; + //factorBouncingForce=0.0018; // this is because we will use a force on the central mass + + +} void rigidLoop::update() { @@ -286,10 +297,16 @@ // Gravity? - side or central attraction? // centerMass.addForce(gravity*centerMass.mass); + // or central spring attraction; + //vector2Df centerAttraction(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_X); + //vector2Df dist=centerMass.pos-centerAttraction; + //centerMass.addForce(-dist*centerMass.mass*0.0007); + + // or "radial gravity": vector2Df centerAttraction(CENTER_AD_MIRROR_X, CENTER_AD_MIRROR_X); vector2Df dist=centerMass.pos-centerAttraction; - centerMass.addForce(-dist*centerMass.mass*0.0007); + centerMass.addForce(dist.normalize()*centerMass.mass*0.5); // update dynamics for the central mass::