x z y (x, y, z) = (nach rechts, nach unten, nach vorne)
x z y (3, 7, 9) = (3 nach rechts, 7 nach unten, 9 nach vorne)
import processing.visualcube1e3.*; // import library VisualCube cube = new VisualCube(this); // set-up cube void setup() { cube.open("192.168.2.173"); cube.clear(); cube.simulate(800, 800); // say hello to cube // clear cube display // show simulator canvas void draw() { cube.set(3, 2, 9, cube 255, 255, ist vom 255); Datentyp // draw VisualCube (3,2,9) white cube.update(); spezieller Datentyp // = update Klasse remote device void destroy() { cube.close(); Initialisiere globale Variable cube Klassen besitzen eigene Funktionen für Zugriff auf Daten: // say goodbye to cube cube.funktionsname(parameterliste)
import processing.visualcube1e3.*; // import library VisualCube cube = new VisualCube(this); // set-up cube void setup() { cube.open("192.168.2.173"); cube.clear(); cube.simulate(800, 800); // say hello to cube // clear cube display // show simulator canvas void draw() { cube.set(3, 2, 9, verbinde 255, 255, mit 255); Gerät // an draw (3,2,9) white cube.update(); Netzwerkadresse // update remote device void destroy() { cube.close(); open(ip-adresse): falls kein Gerät gefunden, starte Simulator trotzdem // say goodbye to cube
import processing.visualcube1e3.*; // import library VisualCube cube = new VisualCube(this); // set-up cube void setup() { cube.open("192.168.2.173"); cube.clear(); cube.simulate(800, 800); clear(): // say hello to cube // clear cube display // show simulator canvas void draw() { cube.set(3, 2, 9, setze 255, alle 255, Voxel 255); zurück // draw auf (3,2,9) schwarz white cube.update(); // update remote device void destroy() { cube.close(); // say goodbye to cube
import processing.visualcube1e3.*; // import library VisualCube cube = new VisualCube(this); // set-up cube void setup() { cube.open("192.168.2.173"); cube.clear(); cube.simulate(800, 800); simulate(width, height): // say hello to cube // clear cube display // show simulator canvas void draw() { cube.set(3, 2, 9, zeige 255, Simulator 255, 255); in // Ausgabefenster draw (3,2,9) white mit cube.update(); festgelegter Breite // und update Höhe remote device void destroy() { cube.close(); // say goodbye to cube
import processing.visualcube1e3.*; // import library VisualCube cube = new VisualCube(this); // set-up cube void setup() { cube.open("192.168.2.173"); cube.clear(); cube.simulate(800, 800); set(x, y, z, r, g, b): setze Voxel an (x, y, z) auf den Farbwert (r, g, b) Rot-/Grün-/Blauanteil " jew. zwischen 0 und 255 // say hello to cube // clear cube display // show simulator canvas void draw() { cube.set(3, 2, 9, 255, 255, 255); // draw (3,2,9) white cube.update(); // update remote device void destroy() { cube.close(); // say goodbye to cube
update(): import processing.visualcube1e3.*; // import library sende alle bisherigen Änderungen seit letztem update() an das Gerät VisualCube cube = new VisualCube(this); // set-up cube void setup() { cube.open("192.168.2.173"); cube.clear(); cube.simulate(800, 800); // say hello to cube // clear cube display // show simulator canvas void draw() { cube.set(3, 2, 9, 255, 255, 255); // draw (3,2,9) white cube.update(); // update remote device void destroy() { cube.close(); // say goodbye to cube
close(): import processing.visualcube1e3.*; // import library schließe Verbindung zum Gerät Gegenstück zu open() VisualCube cube = new VisualCube(this); // set-up cube void setup() { cube.open("192.168.2.173"); cube.clear(); cube.simulate(800, 800); // say hello to cube // clear cube display // show simulator canvas void draw() { cube.set(3, 2, 9, 255, 255, 255); // draw (3,2,9) white cube.update(); // update remote device void destroy() { cube.close(); // say goodbye to cube
set(x, y, z, r, g, b [, a] ) Voxel an (x, y, z) setzen auf Farbe (r, g, b) optional: Deckungsgrad a von 0 bis 1 (durchsichtig bis deckend) getred (x, y, z) getgreen(x, y, z) getblue (x, y, z) Farbwert an (x,y,z) abfragen fill(r, g, b [, a] ) Alle Voxel auf Farbe (r, g, b) setzen optional: Deckungsgrad
line(x1, y1, z1, x2, y2, z2, r, g, b [, a] ) Linie zwischen (x1, y1, z1) und (x2, y2, z2) optional: Deckungsgrad cuboid(x1, y1, z1, x2, y2, z2, r1, g1, b1 [, a1] [, r2, g2, b2 [, a2] ] ) 3D-Box: Rahmen- & Füllfarbe (r1, g1, b1) optional: andere Füllfarbe (r2, g2, b2) x x z z
void draw() { fill(0, 0, 0, 0.1 );...neuen Frame zeichnen... alte Bilder mit jedem neuen Bild um 10% verblassen lassen cube.fill(0, 0, abs(sin(pi*framecount/60))*255); Würfel pulsiert in blau, Pulsweite 1sec bei 60fps 255 60 120
import processing.visualcube1e3.*; VisualCube cube = new VisualCube(this); void setup() { cube.open("192.168.2.173"); // say hello to the cube cube.clear(); // clear the display cube.simulate(800, 800); // show simulator canvas void draw() { hier zeichnen cube.update(); // update remote device void destroy() { cube.clear(); // clear the display cube.update(); // update remote device cube.close(); // say goodbye cube
Zufällige Punkte erscheinen, alte verblassen void draw() { cube.set(0, 0, 0, 0.005); // fade old frames out // draw random point with random color int x = int(random(10)); int y = int(random(10)); int z = int(random(10)); int r = int(random(256)); int g = int(random(256)); int b = int(random(256)); cube.set(x, y, z, r, g, b); cube.update(); // update remote device
um den Mittelpunkt rotierende Linie mit verblassendem Schweif Länge, Position, Farbwahl basieren auf Schwingungen untersch. Periode void draw() { cube.fill(0, 0, 0, 0.005); // fade old frames out int x = int((sin(framecount*0.04)+1)/2*9); int y = int((sin(framecount*0.05)+1)/2*9); int z = int((sin(framecount*0.06)+1)/2*9); int r = int((sin(framecount*0.01)+1)/2*255); int g = int((sin(framecount*0.02)+1)/2*255); int b = int((sin(framecount*0.03)+1)/2*255); cube.line(9 - x, 9 - y, 9 - z, x, y, z, r, g, b); 1 cube.update(); // update remote device 0 500
Raycasting (Lichtstrahl werfen):" für alle zu zeichnenden Objekte: alle Formelemente (z.b. Pixel) in entsprechender Farbe auf entsprechenden Voxel abbilden. z.b. für pixelbasierte Objekte (Linie, Punkt, Pixelbild) Raytracing (Lichtstrahl zurückverfolgen):" für alle Voxel: Effekte jedes Objekts auf den Farbwert eines Voxels auf Basis seiner Position berechnen z.b. für Lichtpunkt: Helligkeit abh. von Abstand automatisches Interpolieren: " Zentrum des Lichtpunkts kann zw. Voxeln liegen
float[][][] sprites = { { {0,1,1,1,0, {1,1,1,1,1, {1,0,1,0,1, {1,1,1,1,1, {1,0,1,0,1, { {0,1,1,1,0, {1,1,1,0,1, {1,1,0,0,0, {1,1,1,0,1, {0,1,1,1,0, ; Ausdruck Ergebnis sprites[0][2][1] 0 sprites[1][2] {1,1,0,0,0 sprites[1][2][2] 0 sprites.length 2 sprites[0].length 5 sprites[0][0].length 5 final int SPRITES_NUM = sprites.length; final int SPRITES_HEIGHT = sprites[0].length; final int SPRITES_WIDTH = sprites[0][0].length;
// draw sprite #n with color r,g,b at position x0,y0,z0 // to z-layer void drawsprite(int x0, int y0, int z0, int n, int r, int g, int b) { for (int x = 0; x < SPRITES_WIDTH; x++) { for (int y = 0; y < SPRITES_HEIGHT; y++) { cube.set(x0 + x, y0 + y, z0, r, g, b, sprites[n][y][x]);
// draw blurry blob with additive blending: // x,y,z defines position in cube [0, 1.0] // d defines diameter [0, 1.0],.25 would be a sphere 25% of the cube's size // c defines color to add void blob(float x, float y, float z, float d, VisualCube.Color c) { if (d <= 0f) return; for (int i = 0; i < VisualCube.width; i++) { for (int j = 0; j < VisualCube.height; j++) { for (int k = 0; k < VisualCube.depth; k++) { float d0 = dist( i*1f/(visualcube.width - 1), j*1f/(visualcube.height - 1), k*1f/(visualcube.depth - 1), x, y, z) / sqrt(3f); float f0 = constrain(1f - (1f / (d/2) * d0), 0f, 1f); VisualCube.Color c0 = cube.get(i, j, k); c0.r += int(f0 * c.r); c0.g += int(f0 * c.g); c0.b += int(f0 * c.b); cube.set(i, j, k, c0); d d0 (x, y, z) (i, j, k)
import ddf.minim.*; import ddf.minim.analysis.*; Minim minim = new Minim(this); AudioPlayer song; BeatDetect beat; void setup() { song = minim.loadfile("lumatico - Europa Model 1908.mp3", 2048); beat = new BeatDetect(/*song.bufferSize(), song.samplerate()*/); beat.setsensitivity(200); song.addlistener( // detect beats at a higher resolution new AudioListener() { void samples(float[] samps) { beat.detect(song.mix); void samples(float[] sampsl, float[] sampsr) { beat.detect(song.mix); ); song.play();
void draw() { if (beat.isonset()) /*iskick() issnare() ishat()*/ { Handlung hier void stop() { song.close(); // free audio buffers minim.stop(); // free audio processing buffers super.stop(); // close sketch
VisualCube bleibt bis Sonntag in diesem Raum:" GPN8 des CCC Programmieren noch bis Sonntag möglich