Skip to content

Commit

Permalink
Final Version for the Exhibition
Browse files Browse the repository at this point in the history
  • Loading branch information
MoritzSkowronski committed Jan 13, 2016
1 parent e64cfc9 commit 45ee129
Show file tree
Hide file tree
Showing 22 changed files with 183 additions and 123 deletions.
Binary file modified bin/box2DWorld/Polygon.class
Binary file not shown.
Binary file modified bin/data/ContentGenerator.class
Binary file not shown.
Binary file modified bin/data/Image.class
Binary file not shown.
Binary file modified bin/data/Video.class
Binary file not shown.
Binary file modified bin/display/MuseumFinal.class
Binary file not shown.
Binary file modified bin/glass/Crack.class
Binary file not shown.
Binary file modified bin/glass/GlassPlane.class
Binary file not shown.
Binary file modified bin/helpers/VoronoiBuilder.class
Binary file not shown.
Binary file modified bin/movement/MovementHandler.class
Binary file not shown.
Binary file modified bin/movement/OSCReceiver.class
Binary file not shown.
Binary file modified bin/persons/TriggerBox.class
Binary file not shown.
5 changes: 3 additions & 2 deletions src/box2DWorld/Polygon.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.jbox2d.dynamics.Fixture;
import org.jbox2d.dynamics.FixtureDef;

