From 90ff1a1335be379fb421d89ed9a72c76c0e14779 Mon Sep 17 00:00:00 2001 From: "Philipp C. Adrian" Date: Tue, 27 Dec 2011 03:29:05 +0100 Subject: [PATCH] pcaRan adoption to new library behavior. --- pcaRan/ElementBlob.pde | 4 +--- pcaRan/ElementChaos.pde | 17 ++++------------- pcaRan/ElementLorenz.pde | 8 ++------ pcaRan/MyCollisionElement.pde | 1 + 4 files changed, 8 insertions(+), 22 deletions(-) diff --git a/pcaRan/ElementBlob.pde b/pcaRan/ElementBlob.pde index a3a0e8f..bb6d7c6 100644 --- a/pcaRan/ElementBlob.pde +++ b/pcaRan/ElementBlob.pde @@ -1,5 +1,5 @@ class ElementBlob extends MyCollisionElement { - float defaultRadius=180; + float defaultRadius=155; int startFrame; @@ -29,8 +29,6 @@ class ElementBlob extends MyCollisionElement { lorenzElement= new ElementLorenz(that, location,this); } /////////////////////////////////////////////////////////// - void frameCollision() {} -/////////////////////////////////////////////////////////// void move(PVector newLocation) { moved=PVector.dist(newLocation, location); diff --git a/pcaRan/ElementChaos.pde b/pcaRan/ElementChaos.pde index aa2152a..4c783a7 100644 --- a/pcaRan/ElementChaos.pde +++ b/pcaRan/ElementChaos.pde @@ -1,7 +1,7 @@ class ElementChaos extends MyCollisionElement { - float defaultRadius=50; + float defaultRadius=25; PVector ranPoint; @@ -30,7 +30,6 @@ class ElementChaos extends MyCollisionElement { void collide (ElementChaos element, CollisionMap collisionMap, boolean mainCollision) { PVector newVelocity; float distance=PVector.dist(location, element.location); - if(distance > actionRadius) return; if(lorenz!=null && !lorenz.allSet) { int index = lorenz.elements.indexOf(this); PVector pointLocation = new PVector(lorenz.points[index][0],lorenz.points[index][1],lorenz.points[index][2]); @@ -39,7 +38,7 @@ class ElementChaos extends MyCollisionElement { pointLocation.add(lorenz.location); if(PVector.dist(location, pointLocation)<=random(5, 15)) return; } - if(distance < actionRadius*0.9) { + if(distance < (actionRadius+element.actionRadius)*0.9) { newVelocity= PVector.sub(location,element.location); if(mainCollision) { @@ -52,7 +51,7 @@ class ElementChaos extends MyCollisionElement { newVelocity= PVector.sub(element.location,location); } newVelocity.normalize(); - newVelocity.mult(map(distance, 0,actionRadius,pushForce,0)); + newVelocity.mult(map(distance, 0,(actionRadius+element.actionRadius),pushForce,0)); velocity.add(newVelocity); @@ -60,9 +59,7 @@ class ElementChaos extends MyCollisionElement { } /////////////////////////////////////////////////////////// void collide(ElementBlob element, CollisionMap collisionMap, boolean mainCollision) { - float distance=PVector.dist(new PVector(location.x,location.y),new PVector(element.location.x, element.location.y)); - - if(element.moved <=0 || distance>element.actionRadius || that.globalFriction < 0.8) return; + if(element.moved <=0 || that.globalFriction < 0.8) return; int pressedFrames = frameCount-element.startFrame; @@ -83,10 +80,6 @@ class ElementChaos extends MyCollisionElement { return; } - float distance=PVector.dist(new PVector(location.x,location.y),new PVector(element.location.x, element.location.y)); - - if(distance>element.actionRadius) return; - PVector newVelocity= PVector.sub(location,element.location); newVelocity.normalize(); newVelocity.mult(10); @@ -186,8 +179,6 @@ class ElementChaos extends MyCollisionElement { friction=1; disturbance--; } -/////////////////////////////////////////////////////////// - void frameCollision() {} /////////////////////////////////////////////////////////// } diff --git a/pcaRan/ElementLorenz.pde b/pcaRan/ElementLorenz.pde index 292dd4e..02f8f13 100644 --- a/pcaRan/ElementLorenz.pde +++ b/pcaRan/ElementLorenz.pde @@ -1,7 +1,7 @@ class ElementLorenz extends MyCollisionElement { ElementBlob blob; - float defaultRadius=180; + float defaultRadius=155; int variableSets=17; float pushForce=5; @@ -47,16 +47,12 @@ class ElementLorenz extends MyCollisionElement { getVariableSet(); generatePoints(); } -/////////////////////////////////////////////////////////// - void frameCollision() {} /////////////////////////////////////////////////////////// void collide(ElementChaos element, CollisionMap collisionMap, boolean mainCollision) { - float distance=PVector.dist(new PVector(location.x,location.y),new PVector(element.location.x, element.location.y)); - if(!allSet) { PVector thisQuadrant= collisionMap.getQuadrant(element.location); - if(distance<=actionRadius && elements.size() < iterations && !thisQuadrant.equals(quadrant)) elements.add(element); + if(elements.size() < iterations && !thisQuadrant.equals(quadrant)) elements.add(element); quadrant=thisQuadrant; return; diff --git a/pcaRan/MyCollisionElement.pde b/pcaRan/MyCollisionElement.pde index 17ad57f..6fc3ac4 100644 --- a/pcaRan/MyCollisionElement.pde +++ b/pcaRan/MyCollisionElement.pde @@ -5,6 +5,7 @@ class MyCollisionElement extends CollisionElement{ void collide(ElementBlob element, CollisionMap collisionMap, boolean mainCollision){}; ///////////////////////////////////////////////////////// void frameCollision(CollisionMap collisionMap) {}; +///////////////////////////////////////////////////////// void collision(CollisionElement element, CollisionMap collisionMap, boolean mainCollision) { String type=element.getClass().getName();