#treecounting
Explore tagged Tumblr posts
Text
Victor SantaMaria! La Ecología en Nueva York
Crean mapa para ubicar los árboles en Nueva York En los últimos años, la administración del Departamento de Parques y Recreación de la Ciudad de Nueva York (NYC Parks), ha puesto en marcha un programa con el cual planean recolectar la información acerca de cada uno de los arboles dentro de los límites de la gran ciudad estadounidense. TreeCount! Es el nombre que le han dado a este programa, y desde el 2015 su población ayudante es de 2.300 voluntarios. Durante varios meses salieron junto a instructores que les guiaron en un recorrido por la ciudad, para capacitarlos con el
Victor Santa Maria from https://ift.tt/2XUWUmo
0 notes
Text
Final Code
import pKinect.PKinect; import pKinect.SkeletonData; import processing.sound.*;
AudioIn input; Amplitude rms; SoundFile file; SoundFile footsteps; AudioDevice device; SoundFile[] file2; PKinect kinect;
ArrayList<SkeletonData> bodies;
int treeCount = 1000;
float xPos; float yPos;
int numsounds = 5;
int value[] = {0,0,0};
float[] z = new float[treeCount]; // The depth in z space or how close / far away from camera float[] x = new float[treeCount]; float[] y = new float[treeCount]; float[] w = new float[treeCount]; float[] h = new float[treeCount];
float[] ogW = new float[treeCount]; float[] ogH = new float[treeCount]; float[] ogX = new float[treeCount]; int scale; int scale2;
// Changing Vars int peopleInteracted; // How many people who have interacted with the code since start
float maxWidth = 1; float maxHeight = 1; float time; // Time since start - I might need a libary to implment float playersHeight; // The height of the person currently interacting float playersWidth; // The width of the person currently interacting int seconds; int minutes; int hours; float heightColour = 25;
boolean madeSound; boolean newPerson; // Is there a new person using the enviorment
void setup() { // The setup function //size(800, 500, P3D); fullScreen(P3D, 1);
kinect = new PKinect(this); bodies = new ArrayList<SkeletonData>(); smooth();
// Load a soundfile from the /data folder of the sketch and play it back file = new SoundFile(this, "Forest.wav"); file.play(); file.loop(); file.amp(.01);
footsteps = new SoundFile(this, "Footsteps.aiff"); footsteps.play(); footsteps.loop(); footsteps.amp(.01);
//Create an Audio input and grab the 1st channel input = new AudioIn(this, 0);
// start the Audio Input input.start();
// create a new Amplitude analyzer rms = new Amplitude(this);
// Patch the input to an volume analyzer rms.input(input);
// Create a Sound renderer and an array of empty soundfiles device = new AudioDevice(this, 48000, 32); file2 = new SoundFile[numsounds];
// Load 5 soundfiles from a folder in a for loop. By naming the files 1., 2., 3., n.aif it is easy to iterate // through the folder and load all files in one line of code. for (int i = 0; i < numsounds; i++){ file2[i] = new SoundFile(this, (i+1) + ".aif"); }
for (int i = 0; i < treeCount; i++) { x[i] = random(-3000, width+3000); y[i] = 420; z[i] = (i*10)-500; // The triangles depth w[i] = 50; h[i] = random(500, 600);
ogW[i] = w[i]; ogH[i] = h[i]; ogX[i] = x[i]; } }
void draw() { time += 0.0001; seconds = second(); minutes = minute(); hours = hour();
// The draw function background(seconds, minutes, hours); // Have the background change based on the time // background(30,30,30); //input.amp(map(mouseY, 0, height, 0.0, 1.0)); scale = int(map(rms.analyze(), 0, 0.01, 500, 800)); scale2 = int(map(rms.analyze(), 0, 0.01, 500, 800)); int colourScale = int(map(yPos, 0, maxHeight, 0, 100));
xPos = mouseX; maxWidth = width; yPos = mouseY; maxHeight = height; for (int i=0; i<bodies.size(); i++) { drawSkeleton(bodies.get(i)); drawPosition(bodies.get(i)); }
for (int i = 0; i < treeCount; i++) { fill(colourScale, colourScale, colourScale); float zR = map(yPos, 0, maxHeight, -4000, -6000); float xR = map(xPos, 0, maxWidth, i*3, -500);
pushMatrix(); // Push Matrix allows the transformations to only effect the 'trees' I want h[i] = scale; // Make sure the tree's aren't getting to big or too small if (w[i] > ogW[i] - 5 && w[i] < ogW[i] + 5) { // Give an abstract feel to the trees w[i] += random(-2, 2); } x[i] += random(-time, time);
rectMode(CORNERS);
// Main Tree stroke(1); strokeWeight(random(0, 1)); translate(xR, 0, z[i]+zR); rect(x[i], y[i], x[i] + w[i], y[i] - h[i]);
// Tree top fill(0, heightColour/2, 0, random(150, 160)); //noStroke(); strokeWeight(0.1); rect(x[i] - random(150, 160), y[i] - h[i], x[i] + w[i] + random(150, 160), y[i] - h[i] - random(100, 105)); rect(x[i] - random(100, 110), y[i] - h[i] - 100, x[i] + w[i] + random(100, 110), y[i] - h[i] - 100 - random(100, 105)); rect(x[i] - random(100, 110), y[i] - h[i] - 100, x[i] + w[i] + random(100, 110), y[i] - h[i] - 200 - random(100, 105));
// Tree Outline noStroke(); fill(random(0, 50), 10, 10, random(20, 60)); rect(x[i] - random(0, 5), y[i], x[i] + w[i] + random(0, 5), y[i] - h[i] - random(0, 5));
// Shadow fill(random(0, 10), random(100, 140)); translate(0, 420, -420); rotateX(radians(90)); rect(x[i], y[i], x[i] + w[i], y[i] + h[i]*2);
popMatrix(); } }
void drawPosition(SkeletonData _s) { }
void drawSkeleton(SkeletonData _s) { // Body DrawBone(_s, PKinect.NUI_SKELETON_POSITION_HEAD, PKinect.NUI_SKELETON_POSITION_SHOULDER_CENTER); }
void DrawBone(SkeletonData _s, int _j1, int _j2) { if (_s.skeletonPositionTrackingState[_j1] != PKinect.NUI_SKELETON_POSITION_NOT_TRACKED && _s.skeletonPositionTrackingState[_j2] != PKinect.NUI_SKELETON_POSITION_NOT_TRACKED) { if (newPerson == true) { newPerson = false;
// Do something based on a new person coming into the enviorment // GrabValues(); } xPos = _s.skeletonPositions[_j1].x; maxWidth = 1; maxHeight = 15000; yPos = _s.skeletonPositions[_j1].z; heightColour = ( _s.skeletonPositions[PKinect.NUI_SKELETON_POSITION_HIP_CENTER].y - _s.skeletonPositions[PKinect.NUI_SKELETON_POSITION_HEAD].y) * 200;
if (_s.skeletonPositions[PKinect.NUI_SKELETON_POSITION_HAND_LEFT].y > _s.skeletonPositions[PKinect.NUI_SKELETON_POSITION_HEAD].y) { if (madeSound == false) { //file2[1].play(1.0, 1.0); madeSound = true; } } else { madeSound = false; } } else { // No one is being tracked so set it up so when someone is tracked is reconises new person newPerson = true; heightColour = 25; } }
void appearEvent(SkeletonData _s) { if (_s.trackingState == PKinect.NUI_SKELETON_NOT_TRACKED) { return; } synchronized(bodies) { bodies.add(_s); } }
void disappearEvent(SkeletonData _s) { synchronized(bodies) { for (int i=bodies.size()-1; i>=0; i--) { if (_s.dwTrackingID == bodies.get(i).dwTrackingID) { bodies.remove(i); } } } }
///////////////////////////////////////////////////////////////////////////////////
How it works.
Basically, it is a parallax effect. At the start, I Assign a number of trees I want in the scene and assign them each there own z value and random x values plus any other values they need width height etc. I then draw them using a for loop and in there I add all the different effects like random jitters, changing colour, sound reactive etc. I then adjust their x and z value based on the positions of the players head in the space. The amount this movement and change effects the objects is based on multiplying it by their z value meaning the further away they are the less they move and the closer they are the faster they move.
0 notes
Link
0 notes