From 6aba83b7c548aad5ced66e9a148179308daebe77 Mon Sep 17 00:00:00 2001 From: Dennis Schoepf Date: Thu, 24 Sep 2020 16:35:03 +0200 Subject: [PATCH] Finishing touches, moving caterpillar indicator, testing arduino sensor actuation --- magic_veneer_processing/data/branch.svg | 12 +- magic_veneer_processing/data/leftwing.svg | 11 +- magic_veneer_processing/data/rightwing.svg | 12 +- .../magic_veneer_processing.pde | 43 ++-- .../out/magic_veneer_processing.class | Bin 3378 -> 7061 bytes .../out/source/magic_veneer_processing.java | 222 ++++++++++++++++-- 6 files changed, 241 insertions(+), 59 deletions(-) diff --git a/magic_veneer_processing/data/branch.svg b/magic_veneer_processing/data/branch.svg index 49b7cc9..9b44e0c 100644 --- a/magic_veneer_processing/data/branch.svg +++ b/magic_veneer_processing/data/branch.svg @@ -44,7 +44,7 @@ image/svg+xml - + @@ -60,28 +60,28 @@ id="g823" transform="translate(-0.31738257,101.25041)"> diff --git a/magic_veneer_processing/data/leftwing.svg b/magic_veneer_processing/data/leftwing.svg index 045bb07..414ec9e 100644 --- a/magic_veneer_processing/data/leftwing.svg +++ b/magic_veneer_processing/data/leftwing.svg @@ -26,7 +26,7 @@ inkscape:pageopacity="0.0" inkscape:pageshadow="2" inkscape:zoom="0.9899495" - inkscape:cx="327.56796" + inkscape:cx="129.57806" inkscape:cy="381.06641" inkscape:document-units="mm" inkscape:current-layer="g1048" @@ -57,9 +57,10 @@ id="g1048" transform="matrix(0.99928225,0,0,0.9973688,-33.107011,47.163965)"> + id="g841" + style="fill:#ffffff;fill-opacity:1;stroke:none"> + style="fill:#ff0000;fill-opacity:1;stroke:none;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" /> + style="fill:#00c800;fill-opacity:1;stroke:none;stroke-width:0.24669409px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" /> + style="fill:#ffffff;fill-opacity:1;stroke:none;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" /> + style="fill:#ff0000;fill-opacity:1;stroke:none;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" /> + style="fill:#00c800;fill-opacity:1;stroke:none;stroke-width:0.24669409px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1" /> = 500 && wingsSpread == false) { - wingWidth = 500; + } else if (wingWidth >= 620 && wingsSpread == false) { + wingWidth = 620; wingsSpread = true; - } else if (wingsSpread == true && wingWidth < 450) { + } else if (wingsSpread == true && wingWidth < 540) { wingDirection = "bigger"; - } else if (wingsSpread == true && wingWidth >= 500) { + } else if (wingsSpread == true && wingWidth >= 620) { wingDirection = "smaller"; } if (wingDirection == "smaller") { - wingWidth -= 3; + wingWidth -= 4; } else if (wingDirection == "bigger") { - wingWidth += 3; + wingWidth += 4; } - shape(leftWing, width / 2 - wingWidth - 20, (height / 2 - wingWidth * 0.8) - backgroundOffset, wingWidth, wingWidth * 1.5); - shape(rightWing, width / 2 + 20, (height / 2 - wingWidth * 0.8) - backgroundOffset, wingWidth, wingWidth * 1.5); + shape(leftWing, width / 2 - wingWidth + 85, (height / 2 - wingWidth * 0.8) - backgroundOffset, wingWidth, wingWidth * 1.5); + shape(rightWing, width / 2 + 215, (height / 2 - wingWidth * 0.8) - backgroundOffset, wingWidth, wingWidth * 1.5); /* END - Scene 4 Butterfly */ } else if (backgroundOffset > 13000) { - background(0); + background(255); } } + void bug(float x, float y, float scale) { PShape leftUpperLeg = bugLeg(scale, false); PShape leftMiddleLeg = bugLeg(scale, false); @@ -230,8 +231,8 @@ void polygon(float x, float y, float radius, int npoints) { float sy = y + sin(a) * radius; vertex(sx, sy); } - fill(0); - stroke(0); + fill(255); + stroke(255); endShape(CLOSE); } @@ -256,8 +257,8 @@ void head(float x, float y, float polygonRadius, int npoints) { PShape antenna(float scale) { PShape antenna = createShape(RECT, 0, 0, 5 * scale, 25 * scale); - antenna.setFill(color(0)); - antenna.setStroke(color(0)); + antenna.setFill(color(255)); + antenna.setStroke(color(255)); antenna.endShape(); return antenna; @@ -266,8 +267,8 @@ PShape antenna(float scale) { PShape bugLeg(float scale, boolean mirrored) { PShape bugLeg = createShape(); bugLeg.beginShape(); - bugLeg.fill(0); - bugLeg.stroke(0); + bugLeg.fill(255); + bugLeg.stroke(255); if (mirrored == true) { bugLeg.vertex(0, 20); diff --git a/magic_veneer_processing/out/magic_veneer_processing.class b/magic_veneer_processing/out/magic_veneer_processing.class index d86d987a7250579fdfa9f59c8556acde6a9b687c..cd292e3058a2de3a4eaadb878386a0dfe125490f 100644 GIT binary patch literal 7061 zcmX^0Z`VEs1_oosKz0TuMh5ZR#PrPM__EZz)YPK*f};H7)Z*gIymWR37Dfhf1YbWn zzbI8dz_FkpC$)r;fjhA%r8F}yKOn!TgponY2T5UZYEfolj(#whvSwu9FG@{L%`8hz z@l7o*PE1c_WDxSnN-Rs%&q>Tn*AFf!%FIi*W@HdbPRvd9%qz(c$tX%K&dA8mNnvDQ zjACS9ODamtOU__qkU+Kt;+)`&#DY|7Mh1?Y)U=ZD%)E3)2F{|)^b9DQFD<9izbv)L zKPf9UxulqpK@?(hX-Q^|zGG2QVx>=Jafvk}17~n%dR}5lX;CU8gFZGjHn{Az1KD1d znvQZemGhex7rFXy-b6k72xNHTDMST;NiQVb#-40enRtjRg~#i<}c2Ob7# zh_n+AgA4-~NX&(YK^9`78xMmVg9wY$35fNcJPh&>32z<-1qLn-246-7_Tt>coSf7m zkWPOd21N!AMh1SL%)C^;(%hufqL9R-9B}f_PfpAUODxI+@u7k&B^jB;j0}=KIP#-4 zBLi!3YDsAU7Xu?h7!N}@Lj)rO7b2xGGO%cPYKCzzM1h3CIYzIzEFGjehKC`RA&!xO zGbcYW1)O6T8FVxtsT?^EYT`=cAnzpbFmN;Qa4;k>GVp*h8z`DV7J%eZco=v=a%qeV zyx_n_mdxN`;A7xnaaaHew`?AU90mzS2G(*=>H#?~kB1?jp@5Nrttc@sB|n#ufmOrJ zP1B9VQGtPh#dR731B;t=0|Sf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{>2iIB(Kc2Jz(#9WZ&225}+1 zX>%DAw1o7xGRQ(yrGb1MxrITJC1ERr?L65FOA7_1m}GFUV0WAH-?y8Y0gGhzTG z2Ubgcd3{j0=`iR*LS!Ky= zW3UE^3E5|Xg&nezl;L8IU@0)r<54+9H>5JNbF7XuFiD+42_?u2-kkr}LpfgxDPTa=|O&w^EJ8-owG1>154 z4P|k*9Sr`eSxFY`Dj;Ssh{>TP&MwZejUh~&O`J8!f=!%F$a~uC|JSqx8UAl$h=NeD zTCCd`5JsHf9!oUOeWH3W2*pnc2Adj;!a4>i?q=7xj&tSli z&cMUK#vsce%#gvr!@$mi8Tjg})^b<$)6nsC3K&Cm0q635GC+PKGW9Rt9+ne}-;`E(SIRMo>!u5-JQ`4D8_2)J97{ zj(rbXBr|tlBnx+7B&$%5a#mm@n^3QER^T>7r3094=eQ;^cfhz zr5-5RE%dj+(S!j8%kJd2;K5eZX z3@dgptXa;$uDyd{4aihTGL{18yH*A+hBgL1hIR%qh7JZvhE4`qhHkJ;Vi409)-kMS j0JRZB7&b7hXJ7;;HckenKMa!W3>%pl7#TK!Lt--k{3Wor diff --git a/magic_veneer_processing/out/source/magic_veneer_processing.java b/magic_veneer_processing/out/source/magic_veneer_processing.java index 27c1131..b47a3ec 100644 --- a/magic_veneer_processing/out/source/magic_veneer_processing.java +++ b/magic_veneer_processing/out/source/magic_veneer_processing.java @@ -22,24 +22,82 @@ Serial arduinoPort; String receivedMessage; boolean cameIntoThreshhold = false; +PShape branch; +PShape leftWing; +PShape rightWing; +ArrayList flyOverObjects = new ArrayList(); +float velocity = 6; +float backgroundOffset = 0; float placementIndicatorOffsetX = 0; int placementIndicatorAnimationCounter = 0; String placementIndicatorAnimationDirection = "right"; +float cocoonOpenDegrees = 0; +String cocoonAnimationDirection = "close"; +boolean cocoonAnimationFinished = false; +float wingOpacity = 0; +float treeOffset = 0; +float wingWidth = 100; +boolean wingsSpread = false; +String wingDirection = "smaller"; public void setup() { /* Set up screen */ background(0); + + /* Load external files */ + branch = loadShape("branch.svg"); + leftWing = loadShape("leftwing.svg"); + rightWing = loadShape("rightwing.svg"); + + /* Spawn random objects the butterfly can fly over */ + for (int i = 0; i < 40; i++) { + float x = random(5, width / 10 - 5) * 10; + float y = random(4800, 12000); + float radius = random(1, 10) * 25; + PShape object = createShape(ELLIPSE, x, -y, radius, radius); + object.setFill(color(150, 150, 150)); + object.setStroke(color(150, 150, 150)); + flyOverObjects.add(object); + } + + /* Set up communication with arduino String portName = Serial.list()[Serial.list().length - 1]; //change index to match your port arduinoPort = new Serial(this, portName, 9600); */ } public void draw() { - /* START - Create and animate placementIndicator */ + /* if ( arduinoPort.available() > 0) { + String rec = arduinoPort.readStringUntil('\n'); + if (rec != null) { + receivedMessage = rec; + } + + // Check for specific events and act upon them + if (receivedMessage != null && receivedMessage.contains("isWithinThreshhold")) { + cameIntoThreshhold = true; + } + }*/ + + // Set up fill and let background move background(0); - placementIndicator(80, 8, placementIndicatorOffsetX); + translate(0, backgroundOffset - 100); + + // TODO: Only start to move background as soon as second sensor is triggered + backgroundOffset = backgroundOffset + velocity; + println(backgroundOffset); + + // Draw fly-over objects + for (int i = 0; i < flyOverObjects.size(); i++) { + PShape object = flyOverObjects.get(i); + shape(object); + } + + /* START - Create and animate placementIndicator */ + // TODO: Trigger when first sensor is actuated + placementIndicator(width / 2 + 100, (height / 2) - backgroundOffset ,130, 8, placementIndicatorOffsetX); if (placementIndicatorAnimationCounter < 5) { if (placementIndicatorAnimationDirection == "right" && placementIndicatorOffsetX < 30) { @@ -60,32 +118,127 @@ public void draw() { } /* END - Create and animate placementIndicator */ - /* if ( arduinoPort.available() > 0) { - String rec = arduinoPort.readStringUntil('\n'); - if (rec != null) { - receivedMessage = rec; + /* START - Scene 1 Bugs going by */ + bug(100, -100, 1); + bug(400, -400, 1); + bug(width - 200, -600, 1); + bug(width - 400, -300, 1); + /* END - Scene 1 Bugs going by */ + + + if (backgroundOffset < 2450) { + /* START - Scene 2 Crawling on branch */ + shape(branch, 0, -3200, width, width); + /* END - Scene 2 Crawling on branch */ + } else if (backgroundOffset > 2450 && backgroundOffset < 4400) { + if (cocoonAnimationFinished == false) { + if (cocoonAnimationDirection == "close" && cocoonOpenDegrees < 165) { + cocoonOpenDegrees++; + } else if (cocoonAnimationDirection == "close" && cocoonOpenDegrees >= 165) { + cocoonOpenDegrees = 165; + cocoonAnimationDirection = "open"; + } if (cocoonAnimationDirection == "open" && cocoonOpenDegrees > 0) { + cocoonOpenDegrees--; + } if (cocoonAnimationDirection == "open" && cocoonOpenDegrees <= 0) { + cocoonOpenDegrees = 0; + cocoonAnimationFinished = true; + } + + fill(255); + noStroke(); + arc(width / 2 + 100, -1800 - (backgroundOffset - 2450), 500, 1100, radians(260 - cocoonOpenDegrees), radians(280 + cocoonOpenDegrees), PIE); + + print("Tree position: "); + shape(branch, 0, -3200 - (backgroundOffset - 2450), width, width); } - // Check for specific events and act upon them - if (receivedMessage != null && receivedMessage.contains("isWithinThreshhold")) { - cameIntoThreshhold = true; + // 3. Let tree move again + /* END - Scene 3 Cocooning */ + } else if (backgroundOffset > 4400 && backgroundOffset < 13000) { + shape(branch, 0, -3200 - (backgroundOffset - 2450) + treeOffset, width, width); + treeOffset = treeOffset + velocity; + /* START - Scene 4 Butterfly */ + + if (wingWidth < 620 && wingsSpread == false) { + wingDirection = "bigger"; + } else if (wingWidth >= 620 && wingsSpread == false) { + wingWidth = 620; + wingsSpread = true; + } else if (wingsSpread == true && wingWidth < 540) { + wingDirection = "bigger"; + } else if (wingsSpread == true && wingWidth >= 620) { + wingDirection = "smaller"; } + + if (wingDirection == "smaller") { + wingWidth -= 4; + } else if (wingDirection == "bigger") { + wingWidth += 4; + } + + shape(leftWing, width / 2 - wingWidth + 35, (height / 2 - wingWidth * 0.8f) - backgroundOffset, wingWidth, wingWidth * 1.5f); + shape(rightWing, width / 2 + 165, (height / 2 - wingWidth * 0.8f) - backgroundOffset, wingWidth, wingWidth * 1.5f); + + + /* END - Scene 4 Butterfly */ + } else if (backgroundOffset > 13000) { + background(255); } - - circle(width / 2, height / 2, radius); - fill(0); - radius += 10; */ } -public void placementIndicator(float polygonRadius, int npoints, float offsetX) { - float centerX = width / 2; - float centerY = height / 2; - polygon(centerX + offsetX, centerY + polygonRadius * 2.75f, polygonRadius * 0.8f, npoints); - polygon(centerX + offsetX * 0.9f, centerY + polygonRadius * 1.6f, polygonRadius, npoints); - polygon(centerX + offsetX * 0.7f, centerY, polygonRadius, npoints); - polygon(centerX + offsetX * 0.3f, centerY - polygonRadius * 1.6f, polygonRadius, npoints); - head(centerX, centerY, polygonRadius, 8); +public void bug(float x, float y, float scale) { + PShape leftUpperLeg = bugLeg(scale, false); + PShape leftMiddleLeg = bugLeg(scale, false); + PShape leftLowerLeg = bugLeg(scale, false); + PShape rightUpperLeg = bugLeg(scale, true); + PShape rightMiddleLeg = bugLeg(scale, true); + PShape rightLowerLeg = bugLeg(scale, true); + + pushMatrix(); + + translate(x, y); + polygon(60 * scale, 40 * scale , 40 * scale, 6); + + pushMatrix(); + leftUpperLeg.translate(5 * scale, 0); + shape(leftUpperLeg); + popMatrix(); + + pushMatrix(); + leftMiddleLeg.translate(0, 20 * scale); + shape(leftMiddleLeg); + popMatrix(); + + pushMatrix(); + leftLowerLeg.translate(5 * scale, 45 * scale); + shape(leftLowerLeg); + popMatrix(); + + pushMatrix(); + rightUpperLeg.translate(85 * scale, 0); + shape(rightUpperLeg); + popMatrix(); + + pushMatrix(); + rightMiddleLeg.translate(90 * scale, 20 * scale); + shape(rightMiddleLeg); + popMatrix(); + + pushMatrix(); + rightLowerLeg.translate(85 * scale, 45 * scale); + shape(rightLowerLeg); + popMatrix(); + + popMatrix(); +} + +public void placementIndicator(float x, float y, float polygonRadius, int npoints, float offsetX) { + polygon(x + offsetX, y + polygonRadius * 2.75f, polygonRadius * 0.8f, npoints); + polygon(x + offsetX * 0.9f, y + polygonRadius * 1.6f, polygonRadius, npoints); + polygon(x + offsetX * 0.7f, y, polygonRadius, npoints); + polygon(x + offsetX * 0.3f, y - polygonRadius * 1.6f, polygonRadius, npoints); + head(x, y, polygonRadius, 8); } public void polygon(float x, float y, float radius, int npoints) { @@ -128,6 +281,33 @@ public PShape antenna(float scale) { return antenna; } + +public PShape bugLeg(float scale, boolean mirrored) { + PShape bugLeg = createShape(); + bugLeg.beginShape(); + bugLeg.fill(255); + bugLeg.stroke(255); + + if (mirrored == true) { + bugLeg.vertex(0, 20); + bugLeg.vertex(15, 20); + bugLeg.vertex(30, 5); + bugLeg.vertex(30, 0); + bugLeg.vertex(15, 15); + bugLeg.vertex(0, 15); + } else { + bugLeg.vertex(0, 0); + bugLeg.vertex(15, 15); + bugLeg.vertex(30, 15); + bugLeg.vertex(30, 20); + bugLeg.vertex(15, 20); + bugLeg.vertex(0, 5); + } + + bugLeg.endShape(CLOSE); + + return bugLeg; +} public void settings() { fullScreen(); } static public void main(String[] passedArgs) { String[] appletArgs = new String[] { "magic_veneer_processing" };