Fix branch position for scene 2, add svg
This commit is contained in:
parent
26669e9ad5
commit
1de7e1e3ac
2 changed files with 218 additions and 44 deletions
91
magic_veneer_processing/data/branch.svg
Normal file
91
magic_veneer_processing/data/branch.svg
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Created with Inkscape (http://www.inkscape.org/) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
width="210mm"
|
||||
height="210mm"
|
||||
viewBox="0 0 210 210"
|
||||
version="1.1"
|
||||
id="svg8"
|
||||
inkscape:version="0.92.5 (2060ec1f9f, 2020-04-08)"
|
||||
sodipodi:docname="branch.svg">
|
||||
<defs
|
||||
id="defs2" />
|
||||
<sodipodi:namedview
|
||||
id="base"
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1.0"
|
||||
inkscape:pageopacity="0.0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:zoom="0.49497475"
|
||||
inkscape:cx="100.51041"
|
||||
inkscape:cy="310.44028"
|
||||
inkscape:document-units="mm"
|
||||
inkscape:current-layer="g823"
|
||||
showgrid="false"
|
||||
inkscape:window-width="1920"
|
||||
inkscape:window-height="1139"
|
||||
inkscape:window-x="0"
|
||||
inkscape:window-y="31"
|
||||
inkscape:window-maximized="1" />
|
||||
<metadata
|
||||
id="metadata5">
|
||||
<rdf:RDF>
|
||||
<cc:Work
|
||||
rdf:about="">
|
||||
<dc:format>image/svg+xml</dc:format>
|
||||
<dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
|
||||
<dc:title></dc:title>
|
||||
</cc:Work>
|
||||
</rdf:RDF>
|
||||
</metadata>
|
||||
<g
|
||||
inkscape:label="Layer 1"
|
||||
inkscape:groupmode="layer"
|
||||
id="layer1"
|
||||
transform="translate(0,-87)">
|
||||
<g
|
||||
id="g890"
|
||||
transform="translate(0.26726953,25.123336)">
|
||||
<g
|
||||
id="g823"
|
||||
transform="translate(-0.31738257,101.25041)">
|
||||
<path
|
||||
style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.26548266px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||
d="m -0.26681887,73.781194 c 0,0 71.16762787,-43.306649 210.65996887,-38.753048 l 0.26502,14.251867 c 0,0 -143.488711,9.256185 -194.984483,56.997557 C 4.1232136,116.98594 0.04306722,183.25283 9.528895e-4,168.37535 Z"
|
||||
id="path819"
|
||||
inkscape:connector-curvature="0"
|
||||
sodipodi:nodetypes="cccssc" />
|
||||
<path
|
||||
style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.46713138px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||
d="m 21.840551,73.05283 c 0,0 12.33198,-9.425182 29.459736,-27.625527 C 68.42804,27.226957 67.05782,21.376847 88.638786,12.926686 110.21977,4.4765245 141.04972,-4.2986416 150.29871,-9.4987406 c 9.24899,-5.2000984 20.21075,-11.3752164 20.21075,-11.3752164 0,0 -20.55331,22.4254274 -62.34502,32.175611 -41.79173,9.750184 -49.327943,56.551078 -49.327943,56.551078 z"
|
||||
id="path838"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.26458332px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||
d="m 62.910782,63.793078 c 0,0 8.544,1.823857 21.750501,7.009064 13.20651,5.185206 14.06575,8.562372 26.908507,7.579228 12.84276,-0.98315 30.32518,-4.098582 36.24315,-3.700619 5.91797,0.397968 12.93502,0.875873 12.93502,0.875873 0,0 -16.00121,-6.525862 -39.13714,-1.189422 C 98.474893,79.703648 82.492073,57.288164 82.492073,57.288164 Z"
|
||||
id="path838-6"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.1277611px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||
d="m 71.06805,22.293829 c 0,0 3.2418,-2.707897 7.70807,-7.892643 4.46628,-5.1847471 4.0572,-6.8057181 9.78734,-9.3032131 5.73013,-2.497491 13.9394,-5.14681202 16.38398,-6.65702 2.44459,-1.51021 5.34179,-3.30344 5.34179,-3.30344 0,0 -5.35539,6.384696 -16.4987,9.378314 C 82.64721,7.5094419 80.95695,20.599801 80.95695,20.599801 Z"
|
||||
id="path838-6-7"
|
||||
inkscape:connector-curvature="0" />
|
||||
<path
|
||||
style="fill:#000000;fill-opacity:1;stroke:#000000;stroke-width:0.08497027px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
|
||||
d="m 135.47301,2.0526661 c 0,0 2.69725,-0.78318 7.21531,-1.32206 4.51807,-0.538884 5.26031,0.289 8.76535,-1.945578 3.50503,-2.234574 8.01425,-5.780914 9.75487,-6.569025 1.74063,-0.788116 3.80541,-1.720883 3.80541,-1.720883 0,0 -5.51005,0.583826 -11.29851,5.621484 -5.78846,5.037666 -13.63654,1.10793 -13.63654,1.10793 z"
|
||||
id="path838-6-7-5"
|
||||
inkscape:connector-curvature="0" />
|
||||
</g>
|
||||
</g>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 4.5 KiB |
|
|
@ -4,6 +4,8 @@ Serial arduinoPort;
|
|||
String receivedMessage;
|
||||
boolean cameIntoThreshhold = false;
|
||||
|
||||
PShape branch;
|
||||
float backgroundOffset = 0;
|
||||
float placementIndicatorOffsetX = 0;
|
||||
int placementIndicatorAnimationCounter = 0;
|
||||
String placementIndicatorAnimationDirection = "right";
|
||||
|
|
@ -13,15 +15,33 @@ void setup() {
|
|||
fullScreen();
|
||||
background(0);
|
||||
|
||||
/* Load external files */
|
||||
branch = loadShape("branch.svg");
|
||||
|
||||
/* 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); */
|
||||
}
|
||||
|
||||
void draw() {
|
||||
background(255);
|
||||
translate(0, backgroundOffset);
|
||||
backgroundOffset+= 4;
|
||||
|
||||
/* 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;
|
||||
}
|
||||
}*/
|
||||
|
||||
/* START - Create and animate placementIndicator */
|
||||
background(0);
|
||||
placementIndicator(80, 8, placementIndicatorOffsetX);
|
||||
placementIndicator(width / 2, (height / 2) - backgroundOffset ,80, 8, placementIndicatorOffsetX);
|
||||
|
||||
if (placementIndicatorAnimationCounter < 5) {
|
||||
if (placementIndicatorAnimationDirection == "right" && placementIndicatorOffsetX < 30) {
|
||||
|
|
@ -41,51 +61,87 @@ void draw() {
|
|||
placementIndicatorOffsetX = 0;
|
||||
}
|
||||
/* END - Create and animate placementIndicator */
|
||||
bug(100, 100, 2);
|
||||
|
||||
/* 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 ( arduinoPort.available() > 0) {
|
||||
String rec = arduinoPort.readStringUntil('\n');
|
||||
if (rec != null) {
|
||||
receivedMessage = rec;
|
||||
}
|
||||
if (backgroundOffset < 2450) {
|
||||
/* START - Scene 2 Crawling on branch */
|
||||
println("Under threshhold");
|
||||
shape(branch, 0, -3200, width, width);
|
||||
/* END - Scene 2 Crawling on branch */
|
||||
}
|
||||
if (backgroundOffset > 2450 && backgroundOffset < 5000) {
|
||||
/* START - Scene 3 Cocooning */
|
||||
// 1. Place tree at initial position minus delta (Offset at entering threshhold to current threshhold)
|
||||
shape(branch, 0, -3200 - (backgroundOffset - 2450), width, width);
|
||||
// 2. Start cocoon animation
|
||||
|
||||
// Check for specific events and act upon them
|
||||
if (receivedMessage != null && receivedMessage.contains("isWithinThreshhold")) {
|
||||
cameIntoThreshhold = true;
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
void bug(float x, float y, float scale) {
|
||||
ArrayList<PShape> legs = new ArrayList<PShape>();
|
||||
|
||||
polygon(x, y, 40 * scale, 6);
|
||||
|
||||
PShape leftUpperLeg = createShape(TRIANGLE, x - 40 * scale, y - 40 * scale, x * scale - 20, y, x - 20 * scale, y);
|
||||
legs.add(leftUpperLeg);
|
||||
PShape leftLowerLeg = createShape(TRIANGLE, x - 40 * scale, y + 40 * scale, x * scale - 20, y, x - 20 * scale, y);
|
||||
legs.add(leftLowerLeg);
|
||||
PShape rightUpperLeg = createShape(TRIANGLE, x + 40 * scale, y - 40 * scale, x * scale + 20, y, x + 20 * scale, y);
|
||||
legs.add(rightUpperLeg);
|
||||
PShape rightLowerLeg = createShape(TRIANGLE, x + 40 * scale, y + 40 * scale, x * scale + 20, y, x + 20 * scale, y);
|
||||
legs.add(rightLowerLeg);
|
||||
|
||||
for (int i = 0; i < legs.size(); i++) {
|
||||
legs.get(i).setFill(color(255));
|
||||
shape(legs.get(i));
|
||||
// 3. Keep cocoon for x amount of time
|
||||
/* END - Scene 3 Cocooning */
|
||||
} else if (backgroundOffset > 5000) {
|
||||
/* START - Scene 4 Butterfly */
|
||||
println("Over threshhold");
|
||||
/* END - Scene 4 Butterfly */
|
||||
}
|
||||
}
|
||||
|
||||
void placementIndicator(float polygonRadius, int npoints, float offsetX) {
|
||||
float centerX = width / 2;
|
||||
float centerY = height / 2;
|
||||
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);
|
||||
|
||||
polygon(centerX + offsetX, centerY + polygonRadius * 2.75, polygonRadius * 0.8, npoints);
|
||||
polygon(centerX + offsetX * 0.9, centerY + polygonRadius * 1.6, polygonRadius, npoints);
|
||||
polygon(centerX + offsetX * 0.7, centerY, polygonRadius, npoints);
|
||||
polygon(centerX + offsetX * 0.3, centerY - polygonRadius * 1.6, polygonRadius, npoints);
|
||||
head(centerX, centerY, polygonRadius, 8);
|
||||
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();
|
||||
}
|
||||
|
||||
void placementIndicator(float x, float y, float polygonRadius, int npoints, float offsetX) {
|
||||
polygon(x + offsetX, y + polygonRadius * 2.75, polygonRadius * 0.8, npoints);
|
||||
polygon(x + offsetX * 0.9, y + polygonRadius * 1.6, polygonRadius, npoints);
|
||||
polygon(x + offsetX * 0.7, y, polygonRadius, npoints);
|
||||
polygon(x + offsetX * 0.3, y - polygonRadius * 1.6, polygonRadius, npoints);
|
||||
head(x, y, polygonRadius, 8);
|
||||
}
|
||||
|
||||
void polygon(float x, float y, float radius, int npoints) {
|
||||
|
|
@ -96,8 +152,8 @@ void polygon(float x, float y, float radius, int npoints) {
|
|||
float sy = y + sin(a) * radius;
|
||||
vertex(sx, sy);
|
||||
}
|
||||
fill(255);
|
||||
stroke(255);
|
||||
fill(0);
|
||||
stroke(0);
|
||||
endShape(CLOSE);
|
||||
}
|
||||
|
||||
|
|
@ -122,9 +178,36 @@ 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(255));
|
||||
antenna.setStroke(color(255));
|
||||
antenna.setFill(color(0));
|
||||
antenna.setStroke(color(0));
|
||||
antenna.endShape();
|
||||
|
||||
return antenna;
|
||||
}
|
||||
|
||||
PShape bugLeg(float scale, boolean mirrored) {
|
||||
PShape bugLeg = createShape();
|
||||
bugLeg.beginShape();
|
||||
bugLeg.fill(0);
|
||||
bugLeg.stroke(0);
|
||||
|
||||
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;
|
||||
}
|
||||
Reference in a new issue