import display.MuseumFinal;
import glass.Fragment;
import processing.core.PApplet;
import processing.core.PVector;
Expand Down Expand Up @@ -89,8 +90,8 @@ public void display() {
p.pushMatrix();
p.translate(pos.x, pos.y);
p.rotate(-a);
p.fill(255);
p.stroke(0);
p.fill(p.color(139,137,137,200));
p.stroke(MuseumFinal.secondColor);
p.beginShape();
// For every vertex, convert to pixel vector
for (int i = 0; i < ps.getVertexCount(); i++) {
Expand Down
17 changes: 13 additions & 4 deletions src/data/ContentGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ private void initialize(List list, String path) {

list.add(new Image(p, p.loadImage(fileName)));
}
if (fileName.endsWith(".avi") || fileName.endsWith(".mp4")) {
if (fileName.endsWith(".avi") || fileName.endsWith(".mp4")
|| fileName.endsWith(".mov")) {

list.add(new Video(p, new Movie(p, fileName)));
}
Expand All @@ -64,6 +65,9 @@ public Image getRandomImage(int maxWidth, int maxHeight) {
}
}

if (possibleImages.size() < 1)
return null;

int index = randomizer.nextInt(possibleImages.size());

return possibleImages.get(index);
Expand All @@ -75,17 +79,22 @@ public Video getRandomVideo(int maxWidth, int maxHeight) {
ArrayList<Video> possibleMovies = new ArrayList<Video>();
for (Video video : (ArrayList<Video>) videos) {

if (video.getResizedWidth() < maxWidth && video.getResizedWidth() < maxHeight) {
if (video.getResizedWidth() <= maxWidth && video.getResizedHeight() <= maxHeight) {

possibleMovies.add(video);
}
}

if (possibleMovies.size() < 0)
if (possibleMovies.size() < 1)
return null;

int index = randomizer.nextInt(possibleMovies.size());

return possibleMovies.get(index);
Video video = possibleMovies.get(index);

video.getMovie().jump(0);

return video;
}

public boolean isReady() {
Expand Down
2 changes: 1 addition & 1 deletion src/data/Image.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public Image(PApplet p, PImage image) {
resizedHeight = originalHeight;

// resize Image
if (image.width > MuseumFinal.maxImageWidth || image.height > MuseumFinal.maxImageHeight) {
if (image.width >= MuseumFinal.maxImageWidth || image.height >= MuseumFinal.maxImageHeight) {

int tempResizeWidth = image.width / MuseumFinal.scaleFactor;
int tempResizeHeight = image.height / MuseumFinal.scaleFactor;
Expand Down
11 changes: 6 additions & 5 deletions src/data/Video.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,23 @@ public class Video {
public Video(PApplet p, Movie video) {
this.video = video;
this.video.play();
this.video.volume(0);
this.video.read();

resizedWidth = this.video.width;
resizedHeight = this.video.height;

// resize Video
if (resizedWidth > MuseumFinal.maxImageWidth
|| resizedHeight > MuseumFinal.maxImageHeight) {
if (resizedWidth >= 1280
|| resizedHeight >= 720) {

int tempResizeWidth = this.video.width / MuseumFinal.scaleFactor;
int tempResizeHeight = this.video.height / MuseumFinal.scaleFactor;
resizedWidth = tempResizeWidth;
resizedHeight = tempResizeHeight;

int i = 1;
while (resizedWidth <= MuseumFinal.maxImageWidth
&& resizedHeight <= MuseumFinal.maxImageHeight) {
while (resizedWidth <= 1280
&& resizedHeight <= 720) {

i++;
resizedWidth = tempResizeWidth * i;
Expand All @@ -42,6 +41,8 @@ public Video(PApplet p, Movie video) {
resizedWidth -= tempResizeWidth;
resizedHeight -= tempResizeHeight;
}

this.video.pause();
}

public Movie getMovie() {
Expand Down
142 changes: 81 additions & 61 deletions src/display/MuseumFinal.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import data.ContentGenerator;
import ddf.minim.AudioOutput;
import ddf.minim.AudioPlayer;
import ddf.minim.AudioSample;
import ddf.minim.Minim;
import ddf.minim.effects.BandPass;
import ddf.minim.ugens.FilePlayer;
Expand All @@ -28,8 +29,8 @@

public class MuseumFinal extends PApplet {

public static final int firstColor = 255;
public static final int secondColor = 0;
public final int firstColor = color(139, 137, 137);
public static final int secondColor = 255;
public static final int strokeStrength = 1;

public static final int formFactorX = 16;
Expand All @@ -43,6 +44,7 @@ public class MuseumFinal extends PApplet {
public static final int showTime = 6000;

public static final int cutAmount = 250;
public static int destroyableCuts = 0;
public static final int interactionSteps = 5;

private MovementHandler movementHandler;
Expand All @@ -56,17 +58,22 @@ public class MuseumFinal extends PApplet {

private ContentGenerator generator;

public static Minim minim;
public static ArrayList<AudioSample> glassBreakSamples;
public static int breakCounter;

@Override
public void settings() {

size(1280, 800, P2D);
// fullScreen(P2D);
// size(1280,800, P2D);
fullScreen(P2D);
smooth(8);
}

@Override
public void setup() {

noCursor();
background(firstColor);
maxImageWidth = width;
maxImageHeight = height;
Expand All @@ -75,19 +82,10 @@ public void setup() {

glass = new GlassPlane(this, maxImageWidth, maxImageHeight);

generator = new ContentGenerator(this, "/Users/Moritz/Dropbox/TellImage",
"/Users/Moritz/Dropbox/TellVideo");
generator = new ContentGenerator(this, "/Users/Moritz/Desktop/TellImage",
"/Users/Moritz/Desktop/TellVideo");

//
// Minim minim = new Minim(this);
// AudioOutput output = minim.getLineOut();
// FilePlayer sound1 = new
// FilePlayer(minim.loadFileStream("/Users/Moritz/Dropbox/Sound/Crack/SuddenCrack.wav"));
// BandPass bpf = new BandPass(440, 20, output.sampleRate());
// bpf.setFreq(300);
// bpf.setBandWidth(500);
// sound1.patch(bpf).patch(output);
// sound1.loop();
initiateAudio();

box2dWorld = new Box2DProcessing(this);
box2dWorld.createWorld();
Expand All @@ -108,14 +106,15 @@ public void draw() {

background(firstColor);
box2dWorld.step();
box2dWorld.step();
strokeWeight(strokeStrength);

updateCrack();

displayAll();

fill(0);
text(frameRate, 20, 20);
// text(frameRate, 20, 20);
}

public void updateCrack() {
Expand All @@ -124,7 +123,7 @@ public void updateCrack() {

if (glass.getCrack() == null) {

if (Math.random() < 0) {
if (Math.random() < 0.4f) {

glass.crack(width / 2, height / 2,
generator.getRandomVideo(maxImageWidth, maxImageHeight));
Expand All @@ -145,75 +144,81 @@ public void updateCrack() {
if (glass.getCrack().getStage() == Stage.WHOLE) {

// glass.getCrack().breakParts(this, box2dWorld, mouseX,
// mouseY, 1, PVector.random2D());
// mouseY, 3,
// PVector.random2D());
if (movementHandler.updateReady()) {

Iterator<Person> iterator = movementHandler.getPersons().values()
.iterator();

Iterator<TriggerBox> boxIterator = movementHandler.getTriggerZones()
.values().iterator();

while (iterator.hasNext()) {

Person person = iterator.next();

// Iterator<TriggerBox> boxIterator =
// movementHandler.getTriggerZones()
// .values().iterator();
//
// while (boxIterator.hasNext()) {
//
// TriggerBox box = boxIterator.next();
//
// if (box.getID().equals("0-Triggerbox 1")) {
//
// if
// (box.getPointsPerPerson().containsKey(person.getId()))
// {
//
// }
// }
// break;
// }

PVector centroid = person.getCentroid();
if (centroid.x > 1 || centroid.y > 1)
continue;
PVector velocity = person.getVelocity();

if (velocity == null) {
velocity = PVector.random2D();
}

if (centroid.x < 0.1) {

continue;
}

if (centroid.x > 0.7) {

continue;
}

centroid.x *= width;

// how much will break
if (centroid.y < 0.2) {
if (centroid.y < 0.3) {

glass.getCrack().breakParts(this, box2dWorld, centroid.x,
height / 2, 1, velocity);
} else if (centroid.y < 0.5) {

glass.getCrack().breakParts(this, box2dWorld, centroid.x,
height / 2, 3, velocity);
} else {
if (centroid.y < 0.4) {
if (centroid.y < 0.7) {

glass.getCrack().breakParts(this, box2dWorld, centroid.x,
height / 2, 2, velocity);
height / 2, 4, velocity);
} else {
if (centroid.y < 0.6) {
// while (boxIterator.hasNext()) {
//
// TriggerBox box =
// boxIterator.next();
// if (box.getPointsInsideBox() !=
// 0) {
// System.out.println("----Person-----");
// System.out.println(person.getId());
// Iterator<Integer> hm =
// box.getPointsPerPerson()
// .keySet().iterator();
// while(hm.hasNext()){
// System.out.println("----trigger----");
// System.out.println(hm.next());
// }
// // if
// // (box.getPointsPerPerson()
// // .containsKey(person.getId()))
// // {
// //
// // }
// }
// }

glass.getCrack().breakParts(this, box2dWorld,
centroid.x, height / 2, 3, velocity);
} else {
if (centroid.y < 0.8) {
if (centroid.y < 1) {

glass.getCrack().breakParts(this, box2dWorld,
centroid.x, height / 2, 4, velocity);
if (person.getAge() > 10) {

glass.getCrack().breakCrack(this, box2dWorld,
velocity);
} else {
if (centroid.y < 1) {

glass.getCrack().breakCrack(this, box2dWorld,
velocity);
}
glass.getCrack().breakParts(this, box2dWorld,
centroid.x, height / 2, 4, velocity);
}
}
}
Expand Down Expand Up @@ -248,6 +253,7 @@ public void displayAll() {
} else {

tint(255, crack.getVisiblity());

image(crack.getVideo().getMovie(), crack.getBoundingBox().get(0).x,
crack.getBoundingBox().get(0).y);
}
Expand Down Expand Up @@ -354,6 +360,20 @@ public void mousePressed() {
glass.getCrack().breakCrack(this, box2dWorld, PVector.random2D());
}
}
}

public void initiateAudio() {

minim = new Minim(this);
AudioPlayer loopPlayer = minim.loadFile("/Users/Moritz/Desktop/FinalSound.mp3");
loopPlayer.loop();

glassBreakSamples = new ArrayList<AudioSample>();
glassBreakSamples.add(minim.loadSample("/Users/Moritz/Desktop/SoundFinal/1.wav"));
glassBreakSamples.add(minim.loadSample("/Users/Moritz/Desktop/SoundFinal/2.wav"));
glassBreakSamples.add(minim.loadSample("/Users/Moritz/Desktop/SoundFinal/3.wav"));
glassBreakSamples.add(minim.loadSample("/Users/Moritz/Desktop/SoundFinal/4.wav"));
glassBreakSamples.add(minim.loadSample("/Users/Moritz/Desktop/SoundFinal/5.wav"));
breakCounter = 0;
}
}
Loading

0 comments on commit 45ee129

Please sign in to comment.