├── LICENSE ├── Processing ├── ActiveLayedOut │ ├── ActiveLayedOut.pde │ ├── OPC.pde │ ├── README.md │ ├── README.md~ │ ├── data │ │ ├── outfile.png │ │ └── transit.mov │ └── sketch.properties ├── ActivePulsing │ ├── ActivePulsing.pde │ └── README.md ├── ActivePulsingCoordinates │ ├── ActivePulsingCoordinates.pde │ ├── README.md │ ├── README.md~ │ ├── data │ │ ├── outfile.png │ │ └── transit.mov │ ├── sketch.properties │ └── web-export │ │ ├── ActivePulsingCoordinates.pde │ │ ├── index.html │ │ ├── outfile.png │ │ ├── processing.js │ │ └── transit.mov ├── ActivePulsingDeDupped │ ├── ActivePulsingDeDupped.pde │ ├── README.md │ ├── README.md~ │ └── data │ │ └── outfile.png ├── ActivePulsingImgs │ ├── ActivePulsingImgs.pde │ ├── README.md │ ├── README.md~ │ └── data │ │ ├── outfile.png │ │ └── transit.mov ├── ActivePulsingRangedX │ ├── ActivePulsingRangedX.pde │ ├── README.md │ └── README.md~ ├── ActivePulsingVideo │ ├── ActivePulsingVideo.pde │ ├── README.md │ ├── README.md~ │ └── data │ │ ├── fingers.mov │ │ ├── outfile.png │ │ └── transit.mov ├── bitmap_generator │ ├── Active.pde │ ├── bitmap_generator.pde │ └── coordinates │ │ └── coordinates.pde ├── bitmap_generator_opc │ ├── Active.pde │ ├── OPC.pde │ ├── bitmap_generator_opc.pde │ ├── coordinates │ │ └── coordinates.pde │ └── sketch.properties ├── opcParticles │ ├── Particle.pde │ └── opcParticles.pde ├── opcParticles3d │ ├── Active.pde │ ├── Particle.pde │ └── opcParticles3d.pde ├── opcSphere3d │ ├── Active.pde │ ├── Particle.pde │ └── opcSphere3d.pde ├── positionData │ ├── data │ │ ├── 1020176.csv │ │ ├── positions.txt │ │ └── trim.csv │ └── positionData.pde ├── ringArtNetOpcOsc_spin │ ├── OPC.pde │ ├── data │ │ └── dot.png │ └── ringArtNetOpcOsc_spin.pde ├── scanningBar │ ├── data │ │ ├── landscape.glsl │ │ ├── monjori.glsl │ │ ├── nebula.glsl │ │ └── shaders.txt │ └── scanningBar.pde ├── scanningPlayer │ ├── data │ │ ├── landscape.glsl │ │ ├── monjori.glsl │ │ ├── nebula.glsl │ │ └── shaders.txt │ └── scanningPlayer.pde ├── tampReceiver │ ├── data │ │ ├── landscape.glsl │ │ ├── monjori.glsl │ │ ├── nebula.glsl │ │ └── shaders.txt │ └── tampReceiver.pde └── videoPlayerWithNight │ ├── data │ └── night_img.png │ ├── sketch.properties │ └── videoPlayerWithNight.pde ├── README.md ├── bin ├── .configure ├── active-local-default.sh ├── active-slinger.sh ├── bbb-rsync-excludes.txt ├── build-latest.sh ├── crontab ├── env.sh ├── hosts ├── monitor-opc.sh ├── monitor-slinger.sh ├── opc-server.sh ├── process-videos.sh ├── pull-latest.sh ├── push-latest.sh ├── push-sparkdata.sh ├── rsync-backups.sh ├── run.sh ├── scratch └── setupEnv.sh ├── docs ├── Active_SmokeMonster_tb.gif ├── Active_TieFighter_tb.gif ├── Active_flyer_dm.jpg └── spi-tlc4957-datacapture.csv ├── layout ├── layout-48x24.json ├── layout-60x24-11-tweak.json ├── layout-60x24-11.json ├── layout-60x24-1n2.json ├── layout-60x24-20.json ├── layout-60x24-24.json ├── layout-60x24-26-n-25.json ├── layout-60x24-26.json ├── layout-60x24-centered.json ├── layout-60x24-rad40.json ├── layout-60x24-rot40.json ├── layout-60x24-rot45.json ├── layout-60x24.csv ├── layout-60x24.h ├── layout-60x24.json ├── layout-60x24.xls ├── layout-test.json ├── wall-12.json └── wall-60.json ├── python ├── Nyan Catbw.png ├── crashlogo-small.png ├── dance.jpg ├── from PIL import Image ├── greyscale.py ├── hobbes-icon.jpeg ├── outfile.png ├── pil-test.py ├── udp-test-swipe.py └── udp-test.py ├── src ├── BlackLib.cpp ├── Makefile ├── ball.cpp ├── ball.h ├── black-rings.cpp ├── black-rings.h ├── data │ ├── bat.png │ ├── bruja.png │ ├── cat.png │ ├── crash.png │ ├── crow_flying_down.png │ ├── crow_up.png │ ├── dance-in.png │ ├── dance.jpg │ ├── dance.png │ ├── dot.png │ ├── evolution-in.png │ ├── evolution2.jpg │ ├── evolution2.png │ ├── flying-pelican.png │ ├── flying.png │ ├── glass.png │ ├── gull_flying.png │ ├── heart-in.png │ ├── heart.png │ ├── img0.png │ ├── img1.png │ ├── img2.png │ ├── img3.png │ ├── img4.png │ ├── man_f7d1301_v1_8820-00370_basic_router.pdf │ ├── nyan.png │ ├── rino.jpeg │ ├── rino.png │ ├── sky.png │ ├── startingcrow.png │ ├── wide-wings.jpeg │ └── witch.jpeg ├── direction-bottom-to-top.cpp ├── direction-front-to-back.cpp ├── direction-right-to-left.cpp ├── dot ├── dot.cpp ├── dot.h ├── example.cpp ├── fixed.cpp ├── images.cpp ├── images.h ├── img ├── img.cpp ├── lib │ ├── BlackDef.h │ ├── BlackErr.h │ ├── BlackLib.h │ ├── BlackLib.o │ ├── README.md │ ├── brightness.h │ ├── color.h │ ├── effect.h │ ├── effect_mixer.h │ ├── effect_runner.h │ ├── nanoflann.h │ ├── noise.h │ ├── opc_client.h │ ├── particle.h │ ├── picopng.h │ ├── rapidjson │ │ ├── README.md │ │ ├── document.h │ │ ├── filestream.h │ │ ├── internal │ │ │ ├── pow10.h │ │ │ ├── stack.h │ │ │ └── strfunc.h │ │ ├── prettywriter.h │ │ ├── rapidjson.h │ │ ├── reader.h │ │ ├── stringbuffer.h │ │ └── writer.h │ ├── svl │ │ ├── Basics.h │ │ ├── Constants.h │ │ ├── LICENSE │ │ ├── Mat.h │ │ ├── Mat2.h │ │ ├── Mat3.h │ │ ├── Mat4.h │ │ ├── README │ │ ├── SVL.h │ │ ├── Transform.h │ │ ├── Utils.h │ │ ├── Vec.h │ │ ├── Vec2.h │ │ ├── Vec3.h │ │ └── Vec4.h │ ├── texture.h │ ├── tinydir.h │ └── tinythread.h ├── matt-mixer ├── matt-mixer.cpp ├── mixer ├── mixer.cpp ├── particle_trail ├── particle_trail.cpp ├── particle_trail.h ├── rings ├── rings.cpp ├── rings.h ├── simple ├── simple.cpp ├── snow.cpp ├── snow.h ├── spokes ├── spokes.cpp ├── spokes.h ├── tinydir.h ├── tlc5947_server.c ├── video.cpp └── video.h └── streamers ├── active-streamers.txt ├── burnin.py ├── cycle.py ├── every-another-white.py ├── every-other-white.py ├── map-tlc.py ├── map.py ├── opc.pyc ├── phased-cycle.py ├── props.py ├── props.pyc ├── semetry.py ├── solid-white.py ├── strobe.py └── testing-fadingaround.py /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 matt pinner 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. -------------------------------------------------------------------------------- /Processing/ActiveLayedOut/README.md: -------------------------------------------------------------------------------- 1 | ##ActivePulsing 2 | 3 | ###Author: @mpinner 4 | 5 | ##intent: create a 3d simulation of the different geometries for Active 6 | 7 | ###control: 8 | 9 | mouse button cycles the colors 10 | 11 | keyboard keys enable or disables the following mode to make it easy to view from the side 12 | * Q - places the interface in to mouse mode so you might drage the form around to view from different angles 13 | * S - puts a 90 degree rotation on the form. this is helpful to view from the side 14 | 15 | 16 | ###bugs: video capture and 3d rendering dont really play well together in processing. i'll move to the real hardware. 17 | -------------------------------------------------------------------------------- /Processing/ActiveLayedOut/README.md~: -------------------------------------------------------------------------------- 1 | ActivePulsing 2 | 3 | Author: @mpinner 4 | 5 | intent: create a 3d simulation of the different geometries for Active 6 | 7 | control: 8 | mouse button cycles the colors 9 | keyboard keys enable or disables the following mode to make it easy to view from the side 10 | Q - places the interface in to mouse mode so you might drage the form around to view from different angles 11 | S - puts a 90 degree rotation on the form. this is helpful to view from the side 12 | 13 | 14 | // bugs: video capture and 3d rendering dont really play well together in processing. i'll move to the real hardware. 15 | -------------------------------------------------------------------------------- /Processing/ActiveLayedOut/data/outfile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpinner/Active/b5e2c9df3a53bc79920fb5f17489296238b898d0/Processing/ActiveLayedOut/data/outfile.png -------------------------------------------------------------------------------- /Processing/ActiveLayedOut/data/transit.mov: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpinner/Active/b5e2c9df3a53bc79920fb5f17489296238b898d0/Processing/ActiveLayedOut/data/transit.mov -------------------------------------------------------------------------------- /Processing/ActiveLayedOut/sketch.properties: -------------------------------------------------------------------------------- 1 | coffee.editor.tabs.size=2 2 | mode.id=processing.mode.java.JavaMode 3 | mode=Java 4 | -------------------------------------------------------------------------------- /Processing/ActivePulsing/README.md: -------------------------------------------------------------------------------- 1 | ##ActivePulsing 2 | 3 | ###Author: @mpinner 4 | 5 | ##intent: create a 3d simulation of the different geometries for Active 6 | 7 | ###control: 8 | 9 | mouse button cycles the colors 10 | 11 | keyboard keys enable or disables the following mode to make it easy to view from the side 12 | * Q - places the interface in to mouse mode so you might drage the form around to view from different angles 13 | * S - puts a 90 degree rotation on the form. this is helpful to view from the side 14 | 15 | 16 | ###bugs: video capture and 3d rendering dont really play well together in processing. i'll move to the real hardware. 17 | -------------------------------------------------------------------------------- /Processing/ActivePulsingCoordinates/README.md: -------------------------------------------------------------------------------- 1 | ##ActivePulsing 2 | 3 | ###Author: @mpinner 4 | 5 | ##intent: create a 3d simulation of the different geometries for Active 6 | 7 | ###control: 8 | 9 | mouse button cycles the colors 10 | 11 | keyboard keys enable or disables the following mode to make it easy to view from the side 12 | * Q - places the interface in to mouse mode so you might drage the form around to view from different angles 13 | * S - puts a 90 degree rotation on the form. this is helpful to view from the side 14 | 15 | 16 | ###bugs: video capture and 3d rendering dont really play well together in processing. i'll move to the real hardware. 17 | -------------------------------------------------------------------------------- /Processing/ActivePulsingCoordinates/README.md~: -------------------------------------------------------------------------------- 1 | ActivePulsing 2 | 3 | Author: @mpinner 4 | 5 | intent: create a 3d simulation of the different geometries for Active 6 | 7 | control: 8 | mouse button cycles the colors 9 | keyboard keys enable or disables the following mode to make it easy to view from the side 10 | Q - places the interface in to mouse mode so you might drage the form around to view from different angles 11 | S - puts a 90 degree rotation on the form. this is helpful to view from the side 12 | 13 | 14 | // bugs: video capture and 3d rendering dont really play well together in processing. i'll move to the real hardware. 15 | -------------------------------------------------------------------------------- /Processing/ActivePulsingCoordinates/data/outfile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpinner/Active/b5e2c9df3a53bc79920fb5f17489296238b898d0/Processing/ActivePulsingCoordinates/data/outfile.png -------------------------------------------------------------------------------- /Processing/ActivePulsingCoordinates/data/transit.mov: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpinner/Active/b5e2c9df3a53bc79920fb5f17489296238b898d0/Processing/ActivePulsingCoordinates/data/transit.mov -------------------------------------------------------------------------------- /Processing/ActivePulsingCoordinates/sketch.properties: -------------------------------------------------------------------------------- 1 | coffee.editor.tabs.size=2 2 | mode.id=processing.mode.java.JavaMode 3 | mode=Java 4 | -------------------------------------------------------------------------------- /Processing/ActivePulsingCoordinates/web-export/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | ActivePulsingCoordinates : Built with Processing and Processing.js 5 | 6 | 7 | 15 | 46 | 49 | 50 | 54 | 55 | 56 | 57 |
58 |
59 | 61 |

Your browser does not support the canvas tag.

62 | 63 |
64 | 67 |
68 |

ActivePulsingCoordinates

69 |

70 |

Source code: ActivePulsingCoordinates

71 |

72 | Built with Processing 73 | and Processing.js 74 |

75 |
76 | 77 | 78 | -------------------------------------------------------------------------------- /Processing/ActivePulsingCoordinates/web-export/outfile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpinner/Active/b5e2c9df3a53bc79920fb5f17489296238b898d0/Processing/ActivePulsingCoordinates/web-export/outfile.png -------------------------------------------------------------------------------- /Processing/ActivePulsingCoordinates/web-export/transit.mov: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpinner/Active/b5e2c9df3a53bc79920fb5f17489296238b898d0/Processing/ActivePulsingCoordinates/web-export/transit.mov -------------------------------------------------------------------------------- /Processing/ActivePulsingDeDupped/README.md: -------------------------------------------------------------------------------- 1 | ##ActivePulsing 2 | 3 | ###Author: @mpinner 4 | 5 | ##intent: create a 3d simulation of the different geometries for Active 6 | 7 | ###control: 8 | 9 | mouse button cycles the colors 10 | 11 | keyboard keys enable or disables the following mode to make it easy to view from the side 12 | * Q - places the interface in to mouse mode so you might drage the form around to view from different angles 13 | * S - puts a 90 degree rotation on the form. this is helpful to view from the side 14 | 15 | 16 | ###bugs: video capture and 3d rendering dont really play well together in processing. i'll move to the real hardware. 17 | -------------------------------------------------------------------------------- /Processing/ActivePulsingDeDupped/README.md~: -------------------------------------------------------------------------------- 1 | ActivePulsing 2 | 3 | Author: @mpinner 4 | 5 | intent: create a 3d simulation of the different geometries for Active 6 | 7 | control: 8 | mouse button cycles the colors 9 | keyboard keys enable or disables the following mode to make it easy to view from the side 10 | Q - places the interface in to mouse mode so you might drage the form around to view from different angles 11 | S - puts a 90 degree rotation on the form. this is helpful to view from the side 12 | 13 | 14 | // bugs: video capture and 3d rendering dont really play well together in processing. i'll move to the real hardware. 15 | -------------------------------------------------------------------------------- /Processing/ActivePulsingDeDupped/data/outfile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpinner/Active/b5e2c9df3a53bc79920fb5f17489296238b898d0/Processing/ActivePulsingDeDupped/data/outfile.png -------------------------------------------------------------------------------- /Processing/ActivePulsingImgs/README.md: -------------------------------------------------------------------------------- 1 | ##ActivePulsing 2 | 3 | ###Author: @mpinner 4 | 5 | ##intent: create a 3d simulation of the different geometries for Active 6 | 7 | ###control: 8 | 9 | mouse button cycles the colors 10 | 11 | keyboard keys enable or disables the following mode to make it easy to view from the side 12 | * Q - places the interface in to mouse mode so you might drage the form around to view from different angles 13 | * S - puts a 90 degree rotation on the form. this is helpful to view from the side 14 | 15 | 16 | ###bugs: video capture and 3d rendering dont really play well together in processing. i'll move to the real hardware. 17 | -------------------------------------------------------------------------------- /Processing/ActivePulsingImgs/README.md~: -------------------------------------------------------------------------------- 1 | ActivePulsing 2 | 3 | Author: @mpinner 4 | 5 | intent: create a 3d simulation of the different geometries for Active 6 | 7 | control: 8 | mouse button cycles the colors 9 | keyboard keys enable or disables the following mode to make it easy to view from the side 10 | Q - places the interface in to mouse mode so you might drage the form around to view from different angles 11 | S - puts a 90 degree rotation on the form. this is helpful to view from the side 12 | 13 | 14 | // bugs: video capture and 3d rendering dont really play well together in processing. i'll move to the real hardware. 15 | -------------------------------------------------------------------------------- /Processing/ActivePulsingImgs/data/outfile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpinner/Active/b5e2c9df3a53bc79920fb5f17489296238b898d0/Processing/ActivePulsingImgs/data/outfile.png -------------------------------------------------------------------------------- /Processing/ActivePulsingImgs/data/transit.mov: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpinner/Active/b5e2c9df3a53bc79920fb5f17489296238b898d0/Processing/ActivePulsingImgs/data/transit.mov -------------------------------------------------------------------------------- /Processing/ActivePulsingRangedX/README.md: -------------------------------------------------------------------------------- 1 | ##ActivePulsing 2 | 3 | ###Author: @mpinner 4 | 5 | ##intent: create a 3d simulation of the different geometries for Active 6 | 7 | ###control: 8 | 9 | mouse button cycles the colors 10 | 11 | keyboard keys enable or disables the following mode to make it easy to view from the side 12 | * Q - places the interface in to mouse mode so you might drage the form around to view from different angles 13 | * S - puts a 90 degree rotation on the form. this is helpful to view from the side 14 | 15 | 16 | ###bugs: video capture and 3d rendering dont really play well together in processing. i'll move to the real hardware. 17 | -------------------------------------------------------------------------------- /Processing/ActivePulsingRangedX/README.md~: -------------------------------------------------------------------------------- 1 | ActivePulsing 2 | 3 | Author: @mpinner 4 | 5 | intent: create a 3d simulation of the different geometries for Active 6 | 7 | control: 8 | mouse button cycles the colors 9 | keyboard keys enable or disables the following mode to make it easy to view from the side 10 | Q - places the interface in to mouse mode so you might drage the form around to view from different angles 11 | S - puts a 90 degree rotation on the form. this is helpful to view from the side 12 | 13 | 14 | // bugs: video capture and 3d rendering dont really play well together in processing. i'll move to the real hardware. 15 | -------------------------------------------------------------------------------- /Processing/ActivePulsingVideo/README.md: -------------------------------------------------------------------------------- 1 | ##ActivePulsing 2 | 3 | ###Author: @mpinner 4 | 5 | ##intent: create a 3d simulation of the different geometries for Active 6 | 7 | ###control: 8 | 9 | mouse button cycles the colors 10 | 11 | keyboard keys enable or disables the following mode to make it easy to view from the side 12 | * Q - places the interface in to mouse mode so you might drage the form around to view from different angles 13 | * S - puts a 90 degree rotation on the form. this is helpful to view from the side 14 | 15 | 16 | ###bugs: video capture and 3d rendering dont really play well together in processing. i'll move to the real hardware. 17 | -------------------------------------------------------------------------------- /Processing/ActivePulsingVideo/README.md~: -------------------------------------------------------------------------------- 1 | ActivePulsing 2 | 3 | Author: @mpinner 4 | 5 | intent: create a 3d simulation of the different geometries for Active 6 | 7 | control: 8 | mouse button cycles the colors 9 | keyboard keys enable or disables the following mode to make it easy to view from the side 10 | Q - places the interface in to mouse mode so you might drage the form around to view from different angles 11 | S - puts a 90 degree rotation on the form. this is helpful to view from the side 12 | 13 | 14 | // bugs: video capture and 3d rendering dont really play well together in processing. i'll move to the real hardware. 15 | -------------------------------------------------------------------------------- /Processing/ActivePulsingVideo/data/fingers.mov: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpinner/Active/b5e2c9df3a53bc79920fb5f17489296238b898d0/Processing/ActivePulsingVideo/data/fingers.mov -------------------------------------------------------------------------------- /Processing/ActivePulsingVideo/data/outfile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpinner/Active/b5e2c9df3a53bc79920fb5f17489296238b898d0/Processing/ActivePulsingVideo/data/outfile.png -------------------------------------------------------------------------------- /Processing/ActivePulsingVideo/data/transit.mov: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpinner/Active/b5e2c9df3a53bc79920fb5f17489296238b898d0/Processing/ActivePulsingVideo/data/transit.mov -------------------------------------------------------------------------------- /Processing/bitmap_generator_opc/sketch.properties: -------------------------------------------------------------------------------- 1 | mode.id=processing.mode.java.JavaMode 2 | mode=Java 3 | -------------------------------------------------------------------------------- /Processing/opcParticles/Particle.pde: -------------------------------------------------------------------------------- 1 | class Particle { 2 | 3 | PVector pos; 4 | float movingArea; 5 | 6 | PVector tail[]; 7 | int tailPosIndex; 8 | int tailLength; 9 | 10 | float psize; 11 | 12 | float inc1, inc2, inc3; 13 | float inc1Increment = random(0.01, 0.05); 14 | float inc2Increment = random(0.01, 0.05); 15 | float inc3Increment = random(0.01, 0.05); 16 | 17 | Particle() { 18 | pos = new PVector(0, 0, 0); 19 | psize = random(0.1, 10.0); 20 | 21 | tailPosIndex = 0; 22 | tailLength = int(psize * 10); 23 | tail = new PVector[tailLength]; 24 | 25 | inc1 = random(TWO_PI); 26 | inc2 = random(TWO_PI); 27 | inc3 = random(TWO_PI); 28 | 29 | movingArea = 120 - tailLength; 30 | } 31 | 32 | void draw() { 33 | updatePosition(); 34 | drawTail(); 35 | } 36 | 37 | void updatePosition() { 38 | inc1 += inc1Increment; 39 | inc2 += inc2Increment; 40 | inc3 += inc3Increment; 41 | 42 | pos.x = sin(inc1) * movingArea; 43 | pos.y = cos(inc2) * movingArea; 44 | pos.z = sin(inc3) * movingArea; 45 | tail[tailPosIndex] = new PVector(pos.x, pos.y, pos.z); 46 | } 47 | 48 | void drawTail() { 49 | float xp, yp, zp; 50 | float xOff, yOff, zOff; 51 | int nullPos = 0; 52 | beginShape(QUAD_STRIP); 53 | for (int i = 0; i < tailLength; i++) { 54 | int index = (i + tailPosIndex + 1) % tailLength; 55 | if ( i < tailLength - 1 && tail[index] != null) { 56 | float per = (i - nullPos) / float(tailLength - nullPos); 57 | xp = tail[index].x; 58 | yp = tail[index].y; 59 | zp = tail[index].z; 60 | int nextIndex = (i + tailPosIndex + 2) % tailLength; 61 | PVector v0 = PVector.sub(tail[index], tail[nextIndex]); 62 | PVector v1 = v0.cross(new PVector(0, 1, 0)); 63 | v1.normalize(); 64 | PVector v2 = v0.cross(v1); 65 | v2.normalize(); 66 | v1 = v0.cross(v2); 67 | v1.normalize(); 68 | xOff = v1.x * psize * per; 69 | yOff = v1.y * psize * per; 70 | zOff = v1.z * psize * per; 71 | 72 | fill(255, 255 * per); 73 | 74 | vertex(xp - xOff, yp - yOff, zp - zOff); 75 | vertex(xp + xOff, yp + yOff, zp + zOff); 76 | } 77 | else nullPos++; 78 | } 79 | endShape(); 80 | 81 | tailPosIndex++; 82 | tailPosIndex %= tailLength; 83 | } 84 | } 85 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /Processing/opcParticles/opcParticles.pde: -------------------------------------------------------------------------------- 1 | Particle[] particles; 2 | int particlesAmount = 5; 3 | 4 | import img2opc.*; 5 | import processing.net.*; 6 | 7 | Img2Opc i2o; 8 | 9 | PImage pixelBuffer; 10 | 11 | int displayWidth = 60; 12 | int displayHeight = 24; 13 | 14 | 15 | void setup() { 16 | 17 | frameRate(30); 18 | 19 | size(720, 480, P3D); 20 | particles = new Particle[particlesAmount]; 21 | for (int i = 0; i < particlesAmount; i++) { 22 | particles[i] = new Particle(); 23 | } 24 | noStroke(); 25 | 26 | pixelBuffer = new PImage(displayWidth, displayHeight, RGB); 27 | i2o = new Img2Opc(this, "localhost", 7890, displayWidth, displayHeight); 28 | i2o.setSourceSize(width, height); 29 | for (int i = 0; i < 1440; i++) { 30 | pixelBuffer.pixels[i] = 255; 31 | } 32 | pixelBuffer.updatePixels(); 33 | image(pixelBuffer, 0, 0); 34 | pixelBuffer.loadPixels(); 35 | i2o.sendImg(pixelBuffer); 36 | 37 | } 38 | 39 | void draw() { 40 | background(0); 41 | lights(); 42 | directionalLight(255, 0, 145, -1, 0, 0); 43 | directionalLight(220, 30, 30, 1, 0, 0); 44 | camera(0, 0, (height * 0.2) / tan(PI * 60.0 / 360.0), 0, 0, 0, 0, 1, 0); 45 | 46 | for (int i = 0; i < particlesAmount; i++) { 47 | rotateZ(radians(mouseX)); 48 | rotateY(radians(mouseY)); 49 | 50 | particles[i].draw(); 51 | 52 | 53 | } 54 | 55 | // pull image from the screen 56 | pixelBuffer = get(); 57 | pixelBuffer.updatePixels(); 58 | 59 | // for (int i = 0; i < (displayWidth*displayHeight); i++) { 60 | 61 | 62 | //pixelBuffer.pixels[i] = color(255, 255, 255); 63 | // } 64 | 65 | i2o.sendImg(pixelBuffer, false); 66 | 67 | return; 68 | 69 | } 70 | 71 | -------------------------------------------------------------------------------- /Processing/opcParticles3d/Particle.pde: -------------------------------------------------------------------------------- 1 | class Particle { 2 | 3 | PVector pos; 4 | float movingArea; 5 | 6 | PVector tail[]; 7 | int tailPosIndex; 8 | int tailLength; 9 | 10 | float psize; 11 | 12 | float inc1, inc2, inc3; 13 | float inc1Increment = random(0.01, 0.05); 14 | float inc2Increment = random(0.01, 0.05); 15 | float inc3Increment = random(0.01, 0.05); 16 | 17 | Particle() { 18 | pos = new PVector(0, 0, 0); 19 | psize = random(0.1, 10.0); 20 | 21 | tailPosIndex = 0; 22 | tailLength = int(psize * 10); 23 | tail = new PVector[tailLength]; 24 | 25 | inc1 = random(TWO_PI); 26 | inc2 = random(TWO_PI); 27 | inc3 = random(TWO_PI); 28 | 29 | movingArea = 80 - tailLength; 30 | } 31 | 32 | void draw() { 33 | updatePosition(); 34 | drawTail(); 35 | } 36 | 37 | void updatePosition() { 38 | inc1 += inc1Increment; 39 | inc2 += inc2Increment; 40 | inc3 += inc3Increment; 41 | 42 | pos.x = sin(inc1) * movingArea * 2; 43 | pos.y = cos(inc2) * movingArea; 44 | pos.z = sin(inc3) * movingArea; 45 | tail[tailPosIndex] = new PVector(pos.x, pos.y, pos.z); 46 | } 47 | 48 | void drawTail() { 49 | float xp, yp, zp; 50 | float xOff, yOff, zOff; 51 | int nullPos = 0; 52 | beginShape(QUAD_STRIP); 53 | for (int i = 0; i < tailLength; i++) { 54 | int index = (i + tailPosIndex + 1) % tailLength; 55 | if ( i < tailLength - 1 && tail[index] != null) { 56 | float per = (i - nullPos) / float(tailLength - nullPos); 57 | xp = tail[index].x; 58 | yp = tail[index].y; 59 | zp = tail[index].z; 60 | int nextIndex = (i + tailPosIndex + 2) % tailLength; 61 | PVector v0 = PVector.sub(tail[index], tail[nextIndex]); 62 | PVector v1 = v0.cross(new PVector(0, 1, 0)); 63 | v1.normalize(); 64 | PVector v2 = v0.cross(v1); 65 | v2.normalize(); 66 | v1 = v0.cross(v2); 67 | v1.normalize(); 68 | xOff = v1.x * psize * per; 69 | yOff = v1.y * psize * per; 70 | zOff = v1.z * psize * per; 71 | 72 | fill(255, 255 * per); 73 | 74 | vertex(xp - xOff, yp - yOff, zp - zOff); 75 | vertex(xp + xOff, yp + yOff, zp + zOff); 76 | } 77 | else nullPos++; 78 | } 79 | endShape(); 80 | 81 | tailPosIndex++; 82 | tailPosIndex %= tailLength; 83 | } 84 | } 85 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /Processing/opcParticles3d/opcParticles3d.pde: -------------------------------------------------------------------------------- 1 | Particle[] particles; 2 | int particlesAmount = 5; 3 | 4 | import img2opc.*; 5 | import processing.net.*; 6 | 7 | Img2Opc i2o; 8 | 9 | PImage pixelBuffer; 10 | 11 | int displayWidth = 60; 12 | int displayHeight = 24; 13 | 14 | 15 | void setup() { 16 | 17 | frameRate(30); 18 | 19 | size(720, 480, P3D); 20 | particles = new Particle[particlesAmount]; 21 | for (int i = 0; i < particlesAmount; i++) { 22 | particles[i] = new Particle(); 23 | } 24 | noStroke(); 25 | 26 | pixelBuffer = new PImage(displayWidth, displayHeight, RGB); 27 | i2o = new Img2Opc(this, "localhost", 7890, displayWidth, displayHeight); 28 | i2o.setSourceSize(displayWidth, displayWidth); 29 | for (int i = 0; i < 1440; i++) { 30 | pixelBuffer.pixels[i] = 255; 31 | } 32 | pixelBuffer.updatePixels(); 33 | image(pixelBuffer, 0, 0); 34 | pixelBuffer.loadPixels(); 35 | i2o.sendImg(pixelBuffer); 36 | } 37 | 38 | void draw() { 39 | background(0); 40 | lights(); 41 | directionalLight(255, 0, 145, -1, 0, 0); 42 | directionalLight(220, 30, 30, 1, 0, 0); 43 | camera(0, 0, (height * 0.2) / tan(PI * 60.0 / 360.0), 0, 0, 0, 0, 1, 0); 44 | 45 | for (int i = 0; i < particlesAmount; i++) { 46 | rotateZ(radians(mouseX)); 47 | rotateY(radians(mouseY)); 48 | 49 | particles[i].draw(); 50 | } 51 | 52 | // pull image from the screen 53 | // pixelBuffer = get(); 54 | pixelBuffer.updatePixels(); 55 | 56 | for (int i = 0; i < (displayWidth*displayHeight); i++) { 57 | 58 | int x = i % 60; 59 | int y = i / 60; 60 | int z = Active.coordinate[x*24+y][2]; 61 | 62 | 63 | 64 | int index = y * 24 + x; 65 | 66 | // pixelBuffer.pixels[i] = color(255, 255, 255); 67 | float shortest = 255.0; 68 | 69 | for (int j = 0; j < particlesAmount; j++) { 70 | 71 | 72 | PVector activePoint = new PVector( 73 | (x- displayWidth/2) * 5, 74 | (y- displayHeight/2) * 3, 75 | (z- displayHeight/2) * 3); 76 | 77 | 78 | float distance = activePoint.dist(particles[j].pos); 79 | // float distance = activePoint.dist(new PVector(0.0,0.0,0.0)); 80 | 81 | if (shortest > distance) { 82 | shortest = distance; 83 | } 84 | 85 | if (i == 0) { 86 | 87 | print(shortest + "\n"); 88 | pixelBuffer.pixels[i] = color(shortest, shortest, shortest); 89 | 90 | print ("j"+j+" x,y,z: "+particles[j].pos.x+","+particles[j].pos.y+","+particles[j].pos.z+"\n"); 91 | print (" x,y,z: "+activePoint.x+","+activePoint.y+","+activePoint.z+"\n"); 92 | 93 | 94 | } 95 | 96 | //shortest *= 5; 97 | 98 | if ( shortest < 50 ) { 99 | shortest = map(shortest, 0, 50, 255, 0); 100 | } else { 101 | shortest = 0; 102 | 103 | } 104 | 105 | 106 | 107 | /*if ( ((millis()/250) % 24) == z ){ 108 | shortest = 255; 109 | } else { 110 | shortest = 0; 111 | } 112 | */ 113 | pixelBuffer.pixels[i] = color(shortest, shortest, shortest); 114 | } 115 | 116 | } 117 | 118 | 119 | for (int j = 0; j < particlesAmount; j++) { 120 | 121 | //print ("j"+j+" x,y,z: "+particles[j].pos.x+","+particles[j].pos.y+","+particles[j].pos.z+"\n"); 122 | 123 | } 124 | 125 | 126 | 127 | i2o.sendImg(pixelBuffer, true); 128 | 129 | return; 130 | } 131 | 132 | -------------------------------------------------------------------------------- /Processing/opcSphere3d/Particle.pde: -------------------------------------------------------------------------------- 1 | class Particle { 2 | 3 | PVector pos; 4 | float movingArea; 5 | 6 | PVector tail[]; 7 | int tailPosIndex; 8 | int tailLength; 9 | 10 | float psize; 11 | 12 | float inc1, inc2, inc3; 13 | float inc1Increment = random(0.01, 0.05); 14 | float inc2Increment = random(0.01, 0.05); 15 | float inc3Increment = random(0.01, 0.05); 16 | 17 | Particle() { 18 | pos = new PVector(0, 0, 0); 19 | psize = random(0.1, 10.0); 20 | 21 | tailPosIndex = 0; 22 | tailLength = int(psize * 10); 23 | tail = new PVector[tailLength]; 24 | 25 | inc1 = random(TWO_PI); 26 | inc2 = random(TWO_PI); 27 | inc3 = random(TWO_PI); 28 | 29 | movingArea = 80 - tailLength; 30 | } 31 | 32 | void draw() { 33 | updatePosition(); 34 | drawTail(); 35 | } 36 | 37 | void updatePosition() { 38 | inc1 += inc1Increment; 39 | inc2 += inc2Increment; 40 | inc3 += inc3Increment; 41 | 42 | pos.x = sin(inc1) * movingArea * 2; 43 | pos.y = cos(inc2) * movingArea; 44 | pos.z = sin(inc3) * movingArea; 45 | tail[tailPosIndex] = new PVector(pos.x, pos.y, pos.z); 46 | } 47 | 48 | void drawTail() { 49 | float xp, yp, zp; 50 | float xOff, yOff, zOff; 51 | int nullPos = 0; 52 | beginShape(QUAD_STRIP); 53 | for (int i = 0; i < tailLength; i++) { 54 | int index = (i + tailPosIndex + 1) % tailLength; 55 | if ( i < tailLength - 1 && tail[index] != null) { 56 | float per = (i - nullPos) / float(tailLength - nullPos); 57 | xp = tail[index].x; 58 | yp = tail[index].y; 59 | zp = tail[index].z; 60 | int nextIndex = (i + tailPosIndex + 2) % tailLength; 61 | PVector v0 = PVector.sub(tail[index], tail[nextIndex]); 62 | PVector v1 = v0.cross(new PVector(0, 1, 0)); 63 | v1.normalize(); 64 | PVector v2 = v0.cross(v1); 65 | v2.normalize(); 66 | v1 = v0.cross(v2); 67 | v1.normalize(); 68 | xOff = v1.x * psize * per; 69 | yOff = v1.y * psize * per; 70 | zOff = v1.z * psize * per; 71 | 72 | fill(255, 255 * per); 73 | 74 | vertex(xp - xOff, yp - yOff, zp - zOff); 75 | vertex(xp + xOff, yp + yOff, zp + zOff); 76 | } 77 | else nullPos++; 78 | } 79 | endShape(); 80 | 81 | tailPosIndex++; 82 | tailPosIndex %= tailLength; 83 | } 84 | } 85 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /Processing/opcSphere3d/opcSphere3d.pde: -------------------------------------------------------------------------------- 1 | Particle[] particles; 2 | int particlesAmount = 5; 3 | 4 | import img2opc.*; 5 | import processing.net.*; 6 | 7 | Img2Opc i2o; 8 | 9 | PImage pixelBuffer; 10 | 11 | int displayWidth = 60; 12 | int displayHeight = 24; 13 | 14 | 15 | void setup() { 16 | 17 | frameRate(30); 18 | 19 | size(720, 480, P3D); 20 | particles = new Particle[particlesAmount]; 21 | for (int i = 0; i < particlesAmount; i++) { 22 | particles[i] = new Particle(); 23 | } 24 | noStroke(); 25 | 26 | pixelBuffer = new PImage(displayWidth, displayHeight, RGB); 27 | i2o = new Img2Opc(this, "localhost", 7890, displayWidth, displayHeight); 28 | i2o.setSourceSize(displayWidth, displayWidth); 29 | for (int i = 0; i < 1440; i++) { 30 | pixelBuffer.pixels[i] = 255; 31 | } 32 | pixelBuffer.updatePixels(); 33 | image(pixelBuffer, 0, 0); 34 | pixelBuffer.loadPixels(); 35 | i2o.sendImg(pixelBuffer); 36 | } 37 | 38 | void draw() { 39 | background(0); 40 | lights(); 41 | directionalLight(255, 0, 145, -1, 0, 0); 42 | directionalLight(220, 30, 30, 1, 0, 0); 43 | camera(0, 0, (height * 0.2) / tan(PI * 60.0 / 360.0), 0, 0, 0, 0, 1, 0); 44 | 45 | for (int i = 0; i < particlesAmount; i++) { 46 | rotateZ(radians(mouseX)); 47 | rotateY(radians(mouseY)); 48 | 49 | particles[i].draw(); 50 | } 51 | 52 | // pull image from the screen 53 | // pixelBuffer = get(); 54 | pixelBuffer.updatePixels(); 55 | 56 | for (int i = 0; i < (displayWidth*displayHeight); i++) { 57 | 58 | int x = i % 60; 59 | int y = i / 60; 60 | int z = Active.coordinate[x*24+y][2]; 61 | 62 | 63 | 64 | int index = y * 24 + x; 65 | 66 | // pixelBuffer.pixels[i] = color(255, 255, 255); 67 | float shortest = 255.0; 68 | 69 | for (int j = 0; j < particlesAmount; j++) { 70 | 71 | 72 | PVector activePoint = new PVector( 73 | (x- displayWidth/2), 74 | (y- displayHeight/2), 75 | (z- displayHeight/2)); 76 | 77 | 78 | // float distance = activePoint.dist(particles[j].pos); 79 | float distance = activePoint.dist(new PVector(0.0,0.0,0.0)); 80 | 81 | if (shortest > distance) { 82 | shortest = distance; 83 | } 84 | 85 | if (i == 0) { 86 | 87 | print(shortest + "\n"); 88 | pixelBuffer.pixels[i] = color(shortest, shortest, shortest); 89 | 90 | print ("j"+j+" x,y,z: "+particles[j].pos.x+","+particles[j].pos.y+","+particles[j].pos.z+"\n"); 91 | print (" x,y,z: "+activePoint.x+","+activePoint.y+","+activePoint.z+"\n"); 92 | 93 | 94 | } 95 | 96 | float speed = 1.0; 97 | float cycle = (millis()/250 * speed) % TWO_PI; 98 | float wave = sin(distance/2 - cycle);// + noise3(p.point); 99 | shortest= wave *255; 100 | 101 | 102 | //shortest *= 5; 103 | /* 104 | if ( shortest < 50 ) { 105 | shortest = map(shortest, 0, 50, 255, 0); 106 | } else { 107 | shortest = 0; 108 | 109 | } 110 | */ 111 | 112 | 113 | /*if ( ((millis()/250) % 24) == z ){ 114 | shortest = 255; 115 | } else { 116 | shortest = 0; 117 | } 118 | */ 119 | pixelBuffer.pixels[i] = color(shortest, shortest, shortest); 120 | } 121 | 122 | } 123 | 124 | 125 | for (int j = 0; j < particlesAmount; j++) { 126 | 127 | //print ("j"+j+" x,y,z: "+particles[j].pos.x+","+particles[j].pos.y+","+particles[j].pos.z+"\n"); 128 | 129 | } 130 | 131 | 132 | 133 | i2o.sendImg(pixelBuffer, true); 134 | 135 | return; 136 | } 137 | 138 | -------------------------------------------------------------------------------- /Processing/positionData/data/positions.txt: -------------------------------------------------------------------------------- 1 | 70 35 2 | 69 35 3 | 68 39 4 | 67 42 5 | 66 47 6 | 64 51 7 | 64 54 8 | 63 57 9 | 60 60 10 | 58 64 11 | 51 69 12 | 48 72 13 | 44 73 14 | 39 75 15 | 35 75 16 | 30 75 17 | 25 75 18 | 21 75 19 | 17 73 20 | 13 69 21 | 12 66 22 | 11 61 23 | 11 57 24 | 10 49 25 | 10 45 26 | 10 38 27 | 12 32 28 | 13 29 29 | 16 23 30 | 20 19 31 | 24 16 32 | 27 15 33 | 31 13 34 | 33 13 35 | 37 13 36 | 40 15 37 | 42 16 38 | 45 19 39 | 46 21 40 | 47 24 41 | 48 26 42 | 48 29 43 | 48 33 44 | 47 39 45 | 43 45 46 | 42 47 47 | 38 50 48 | 35 51 49 | 32 51 50 | 30 51 51 | 27 50 52 | 27 50 53 | 26 46 54 | 26 41 55 | 29 36 56 | 30 34 57 | 31 33 58 | 31 33 59 | 32 33 60 | 33 33 61 | 34 33 62 | 34 33 63 | 35 33 64 | 37 33 65 | 39 33 66 | 42 32 67 | 44 31 68 | 46 29 69 | 48 29 70 | 49 27 71 | 52 24 72 | 53 23 73 | 57 19 74 | 61 16 75 | 63 14 76 | 67 13 77 | 69 12 78 | 69 12 79 | 77 11 80 | 77 11 81 | 80 11 82 | 86 16 83 | 90 21 84 | 93 25 85 | 95 29 86 | 95 32 87 | 95 33 88 | 95 37 89 | 94 41 90 | 93 44 91 | 92 46 92 | 91 49 93 | 89 51 94 | 87 55 95 | 85 59 96 | 82 62 97 | 80 64 98 | 79 67 99 | 77 69 100 | 74 71 101 | 68 72 102 | 65 73 103 | 63 73 104 | 62 73 105 | 60 72 106 | 58 69 107 | 57 67 108 | 57 66 109 | 56 60 110 | 56 56 111 | 56 54 112 | 58 49 113 | 60 47 114 | 62 47 115 | 63 47 116 | 67 48 117 | 70 52 118 | 73 55 119 | 74 57 120 | 74 58 121 | 74 60 122 | 74 62 123 | 73 65 124 | 70 68 125 | 67 69 126 | 65 70 127 | 63 70 128 | 62 70 129 | 60 68 130 | 57 65 131 | 55 64 132 | 50 62 133 | 46 61 134 | 40 60 135 | 38 60 136 | 36 60 137 | 32 61 138 | 30 62 139 | 27 64 140 | 26 68 141 | 25 71 142 | 25 77 143 | 25 81 144 | 26 84 145 | 28 86 146 | 31 87 147 | 33 88 148 | 36 88 149 | 39 86 150 | 41 85 151 | 43 83 152 | 44 81 153 | 45 76 154 | 45 74 155 | 45 71 156 | 40 67 157 | 37 65 158 | 34 63 159 | 33 61 160 | 33 61 161 | 32 60 162 | 33 49 163 | 37 45 164 | 41 41 165 | 45 39 166 | 47 38 167 | 51 37 168 | 54 37 169 | 58 38 170 | 61 41 171 | 63 44 172 | 65 46 173 | 66 49 174 | 66 51 175 | 67 55 176 | 67 58 177 | 67 60 178 | 66 62 179 | 64 65 180 | 63 66 181 | 61 67 182 | 60 68 183 | 58 68 184 | 55 69 185 | 54 69 186 | 51 69 187 | 48 69 188 | 46 68 189 | 45 66 190 | 44 65 191 | 44 63 192 | 44 61 193 | 44 59 194 | 44 56 195 | 44 55 196 | 45 53 197 | 47 52 198 | 49 50 199 | 50 48 200 | 51 47 201 | 52 46 202 | 54 46 203 | 55 45 204 | 55 45 205 | 56 44 206 | 57 44 207 | -------------------------------------------------------------------------------- /Processing/positionData/positionData.pde: -------------------------------------------------------------------------------- 1 | /** 2 | * LoadFile 1 3 | * 4 | * Loads a text file that contains two numbers separated by a tab ('\t'). 5 | * A new pair of numbers is loaded each frame and used to draw a point on the screen. 6 | */ 7 | 8 | String[] lines; 9 | int index = 0; 10 | 11 | void setup() { 12 | size(500, 500, P3D); 13 | background(0); 14 | 15 | noStroke(); 16 | frameRate(60); 17 | lights(); 18 | 19 | lines = loadStrings("trim.csv"); 20 | } 21 | 22 | void draw() { 23 | if (index < lines.length) { 24 | String[] pieces = split(lines[index], ' '); 25 | if (pieces.length == 3) { 26 | float x = abs(float(pieces[0]) * 300); 27 | float y = abs(float(pieces[1]) * 200); 28 | float z = abs(float(pieces[2])); 29 | translate((int)x-300, (int)y, (int)z-10); 30 | fill(frameCount/3%250); 31 | sphere(10); 32 | println(x+","+y+","+z); 33 | } 34 | // Go to the next line for the next run through draw() 35 | index = index + 1; 36 | } 37 | } -------------------------------------------------------------------------------- /Processing/ringArtNetOpcOsc_spin/data/dot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpinner/Active/b5e2c9df3a53bc79920fb5f17489296238b898d0/Processing/ringArtNetOpcOsc_spin/data/dot.png -------------------------------------------------------------------------------- /Processing/ringArtNetOpcOsc_spin/ringArtNetOpcOsc_spin.pde: -------------------------------------------------------------------------------- 1 | OPC opc; 2 | PImage dot; 3 | 4 | 5 | import oscP5.*; 6 | import netP5.*; 7 | 8 | OscP5 osc; 9 | NetAddress oscOut; 10 | 11 | HashMap position = new HashMap(); 12 | 13 | OscMessage msg = new OscMessage("/default"); 14 | 15 | void setup() 16 | { 17 | size(500, 500); 18 | 19 | osc = new OscP5(this,12000); 20 | oscOut = new NetAddress("127.0.0.1",8017); 21 | 22 | 23 | 24 | 25 | // Load a sample image 26 | dot = loadImage("dot.png"); 27 | 28 | // Connect to the local instance of fcserver 29 | opc = new OPC(this, "127.0.0.1", 7890); 30 | 31 | // Map one 24-LED ring to the center of the window 32 | opc.ledRing(0, 4, width/2, height/2, width*0.3, 0); 33 | opc.ledRing(4, 4, width/2, height/2, width*0.1, 0); 34 | } 35 | 36 | 37 | 38 | 39 | void drawDot(float angle, float distance, float size) 40 | { 41 | image(dot, width/2 - distance * sin(angle) - size/2, 42 | height/2 - distance * cos(angle) - size/2, size, size); 43 | } 44 | 45 | void draw() 46 | { 47 | background(0); 48 | 49 | float a = millis(); 50 | 51 | blendMode(ADD); 52 | tint(40, 0, 130); 53 | drawDot(a * -0.002, width*0.2, width*0.6); 54 | 55 | tint(155, 155, 155); 56 | drawDot(a * -0.001, width*0.2, width*0.6); 57 | 58 | tint(90, 90, 155); 59 | drawDot(a * 0.001, width*0.1, width*0.6); 60 | 61 | 62 | int msgSize = 44; 63 | 64 | // todo: impl position 65 | msgSize = 24; 66 | 67 | 68 | // traditional artnet 24 channel 69 | int colorChannels = 3 ; // rgb 70 | for(int i = 0; i < msgSize/colorChannels; i++ ) { 71 | 72 | color pixel = opc.getPixel(i); 73 | msg.add(red(pixel)); 74 | msg.add(green(pixel)); 75 | msg.add(blue(pixel)); 76 | 77 | 78 | 79 | } 80 | 81 | 82 | 83 | 84 | 85 | //osc sending 86 | msg.setAddrPattern("/artnet" ); 87 | osc.send(msg, oscOut); 88 | msg.clear(); 89 | 90 | 91 | 92 | 93 | } -------------------------------------------------------------------------------- /Processing/scanningBar/data/monjori.glsl: -------------------------------------------------------------------------------- 1 | #define PROCESSING_COLOR_SHADER 2 | 3 | uniform vec2 resolution; 4 | uniform float time; 5 | 6 | void main(void) { 7 | vec2 p = -1.0 + 2.0 * gl_FragCoord.xy / resolution.xy; 8 | float a = time*40.0; 9 | float d,e,f,g=1.0/40.0,h,i,r,q; 10 | e=400.0*(p.x*0.5+0.5); 11 | f=400.0*(p.y*0.5+0.5); 12 | i=200.0+sin(e*g+a/150.0)*20.0; 13 | d=200.0+cos(f*g/2.0)*18.0+cos(e*g)*7.0; 14 | r=sqrt(pow(i-e,2.0)+pow(d-f,2.0)); 15 | q=f/r; 16 | e=(r*cos(q))-a/2.0;f=(r*sin(q))-a/2.0; 17 | d=sin(e*g)*176.0+sin(e*g)*164.0+r; 18 | h=((f+d)+a/2.0)*g; 19 | i=cos(h+r*p.x/1.3)*(e+e+a)+cos(q*g*6.0)*(r+h/3.0); 20 | h=sin(f*g)*144.0-sin(e*g)*212.0*p.x; 21 | h=(h+(f-e)*q+sin(r-(a+h)/7.0)*10.0+i/4.0)*g; 22 | i+=cos(h*2.3*sin(a/350.0-q))*184.0*sin(q-(r*4.3+a/12.0)*g)+tan(r*g+h)*184.0*cos(r*g+h); 23 | i=mod(i/5.6,256.0)/64.0; 24 | if(i<0.0) i+=4.0; 25 | if(i>=2.0) i=4.0-i; 26 | d=r/350.0; 27 | d+=sin(d*d*8.0)*0.52; 28 | f=(sin(a*g)+1.0)/2.0; 29 | gl_FragColor=vec4(vec3(f*i/1.6,i/2.0+d/13.0,i)*d*p.x+vec3(i/1.3+d/8.0,i/2.0+d/18.0,i)*d*(1.0-p.x),1.0); 30 | } 31 | -------------------------------------------------------------------------------- /Processing/scanningBar/data/nebula.glsl: -------------------------------------------------------------------------------- 1 | #define PROCESSING_COLOR_SHADER 2 | 3 | uniform float time; 4 | uniform vec2 resolution; 5 | 6 | // NEBULA - CoffeeBreakStudios.com (CBS) 7 | // Work in progress... 8 | // 9 | // 3148.26: Switched from classic to simplex noise 10 | // 3148.27: Reduced number of stars 11 | // 3249.0: Switched to fast computed 3D noise. Less quality but ~ 2x faster 12 | // 3249.5: Removed use of random number generator to gain performance 13 | // 3265.0: Added rotation: glsl.heroku.com/e#3005.1 14 | 15 | //Utility functions 16 | 17 | vec3 fade(vec3 t) { 18 | return vec3(1.0,1.0,1.0);//t*t*t*(t*(t*6.0-15.0)+10.0); 19 | } 20 | 21 | vec2 rotate(vec2 point, float rads) { 22 | float cs = cos(rads); 23 | float sn = sin(rads); 24 | return point * mat2(cs, -sn, sn, cs); 25 | } 26 | 27 | vec4 randomizer4(const vec4 x) 28 | { 29 | vec4 z = mod(x, vec4(5612.0)); 30 | z = mod(z, vec4(3.1415927 * 2.0)); 31 | return(fract(cos(z) * vec4(56812.5453))); 32 | } 33 | 34 | // Fast computed noise 35 | // http://www.gamedev.net/topic/502913-fast-computed-noise/ 36 | 37 | const float A = 1.0; 38 | const float B = 57.0; 39 | const float C = 113.0; 40 | const vec3 ABC = vec3(A, B, C); 41 | const vec4 A3 = vec4(0, B, C, C+B); 42 | const vec4 A4 = vec4(A, A+B, C+A, C+A+B); 43 | 44 | float cnoise4(const in vec3 xx) 45 | { 46 | vec3 x = mod(xx + 32768.0, 65536.0); 47 | vec3 ix = floor(x); 48 | vec3 fx = fract(x); 49 | vec3 wx = fx*fx*(3.0-2.0*fx); 50 | float nn = dot(ix, ABC); 51 | 52 | vec4 N1 = nn + A3; 53 | vec4 N2 = nn + A4; 54 | vec4 R1 = randomizer4(N1); 55 | vec4 R2 = randomizer4(N2); 56 | vec4 R = mix(R1, R2, wx.x); 57 | float re = mix(mix(R.x, R.y, wx.y), mix(R.z, R.w, wx.y), wx.z); 58 | 59 | return 1.0 - 2.0 * re; 60 | } 61 | float surface3 ( vec3 coord, float frequency ) { 62 | 63 | float n = 0.0; 64 | 65 | n += 1.0 * abs( cnoise4( coord * frequency ) ); 66 | n += 0.5 * abs( cnoise4( coord * frequency * 2.0 ) ); 67 | n += 0.25 * abs( cnoise4( coord * frequency * 4.0 ) ); 68 | n += 0.125 * abs( cnoise4( coord * frequency * 8.0 ) ); 69 | n += 0.0625 * abs( cnoise4( coord * frequency * 16.0 ) ); 70 | 71 | return n; 72 | } 73 | 74 | void main( void ) { 75 | float rads = radians(time*3.15); 76 | vec2 position = gl_FragCoord.xy / resolution.xy; 77 | position += rotate(position, rads); 78 | float n = surface3(vec3(position*sin(time*0.1), time * 0.05)*mat3(1,0,0,0,.8,.6,0,-.6,.8),0.9); 79 | float n2 = surface3(vec3(position*cos(time*0.1), time * 0.04)*mat3(1,0,0,0,.8,.6,0,-.6,.8),0.8); 80 | float lum = length(n); 81 | float lum2 = length(n2); 82 | 83 | vec3 tc = pow(vec3(1.0-lum),vec3(sin(position.x)+cos(time)+4.0,8.0+sin(time)+4.0,8.0)); 84 | vec3 tc2 = pow(vec3(1.1-lum2),vec3(5.0,position.y+cos(time)+7.0,sin(position.x)+sin(time)+2.0)); 85 | vec3 curr_color = (tc*0.8) + (tc2*0.5); 86 | 87 | 88 | //Let's draw some stars 89 | 90 | float scale = sin(0.3 * time) + 5.0; 91 | vec2 position2 = (((gl_FragCoord.xy / resolution) - 0.5) * scale); 92 | float gradient = 0.0; 93 | vec3 color = vec3(0.0); 94 | float fade = 0.0; 95 | float z = 0.0; 96 | vec2 centered_coord = position2 - vec2(sin(time*0.1),sin(time*0.1)); 97 | centered_coord = rotate(centered_coord, rads); 98 | 99 | for (float i=1.0; i<=60.0; i++) 100 | { 101 | vec2 star_pos = vec2(sin(i) * 250.0, sin(i*i*i) * 250.0); 102 | float z = mod(i*i - 10.0*time, 256.0); 103 | float fade = (256.0 - z) /256.0; 104 | vec2 blob_coord = star_pos / z; 105 | gradient += ((fade / 384.0) / pow(length(centered_coord - blob_coord), 1.5)) * ( fade); 106 | } 107 | 108 | curr_color += gradient; 109 | 110 | gl_FragColor = vec4(curr_color, 1.0); 111 | } -------------------------------------------------------------------------------- /Processing/scanningBar/data/shaders.txt: -------------------------------------------------------------------------------- 1 | 2 | // nebula = loadShader("FishEye.glsl"); 3 | // nebula = loadShader("GlossyFrag.glsl"); 4 | // nebula = loadShader("ToonVert.glsl"); 5 | // nebula = loadShader("blur.glsl"); 6 | // nebula = loadShader("burn.glsl"); 7 | // nebula = loadShader("conway.glsl"); 8 | // nebula = loadShader("cubemapvert.glsl"); 9 | // nebula = loadShader("difference.glsl"); 10 | // nebula = loadShader("dodge.glsl"); 11 | // nebula = loadShader("edges.glsl"); 12 | // nebula = loadShader("frag.glsl"); 13 | // nebula = loadShader("landscape.glsl"); 14 | // nebula = loadShader("mask.glsl"); 15 | // nebula = loadShader("monjori.glsl"); 16 | // nebula = loadShader("nebula.glsl"); 17 | // nebula = loadShader("overlay.glsl"); 18 | // nebula = loadShader("shaders.txt"); 19 | -------------------------------------------------------------------------------- /Processing/scanningBar/scanningBar.pde: -------------------------------------------------------------------------------- 1 | /* 2 | mpinner 3 | 4 | intent : scan possible three dimensional content in web or kiosk interface. 5 | 6 | todo: 7 | event model for live position data 8 | playback record multiple position streams 9 | portable data formats (jpeg, osc messages, artnet) 10 | swappable shaders (bc why not) 11 | animated point cloud colliders ( 3d simulation environment) 12 | 13 | 14 | inspiration: 15 | - Arc Length parametrization of curves by Jakub Valtar 16 | - From Nebula from CoffeeBreakStudios.com (CBS) 17 | - From Follow 3 from Keith Peters. 18 | 19 | */ 20 | 21 | PShader shader; 22 | 23 | import oscP5.*; 24 | import netP5.*; 25 | 26 | OscP5 oscP5; 27 | NetAddress myRemoteLocation; 28 | 29 | 30 | String tag = "01020224"; 31 | 32 | // segment points 33 | float[] x = new float[20]; 34 | float[] y = new float[20]; 35 | float segLength = 15; 36 | 37 | //time slicer 38 | float t = 0.0; 39 | float tStep = 0.004; 40 | 41 | int borderSize = 40; 42 | 43 | 44 | //////// 45 | // SETUP 46 | void setup() { 47 | size(400, 400, P2D); 48 | 49 | 50 | frameRate(60); 51 | /* create a new instance of oscP5 using a multicast socket. */ 52 | // oscP5 = new OscP5(this,"239.255.0.76",10076); 53 | oscP5 = new OscP5(this,11000); 54 | 55 | myRemoteLocation = new NetAddress("127.0.0.1",12000); 56 | 57 | frameRate(60); 58 | smooth(8); 59 | textAlign(CENTER); 60 | textSize(16); 61 | strokeWeight(9); 62 | 63 | // fun shaders 64 | shader = loadShader("landscape.glsl"); 65 | //shader = loadShader("monjori.glsl"); 66 | // shader = loadShader("nebula.glsl"); 67 | 68 | // noops 69 | // shader = loadShader("mask.glsl"); 70 | // shader = loadShader("frag.glsl"); 71 | // shader = loadShader("edges.glsl"); 72 | // shader = loadShader("blur.glsl"); 73 | // shader = loadShader("FishEye.glsl"); 74 | 75 | 76 | shader.set("resolution", float(width), float(height)); 77 | 78 | return; 79 | } 80 | 81 | 82 | void draw() { 83 | 84 | // Show static value when mouse is pressed, animate otherwise 85 | if (mousePressed) { 86 | int a = constrain(mouseX, borderSize, width - borderSize); 87 | t = map(a, borderSize, width - borderSize, 0.0, 1.0); 88 | } else { 89 | t += tStep; 90 | if (t > 1.0) t = 0.0; 91 | } 92 | 93 | 94 | background(0); 95 | 96 | // iterate shader 97 | shader.set("time", millis() / 500.0); 98 | shader(shader); 99 | 100 | 101 | // draw segment line follower 102 | pushMatrix(); 103 | { 104 | strokeWeight(10); 105 | stroke(255, 100); 106 | dragSegment(0, mouseX, mouseY); 107 | for (int i=0; i=2.0) i=4.0-i; 26 | d=r/350.0; 27 | d+=sin(d*d*8.0)*0.52; 28 | f=(sin(a*g)+1.0)/2.0; 29 | gl_FragColor=vec4(vec3(f*i/1.6,i/2.0+d/13.0,i)*d*p.x+vec3(i/1.3+d/8.0,i/2.0+d/18.0,i)*d*(1.0-p.x),1.0); 30 | } 31 | -------------------------------------------------------------------------------- /Processing/scanningPlayer/data/nebula.glsl: -------------------------------------------------------------------------------- 1 | #define PROCESSING_COLOR_SHADER 2 | 3 | uniform float time; 4 | uniform vec2 resolution; 5 | 6 | // NEBULA - CoffeeBreakStudios.com (CBS) 7 | // Work in progress... 8 | // 9 | // 3148.26: Switched from classic to simplex noise 10 | // 3148.27: Reduced number of stars 11 | // 3249.0: Switched to fast computed 3D noise. Less quality but ~ 2x faster 12 | // 3249.5: Removed use of random number generator to gain performance 13 | // 3265.0: Added rotation: glsl.heroku.com/e#3005.1 14 | 15 | //Utility functions 16 | 17 | vec3 fade(vec3 t) { 18 | return vec3(1.0,1.0,1.0);//t*t*t*(t*(t*6.0-15.0)+10.0); 19 | } 20 | 21 | vec2 rotate(vec2 point, float rads) { 22 | float cs = cos(rads); 23 | float sn = sin(rads); 24 | return point * mat2(cs, -sn, sn, cs); 25 | } 26 | 27 | vec4 randomizer4(const vec4 x) 28 | { 29 | vec4 z = mod(x, vec4(5612.0)); 30 | z = mod(z, vec4(3.1415927 * 2.0)); 31 | return(fract(cos(z) * vec4(56812.5453))); 32 | } 33 | 34 | // Fast computed noise 35 | // http://www.gamedev.net/topic/502913-fast-computed-noise/ 36 | 37 | const float A = 1.0; 38 | const float B = 57.0; 39 | const float C = 113.0; 40 | const vec3 ABC = vec3(A, B, C); 41 | const vec4 A3 = vec4(0, B, C, C+B); 42 | const vec4 A4 = vec4(A, A+B, C+A, C+A+B); 43 | 44 | float cnoise4(const in vec3 xx) 45 | { 46 | vec3 x = mod(xx + 32768.0, 65536.0); 47 | vec3 ix = floor(x); 48 | vec3 fx = fract(x); 49 | vec3 wx = fx*fx*(3.0-2.0*fx); 50 | float nn = dot(ix, ABC); 51 | 52 | vec4 N1 = nn + A3; 53 | vec4 N2 = nn + A4; 54 | vec4 R1 = randomizer4(N1); 55 | vec4 R2 = randomizer4(N2); 56 | vec4 R = mix(R1, R2, wx.x); 57 | float re = mix(mix(R.x, R.y, wx.y), mix(R.z, R.w, wx.y), wx.z); 58 | 59 | return 1.0 - 2.0 * re; 60 | } 61 | float surface3 ( vec3 coord, float frequency ) { 62 | 63 | float n = 0.0; 64 | 65 | n += 1.0 * abs( cnoise4( coord * frequency ) ); 66 | n += 0.5 * abs( cnoise4( coord * frequency * 2.0 ) ); 67 | n += 0.25 * abs( cnoise4( coord * frequency * 4.0 ) ); 68 | n += 0.125 * abs( cnoise4( coord * frequency * 8.0 ) ); 69 | n += 0.0625 * abs( cnoise4( coord * frequency * 16.0 ) ); 70 | 71 | return n; 72 | } 73 | 74 | void main( void ) { 75 | float rads = radians(time*3.15); 76 | vec2 position = gl_FragCoord.xy / resolution.xy; 77 | position += rotate(position, rads); 78 | float n = surface3(vec3(position*sin(time*0.1), time * 0.05)*mat3(1,0,0,0,.8,.6,0,-.6,.8),0.9); 79 | float n2 = surface3(vec3(position*cos(time*0.1), time * 0.04)*mat3(1,0,0,0,.8,.6,0,-.6,.8),0.8); 80 | float lum = length(n); 81 | float lum2 = length(n2); 82 | 83 | vec3 tc = pow(vec3(1.0-lum),vec3(sin(position.x)+cos(time)+4.0,8.0+sin(time)+4.0,8.0)); 84 | vec3 tc2 = pow(vec3(1.1-lum2),vec3(5.0,position.y+cos(time)+7.0,sin(position.x)+sin(time)+2.0)); 85 | vec3 curr_color = (tc*0.8) + (tc2*0.5); 86 | 87 | 88 | //Let's draw some stars 89 | 90 | float scale = sin(0.3 * time) + 5.0; 91 | vec2 position2 = (((gl_FragCoord.xy / resolution) - 0.5) * scale); 92 | float gradient = 0.0; 93 | vec3 color = vec3(0.0); 94 | float fade = 0.0; 95 | float z = 0.0; 96 | vec2 centered_coord = position2 - vec2(sin(time*0.1),sin(time*0.1)); 97 | centered_coord = rotate(centered_coord, rads); 98 | 99 | for (float i=1.0; i<=60.0; i++) 100 | { 101 | vec2 star_pos = vec2(sin(i) * 250.0, sin(i*i*i) * 250.0); 102 | float z = mod(i*i - 10.0*time, 256.0); 103 | float fade = (256.0 - z) /256.0; 104 | vec2 blob_coord = star_pos / z; 105 | gradient += ((fade / 384.0) / pow(length(centered_coord - blob_coord), 1.5)) * ( fade); 106 | } 107 | 108 | curr_color += gradient; 109 | 110 | gl_FragColor = vec4(curr_color, 1.0); 111 | } -------------------------------------------------------------------------------- /Processing/scanningPlayer/data/shaders.txt: -------------------------------------------------------------------------------- 1 | 2 | // nebula = loadShader("FishEye.glsl"); 3 | // nebula = loadShader("GlossyFrag.glsl"); 4 | // nebula = loadShader("ToonVert.glsl"); 5 | // nebula = loadShader("blur.glsl"); 6 | // nebula = loadShader("burn.glsl"); 7 | // nebula = loadShader("conway.glsl"); 8 | // nebula = loadShader("cubemapvert.glsl"); 9 | // nebula = loadShader("difference.glsl"); 10 | // nebula = loadShader("dodge.glsl"); 11 | // nebula = loadShader("edges.glsl"); 12 | // nebula = loadShader("frag.glsl"); 13 | // nebula = loadShader("landscape.glsl"); 14 | // nebula = loadShader("mask.glsl"); 15 | // nebula = loadShader("monjori.glsl"); 16 | // nebula = loadShader("nebula.glsl"); 17 | // nebula = loadShader("overlay.glsl"); 18 | // nebula = loadShader("shaders.txt"); 19 | -------------------------------------------------------------------------------- /Processing/scanningPlayer/scanningPlayer.pde: -------------------------------------------------------------------------------- 1 | /* 2 | mpinner 3 | 4 | intent : scan possible three dimensional content in web or kiosk interface. 5 | 6 | todo: 7 | event model for live position data 8 | playback record multiple position streams 9 | portable data formats (jpeg, osc messages, artnet) 10 | swappable shaders (bc why not) 11 | animated point cloud colliders ( 3d simulation environment) 12 | 13 | 14 | inspiration: 15 | - Arc Length parametrization of curves by Jakub Valtar 16 | - From Nebula from CoffeeBreakStudios.com (CBS) 17 | - From Follow 3 from Keith Peters. 18 | 19 | */ 20 | 21 | PShader shader; 22 | 23 | import oscP5.*; 24 | import netP5.*; 25 | 26 | OscP5 oscP5; 27 | NetAddress myRemoteLocation; 28 | 29 | 30 | String tag = "01020224"; 31 | 32 | // segment points 33 | float[] x = new float[20]; 34 | float[] y = new float[20]; 35 | float segLength = 15; 36 | 37 | //time slicer 38 | float t = 0.0; 39 | float tStep = 0.004; 40 | 41 | int borderSize = 40; 42 | 43 | 44 | //////// 45 | // SETUP 46 | void setup() { 47 | size(400, 400, P2D); 48 | 49 | 50 | frameRate(60); 51 | /* create a new instance of oscP5 using a multicast socket. */ 52 | // oscP5 = new OscP5(this,"239.255.0.76",10076); 53 | oscP5 = new OscP5(this,11000); 54 | 55 | myRemoteLocation = new NetAddress("127.0.0.1",12000); 56 | 57 | frameRate(60); 58 | smooth(8); 59 | textAlign(CENTER); 60 | textSize(16); 61 | strokeWeight(9); 62 | 63 | // fun shaders 64 | shader = loadShader("landscape.glsl"); 65 | //shader = loadShader("monjori.glsl"); 66 | // shader = loadShader("nebula.glsl"); 67 | 68 | // noops 69 | // shader = loadShader("mask.glsl"); 70 | // shader = loadShader("frag.glsl"); 71 | // shader = loadShader("edges.glsl"); 72 | // shader = loadShader("blur.glsl"); 73 | // shader = loadShader("FishEye.glsl"); 74 | 75 | 76 | shader.set("resolution", float(width), float(height)); 77 | 78 | return; 79 | } 80 | 81 | 82 | void draw() { 83 | 84 | // Show static value when mouse is pressed, animate otherwise 85 | if (mousePressed) { 86 | int a = constrain(mouseX, borderSize, width - borderSize); 87 | t = map(a, borderSize, width - borderSize, 0.0, 1.0); 88 | } else { 89 | t += tStep; 90 | if (t > 1.0) t = 0.0; 91 | } 92 | 93 | 94 | background(0); 95 | 96 | // iterate shader 97 | shader.set("time", millis() / 500.0); 98 | shader(shader); 99 | 100 | 101 | // draw segment line follower 102 | pushMatrix(); 103 | { 104 | strokeWeight(10); 105 | stroke(255, 100); 106 | dragSegment(0, mouseX, mouseY); 107 | for (int i=0; i=2.0) i=4.0-i; 26 | d=r/350.0; 27 | d+=sin(d*d*8.0)*0.52; 28 | f=(sin(a*g)+1.0)/2.0; 29 | gl_FragColor=vec4(vec3(f*i/1.6,i/2.0+d/13.0,i)*d*p.x+vec3(i/1.3+d/8.0,i/2.0+d/18.0,i)*d*(1.0-p.x),1.0); 30 | } 31 | -------------------------------------------------------------------------------- /Processing/tampReceiver/data/nebula.glsl: -------------------------------------------------------------------------------- 1 | #define PROCESSING_COLOR_SHADER 2 | 3 | uniform float time; 4 | uniform vec2 resolution; 5 | 6 | // NEBULA - CoffeeBreakStudios.com (CBS) 7 | // Work in progress... 8 | // 9 | // 3148.26: Switched from classic to simplex noise 10 | // 3148.27: Reduced number of stars 11 | // 3249.0: Switched to fast computed 3D noise. Less quality but ~ 2x faster 12 | // 3249.5: Removed use of random number generator to gain performance 13 | // 3265.0: Added rotation: glsl.heroku.com/e#3005.1 14 | 15 | //Utility functions 16 | 17 | vec3 fade(vec3 t) { 18 | return vec3(1.0,1.0,1.0);//t*t*t*(t*(t*6.0-15.0)+10.0); 19 | } 20 | 21 | vec2 rotate(vec2 point, float rads) { 22 | float cs = cos(rads); 23 | float sn = sin(rads); 24 | return point * mat2(cs, -sn, sn, cs); 25 | } 26 | 27 | vec4 randomizer4(const vec4 x) 28 | { 29 | vec4 z = mod(x, vec4(5612.0)); 30 | z = mod(z, vec4(3.1415927 * 2.0)); 31 | return(fract(cos(z) * vec4(56812.5453))); 32 | } 33 | 34 | // Fast computed noise 35 | // http://www.gamedev.net/topic/502913-fast-computed-noise/ 36 | 37 | const float A = 1.0; 38 | const float B = 57.0; 39 | const float C = 113.0; 40 | const vec3 ABC = vec3(A, B, C); 41 | const vec4 A3 = vec4(0, B, C, C+B); 42 | const vec4 A4 = vec4(A, A+B, C+A, C+A+B); 43 | 44 | float cnoise4(const in vec3 xx) 45 | { 46 | vec3 x = mod(xx + 32768.0, 65536.0); 47 | vec3 ix = floor(x); 48 | vec3 fx = fract(x); 49 | vec3 wx = fx*fx*(3.0-2.0*fx); 50 | float nn = dot(ix, ABC); 51 | 52 | vec4 N1 = nn + A3; 53 | vec4 N2 = nn + A4; 54 | vec4 R1 = randomizer4(N1); 55 | vec4 R2 = randomizer4(N2); 56 | vec4 R = mix(R1, R2, wx.x); 57 | float re = mix(mix(R.x, R.y, wx.y), mix(R.z, R.w, wx.y), wx.z); 58 | 59 | return 1.0 - 2.0 * re; 60 | } 61 | float surface3 ( vec3 coord, float frequency ) { 62 | 63 | float n = 0.0; 64 | 65 | n += 1.0 * abs( cnoise4( coord * frequency ) ); 66 | n += 0.5 * abs( cnoise4( coord * frequency * 2.0 ) ); 67 | n += 0.25 * abs( cnoise4( coord * frequency * 4.0 ) ); 68 | n += 0.125 * abs( cnoise4( coord * frequency * 8.0 ) ); 69 | n += 0.0625 * abs( cnoise4( coord * frequency * 16.0 ) ); 70 | 71 | return n; 72 | } 73 | 74 | void main( void ) { 75 | float rads = radians(time*3.15); 76 | vec2 position = gl_FragCoord.xy / resolution.xy; 77 | position += rotate(position, rads); 78 | float n = surface3(vec3(position*sin(time*0.1), time * 0.05)*mat3(1,0,0,0,.8,.6,0,-.6,.8),0.9); 79 | float n2 = surface3(vec3(position*cos(time*0.1), time * 0.04)*mat3(1,0,0,0,.8,.6,0,-.6,.8),0.8); 80 | float lum = length(n); 81 | float lum2 = length(n2); 82 | 83 | vec3 tc = pow(vec3(1.0-lum),vec3(sin(position.x)+cos(time)+4.0,8.0+sin(time)+4.0,8.0)); 84 | vec3 tc2 = pow(vec3(1.1-lum2),vec3(5.0,position.y+cos(time)+7.0,sin(position.x)+sin(time)+2.0)); 85 | vec3 curr_color = (tc*0.8) + (tc2*0.5); 86 | 87 | 88 | //Let's draw some stars 89 | 90 | float scale = sin(0.3 * time) + 5.0; 91 | vec2 position2 = (((gl_FragCoord.xy / resolution) - 0.5) * scale); 92 | float gradient = 0.0; 93 | vec3 color = vec3(0.0); 94 | float fade = 0.0; 95 | float z = 0.0; 96 | vec2 centered_coord = position2 - vec2(sin(time*0.1),sin(time*0.1)); 97 | centered_coord = rotate(centered_coord, rads); 98 | 99 | for (float i=1.0; i<=60.0; i++) 100 | { 101 | vec2 star_pos = vec2(sin(i) * 250.0, sin(i*i*i) * 250.0); 102 | float z = mod(i*i - 10.0*time, 256.0); 103 | float fade = (256.0 - z) /256.0; 104 | vec2 blob_coord = star_pos / z; 105 | gradient += ((fade / 384.0) / pow(length(centered_coord - blob_coord), 1.5)) * ( fade); 106 | } 107 | 108 | curr_color += gradient; 109 | 110 | gl_FragColor = vec4(curr_color, 1.0); 111 | } -------------------------------------------------------------------------------- /Processing/tampReceiver/data/shaders.txt: -------------------------------------------------------------------------------- 1 | 2 | // nebula = loadShader("FishEye.glsl"); 3 | // nebula = loadShader("GlossyFrag.glsl"); 4 | // nebula = loadShader("ToonVert.glsl"); 5 | // nebula = loadShader("blur.glsl"); 6 | // nebula = loadShader("burn.glsl"); 7 | // nebula = loadShader("conway.glsl"); 8 | // nebula = loadShader("cubemapvert.glsl"); 9 | // nebula = loadShader("difference.glsl"); 10 | // nebula = loadShader("dodge.glsl"); 11 | // nebula = loadShader("edges.glsl"); 12 | // nebula = loadShader("frag.glsl"); 13 | // nebula = loadShader("landscape.glsl"); 14 | // nebula = loadShader("mask.glsl"); 15 | // nebula = loadShader("monjori.glsl"); 16 | // nebula = loadShader("nebula.glsl"); 17 | // nebula = loadShader("overlay.glsl"); 18 | // nebula = loadShader("shaders.txt"); 19 | -------------------------------------------------------------------------------- /Processing/videoPlayerWithNight/data/night_img.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpinner/Active/b5e2c9df3a53bc79920fb5f17489296238b898d0/Processing/videoPlayerWithNight/data/night_img.png -------------------------------------------------------------------------------- /Processing/videoPlayerWithNight/sketch.properties: -------------------------------------------------------------------------------- 1 | mode.id=processing.mode.java.JavaMode 2 | mode=Java 3 | -------------------------------------------------------------------------------- /Processing/videoPlayerWithNight/videoPlayerWithNight.pde: -------------------------------------------------------------------------------- 1 | import img2opc.*; 2 | import processing.video.*; 3 | import processing.net.*; 4 | 5 | /* 6 | * This sketch uses the img2opc library to display video files in the data 7 | * directory at random. 8 | */ 9 | 10 | Movie m; 11 | Img2Opc i2o; 12 | //Img2Opc i2oLocal; 13 | PImage resized; 14 | int displayWidth = 60; 15 | int displayHeight = 24; 16 | Movie endingMovie = null; 17 | 18 | PImage black; 19 | 20 | void setup() { 21 | 22 | println("user.dir : " + System.getProperty("user.dir") ); 23 | println("Sketch path: " + sketchPath); 24 | println("Sketch data: " + dataPath("")); 25 | 26 | println( javaVersionName ); 27 | println( System.getProperty("java.home") + "\n"); 28 | 29 | println( System.getProperty("os.arch") ); 30 | println( System.getProperty("os.name") ); 31 | println( System.getProperty("os.version") + "\n"); 32 | 33 | println( System.getProperty("user.home") ); 34 | println( System.getProperty("user.dir") ); 35 | println( dataPath("") ); 36 | 37 | black = loadImage("night_img.png"); 38 | 39 | background(0); 40 | size(600, 480); 41 | 42 | //i2o = new Img2Opc(this, "white", 7890, displayWidth, displayHeight); 43 | i2o = new Img2Opc(this, "localhost", 7890, displayWidth, displayHeight); 44 | loadMovie(); 45 | } 46 | 47 | void mousePressed() { 48 | if (endingMovie != null) { 49 | endingMovie.stop(); 50 | endingMovie = null; 51 | } 52 | endingMovie = m; 53 | loadMovie(); 54 | endingMovie.stop(); 55 | endingMovie = null; 56 | } 57 | 58 | void loadMovie() { 59 | m = null; 60 | 61 | 62 | java.io.File folder = new java.io.File(dataPath("")); 63 | String[] filenames = folder.list(); 64 | 65 | String f; 66 | do { 67 | f = filenames[int(random(filenames.length))]; 68 | } 69 | while (f.equals (".DS_Store")); 70 | print("loading '"); 71 | print(f); 72 | println("'"); 73 | m = new Movie(this, f); 74 | m.play(); 75 | m.read(); 76 | i2o.setSourceSize(m.width, m.height); 77 | //i2oLocal.setSourceSize(m.width, m.height); 78 | } 79 | 80 | void movieEvent(Movie mov) { 81 | if (mov == endingMovie) { 82 | return; 83 | } 84 | mov.read(); 85 | 86 | // between midnight and 8am keep it off 87 | if (hour() > 7) { 88 | 89 | resized = i2o.sendImg(mov, true); 90 | 91 | } else { 92 | resized = i2o.sendImg(black, true); 93 | } 94 | 95 | 96 | if (mov.time() >= mov.duration() - 0.1) { 97 | if (endingMovie != null) { 98 | endingMovie.stop(); 99 | endingMovie = null; 100 | } 101 | endingMovie = mov; 102 | loadMovie(); 103 | } 104 | } 105 | 106 | void draw() { 107 | 108 | 109 | 110 | if (m != null) { 111 | image(m, displayWidth, 0); 112 | } 113 | if (resized != null) { 114 | image(resized, 0, 0); 115 | } 116 | } 117 | 118 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Active 2 | === 3 | 4 | [![pulsing led sculpture - evan miller + mpinner - test 01 ](https://raw.githubusercontent.com/mpinner/Active/master/docs/Active_SmokeMonster_tb.gif)](http://www.youtube.com/watch?v=6qRlZ3MchNk) 5 | 6 | 7 | Lightning 10 gross LEDs begins in the one of a kind video art experience for visitors to The Source. 8 | 9 | Giant expansive space high above the patrons is sparsely populated for creative expression. bring a local flavor of of collaborative expression to a focal point below. 10 | 11 | Reacting to your motion as you enter the space; Sensors, video, images, and the live data from the internet are all merged to creating a living space above The Source, an urban marketplace in the Rino Arts District. 12 | 13 | 14 | [![opening event](https://raw.githubusercontent.com/mpinner/Active/master/docs/Active_flyer_dm.jpg)] 15 | 16 | 17 | 18 | SRC 19 | === 20 | applications for rendering content to [Open Pixel Control](http://openpixelcontrol.org/) network stream. 21 | 22 | depends on [FadeCandy C Libs](https://github.com/scanlime/fadecandy/tree/master/examples/cpp) for opc client and effects framework. we've added some custom effect mixing and image loading for realtime brightness control. 23 | 24 | [optionally] depends on [BlackLib](http://blacklib.yigityuce.com/) for live analog brightness control sensors. 25 | 26 | 27 | 28 | STREAMERS 29 | === 30 | opc content generation for testing troubleshoot and user contributions in mostly Python from opc/fadecandy examples 31 | 32 | 33 | PROCESSING 34 | === 35 | Toolkit for developing image manipulation code, layouts, and renderings for concept art in [Processing](https://www.processing.org/) 36 | 37 | **processing simulation** 38 | 39 | [![pulsing led sculpture - evan miller + mpinner - test 01 ](https://raw.githubusercontent.com/mpinner/Active/master/docs/Active_TieFighter_tb.gif)](http://www.youtube.com/watch?v=eXs2kY__nDY) 40 | 41 | 42 | 43 | BIN 44 | === 45 | tool kit for running and configuring [beaglebone black](http://beagleboard.org/) 46 | 47 | 48 | Installation 49 | === 50 | 51 | **Materials** 52 | 53 | * 2x the latest BBB or [upgrade any version to debian](http://elinux.org/BeagleBoardDebian) 54 | * tlc [spi style](http://guy.carpenter.id.au/gaugette/2014/01/28/controlling-an-adafruit-spi-oled-with-a-beaglebone-black/) led drivers ([tlc5947](https://www.adafruit.com/products/1429), http://www.ti.com/product/TLC5955, [tlc5940](https://www.sparkfun.com/products/10616) [tlc59711](https://www.adafruit.com/product/815) ) 55 | * [analog input](http://beaglebone.cameon.net/home/reading-the-analog-inputs-adc) on AIN1 56 | 57 | **Steps** 58 | 59 | Pulling the latest and Building 60 | 61 | mkdir git; cd git 62 | git clone https://github.com/mpinner/Active.git 63 | cd Active/bin/ 64 | chmod +x *.sh 65 | . ./env.sh 66 | ./setupEnv.sh 67 | 68 | 69 | my openpixelcontrol fork with SPI / TLC support 70 | 71 | git clone https://github.com/mpinner/openpixelcontrol.git 72 | cd openpixelcontrol 73 | make 74 | 75 | 76 | change hostname 77 | 78 | sudo emacs /etc/hostname 79 | sudo emacs /etc/hosts 80 | 81 | Setup root crontab for script autorun 82 | 83 | sudo crontab -e 84 | 85 | Add in the [following](https://github.com/mpinner/Active/blob/master/bin/crontab) 86 | 87 | # push-sparkdata.sh 88 | 00 11,23 * * * /home/debian/git/Active/bin/push-sparkdata.sh >> /var/log/active-push-sparkfun.log 2>&1 89 | 90 | # starts spi overlay gpio pins 91 | # creates /dev/spidev* files 92 | @reboot /usr/bin/python -c "from Adafruit_BBIO.SPI import SPI; SPI(0,0)" >> /var/log/active-gpio.log 2>&1 93 | 94 | #pre-process videos 95 | #(with some large videos bbb cannot transcode in realtime) 96 | */1 * * * * /home/debian/git/Active/bin/process-videos.sh >> /var/log/active-process-videos.log 2>&1 97 | 98 | # on boot start whatever this bone id configured for 99 | @reboot /home/debian/git/Active/bin/run.sh >> /var/log/active-monitor.log 2>&1 100 | 101 | 102 | 103 | 104 | 105 | Edit /etc/fstab to make for less disk 106 | 107 | UUID=8037fd09-ea0d-4c28-a348-1fbdf9fb0b92 / ext3 108 | relatime,noatime,errors=remount-ro 0 1 109 | 110 | tmpfs /tmp tmpfs defaults,noatime 0 0 111 | tmpfs /var/run tmpfs defaults,noatime 0 0 112 | tmpfs /var/log tmpfs defaults,noatime 0 0 113 | tmpfs /var/lock tmpfs defaults,noatime 0 0 114 | tmpfs /var/tmp tmpfs defaults,noatime 0 0 115 | tmpfs /var/lib/dhcp3 tmpfs defaults,noatime 0 0 116 | 117 | Double check /boot/uboot/env.sh for IP addresses and the configurations you might want. 118 | 119 | 120 | INSPIRATION 121 | ==== 122 | 123 | [Light Emitting Ball (LEB)](https://hackaday.io/project/138-Light-Emitting-Ball-(LEB)) 124 | 125 | [Nsl Blinky Ball](http://charliex2.wordpress.com/2012/02/11/the-blinky-ball-nullspacelabs/) 126 | 127 | [jim campbell](http://www.jimcampbell.tv/) 128 | 129 | [disorient pyramid](http://blog.crashspace.org/2013/09/disorient-pyramid-at-burning-man-2013/) 130 | 131 | [fadecandy ecstatic-epiphany](http://www.misc.name/ecstatic-epiphany/) 132 | -------------------------------------------------------------------------------- /bin/.configure: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd /home/debian 4 | mkdir git 5 | cd git 6 | git clone https://github.com/mpinner/Active.git 7 | 8 | 9 | #setuo ACTIVE 10 | cd ~debian/git/Active/bin/ 11 | chmod +x *.sh 12 | cp env.sh /boot/uboot/ 13 | 14 | . /boot/uboot/env.sh 15 | 16 | 17 | sudo touch $OPC_LOG 18 | sudo touch $STREAMER_LOG 19 | sudo touch $MONITOR_LOG 20 | sudo touch $SPARKFUN_LOG 21 | 22 | sudo chown debian $OPC_LOG 23 | sudo chown debian $STREAMER_LOG 24 | sudo chown debian $MONITOR_LOG 25 | sudo chown debian $SPARKFUN_LOG 26 | 27 | 28 | #setup log rotate 29 | sudo touch /etc/logrotate.d/active 30 | sudo chown debian /etc/logrotate.d/active 31 | 32 | 33 | # setup OPC 34 | git clone https://github.com/mpinner/openpixelcontrol.git 35 | cd openpixelcontrol 36 | git checkout tlc5947 37 | sudo apt-get -y install mesa-common-dev freeglut3-dev 38 | make 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /bin/active-local-default.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | . /home/debian/git/Active/bin/env.sh 4 | 5 | . /boot/uboot/env.sh 6 | 7 | cd $ACTIVE_HOME/streamers/ 8 | 9 | ## loop through streamers 10 | cat ./active-streamers.txt | while read script 11 | do 12 | echo "running '$script'..." >> $STREAMER_LOG 2>&1 13 | timeout $TIMEOUT ./$script >> $STREAMER_LOG 2>&1 14 | echo "done '$script'" >> $STREAMER_LOG 2>&1 15 | done 16 | -------------------------------------------------------------------------------- /bin/active-slinger.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | . /home/debian/git/Active/bin/env.sh 4 | 5 | . /boot/uboot/env.sh 6 | 7 | cd $ACTIVE_HOME/src/ 8 | echo "running against ./images -layout $LAYOUT -server $OPC_SERVER" >> $STREAMER_LOG 2>&1 9 | ./images -layout $LAYOUT -server $OPC_SERVER >> $STREAMER_LOG 2>&1 10 | 11 | ## loop through streamers 12 | #ls -ctr ./streamers/*.py ./streamers/active-streams/*.py | while read script 13 | #do 14 | # echo "running '$script'..." >> $STREAMER_LOG 2>&1 15 | # timeout 10s $script >> $STREAMER_LOG 2>&1 16 | # echo "done '$script'" >> $STREAMER_LOG 2>&1 17 | #done 18 | -------------------------------------------------------------------------------- /bin/bbb-rsync-excludes.txt: -------------------------------------------------------------------------------- 1 | /proc/* 2 | /sys/* 3 | /dev/* 4 | /boot/* 5 | /tmp/* 6 | /run/* 7 | /mnt/* 8 | /media/* -------------------------------------------------------------------------------- /bin/build-latest.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd $ACTIVE_HOME/src; 4 | make 5 | 6 | sudo cp $ACTIVE_HOME/bin/env.sh /boot/uboot/ 7 | 8 | cd $OPC_SERVER_HOME 9 | make 10 | -------------------------------------------------------------------------------- /bin/crontab: -------------------------------------------------------------------------------- 1 | # push-sparkdata.sh 2 | 00 11,23 * * *OB /home/debian/git/Active/bin/push-sparkdata.sh >> /var/log/active-push-sparkfun.log 2>&1 3 | 4 | # configure spi overlay gpio pins 5 | # creates /dev/spidev* files 6 | @reboot /usr/bin/python -c "from Adafruit_BBIO.SPI import SPI; SPI(0,0)" >> /var/log/active-gpio.log 2>&1 7 | 8 | # this never worked. halp? 9 | #@reboot echo cape-bone-iio > /sys/devices/bone_capemgr.*/slots 2>&1 10 | 11 | #start up our OPC SERVER 12 | @reboot /home/debian/git/Active/bin/monitor-opc.sh >> /var/log/active-monitor.log 2>&1 13 | 14 | #start our pixel slinger (generates content) 15 | 16 | @reboot /home/debian/git/Active/bin/monitor-slinger.sh >> /var/log/active-monitor.log 2>&1 -------------------------------------------------------------------------------- /bin/env.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ## 4 | # env.sh 5 | # author: @mpinner 6 | # intent: 7 | # - holds properties for configuring beaglebone for Active 8 | # - hold commands for administering the services 9 | # - this is stored in the /boot/uboot/ so it can be accessed via usb when the BBB 10 | # appears as a removeable drive. 11 | # - most changes here will require a reboot of the BBB before they take affect 12 | ## 13 | 14 | 15 | # images can be added via thumbdrive which mounts as the following 16 | export THUMB_DRIVE=/media/ACTIVE 17 | 18 | #standard installation directory for our main code base and git repo 19 | export ACTIVE_HOME=/home/debian/git/Active/ 20 | 21 | # send to yourself 22 | #export ACTIVE_SLINGER_BIN=$ACTIVE_HOME/bin/active-local-default.sh 23 | export ACTIVE_SLINGER_BIN=$ACTIVE_HOME/bin/active-slinger.sh 24 | 25 | 26 | # layout file to use for the mapping from pixel indexes to physical space 27 | # a few options exist here to rotate the visual perspective 28 | export LAYOUT=$ACTIVE_HOME/layout/layout-60x24.json 29 | 30 | # sequences will restart after a duration to allow bin level cycling of active-streamers 31 | # small timeouts help for the OPC_SERVER host bc it allows other sources to connect 32 | export TIMEOUT=30s # seconds 33 | 34 | # ip and port of the beagle that is resident in the piece to push the pixels to the actual hardware 35 | #local tests 36 | export OPC_SERVER=127.0.0.1:7890 37 | 38 | #Active: white 39 | #export OPC_SERVER=192.168.163.141:7890 40 | 41 | #usb connection 42 | #export OPC_SERVER=192.168.7.1:7890 43 | 44 | 45 | # source for our fork of the OPC server code and binaries 46 | export OPC_SERVER_HOME=/home/debian/git/openpixelcontrol/ 47 | export OPC_SERVER_BIN=$OPC_SERVER_HOME/bin/gl_server 48 | 49 | # if the system is configured to call home here is a start 50 | export GMAIL_ADDY=active@threadable.com 51 | export DATA_SERVICE=http://data.sparkfun.com/ 52 | 53 | # logging is kept here and should be moved as these are configured with /etc/logrotate.d/active 54 | export LOG_DIR=/var/log/ 55 | export OPC_LOG=$LOG_DIR/active-tlc5947-server.log 56 | export STREAMER_LOG=$LOG_DIR/active-streamers.log 57 | export MONITOR_LOG=$LOG_DIR/active-monitor.log 58 | export SPARKFUN_LOG=$LOG_DIR/active-push-sparkfun.log 59 | export ACTIVE_SPARKFUN_URL=http://data.sparkfun.com/input/wppV3QYqbOs0qzoaYoRq?private_key=wzzXAwMWNniaGBlXNl0G&=3.21 60 | 61 | 62 | cd $OPC_SERVER_DIR 63 | alias activegl="cd OPC_SERVER_DIR; $OPC_SERVER_BIN $LAYOUT " 64 | alias restart-opc-server="sudo killall -r tlc" 65 | alias kill-opc-server="sudo killall -r opc tlc" 66 | alias logs="tail -f /var/log/active-*" 67 | alias restart-slinger-server="sudo killall -r tlc" 68 | alias kill-slinger="sudo killall -r slinger mixer" 69 | alias restart-slinger="sudo killall -r mixer" 70 | alias restart-slinger="sudo killall -r mixer" 71 | alias restart-bbb="sudo reboot -n" 72 | alias pull-latest="$ACTIVE_HOME/bin/pull-latest.sh" 73 | alias build-latest="$ACTIVE_HOME/bin/build-latest.sh" 74 | 75 | 76 | 77 | 78 | -------------------------------------------------------------------------------- /bin/hosts: -------------------------------------------------------------------------------- 1 | 192.168.163.109 green 2 | 192.168.163.141 white 3 | 192.168.163.108 clear 4 | 192.168.163.120 blue 5 | 6 | -------------------------------------------------------------------------------- /bin/monitor-opc.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | until /home/debian/git/Active/bin/opc-server.sh; do 4 | echo "OPC Server crashed with exit code $?. Respawning.." >&2 5 | sleep 1 6 | done 7 | -------------------------------------------------------------------------------- /bin/monitor-slinger.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | . /home/debian/git/Active/bin/env.sh 4 | 5 | . /boot/uboot/env.sh 6 | 7 | echo cape-bone-iio > /sys/devices/bone_capemgr.*/slots 8 | 9 | cd $ACTIVE_HOME; 10 | 11 | while true; do 12 | 13 | until $ACTIVE_SLINGER_BIN; do 14 | echo "Active Slinger crashed with exit code $?. Respawning.." >&2 15 | sleep 1 16 | done 17 | done -------------------------------------------------------------------------------- /bin/opc-server.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | LOG=/var/log/active-tlc5947-server.log 4 | LAYOUT=layouts/wall.json 5 | 6 | cd /home/debian/git/openpixelcontrol; 7 | 8 | bin/tlc5947_server $LAYOUT 7890 12 >> $LOG 2>&1 9 | 10 | -------------------------------------------------------------------------------- /bin/process-videos.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # process-video 4 | # mpinner 5 | # 6 | # to be run repeatedly for making videos into small images 7 | 8 | . /boot/uboot/env.sh 9 | 10 | 11 | VIDEO_DIR=$THUMB_DRIVE/video 12 | INCOMING_DIR=$VIDEO_DIR/incoming 13 | LOCK_FILE=$VIDEO_DIR/lock/ 14 | VIDEO_EXT=mp4 15 | VIDEO_FILE_PATTERN=$INCOMING_DIR/*.$VIDEO_EXT 16 | QUEUE_DIR=$VIDEO_DIR/playlist/ 17 | DONE_DIR=$VIDEO_DIR/backup/ 18 | 19 | 20 | #test for thumbdrive dir 21 | if [ ! -d "$THUMB_DRIVE" ]; then 22 | echo "Thumb Drive not found at $THUMB_DRIVE!" 23 | exit 1 24 | fi 25 | #test for video dir 26 | if [ ! -d "$VIDEO_DIR" ]; then 27 | echo "Video Directory not found at $VIDEO_DIR!" 28 | exit 1 29 | fi 30 | 31 | if [ ! -d "$INCOMING_DIR" ]; then 32 | mkdir -p $INCOMING_DIR 33 | if [ ! -d "$INCOMING_DIR" ]; then 34 | echo "Video Incoming Directory not found!" 35 | exit 1 36 | fi 37 | fi 38 | 39 | if [ ! -d "$QUEUE_DIR" ]; then 40 | mkdir -p $QUEUE_DIR 41 | if [ ! -d "$QUEUE_DIR" ]; then 42 | echo "Video Queue Directory not found!" 43 | exit 1 44 | fi 45 | fi 46 | 47 | if [ ! -d "$DONE_DIR" ]; then 48 | mkdir -p $DONE_DIR 49 | if [ ! -d "$DONE_DIR" ]; then 50 | echo "Video Done Directory not found!" 51 | exit 1 52 | fi 53 | fi 54 | 55 | #test for new files 56 | shopt -s nullglob 57 | FILES=`echo $VIDEO_FILE_PATTERN` 58 | if [[ -z $FILES ]]; then 59 | # todo if silent 60 | #echo "No new videos found" 61 | exit 1 62 | fi 63 | 64 | 65 | # New videos !! 66 | 67 | # set lock 68 | if mkdir $LOCK_FILE; then 69 | echo "Locking succeeded" >&2 70 | else 71 | echo "Lock failed - exit" >&2 72 | exit 1 73 | fi 74 | 75 | 76 | #process all videos into image queues 77 | for video in $FILES; do 78 | 79 | filename=$(basename "$video") 80 | name=`echo $filename | cut -d'.' -f1`; 81 | echo $name; 82 | 83 | #process video 84 | echo "/usr/local/bin/ffmpeg -i $video -vf scale=60:24 -r 15 -f image2 $DONE_DIR$name%03d.png" 85 | time /usr/local/bin/ffmpeg -i $video -vf scale=60:24 -r 15 -f image2 $QUEUE_DIR$name%06d.png 86 | 87 | #move to done 88 | mv $video $DONE_DIR 89 | 90 | done 91 | 92 | 93 | #remove lock 94 | rm -r $LOCK_FILE 95 | 96 | sudo killall -r video 97 | 98 | -------------------------------------------------------------------------------- /bin/pull-latest.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd $ACTIVE_HOME; 4 | git pull; 5 | 6 | cd $OPC_SERVER_HOME 7 | git pull 8 | -------------------------------------------------------------------------------- /bin/push-latest.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | scp -r bin debian@bbb:git/Active/ 4 | scp -r src debian@bbb:git/Active/ 5 | scp -r streamers debian@bbb:git/Active/ 6 | scp -r layout debian@bbb:git/Active/ -------------------------------------------------------------------------------- /bin/push-sparkdata.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | 4 | . /boot/uboot/env.sh 5 | 6 | RECENT_UPTIME=`uptime` 7 | DISK_SPACE=`df|grep disk|awk '{print $4}'` 8 | HOSTNAME=`hostname` 9 | 10 | #impossibly weak security 11 | wget --append-output=$SPARKFUN_LOG "$ACTIVE_SPARKFUN_URL&diskspace=$DISK_SPACE&uptime=$RECENT_UPTIME&hostname=$HOSTNAME" 12 | 13 | -------------------------------------------------------------------------------- /bin/rsync-backups.sh: -------------------------------------------------------------------------------- 1 | rsync -aEv --delete-during --exclude-from=../bbb-rsync-excludes.txt root@192.168.163.115:/ . -------------------------------------------------------------------------------- /bin/run.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | . /boot/uboot/env.sh 4 | 5 | if [ ! -f "$THUMB_DRIVE" ]; then 6 | echo "Thumbdrive not found!" 7 | else 8 | if [ ! -f "$THUMB_DRIVE/copy-lock" ]; then 9 | echo "copy-lock not found.." 10 | #$ACTIVE_HOME/bin/pull-from-thumbdrive.sh >> $MONITOR_LOG 2>&1 11 | #touch $THUMB_DRIVE/copy-lock 12 | #echo "done copying. added lock." 13 | 14 | fi 15 | 16 | if [ -f "$THUMB_DRIVE/opc-server" ]; then 17 | echo "opc-server starting...." 18 | /usr/bin/python -c "from Adafruit_BBIO.SPI import SPI; SPI(0,0)" >> $MONITOR_LOG 2>&1 19 | $ACTIVE_HOME/bin/monitor-opc.sh >> $MONITOR_LOG 2>&1 & 20 | echo "opc-server started." 21 | fi 22 | 23 | if [ -f "$THUMB_DRIVE/active-slinger" ]; then 24 | echo "active-slinger found...." 25 | #echo cape-bone-iio > /sys/devices/bone_capemgr.*/slots 2>&1 26 | #$ACTIVE_HOME/bin/monitor-slinger.sh >> $MONITOR_LOG 2>&1 & 27 | #echo "active-slinger started." 28 | 29 | fi 30 | 31 | fi 32 | 33 | 34 | echo "active-slinger starting...." 35 | echo cape-bone-iio > /sys/devices/bone_capemgr.*/slots 2>&1 36 | $ACTIVE_HOME/bin/monitor-slinger.sh >> $MONITOR_LOG 2>&1 & 37 | echo "active-slinger started." 38 | 39 | 40 | -------------------------------------------------------------------------------- /bin/scratch: -------------------------------------------------------------------------------- 1 | ;; This buffer is for notes you don't want to save, and for Lisp evaluation. 2 | ;; If you want to create a file, visit that file with C-x C-f, 3 | ;; then enter the text in that file's own buffer. 4 | 5 | 6 | DotEffect nyan("data/nyan.png"); 7 | mixer.add(&nyan); 8 | 9 | DotEffect crash("data/crash.png"); 10 | mixer.add(&crash); 11 | 12 | DotEffect sky("data/sky.png"); 13 | mixer.add(&sky); 14 | 15 | DotEffect glass("data/glass.png"); 16 | mixer.add(&glass); 17 | 18 | DotEffect dot("data/dot.png"); 19 | mixer.add(&dot); 20 | 21 | DotEffect dance("data/dance.png"); 22 | mixer.add(&dance); 23 | 24 | DotEffect dance("data/dance-in.png"); 25 | mixer.add(&dance); 26 | 27 | DotEffect startingcrow("data/startingcrow.png"); 28 | mixer.add(&startingcrow); 29 | 30 | DotEffect crow("data/crow_up.png"); 31 | mixer.add(&crow); 32 | 33 | DotEffect crow("data/crow_flying_down.png"); 34 | mixer.add(&crow); 35 | 36 | DotEffect gull("data/gull_flying.png"); 37 | mixer.add(&gull); 38 | 39 | DotEffect flying("data/flying-pelican.png"); 40 | mixer.add(&flying); 41 | 42 | DotEffect bruja("data/bruja.png"); 43 | mixer.add(&bruja); 44 | 45 | DotEffect cat("data/cat.png"); 46 | mixer.add(&cat); 47 | 48 | DotEffect bat("data/bat.png"); 49 | mixer.add(&bat); 50 | -------------------------------------------------------------------------------- /bin/setupEnv.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | cd /home/debian 4 | 5 | #system libraries 6 | sudo apt-get -y install mesa-common-dev freeglut3-dev 7 | 8 | # if you have a new beagle bone w 4gb 9 | sudo apt-get -y install emacs 10 | 11 | 12 | # if you have an old beagle bone w 2gb 13 | #turn off bone scripts: 14 | sudo systemctl disable bonescript.socket 15 | sudo systemctl disable bonescript.service 16 | sudo systemctl disable bonescript-autorun.service 17 | sudo systemctl stop bonescript.socket 18 | sudo systemctl stop bonescript.service 19 | sudo systemctl stop bonescript-autorun.service 20 | 21 | 22 | 23 | # pull repos 24 | mkdir git 25 | cd git 26 | git clone https://github.com/mpinner/Active.git 27 | git clone https://github.com/mpinner/openpixelcontrol.git 28 | cd /home/debian/git/openpixelcontrol 29 | git checkout tlc5947 30 | 31 | 32 | 33 | #setup ACTIVE 34 | cd /home/debian/git/Active/bin/ 35 | chmod +x *.sh 36 | sudo cp env.sh /boot/uboot/ 37 | 38 | . /boot/uboot/env.sh 39 | 40 | echo ". /boot/uboot/env.sh" >> .bashrc 41 | 42 | cd /home/debian/git/Active/streamers/ 43 | chmod +x *.py 44 | 45 | 46 | 47 | sudo touch $OPC_LOG 48 | sudo touch $STREAMER_LOG 49 | sudo touch $MONITOR_LOG 50 | sudo touch $SPARKFUN_LOG 51 | 52 | sudo chown debian $OPC_LOG 53 | sudo chown debian $STREAMER_LOG 54 | sudo chown debian $MONITOR_LOG 55 | sudo chown debian $SPARKFUN_LOG 56 | 57 | 58 | #setup log rotate 59 | sudo touch /etc/logrotate.d/active 60 | sudo chown debian /etc/logrotate.d/active 61 | 62 | 63 | 64 | # make OPC 65 | cd /home/debian/git/openpixelcontrol 66 | make 67 | 68 | # make cpp streamer 69 | cd /home/debian/git/Active/src 70 | make 71 | 72 | 73 | # sudo 74 | sudo su - 75 | cat /home/debian/git/Active/bin/hosts >> /etc/hosts 76 | echo ". /boot/uboot/env.sh" >> .bashrc 77 | exit 78 | 79 | 80 | 81 | 82 | 83 | cd ~/git; 84 | git clone git://git.videolan.org/x264.git 85 | cd x264/ 86 | ./configure --enable-static --enable-shared 87 | date ; make ; date 88 | 89 | 90 | sudo su - 91 | cd /home/debian/git/x264 92 | make install 93 | ldconfig 94 | 95 | exit 96 | 97 | cd ~/git; 98 | git clone git://git.videolan.org/ffmpeg.git 99 | cd ffmpeg 100 | ./configure --enable-shared --enable-libx264 --enable-gpl 101 | git remote set-url origin git://source.ffmpeg.org/ffmpeg 102 | make 103 | sudo make install 104 | 105 | 106 | 107 | sudo su - 108 | cd /home/debian/git/ffmpeg 109 | make install 110 | ldconfig 111 | 112 | exit 113 | 114 | 115 | 116 | 117 | 118 | -------------------------------------------------------------------------------- /docs/Active_SmokeMonster_tb.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpinner/Active/b5e2c9df3a53bc79920fb5f17489296238b898d0/docs/Active_SmokeMonster_tb.gif -------------------------------------------------------------------------------- /docs/Active_TieFighter_tb.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpinner/Active/b5e2c9df3a53bc79920fb5f17489296238b898d0/docs/Active_TieFighter_tb.gif -------------------------------------------------------------------------------- /docs/Active_flyer_dm.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpinner/Active/b5e2c9df3a53bc79920fb5f17489296238b898d0/docs/Active_flyer_dm.jpg -------------------------------------------------------------------------------- /layout/layout-60x24-1n2.json: -------------------------------------------------------------------------------- 1 | [ 2 | {"point": [-4.6, -2.4, -1.4]}, 3 | {"point": [-4.6, -2.2, -1.2]}, 4 | {"point": [-4.6, -2.0, 1.2]}, 5 | {"point": [-4.6, -1.8, 2.2]}, 6 | {"point": [-4.6, -1.6, -1.0]}, 7 | {"point": [-4.6, -1.4, 0.8]}, 8 | {"point": [-4.6, -1.2, 0.0]}, 9 | {"point": [-4.6, -1.0, -2.0]}, 10 | {"point": [-4.6, -0.8, 0.2]}, 11 | {"point": [-4.6, -0.6, -2.4]}, 12 | {"point": [-4.6, -0.4, -1.8]}, 13 | {"point": [-4.6, -0.2, -0.4]}, 14 | {"point": [-4.6, 0.0, 1.6]}, 15 | {"point": [-4.6, 0.2, 1.4]}, 16 | {"point": [-4.6, 0.4, 0.4]}, 17 | {"point": [-4.6, 0.6, -1.6]}, 18 | {"point": [-4.6, 0.8, 0.6]}, 19 | {"point": [-4.6, 1.0, -0.2]}, 20 | {"point": [-4.6, 1.2, 1.0]}, 21 | {"point": [-4.6, 1.4, -0.8]}, 22 | {"point": [-4.6, 1.6, -0.6]}, 23 | {"point": [-4.6, 1.8, 1.8]}, 24 | {"point": [-4.6, 2.0, 2.0]}, 25 | {"point": [-4.6, 2.2, -2.2]}, 26 | {"point": [-4.4, -2.4, 1.4]}, 27 | {"point": [-4.4, -2.2, 0.6]}, 28 | {"point": [-4.4, -2.0, 1.0]}, 29 | {"point": [-4.4, -1.8, 0.4]}, 30 | {"point": [-4.4, -1.6, -0.6]}, 31 | {"point": [-4.4, -1.4, 0.8]}, 32 | {"point": [-4.4, -1.2, 1.2]}, 33 | {"point": [-4.4, -1.0, -1.8]}, 34 | {"point": [-4.4, -0.8, 2.2]}, 35 | {"point": [-4.4, -0.6, -1.0]}, 36 | {"point": [-4.4, -0.4, -1.2]}, 37 | {"point": [-4.4, -0.2, 0.0]}, 38 | {"point": [-4.4, 0.0, 0.2]}, 39 | {"point": [-4.4, 0.2, -0.4]}, 40 | {"point": [-4.4, 0.4, -2.2]}, 41 | {"point": [-4.4, 0.6, 1.6]}, 42 | {"point": [-4.4, 0.8, -2.4]}, 43 | {"point": [-4.4, 1.0, -1.4]}, 44 | {"point": [-4.4, 1.2, -0.2]}, 45 | {"point": [-4.4, 1.4, 1.8]}, 46 | {"point": [-4.4, 1.6, -0.8]}, 47 | {"point": [-4.4, 1.8, -1.6]}, 48 | {"point": [-4.4, 2.0, 2.0]}, 49 | {"point": [-4.4, 2.2, -2.0]} 50 | ] -------------------------------------------------------------------------------- /layout/layout-60x24-26-n-25.json: -------------------------------------------------------------------------------- 1 | [ 2 | {"point": [0.0, -2.4, 1.2]}, 3 | {"point": [0.0, -2.2, -0.2]}, 4 | {"point": [0.0, -2.0, 0.8]}, 5 | {"point": [0.0, -1.8, 1.4]}, 6 | {"point": [0.0, -1.6, -1.0]}, 7 | {"point": [0.0, -1.4, -2.4]}, 8 | {"point": [0.0, -1.2, 1.0]}, 9 | {"point": [0.0, -1.0, 1.8]}, 10 | {"point": [0.0, -0.8, -0.8]}, 11 | {"point": [0.0, -0.6, -1.8]}, 12 | {"point": [0.0, -0.4, -1.4]}, 13 | {"point": [0.0, -0.2, -0.6]}, 14 | {"point": [0.0, 0.0, -0.4]}, 15 | {"point": [0.0, 0.2, 0.6]}, 16 | {"point": [0.0, 0.4, 2.2]}, 17 | {"point": [0.0, 0.6, 1.6]}, 18 | {"point": [0.0, 0.8, -2.2]}, 19 | {"point": [0.0, 1.0, -1.2]}, 20 | {"point": [0.0, 1.2, 0.4]}, 21 | {"point": [0.0, 1.4, 0.0]}, 22 | {"point": [0.0, 1.6, -1.6]}, 23 | {"point": [0.0, 1.8, 2.0]}, 24 | {"point": [0.0, 2.0, -2.0]}, 25 | {"point": [0.0, 2.2, 0.2]}, 26 | {"point": [0.2, -2.4, -2.4]}, 27 | {"point": [0.2, -2.2, 1.4]}, 28 | {"point": [0.2, -2.0, -0.8]}, 29 | {"point": [0.2, -1.8, 1.2]}, 30 | {"point": [0.2, -1.6, -1.2]}, 31 | {"point": [0.2, -1.4, -0.4]}, 32 | {"point": [0.2, -1.2, 1.8]}, 33 | {"point": [0.2, -1.0, -1.6]}, 34 | {"point": [0.2, -0.8, 2.2]}, 35 | {"point": [0.2, -0.6, -1.0]}, 36 | {"point": [0.2, -0.4, 0.0]}, 37 | {"point": [0.2, -0.2, 0.6]}, 38 | {"point": [0.2, 0.0, 1.6]}, 39 | {"point": [0.2, 0.2, -2.0]}, 40 | {"point": [0.2, 0.4, -2.2]}, 41 | {"point": [0.2, 0.6, -1.4]}, 42 | {"point": [0.2, 0.8, -0.2]}, 43 | {"point": [0.2, 1.0, 0.2]}, 44 | {"point": [0.2, 1.2, -1.8]}, 45 | {"point": [0.2, 1.4, 0.8]}, 46 | {"point": [0.2, 1.6, -0.6]}, 47 | {"point": [0.2, 1.8, 0.4]}, 48 | {"point": [0.2, 2.0, 2.0]}, 49 | {"point": [0.2, 2.2, 1.0]} 50 | ] -------------------------------------------------------------------------------- /layout/layout-60x24-26.json: -------------------------------------------------------------------------------- 1 | [ 2 | {"point": [0.0, -2.4, 1.2]}, 3 | {"point": [0.0, -2.2, -0.2]}, 4 | {"point": [0.0, -2.0, 0.8]}, 5 | {"point": [0.0, -1.8, 1.4]}, 6 | {"point": [0.0, -1.6, -1.0]}, 7 | {"point": [0.0, -1.4, -2.4]}, 8 | {"point": [0.0, -1.2, 1.0]}, 9 | {"point": [0.0, -1.0, 1.8]}, 10 | {"point": [0.0, -0.8, -0.8]}, 11 | {"point": [0.0, -0.6, -1.8]}, 12 | {"point": [0.0, -0.4, -1.4]}, 13 | {"point": [0.0, -0.2, -0.6]}, 14 | {"point": [0.0, 0.0, -0.4]}, 15 | {"point": [0.0, 0.2, 0.6]}, 16 | {"point": [0.0, 0.4, 2.2]}, 17 | {"point": [0.0, 0.6, 1.6]}, 18 | {"point": [0.0, 0.8, -2.2]}, 19 | {"point": [0.0, 1.0, -1.2]}, 20 | {"point": [0.0, 1.2, 0.4]}, 21 | {"point": [0.0, 1.4, 0.0]}, 22 | {"point": [0.0, 1.6, -1.6]}, 23 | {"point": [0.0, 1.8, 2.0]}, 24 | {"point": [0.0, 2.0, -2.0]}, 25 | {"point": [0.0, 2.2, 0.2]}, 26 | {"point": [0.2, -2.4, -2.4]}, 27 | {"point": [0.2, -2.2, 1.4]}, 28 | {"point": [0.2, -2.0, -0.8]}, 29 | {"point": [0.2, -1.8, 1.2]}, 30 | {"point": [0.2, -1.6, -1.2]}, 31 | {"point": [0.2, -1.4, -0.4]}, 32 | {"point": [0.2, -1.2, 1.8]}, 33 | {"point": [0.2, -1.0, -1.6]}, 34 | {"point": [0.2, -0.8, 2.2]}, 35 | {"point": [0.2, -0.6, -1.0]}, 36 | {"point": [0.2, -0.4, 0.0]}, 37 | {"point": [0.2, -0.2, 0.6]}, 38 | {"point": [0.2, 0.0, 1.6]}, 39 | {"point": [0.2, 0.2, -2.0]}, 40 | {"point": [0.2, 0.4, -2.2]}, 41 | {"point": [0.2, 0.6, -1.4]}, 42 | {"point": [0.2, 0.8, -0.2]}, 43 | {"point": [0.2, 1.0, 0.2]}, 44 | {"point": [0.2, 1.2, -1.8]}, 45 | {"point": [0.2, 1.4, 0.8]}, 46 | {"point": [0.2, 1.6, -0.6]}, 47 | {"point": [0.2, 1.8, 0.4]}, 48 | {"point": [0.2, 2.0, 2.0]}, 49 | {"point": [0.2, 2.2, 1.0]} 50 | ] -------------------------------------------------------------------------------- /layout/layout-60x24.xls: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpinner/Active/b5e2c9df3a53bc79920fb5f17489296238b898d0/layout/layout-60x24.xls -------------------------------------------------------------------------------- /layout/wall-12.json: -------------------------------------------------------------------------------- 1 | [ 2 | {"point": [-1.20, 0.00, -0.10]}, 3 | {"point": [-1.20, 0.00, 0.00]}, 4 | {"point": [-1.10, 0.00, -0.10]}, 5 | {"point": [-1.10, 0.00, 0.00]}, 6 | {"point": [-1.00, 0.00, -0.10]}, 7 | {"point": [-1.00, 0.00, 0.00]}, 8 | {"point": [-0.90, 0.00, -0.10]}, 9 | {"point": [-0.90, 0.00, 0.00]}, 10 | {"point": [-0.80, 0.00, -0.10]}, 11 | {"point": [-0.80, 0.00, 0.00]}, 12 | {"point": [-0.70, 0.00, -0.10]}, 13 | {"point": [-0.70, 0.00, 0.00]}, 14 | {"point": [-0.60, 0.00, -0.10]}, 15 | {"point": [-0.60, 0.00, 0.00]}, 16 | {"point": [-0.50, 0.00, -0.10]}, 17 | {"point": [-0.50, 0.00, 0.00]}, 18 | {"point": [-0.40, 0.00, -0.10]}, 19 | {"point": [-0.40, 0.00, 0.00]}, 20 | {"point": [-0.30, 0.00, -0.10]}, 21 | {"point": [-0.30, 0.00, 0.00]}, 22 | {"point": [-0.20, 0.00, -0.10]}, 23 | {"point": [-0.20, 0.00, 0.00]}, 24 | {"point": [-0.10, 0.00, -0.10]}, 25 | {"point": [-0.10, 0.00, 0.00]}, 26 | {"point": [0.00, 0.00, -0.10]}, 27 | {"point": [0.00, 0.00, 0.00]}, 28 | {"point": [0.10, 0.00, -0.10]}, 29 | {"point": [0.10, 0.00, 0.00]}, 30 | {"point": [0.20, 0.00, -0.10]}, 31 | {"point": [0.20, 0.00, 0.00]}, 32 | {"point": [0.30, 0.00, -0.10]}, 33 | {"point": [0.30, 0.00, 0.00]}, 34 | {"point": [0.40, 0.00, -0.10]}, 35 | {"point": [0.40, 0.00, 0.00]}, 36 | {"point": [0.50, 0.00, -0.10]}, 37 | {"point": [0.50, 0.00, 0.00]}, 38 | {"point": [0.60, 0.00, -0.10]}, 39 | {"point": [0.60, 0.00, 0.00]}, 40 | {"point": [0.70, 0.00, -0.10]}, 41 | {"point": [0.70, 0.00, 0.00]}, 42 | {"point": [0.80, 0.00, -0.10]}, 43 | {"point": [0.80, 0.00, 0.00]}, 44 | {"point": [0.90, 0.00, -0.10]}, 45 | {"point": [0.90, 0.00, 0.00]}, 46 | {"point": [1.00, 0.00, -0.10]}, 47 | {"point": [1.00, 0.00, 0.00]}, 48 | {"point": [1.10, 0.00, -0.10]}, 49 | {"point": [1.10, 0.00, 0.00]} 50 | ] 51 | -------------------------------------------------------------------------------- /python/Nyan Catbw.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpinner/Active/b5e2c9df3a53bc79920fb5f17489296238b898d0/python/Nyan Catbw.png -------------------------------------------------------------------------------- /python/crashlogo-small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpinner/Active/b5e2c9df3a53bc79920fb5f17489296238b898d0/python/crashlogo-small.png -------------------------------------------------------------------------------- /python/dance.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpinner/Active/b5e2c9df3a53bc79920fb5f17489296238b898d0/python/dance.jpg -------------------------------------------------------------------------------- /python/from PIL import Image: -------------------------------------------------------------------------------- 1 | from PIL import Image 2 | im = Image.open("bride.jpg") 3 | im.rotate(45).show() 4 | 5 | -------------------------------------------------------------------------------- /python/greyscale.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/python 2 | from PIL import Image, ImageStat 3 | 4 | 5 | import sys, getopt 6 | 7 | 8 | 9 | def is_color_image(file, thumb_size=40, MSE_cutoff=22, adjust_color_bias=True): 10 | pil_img = Image.open(file) 11 | bands = pil_img.getbands() 12 | if bands == ('R','G','B') or bands== ('R','G','B','A'): 13 | thumb = pil_img.resize((thumb_size,thumb_size)) 14 | SSE, bias = 0, [0,0,0] 15 | if adjust_color_bias: 16 | bias = ImageStat.Stat(thumb).mean[:3] 17 | bias = [b - sum(bias)/3 for b in bias ] 18 | for pixel in thumb.getdata(): 19 | mu = sum(pixel)/3 20 | SSE += sum((pixel[i] - mu - bias[i])*(pixel[i] - mu - bias[i]) for i in [0,1,2]) 21 | MSE = float(SSE)/(thumb_size*thumb_size) 22 | if MSE <= MSE_cutoff: 23 | print "grayscale\t", 24 | return False 25 | else: 26 | print "Color\t\t\t", 27 | print "( MSE=",MSE,")" 28 | elif len(bands)==1: 29 | print "Black and white", bands 30 | return False 31 | else: 32 | print "Don't know...", bands 33 | 34 | return True 35 | 36 | 37 | def main(argv): 38 | print 'HI List:', argv 39 | 40 | 41 | inputfile = argv[1] 42 | 43 | 44 | im = Image.open(inputfile) 45 | 46 | # this is clearly a terrible idea 47 | #im = im.rotate(45) 48 | 49 | # this does 50 | #im = im.convert('1') #this converts to 1-bit B&Ws 51 | 52 | if is_color_image(inputfile): 53 | im = im.convert('LA') #this converts to grey scale 54 | 55 | im = im.resize((60,24)) 56 | 57 | im.save('outfile.png') 58 | 59 | #if (env.) 60 | 61 | 62 | 63 | im.show() 64 | 65 | 66 | 67 | if __name__ == "__main__": 68 | 69 | print 'Number of arguments:', len(sys.argv), 'arguments.' 70 | print 'Argument List:', str(sys.argv) 71 | main(sys.argv) 72 | 73 | -------------------------------------------------------------------------------- /python/hobbes-icon.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpinner/Active/b5e2c9df3a53bc79920fb5f17489296238b898d0/python/hobbes-icon.jpeg -------------------------------------------------------------------------------- /python/outfile.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpinner/Active/b5e2c9df3a53bc79920fb5f17489296238b898d0/python/outfile.png -------------------------------------------------------------------------------- /python/pil-test.py: -------------------------------------------------------------------------------- 1 | from PIL import Image 2 | im = Image.open("bride.jpg") 3 | im.rotate(45).show() 4 | 5 | pilImage=Image.open(inputImage) 6 | pilImage = pilImage.convert('1') #this convert to black&white 7 | pilImage.draft('L',(500,500)) 8 | 9 | pilImage.save('outfile.png') -------------------------------------------------------------------------------- /python/udp-test-swipe.py: -------------------------------------------------------------------------------- 1 | import socket 2 | from time import sleep 3 | 4 | UDP_IP = "192.168.1.177"; 5 | UDP_PORT = 8888; 6 | #MESSAGE = 0x0101010101010101010101010101010101010101010101010110 7 | #NOT_MESSAGE = 0x10101010101010101010101010101010101010101010101010110 8 | 9 | #"Hello, World!"; 10 | 11 | print "UDP target IP:", UDP_IP; 12 | print "UDP target port:", UDP_PORT; 13 | 14 | sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM); 15 | 16 | 17 | for j in range(0,65): 18 | 19 | for i in range(0,26): 20 | 21 | MESSAGE = char(j) * i; 22 | print "message:", MESSAGE; 23 | sock.sendto(MESSAGE, (UDP_IP ,UDP_PORT)); 24 | sleep(.5); 25 | 26 | 27 | -------------------------------------------------------------------------------- /python/udp-test.py: -------------------------------------------------------------------------------- 1 | import socket 2 | from time import sleep 3 | 4 | UDP_IP = "192.168.1.177"; 5 | UDP_PORT = 8888; 6 | #MESSAGE = 0x0101010101010101010101010101010101010101010101010110 7 | #NOT_MESSAGE = 0x10101010101010101010101010101010101010101010101010110 8 | 9 | #"Hello, World!"; 10 | 11 | print "UDP target IP:", UDP_IP; 12 | print "UDP target port:", UDP_PORT; 13 | 14 | sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM); 15 | 16 | 17 | for j in range(0,65): 18 | 19 | for i in range(0,26): 20 | 21 | MESSAGE = char(j) * i; 22 | print "message:", MESSAGE; 23 | sock.sendto(MESSAGE, (UDP_IP ,UDP_PORT)); 24 | sleep(.5); 25 | 26 | 27 | -------------------------------------------------------------------------------- /src/Makefile: -------------------------------------------------------------------------------- 1 | PROGRAMS = simple rings spokes dot particle_trail mixer images video 2 | 3 | 4 | # Important optimization options 5 | CFLAGS = -O3 -ffast-math -fno-rtti 6 | 7 | # Standard libraries 8 | LFLAGS = -lm -lstdc++ -lpthread 9 | 10 | # Debugging 11 | CFLAGS += -g -Wall 12 | LFLAGS += -g 13 | 14 | # Annoying warnings on by default on Mac OS 15 | CFLAGS += -Wno-tautological-constant-out-of-range-compare -Wno-gnu-static-float-init 16 | 17 | 18 | all: $(PROGRAMS) 19 | 20 | .cpp: 21 | $(CC) $(CFLAGS) $< -o $@ $(LFLAGS) ./lib/BlackLib.o 22 | 23 | .PHONY: clean all 24 | 25 | clean: 26 | rm -f $(PROGRAMS) 27 | -------------------------------------------------------------------------------- /src/ball.cpp: -------------------------------------------------------------------------------- 1 | // Simple example effect: 2 | // Draws a noise pattern modulated by an expanding sine wave. 3 | 4 | #include "lib/effect_runner.h" 5 | #include "ball.h" 6 | 7 | int main(int argc, char **argv) 8 | { 9 | EffectRunner r; 10 | 11 | BallEffect e; 12 | r.setEffect(&e); 13 | 14 | // Defaults, overridable with command line options 15 | r.setLayout("../layouts/grid32x16z.json"); 16 | 17 | return r.main(argc, argv); 18 | } -------------------------------------------------------------------------------- /src/ball.h: -------------------------------------------------------------------------------- 1 | // Ball effect: 2 | // Draws a noise pattern modulated by an expanding sine wave. 3 | 4 | #include 5 | #include "lib/color.h" 6 | #include "lib/effect.h" 7 | #include "lib/effect_runner.h" 8 | #include "lib/noise.h" 9 | 10 | class BallEffect : public Effect 11 | { 12 | public: 13 | BallEffect() 14 | : cycle (0) {} 15 | 16 | float cycle; 17 | 18 | virtual void beginFrame(const FrameInfo &f) 19 | { 20 | const float speed = 1.0; 21 | cycle = fmodf(cycle + f.timeDelta * speed, 2 * M_PI); 22 | } 23 | 24 | virtual void shader(Vec3& rgb, const PixelInfo &p) const 25 | { 26 | float distance = len(p.point); 27 | float wave = sinf(3.0 * distance - cycle) ; //+ noise3(p.point); 28 | hsv2rgb(rgb, 0.2, 0.3, wave); 29 | } 30 | }; 31 | -------------------------------------------------------------------------------- /src/black-rings.cpp: -------------------------------------------------------------------------------- 1 | #include "lib/effect_runner.h" 2 | #include "black-rings.h" 3 | 4 | 5 | int main(int argc, char **argv) 6 | { 7 | RingsEffect e("data/glass.png"); 8 | 9 | EffectRunner r; 10 | r.setEffect(&e); 11 | 12 | r.setLayout("../layouts/grid32x16z.json"); 13 | return r.main(argc, argv); 14 | } 15 | -------------------------------------------------------------------------------- /src/data/bat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpinner/Active/b5e2c9df3a53bc79920fb5f17489296238b898d0/src/data/bat.png -------------------------------------------------------------------------------- /src/data/bruja.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpinner/Active/b5e2c9df3a53bc79920fb5f17489296238b898d0/src/data/bruja.png -------------------------------------------------------------------------------- /src/data/cat.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpinner/Active/b5e2c9df3a53bc79920fb5f17489296238b898d0/src/data/cat.png -------------------------------------------------------------------------------- /src/data/crash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpinner/Active/b5e2c9df3a53bc79920fb5f17489296238b898d0/src/data/crash.png -------------------------------------------------------------------------------- /src/data/crow_flying_down.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpinner/Active/b5e2c9df3a53bc79920fb5f17489296238b898d0/src/data/crow_flying_down.png -------------------------------------------------------------------------------- /src/data/crow_up.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpinner/Active/b5e2c9df3a53bc79920fb5f17489296238b898d0/src/data/crow_up.png -------------------------------------------------------------------------------- /src/data/dance-in.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpinner/Active/b5e2c9df3a53bc79920fb5f17489296238b898d0/src/data/dance-in.png -------------------------------------------------------------------------------- /src/data/dance.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpinner/Active/b5e2c9df3a53bc79920fb5f17489296238b898d0/src/data/dance.jpg -------------------------------------------------------------------------------- /src/data/dance.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpinner/Active/b5e2c9df3a53bc79920fb5f17489296238b898d0/src/data/dance.png -------------------------------------------------------------------------------- /src/data/dot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpinner/Active/b5e2c9df3a53bc79920fb5f17489296238b898d0/src/data/dot.png -------------------------------------------------------------------------------- /src/data/evolution-in.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpinner/Active/b5e2c9df3a53bc79920fb5f17489296238b898d0/src/data/evolution-in.png -------------------------------------------------------------------------------- /src/data/evolution2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpinner/Active/b5e2c9df3a53bc79920fb5f17489296238b898d0/src/data/evolution2.jpg -------------------------------------------------------------------------------- /src/data/evolution2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpinner/Active/b5e2c9df3a53bc79920fb5f17489296238b898d0/src/data/evolution2.png -------------------------------------------------------------------------------- /src/data/flying-pelican.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpinner/Active/b5e2c9df3a53bc79920fb5f17489296238b898d0/src/data/flying-pelican.png -------------------------------------------------------------------------------- /src/data/flying.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpinner/Active/b5e2c9df3a53bc79920fb5f17489296238b898d0/src/data/flying.png -------------------------------------------------------------------------------- /src/data/glass.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpinner/Active/b5e2c9df3a53bc79920fb5f17489296238b898d0/src/data/glass.png -------------------------------------------------------------------------------- /src/data/gull_flying.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpinner/Active/b5e2c9df3a53bc79920fb5f17489296238b898d0/src/data/gull_flying.png -------------------------------------------------------------------------------- /src/data/heart-in.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpinner/Active/b5e2c9df3a53bc79920fb5f17489296238b898d0/src/data/heart-in.png -------------------------------------------------------------------------------- /src/data/heart.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpinner/Active/b5e2c9df3a53bc79920fb5f17489296238b898d0/src/data/heart.png -------------------------------------------------------------------------------- /src/data/img0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpinner/Active/b5e2c9df3a53bc79920fb5f17489296238b898d0/src/data/img0.png -------------------------------------------------------------------------------- /src/data/img1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpinner/Active/b5e2c9df3a53bc79920fb5f17489296238b898d0/src/data/img1.png -------------------------------------------------------------------------------- /src/data/img2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpinner/Active/b5e2c9df3a53bc79920fb5f17489296238b898d0/src/data/img2.png -------------------------------------------------------------------------------- /src/data/img3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpinner/Active/b5e2c9df3a53bc79920fb5f17489296238b898d0/src/data/img3.png -------------------------------------------------------------------------------- /src/data/img4.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpinner/Active/b5e2c9df3a53bc79920fb5f17489296238b898d0/src/data/img4.png -------------------------------------------------------------------------------- /src/data/man_f7d1301_v1_8820-00370_basic_router.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpinner/Active/b5e2c9df3a53bc79920fb5f17489296238b898d0/src/data/man_f7d1301_v1_8820-00370_basic_router.pdf -------------------------------------------------------------------------------- /src/data/nyan.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpinner/Active/b5e2c9df3a53bc79920fb5f17489296238b898d0/src/data/nyan.png -------------------------------------------------------------------------------- /src/data/rino.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpinner/Active/b5e2c9df3a53bc79920fb5f17489296238b898d0/src/data/rino.jpeg -------------------------------------------------------------------------------- /src/data/rino.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpinner/Active/b5e2c9df3a53bc79920fb5f17489296238b898d0/src/data/rino.png -------------------------------------------------------------------------------- /src/data/sky.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpinner/Active/b5e2c9df3a53bc79920fb5f17489296238b898d0/src/data/sky.png -------------------------------------------------------------------------------- /src/data/startingcrow.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpinner/Active/b5e2c9df3a53bc79920fb5f17489296238b898d0/src/data/startingcrow.png -------------------------------------------------------------------------------- /src/data/wide-wings.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpinner/Active/b5e2c9df3a53bc79920fb5f17489296238b898d0/src/data/wide-wings.jpeg -------------------------------------------------------------------------------- /src/data/witch.jpeg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpinner/Active/b5e2c9df3a53bc79920fb5f17489296238b898d0/src/data/witch.jpeg -------------------------------------------------------------------------------- /src/direction-bottom-to-top.cpp: -------------------------------------------------------------------------------- 1 | // Simple example effect: 2 | // Draws a noise pattern modulated by an expanding sine wave. 3 | 4 | #include 5 | #include "lib/color.h" 6 | #include "lib/effect.h" 7 | #include "lib/effect_runner.h" 8 | #include "lib/noise.h" 9 | 10 | class MyEffect : public Effect 11 | { 12 | public: 13 | MyEffect() 14 | : cycle (0) {} 15 | 16 | float cycle; 17 | 18 | virtual void beginFrame(const FrameInfo &f) 19 | { 20 | const float speed = 10.0; 21 | cycle = fmodf(cycle + f.timeDelta * speed, 2 * M_PI); 22 | } 23 | 24 | virtual void shader(Vec3& rgb, const PixelInfo &p) const 25 | { 26 | if (p.point[1] == -2.4) { 27 | hsv2rgb(rgb, 0.2, 0.3, 1.0); 28 | 29 | } 30 | 31 | } 32 | }; 33 | 34 | int main(int argc, char **argv) 35 | { 36 | EffectRunner r; 37 | 38 | MyEffect e; 39 | r.setEffect(&e); 40 | 41 | // Defaults, overridable with command line options 42 | r.setMaxFrameRate(100); 43 | r.setLayout("../layouts/grid32x16z.json"); 44 | 45 | return r.main(argc, argv); 46 | } 47 | -------------------------------------------------------------------------------- /src/direction-front-to-back.cpp: -------------------------------------------------------------------------------- 1 | // Simple example effect: 2 | // Draws a noise pattern modulated by an expanding sine wave. 3 | 4 | #include 5 | #include "lib/color.h" 6 | #include "lib/effect.h" 7 | #include "lib/effect_runner.h" 8 | #include "lib/noise.h" 9 | 10 | class MyEffect : public Effect 11 | { 12 | public: 13 | MyEffect() 14 | : cycle (0) {} 15 | 16 | float cycle; 17 | 18 | virtual void beginFrame(const FrameInfo &f) 19 | { 20 | const float speed = 10.0; 21 | cycle = fmodf(cycle + f.timeDelta * speed, 2 * M_PI); 22 | } 23 | 24 | virtual void shader(Vec3& rgb, const PixelInfo &p) const 25 | { 26 | float distance = len(p.point); 27 | float wave = sinf(3.0 * distance - cycle) + p.point[2]; 28 | hsv2rgb(rgb, 0.2, 0.3, wave); 29 | } 30 | }; 31 | 32 | int main(int argc, char **argv) 33 | { 34 | EffectRunner r; 35 | 36 | MyEffect e; 37 | r.setEffect(&e); 38 | 39 | // Defaults, overridable with command line options 40 | r.setMaxFrameRate(100); 41 | r.setLayout("../layouts/grid32x16z.json"); 42 | 43 | return r.main(argc, argv); 44 | } 45 | -------------------------------------------------------------------------------- /src/direction-right-to-left.cpp: -------------------------------------------------------------------------------- 1 | // Simple example effect: 2 | // Draws a noise pattern modulated by an expanding sine wave. 3 | 4 | #include 5 | #include "lib/color.h" 6 | #include "lib/effect.h" 7 | #include "lib/effect_runner.h" 8 | #include "lib/noise.h" 9 | 10 | class MyEffect : public Effect 11 | { 12 | public: 13 | MyEffect() 14 | : cycle (0) {} 15 | 16 | float cycle; 17 | 18 | virtual void beginFrame(const FrameInfo &f) 19 | { 20 | const float speed = 10.0; 21 | cycle = fmodf(cycle + f.timeDelta * speed, 2 * M_PI); 22 | } 23 | 24 | virtual void shader(Vec3& rgb, const PixelInfo &p) const 25 | { 26 | float distance = len(p.point); 27 | float wave = sinf(3.0 * distance - cycle) + p.point[0]; 28 | hsv2rgb(rgb, 0.2, 0.3, wave); 29 | } 30 | }; 31 | 32 | int main(int argc, char **argv) 33 | { 34 | EffectRunner r; 35 | 36 | MyEffect e; 37 | r.setEffect(&e); 38 | 39 | // Defaults, overridable with command line options 40 | r.setMaxFrameRate(100); 41 | r.setLayout("../layouts/grid32x16z.json"); 42 | 43 | return r.main(argc, argv); 44 | } 45 | -------------------------------------------------------------------------------- /src/dot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpinner/Active/b5e2c9df3a53bc79920fb5f17489296238b898d0/src/dot -------------------------------------------------------------------------------- /src/dot.cpp: -------------------------------------------------------------------------------- 1 | #include "lib/effect_runner.h" 2 | #include "dot.h" 3 | 4 | int main(int argc, char **argv) 5 | { 6 | EffectRunner r; 7 | 8 | DotEffect e("data/dot.png"); 9 | r.setEffect(&e); 10 | 11 | // Defaults, overridable with command line options 12 | r.setLayout("../layouts/grid32x16z.json"); 13 | 14 | return r.main(argc, argv); 15 | } 16 | -------------------------------------------------------------------------------- /src/dot.h: -------------------------------------------------------------------------------- 1 | // Texture example: "dot" image, wandering around the frame. 2 | 3 | #pragma once 4 | 5 | #include "lib/color.h" 6 | #include "lib/effect.h" 7 | #include "lib/texture.h" 8 | 9 | class DotEffect : public Effect 10 | { 11 | public: 12 | DotEffect(const char *filename) 13 | : dot(filename), 14 | angle1(2*M_PI), angle2(0), angle3(0) 15 | {} 16 | 17 | Texture dot; 18 | 19 | float angle1; 20 | float angle2; 21 | float angle3; 22 | 23 | virtual void beginFrame(const FrameInfo &f) 24 | { 25 | 26 | const float speed = 0.01; // SLOW 27 | // const float speed = 1.01; // FAST 28 | 29 | // Several bounded state variables, rotating at different rates 30 | ///* 31 | angle1 = fmodf(angle1 + f.timeDelta * speed, 2 * M_PI); 32 | angle2 = fmodf(angle2 + f.timeDelta * speed * 0.2f, 2 * M_PI); 33 | angle3 = fmodf(angle3 + f.timeDelta * speed * 0.7f, 2 * M_PI); 34 | //*/ 35 | // Several bounded state variables, rotating at different rates 36 | /* 37 | angle1 = fmodf(angle1 * speed, 2 * M_PI); 38 | angle2 = fmodf(angle2 * speed , 2 * M_PI); 39 | angle3 = fmodf(angle3 + f.timeDelta * speed , 2 * M_PI); 40 | */ 41 | } 42 | 43 | virtual void shader(Vec3& rgb, const PixelInfo &p) const 44 | { 45 | // Project onto the XZ plane 46 | Vec2 plane = Vec2(p.point[0]*-0.5f, p.point[1]); 47 | 48 | // rotate this 49 | // plane 50 | 51 | // Moving dot 52 | Vec2 position = 0.8 * Vec2( sinf(angle1)*4, cosf(angle1 + sin(angle2)) ); 53 | 54 | // Texture geometry 55 | Vec2 center(0.3, 0.2); 56 | float size = 2.5 + 0.8 * sinf(angle3); 57 | 58 | rgb = dot.sample( (plane + position) / size + center ); 59 | 60 | // rgb = dot.sample( (plane - position) / size + center ); 61 | } 62 | 63 | }; 64 | -------------------------------------------------------------------------------- /src/example.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | ######################################################################################## 4 | # BlackLib Library controls Beaglebone Black's inputs and outputs. # 5 | # Copyright (C) 2013-2014 by Yigit YUCE # 6 | ######################################################################################## 7 | # # 8 | # This file is part of BlackLib library. # 9 | # # 10 | # BlackLib library is free software: you can redistribute it and/or modify # 11 | # it under the terms of the GNU Lesser General Public License as published by # 12 | # the Free Software Foundation, either version 3 of the License, or # 13 | # (at your option) any later version. # 14 | # # 15 | # BlackLib library is distributed in the hope that it will be useful, # 16 | # but WITHOUT ANY WARRANTY; without even the implied warranty of # 17 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # 18 | # GNU Lesser General Public License for more details. # 19 | # # 20 | # You should have received a copy of the GNU Lesser General Public License # 21 | # along with this program. If not, see . # 22 | # # 23 | # For any comment or suggestion please contact the creator of BlackLib Library # 24 | # at ygtyce@gmail.com # 25 | # # 26 | ######################################################################################## 27 | 28 | */ 29 | 30 | 31 | #include 32 | #include 33 | #include 34 | #include "BlackLib.h" 35 | using namespace std; 36 | 37 | void linePrint(int number,char symbol) 38 | { 39 | for(int i=0;i 5 | #include "lib/color.h" 6 | #include "lib/effect.h" 7 | #include "lib/effect_runner.h" 8 | #include "lib/noise.h" 9 | 10 | class MyEffect : public Effect 11 | { 12 | public: 13 | MyEffect() 14 | : cycle (0) {} 15 | 16 | float cycle; 17 | float theIndex; 18 | 19 | 20 | virtual void beginFrame(const FrameInfo &f) 21 | { 22 | const float speed = 9.3; 23 | cycle = fmodf(cycle + f.timeDelta * speed, 24); 24 | 25 | theIndex = ((int)cycle) % 24; 26 | theIndex -= 12; 27 | theIndex /= 5.0; 28 | } 29 | 30 | virtual void shader(Vec3& rgb, const PixelInfo &p) const 31 | { 32 | 33 | 34 | 35 | // float distance = len(p.point); 36 | // float wave = sinf(0.7 * p.point[2] - cycle) + noise3(p.point); 37 | 38 | 39 | for (int i = 0; i < 3; i++) { 40 | if (theIndex == p.point[2]) { 41 | rgb[i] = (p.point[1] + 2.2); 42 | } else { 43 | rgb[i] = 1.0; 44 | } 45 | } 46 | 47 | return; 48 | } 49 | 50 | virtual void debug(const DebugInfo& d) 51 | { 52 | fprintf(stderr, "\t[fixed] cycle = %f , theIndex = %f\n", cycle, theIndex); 53 | return; 54 | } 55 | 56 | virtual void endFrame(const FrameInfo &f) { 57 | usleep(1e3); 58 | 59 | } 60 | 61 | }; 62 | 63 | 64 | 65 | 66 | int main(int argc, char **argv) 67 | { 68 | EffectRunner r; 69 | 70 | MyEffect e; 71 | r.setEffect(&e); 72 | 73 | // Defaults, overridable with command line options 74 | r.setMaxFrameRate(30); 75 | r.setLayout("../layouts/grid32x16z.json"); 76 | 77 | return r.main(argc, argv); 78 | } 79 | -------------------------------------------------------------------------------- /src/images.cpp: -------------------------------------------------------------------------------- 1 | // Simple example for EffectMixer. Mixers let you run multiple effects, and they 2 | // handle concurrent rendering on multiple CPU cores. 3 | 4 | #include "lib/effect_runner.h" 5 | #include "lib/effect_mixer.h" 6 | #include "lib/tinydir.h" 7 | 8 | #include "images.h" 9 | #include "particle_trail.h" 10 | #include "rings.h" 11 | 12 | int main(int argc, char **argv) 13 | { 14 | tinydir_dir dir; 15 | if (tinydir_open(&dir, "/Users/matt//active/video/queue/") == -1) 16 | { 17 | perror("Error opening file"); 18 | tinydir_close(&dir); 19 | return 0; 20 | } 21 | 22 | EffectMixer mixer; 23 | 24 | ImageEffect * tmpImage; 25 | 26 | 27 | int imageIndex = 0; 28 | int maxImageIndex = 150; 29 | 30 | 31 | while (dir.has_next) { 32 | tinydir_file file; 33 | if (tinydir_readfile(&dir, &file) == -1) 34 | { 35 | perror("Error getting file"); 36 | tinydir_close(&dir); 37 | return 0; 38 | } 39 | 40 | printf("%s", file.name); 41 | if (file.is_dir) 42 | { 43 | printf("/"); 44 | } 45 | printf("\n"); 46 | 47 | if (maxImageIndex > imageIndex) { 48 | if (!strcmp(file.extension, "png")) { 49 | printf("found image %s\n", file.name); 50 | /* 51 | printf("Path: %s\nName: %s\nExtension: %s\nIs dir? %s\nIs regular file? %s\n", 52 | file.path, file.name, file.extension, 53 | file.is_dir?"yes":"no", file.is_reg?"yes":"no"); 54 | */ 55 | 56 | tmpImage = new ImageEffect(file.path); 57 | // DotEffect e("data/dot.png"); 58 | // img[imageIndex] = tmpImage; 59 | // mixer.add(img[imageIndex]); 60 | mixer.add(tmpImage); 61 | // imageIndex++; 62 | } 63 | } 64 | 65 | tinydir_next(&dir); 66 | } 67 | 68 | 69 | EffectRunner r; 70 | r.setEffect(&mixer); 71 | r.setMaxFrameRate(30); 72 | 73 | r.setLayout("../../../Active/layout/layout-60x24.json"); 74 | if (!r.parseArguments(argc, argv)) { 75 | return 1; 76 | } 77 | 78 | float state = 0; 79 | 80 | while (true) { 81 | EffectRunner::FrameStatus frame = r.doFrame(); 82 | const float speed = 10.0f; //FAST 83 | // const float speed = 0.001f; //SLOW 84 | 85 | /* 86 | // Animate the mixer's fader controls 87 | state = fmod(state + frame.timeDelta * speed, 2 * M_PI); 88 | for (int i = 0; i < mixer.numChannels(); i++) { 89 | float theta = state + i * (2 * M_PI) / mixer.numChannels(); 90 | mixer.setFader(i, std::max(0.0f, sinf(theta))); 91 | } 92 | 93 | */ 94 | 95 | // Animate the mixer's fader controls 96 | ///* 97 | state = fmod(state + frame.timeDelta * speed, mixer.numChannels()); 98 | for (int i = 0; i < mixer.numChannels(); i++) { 99 | 100 | mixer.setFader(i, 0.0); 101 | 102 | //float remainder = state - i; 103 | // is this state 104 | if ( i == (int)state) { 105 | mixer.setFader(i, 1.0); 106 | } 107 | 108 | /* // is next state 109 | int nextState = (int) state; 110 | nextState += 1; 111 | nextState % mixer.numChannels(); 112 | if (i == nextState) { 113 | mixer.setFader(i, 1-remainder); 114 | } 115 | */ 116 | // float theta = state + i * (2 * M_PI) / mixer.numChannels(); 117 | // mixer.setFader(i, std::max(0.0f, sinf(theta))); 118 | } 119 | // */ 120 | 121 | // Main loops and Effects can both generate verbose debug output (-v command line option) 122 | if (frame.debugOutput) { 123 | fprintf(stderr, "\t[main] state = %f\n", state); 124 | } 125 | } 126 | 127 | 128 | 129 | } -------------------------------------------------------------------------------- /src/images.h: -------------------------------------------------------------------------------- 1 | // images for movie frames 2 | 3 | #pragma once 4 | 5 | #include "lib/color.h" 6 | #include "lib/effect.h" 7 | #include "lib/texture.h" 8 | 9 | class ImageEffect : public Effect 10 | { 11 | public: 12 | ImageEffect(const char *filename) 13 | : dot(filename), 14 | angle1(2*M_PI), angle2(0), angle3(0) 15 | {} 16 | 17 | Texture dot; 18 | 19 | float angle1; 20 | float angle2; 21 | float angle3; 22 | 23 | virtual void beginFrame(const FrameInfo &f) 24 | { 25 | 26 | // const float speed = 0.01; // SLOW 27 | const float speed = 1.01; // FAST 28 | 29 | // Several bounded state variables, rotating at different rates 30 | ///* 31 | angle1 = fmodf(angle1 + f.timeDelta * speed, 2 * M_PI); 32 | angle2 = fmodf(angle2 + f.timeDelta * speed * 0.2f, 2 * M_PI); 33 | angle3 = fmodf(angle3 + f.timeDelta * speed * 0.7f, 2 * M_PI); 34 | //*/ 35 | // Several bounded state variables, rotating at different rates 36 | /* 37 | angle1 = fmodf(angle1 * speed, 2 * M_PI); 38 | angle2 = fmodf(angle2 * speed , 2 * M_PI); 39 | angle3 = fmodf(angle3 + f.timeDelta * speed , 2 * M_PI); 40 | */ 41 | } 42 | 43 | virtual void shader(Vec3& rgb, const PixelInfo &p) const 44 | { 45 | // Project onto the XZ plane 46 | // Vec2 plane = Vec2(p.point[0], p.point[2]*-1.0); 47 | Vec2 plane = Vec2(p.point[0]*-0.4, p.point[2]*-1.0); 48 | 49 | // rotate this 50 | // plane 51 | 52 | // Moving dot 53 | Vec2 position = 1.0 * Vec2( sinf(angle1)*4.0+1.0, cosf(angle1 + sin(angle2)) ); 54 | 55 | // Texture geometry 56 | Vec2 center(0.6, 0.4); 57 | float size = 5.0; 58 | 59 | // rgb = dot.sample( (plane + position) / size + center ); 60 | rgb = dot.sample( (plane) / size + center ); 61 | 62 | // rgb = dot.sample( (plane - position) / size + center ); 63 | } 64 | 65 | }; 66 | -------------------------------------------------------------------------------- /src/img: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpinner/Active/b5e2c9df3a53bc79920fb5f17489296238b898d0/src/img -------------------------------------------------------------------------------- /src/img.cpp: -------------------------------------------------------------------------------- 1 | #include "lib/effect_runner.h" 2 | #include "dot.h" 3 | 4 | int main(int argc, char **argv) 5 | { 6 | EffectRunner r; 7 | 8 | DotEffect e("data/crash-in.png"); 9 | // DotEffect e("data/nyan.png"); 10 | 11 | r.setEffect(&e); 12 | 13 | // Defaults, overridable with command line options 14 | r.setLayout("../layouts/grid32x16z.json"); 15 | 16 | return r.main(argc, argv); 17 | } 18 | -------------------------------------------------------------------------------- /src/lib/BlackLib.o: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpinner/Active/b5e2c9df3a53bc79920fb5f17489296238b898d0/src/lib/BlackLib.o -------------------------------------------------------------------------------- /src/lib/README.md: -------------------------------------------------------------------------------- 1 | Fadecandy C++ Mini-Framework 2 | ---------------------------- 3 | 4 | This is a tiny self-contained package of C++ header files that you can use to implement blazing fast LED patterns that can run on large or small computers. There are no other dependencies or libraries to fuss with, and you can copy these headers right into your own project. 5 | 6 | This library includes: 7 | 8 | * Efficient [Open Pixel Control](http://openpixelcontrol.org/) client 9 | * JSON parsing ([rapidjson](https://code.google.com/p/rapidjson/)) 10 | * Vector math ([SVL](http://www.cs.cmu.edu/~ajw/doc/svl.html)) 11 | * PNG decoding ([picopng](http://lodev.org/lodepng/)) 12 | * KD-trees for spatial search ([nanoflann](https://code.google.com/p/nanoflann/)) 13 | * Texture sampling with bilinear interpolation 14 | * HSV color space conversion 15 | * Particle system rendering, with floating point precision 16 | * [Perlin Noise](http://www.algorithmic-worlds.net/info/info.php?page=pg-perlin) function 17 | * Generalized *Effect* framework 18 | * Main loop with smooth frame rate throttling 19 | * Concurrent rendering on multiple CPU cores, via the EffectMixer class 20 | * Command line parameters 21 | * Debug output including performance metrics 22 | 23 | Writing an Effect is like writing a GPU shader. At its core, an Effect is a function that maps LED metadata to an LED color. 24 | 25 | The color in this case uses floating point precision, so you can chain effects without losing color precision. It's converted to 8-bit per channel just before being sent out to the Fadecandy board. 26 | 27 | The LED metadata includes a 3D position vector as well as any other data you choose to include in your layout JSON file. The full JSON object model is available for you to use to describe the properties of each light in your project. 28 | 29 | 30 | Usage 31 | ----- 32 | 33 | 1. Copy the `lib` directory somewhere on your project's include search path. 34 | 2. Use `Makefile` and `simple.cpp` as an example for starting your own project. 35 | 3. Write an *Effect* subclass that does awesome things. 36 | 4. Instantiate an *EffectRunner* and your *Effect*. 37 | 5. Set up default options on the *EffectRunner*. 38 | 6. Let the *EffectRunner* main loop do the rest. 39 | 40 | License 41 | ------- 42 | 43 | All components are under BSD-style licenses. You're free to use this code in commercial or free software, as long as you keep copyright notices in the source. 44 | 45 | Download 46 | -------- 47 | 48 | The latest revision of this library lives on GitHub in the [`scanlime/fadecandy`](https://github.com/scanlime/fadecandy/) repository. at [`examples/cpp/lib`](https://github.com/scanlime/fadecandy/tree/master/examples/cpp/lib). 49 | 50 | -------------------------------------------------------------------------------- /src/lib/color.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Color Utilities 3 | */ 4 | 5 | #pragma once 6 | 7 | #include "svl/SVL.h" 8 | 9 | static inline void hsv2rgb(Vec3 &rgb, float h, float s, float v) 10 | { 11 | /* 12 | * Converts an HSV color value to RGB. 13 | * 14 | * Normal hsv range is in [0, 1], RGB range is [0, 255]. 15 | * Colors may extend outside these bounds. Hue values will wrap. 16 | * 17 | * Based on tinycolor: 18 | * https://github.com/bgrins/TinyColor/blob/master/tinycolor.js 19 | * 2013-08-10, Brian Grinstead, MIT License 20 | */ 21 | 22 | h = fmodf(h, 1) * 6.0f; 23 | if (h < 0) h += 6.0f; 24 | 25 | int i = h; 26 | float f = h - i; 27 | float p = v * (1 - s); 28 | float q = v * (1 - f * s); 29 | float t = v * (1 - (1 - f) * s); 30 | 31 | switch (i) { 32 | case 0: rgb[0] = v; rgb[1] = t; rgb[2] = p; break; 33 | case 1: rgb[0] = q; rgb[1] = v; rgb[2] = p; break; 34 | case 2: rgb[0] = p; rgb[1] = v; rgb[2] = t; break; 35 | case 3: rgb[0] = p; rgb[1] = q; rgb[2] = v; break; 36 | case 4: rgb[0] = t; rgb[1] = p; rgb[2] = v; break; 37 | case 5: rgb[0] = v; rgb[1] = p; rgb[2] = q; break; 38 | } 39 | } 40 | 41 | static inline void hsv2rgb(Vec3 &rgb, Vec3 hsv) 42 | { 43 | return hsv2rgb(rgb, hsv[0], hsv[1], hsv[2]); 44 | } 45 | -------------------------------------------------------------------------------- /src/lib/rapidjson/README.md: -------------------------------------------------------------------------------- 1 | Rapidjson 0.11 2 | -------------- 3 | 4 | This directory contains third party sources from the 5 | [rapidjson project](https://code.google.com/p/rapidjson/). MIT Licensed. 6 | -------------------------------------------------------------------------------- /src/lib/rapidjson/filestream.h: -------------------------------------------------------------------------------- 1 | #ifndef RAPIDJSON_FILESTREAM_H_ 2 | #define RAPIDJSON_FILESTREAM_H_ 3 | 4 | #include 5 | 6 | namespace rapidjson { 7 | 8 | //! Wrapper of C file stream for input or output. 9 | /*! 10 | This simple wrapper does not check the validity of the stream. 11 | \implements Stream 12 | */ 13 | class FileStream { 14 | public: 15 | typedef char Ch; //!< Character type. Only support char. 16 | 17 | FileStream(FILE* fp) : fp_(fp), count_(0) { Read(); } 18 | char Peek() const { return current_; } 19 | char Take() { char c = current_; Read(); return c; } 20 | size_t Tell() const { return count_; } 21 | void Put(char c) { fputc(c, fp_); } 22 | 23 | // Not implemented 24 | char* PutBegin() { return 0; } 25 | size_t PutEnd(char*) { return 0; } 26 | 27 | private: 28 | void Read() { 29 | RAPIDJSON_ASSERT(fp_ != 0); 30 | int c = fgetc(fp_); 31 | if (c != EOF) { 32 | current_ = (char)c; 33 | count_++; 34 | } 35 | else 36 | current_ = '\0'; 37 | } 38 | 39 | FILE* fp_; 40 | char current_; 41 | size_t count_; 42 | }; 43 | 44 | } // namespace rapidjson 45 | 46 | #endif // RAPIDJSON_FILESTREAM_H_ 47 | -------------------------------------------------------------------------------- /src/lib/rapidjson/internal/pow10.h: -------------------------------------------------------------------------------- 1 | #ifndef RAPIDJSON_POW10_ 2 | #define RAPIDJSON_POW10_ 3 | 4 | namespace rapidjson { 5 | namespace internal { 6 | 7 | //! Computes integer powers of 10 in double (10.0^n). 8 | /*! This function uses lookup table for fast and accurate results. 9 | \param n positive/negative exponent. Must <= 308. 10 | \return 10.0^n 11 | */ 12 | inline double Pow10(int n) { 13 | static const double e[] = { // 1e-308...1e308: 617 * 8 bytes = 4936 bytes 14 | 1e-308,1e-307,1e-306,1e-305,1e-304,1e-303,1e-302,1e-301,1e-300, 15 | 1e-299,1e-298,1e-297,1e-296,1e-295,1e-294,1e-293,1e-292,1e-291,1e-290,1e-289,1e-288,1e-287,1e-286,1e-285,1e-284,1e-283,1e-282,1e-281,1e-280, 16 | 1e-279,1e-278,1e-277,1e-276,1e-275,1e-274,1e-273,1e-272,1e-271,1e-270,1e-269,1e-268,1e-267,1e-266,1e-265,1e-264,1e-263,1e-262,1e-261,1e-260, 17 | 1e-259,1e-258,1e-257,1e-256,1e-255,1e-254,1e-253,1e-252,1e-251,1e-250,1e-249,1e-248,1e-247,1e-246,1e-245,1e-244,1e-243,1e-242,1e-241,1e-240, 18 | 1e-239,1e-238,1e-237,1e-236,1e-235,1e-234,1e-233,1e-232,1e-231,1e-230,1e-229,1e-228,1e-227,1e-226,1e-225,1e-224,1e-223,1e-222,1e-221,1e-220, 19 | 1e-219,1e-218,1e-217,1e-216,1e-215,1e-214,1e-213,1e-212,1e-211,1e-210,1e-209,1e-208,1e-207,1e-206,1e-205,1e-204,1e-203,1e-202,1e-201,1e-200, 20 | 1e-199,1e-198,1e-197,1e-196,1e-195,1e-194,1e-193,1e-192,1e-191,1e-190,1e-189,1e-188,1e-187,1e-186,1e-185,1e-184,1e-183,1e-182,1e-181,1e-180, 21 | 1e-179,1e-178,1e-177,1e-176,1e-175,1e-174,1e-173,1e-172,1e-171,1e-170,1e-169,1e-168,1e-167,1e-166,1e-165,1e-164,1e-163,1e-162,1e-161,1e-160, 22 | 1e-159,1e-158,1e-157,1e-156,1e-155,1e-154,1e-153,1e-152,1e-151,1e-150,1e-149,1e-148,1e-147,1e-146,1e-145,1e-144,1e-143,1e-142,1e-141,1e-140, 23 | 1e-139,1e-138,1e-137,1e-136,1e-135,1e-134,1e-133,1e-132,1e-131,1e-130,1e-129,1e-128,1e-127,1e-126,1e-125,1e-124,1e-123,1e-122,1e-121,1e-120, 24 | 1e-119,1e-118,1e-117,1e-116,1e-115,1e-114,1e-113,1e-112,1e-111,1e-110,1e-109,1e-108,1e-107,1e-106,1e-105,1e-104,1e-103,1e-102,1e-101,1e-100, 25 | 1e-99, 1e-98, 1e-97, 1e-96, 1e-95, 1e-94, 1e-93, 1e-92, 1e-91, 1e-90, 1e-89, 1e-88, 1e-87, 1e-86, 1e-85, 1e-84, 1e-83, 1e-82, 1e-81, 1e-80, 26 | 1e-79, 1e-78, 1e-77, 1e-76, 1e-75, 1e-74, 1e-73, 1e-72, 1e-71, 1e-70, 1e-69, 1e-68, 1e-67, 1e-66, 1e-65, 1e-64, 1e-63, 1e-62, 1e-61, 1e-60, 27 | 1e-59, 1e-58, 1e-57, 1e-56, 1e-55, 1e-54, 1e-53, 1e-52, 1e-51, 1e-50, 1e-49, 1e-48, 1e-47, 1e-46, 1e-45, 1e-44, 1e-43, 1e-42, 1e-41, 1e-40, 28 | 1e-39, 1e-38, 1e-37, 1e-36, 1e-35, 1e-34, 1e-33, 1e-32, 1e-31, 1e-30, 1e-29, 1e-28, 1e-27, 1e-26, 1e-25, 1e-24, 1e-23, 1e-22, 1e-21, 1e-20, 29 | 1e-19, 1e-18, 1e-17, 1e-16, 1e-15, 1e-14, 1e-13, 1e-12, 1e-11, 1e-10, 1e-9, 1e-8, 1e-7, 1e-6, 1e-5, 1e-4, 1e-3, 1e-2, 1e-1, 1e+0, 30 | 1e+1, 1e+2, 1e+3, 1e+4, 1e+5, 1e+6, 1e+7, 1e+8, 1e+9, 1e+10, 1e+11, 1e+12, 1e+13, 1e+14, 1e+15, 1e+16, 1e+17, 1e+18, 1e+19, 1e+20, 31 | 1e+21, 1e+22, 1e+23, 1e+24, 1e+25, 1e+26, 1e+27, 1e+28, 1e+29, 1e+30, 1e+31, 1e+32, 1e+33, 1e+34, 1e+35, 1e+36, 1e+37, 1e+38, 1e+39, 1e+40, 32 | 1e+41, 1e+42, 1e+43, 1e+44, 1e+45, 1e+46, 1e+47, 1e+48, 1e+49, 1e+50, 1e+51, 1e+52, 1e+53, 1e+54, 1e+55, 1e+56, 1e+57, 1e+58, 1e+59, 1e+60, 33 | 1e+61, 1e+62, 1e+63, 1e+64, 1e+65, 1e+66, 1e+67, 1e+68, 1e+69, 1e+70, 1e+71, 1e+72, 1e+73, 1e+74, 1e+75, 1e+76, 1e+77, 1e+78, 1e+79, 1e+80, 34 | 1e+81, 1e+82, 1e+83, 1e+84, 1e+85, 1e+86, 1e+87, 1e+88, 1e+89, 1e+90, 1e+91, 1e+92, 1e+93, 1e+94, 1e+95, 1e+96, 1e+97, 1e+98, 1e+99, 1e+100, 35 | 1e+101,1e+102,1e+103,1e+104,1e+105,1e+106,1e+107,1e+108,1e+109,1e+110,1e+111,1e+112,1e+113,1e+114,1e+115,1e+116,1e+117,1e+118,1e+119,1e+120, 36 | 1e+121,1e+122,1e+123,1e+124,1e+125,1e+126,1e+127,1e+128,1e+129,1e+130,1e+131,1e+132,1e+133,1e+134,1e+135,1e+136,1e+137,1e+138,1e+139,1e+140, 37 | 1e+141,1e+142,1e+143,1e+144,1e+145,1e+146,1e+147,1e+148,1e+149,1e+150,1e+151,1e+152,1e+153,1e+154,1e+155,1e+156,1e+157,1e+158,1e+159,1e+160, 38 | 1e+161,1e+162,1e+163,1e+164,1e+165,1e+166,1e+167,1e+168,1e+169,1e+170,1e+171,1e+172,1e+173,1e+174,1e+175,1e+176,1e+177,1e+178,1e+179,1e+180, 39 | 1e+181,1e+182,1e+183,1e+184,1e+185,1e+186,1e+187,1e+188,1e+189,1e+190,1e+191,1e+192,1e+193,1e+194,1e+195,1e+196,1e+197,1e+198,1e+199,1e+200, 40 | 1e+201,1e+202,1e+203,1e+204,1e+205,1e+206,1e+207,1e+208,1e+209,1e+210,1e+211,1e+212,1e+213,1e+214,1e+215,1e+216,1e+217,1e+218,1e+219,1e+220, 41 | 1e+221,1e+222,1e+223,1e+224,1e+225,1e+226,1e+227,1e+228,1e+229,1e+230,1e+231,1e+232,1e+233,1e+234,1e+235,1e+236,1e+237,1e+238,1e+239,1e+240, 42 | 1e+241,1e+242,1e+243,1e+244,1e+245,1e+246,1e+247,1e+248,1e+249,1e+250,1e+251,1e+252,1e+253,1e+254,1e+255,1e+256,1e+257,1e+258,1e+259,1e+260, 43 | 1e+261,1e+262,1e+263,1e+264,1e+265,1e+266,1e+267,1e+268,1e+269,1e+270,1e+271,1e+272,1e+273,1e+274,1e+275,1e+276,1e+277,1e+278,1e+279,1e+280, 44 | 1e+281,1e+282,1e+283,1e+284,1e+285,1e+286,1e+287,1e+288,1e+289,1e+290,1e+291,1e+292,1e+293,1e+294,1e+295,1e+296,1e+297,1e+298,1e+299,1e+300, 45 | 1e+301,1e+302,1e+303,1e+304,1e+305,1e+306,1e+307,1e+308 46 | }; 47 | RAPIDJSON_ASSERT(n <= 308); 48 | return n < -308 ? 0.0 : e[n + 308]; 49 | } 50 | 51 | } // namespace internal 52 | } // namespace rapidjson 53 | 54 | #endif // RAPIDJSON_POW10_ 55 | -------------------------------------------------------------------------------- /src/lib/rapidjson/internal/stack.h: -------------------------------------------------------------------------------- 1 | #ifndef RAPIDJSON_INTERNAL_STACK_H_ 2 | #define RAPIDJSON_INTERNAL_STACK_H_ 3 | 4 | namespace rapidjson { 5 | namespace internal { 6 | 7 | /////////////////////////////////////////////////////////////////////////////// 8 | // Stack 9 | 10 | //! A type-unsafe stack for storing different types of data. 11 | /*! \tparam Allocator Allocator for allocating stack memory. 12 | */ 13 | template 14 | class Stack { 15 | public: 16 | Stack(Allocator* allocator, size_t stack_capacity) : allocator_(allocator), own_allocator_(0), stack_(0), stack_top_(0), stack_end_(0), stack_capacity_(stack_capacity) { 17 | RAPIDJSON_ASSERT(stack_capacity_ > 0); 18 | if (!allocator_) 19 | own_allocator_ = allocator_ = new Allocator(); 20 | stack_top_ = stack_ = (char*)allocator_->Malloc(stack_capacity_); 21 | stack_end_ = stack_ + stack_capacity_; 22 | } 23 | 24 | ~Stack() { 25 | Allocator::Free(stack_); 26 | delete own_allocator_; // Only delete if it is owned by the stack 27 | } 28 | 29 | void Clear() { /*stack_top_ = 0;*/ stack_top_ = stack_; } 30 | 31 | template 32 | T* Push(size_t count = 1) { 33 | // Expand the stack if needed 34 | if (stack_top_ + sizeof(T) * count >= stack_end_) { 35 | size_t new_capacity = stack_capacity_ * 2; 36 | size_t size = GetSize(); 37 | size_t new_size = GetSize() + sizeof(T) * count; 38 | if (new_capacity < new_size) 39 | new_capacity = new_size; 40 | stack_ = (char*)allocator_->Realloc(stack_, stack_capacity_, new_capacity); 41 | stack_capacity_ = new_capacity; 42 | stack_top_ = stack_ + size; 43 | stack_end_ = stack_ + stack_capacity_; 44 | } 45 | T* ret = (T*)stack_top_; 46 | stack_top_ += sizeof(T) * count; 47 | return ret; 48 | } 49 | 50 | template 51 | T* Pop(size_t count) { 52 | RAPIDJSON_ASSERT(GetSize() >= count * sizeof(T)); 53 | stack_top_ -= count * sizeof(T); 54 | return (T*)stack_top_; 55 | } 56 | 57 | template 58 | T* Top() { 59 | RAPIDJSON_ASSERT(GetSize() >= sizeof(T)); 60 | return (T*)(stack_top_ - sizeof(T)); 61 | } 62 | 63 | template 64 | T* Bottom() { return (T*)stack_; } 65 | 66 | Allocator& GetAllocator() { return *allocator_; } 67 | size_t GetSize() const { return stack_top_ - stack_; } 68 | size_t GetCapacity() const { return stack_capacity_; } 69 | 70 | private: 71 | Allocator* allocator_; 72 | Allocator* own_allocator_; 73 | char *stack_; 74 | char *stack_top_; 75 | char *stack_end_; 76 | size_t stack_capacity_; 77 | }; 78 | 79 | } // namespace internal 80 | } // namespace rapidjson 81 | 82 | #endif // RAPIDJSON_STACK_H_ 83 | -------------------------------------------------------------------------------- /src/lib/rapidjson/internal/strfunc.h: -------------------------------------------------------------------------------- 1 | #ifndef RAPIDJSON_INTERNAL_STRFUNC_H_ 2 | #define RAPIDJSON_INTERNAL_STRFUNC_H_ 3 | 4 | namespace rapidjson { 5 | namespace internal { 6 | 7 | //! Custom strlen() which works on different character types. 8 | /*! \tparam Ch Character type (e.g. char, wchar_t, short) 9 | \param s Null-terminated input string. 10 | \return Number of characters in the string. 11 | \note This has the same semantics as strlen(), the return value is not number of Unicode codepoints. 12 | */ 13 | template 14 | inline SizeType StrLen(const Ch* s) { 15 | const Ch* p = s; 16 | while (*p != '\0') 17 | ++p; 18 | return SizeType(p - s); 19 | } 20 | 21 | } // namespace internal 22 | } // namespace rapidjson 23 | 24 | #endif // RAPIDJSON_INTERNAL_STRFUNC_H_ 25 | -------------------------------------------------------------------------------- /src/lib/rapidjson/prettywriter.h: -------------------------------------------------------------------------------- 1 | #ifndef RAPIDJSON_PRETTYWRITER_H_ 2 | #define RAPIDJSON_PRETTYWRITER_H_ 3 | 4 | #include "writer.h" 5 | 6 | namespace rapidjson { 7 | 8 | //! Writer with indentation and spacing. 9 | /*! 10 | \tparam Stream Type of ouptut stream. 11 | \tparam Encoding Encoding of both source strings and output. 12 | \tparam Allocator Type of allocator for allocating memory of stack. 13 | */ 14 | template, typename Allocator = MemoryPoolAllocator<> > 15 | class PrettyWriter : public Writer { 16 | public: 17 | typedef Writer Base; 18 | typedef typename Base::Ch Ch; 19 | 20 | //! Constructor 21 | /*! \param stream Output stream. 22 | \param allocator User supplied allocator. If it is null, it will create a private one. 23 | \param levelDepth Initial capacity of 24 | */ 25 | PrettyWriter(Stream& stream, Allocator* allocator = 0, size_t levelDepth = Base::kDefaultLevelDepth) : 26 | Base(stream, allocator, levelDepth), indentChar_(' '), indentCharCount_(4) {} 27 | 28 | //! Set custom indentation. 29 | /*! \param indentChar Character for indentation. Must be whitespace character (' ', '\t', '\n', '\r'). 30 | \param indentCharCount Number of indent characters for each indentation level. 31 | \note The default indentation is 4 spaces. 32 | */ 33 | PrettyWriter& SetIndent(Ch indentChar, unsigned indentCharCount) { 34 | RAPIDJSON_ASSERT(indentChar == ' ' || indentChar == '\t' || indentChar == '\n' || indentChar == '\r'); 35 | indentChar_ = indentChar; 36 | indentCharCount_ = indentCharCount; 37 | return *this; 38 | } 39 | 40 | //@name Implementation of Handler. 41 | //@{ 42 | 43 | PrettyWriter& Null() { PrettyPrefix(kNullType); Base::WriteNull(); return *this; } 44 | PrettyWriter& Bool(bool b) { PrettyPrefix(b ? kTrueType : kFalseType); Base::WriteBool(b); return *this; } 45 | PrettyWriter& Int(int i) { PrettyPrefix(kNumberType); Base::WriteInt(i); return *this; } 46 | PrettyWriter& Uint(unsigned u) { PrettyPrefix(kNumberType); Base::WriteUint(u); return *this; } 47 | PrettyWriter& Int64(int64_t i64) { PrettyPrefix(kNumberType); Base::WriteInt64(i64); return *this; } 48 | PrettyWriter& Uint64(uint64_t u64) { PrettyPrefix(kNumberType); Base::WriteUint64(u64); return *this; } 49 | PrettyWriter& Double(double d) { PrettyPrefix(kNumberType); Base::WriteDouble(d); return *this; } 50 | 51 | PrettyWriter& String(const Ch* str, SizeType length, bool copy = false) { 52 | (void)copy; 53 | PrettyPrefix(kStringType); 54 | Base::WriteString(str, length); 55 | return *this; 56 | } 57 | 58 | PrettyWriter& StartObject() { 59 | PrettyPrefix(kObjectType); 60 | new (Base::level_stack_.template Push()) typename Base::Level(false); 61 | Base::WriteStartObject(); 62 | return *this; 63 | } 64 | 65 | PrettyWriter& EndObject(SizeType memberCount = 0) { 66 | (void)memberCount; 67 | RAPIDJSON_ASSERT(Base::level_stack_.GetSize() >= sizeof(typename Base::Level)); 68 | RAPIDJSON_ASSERT(!Base::level_stack_.template Top()->inArray); 69 | bool empty = Base::level_stack_.template Pop(1)->valueCount == 0; 70 | 71 | if (!empty) { 72 | Base::stream_.Put('\n'); 73 | WriteIndent(); 74 | } 75 | Base::WriteEndObject(); 76 | return *this; 77 | } 78 | 79 | PrettyWriter& StartArray() { 80 | PrettyPrefix(kArrayType); 81 | new (Base::level_stack_.template Push()) typename Base::Level(true); 82 | Base::WriteStartArray(); 83 | return *this; 84 | } 85 | 86 | PrettyWriter& EndArray(SizeType memberCount = 0) { 87 | (void)memberCount; 88 | RAPIDJSON_ASSERT(Base::level_stack_.GetSize() >= sizeof(typename Base::Level)); 89 | RAPIDJSON_ASSERT(Base::level_stack_.template Top()->inArray); 90 | bool empty = Base::level_stack_.template Pop(1)->valueCount == 0; 91 | 92 | if (!empty) { 93 | Base::stream_.Put('\n'); 94 | WriteIndent(); 95 | } 96 | Base::WriteEndArray(); 97 | return *this; 98 | } 99 | 100 | //@} 101 | 102 | //! Simpler but slower overload. 103 | PrettyWriter& String(const Ch* str) { return String(str, internal::StrLen(str)); } 104 | 105 | protected: 106 | void PrettyPrefix(Type type) { 107 | (void)type; 108 | if (Base::level_stack_.GetSize() != 0) { // this value is not at root 109 | typename Base::Level* level = Base::level_stack_.template Top(); 110 | 111 | if (level->inArray) { 112 | if (level->valueCount > 0) { 113 | Base::stream_.Put(','); // add comma if it is not the first element in array 114 | Base::stream_.Put('\n'); 115 | } 116 | else 117 | Base::stream_.Put('\n'); 118 | WriteIndent(); 119 | } 120 | else { // in object 121 | if (level->valueCount > 0) { 122 | if (level->valueCount % 2 == 0) { 123 | Base::stream_.Put(','); 124 | Base::stream_.Put('\n'); 125 | } 126 | else { 127 | Base::stream_.Put(':'); 128 | Base::stream_.Put(' '); 129 | } 130 | } 131 | else 132 | Base::stream_.Put('\n'); 133 | 134 | if (level->valueCount % 2 == 0) 135 | WriteIndent(); 136 | } 137 | if (!level->inArray && level->valueCount % 2 == 0) 138 | RAPIDJSON_ASSERT(type == kStringType); // if it's in object, then even number should be a name 139 | level->valueCount++; 140 | } 141 | else 142 | RAPIDJSON_ASSERT(type == kObjectType || type == kArrayType); 143 | } 144 | 145 | void WriteIndent() { 146 | size_t count = (Base::level_stack_.GetSize() / sizeof(typename Base::Level)) * indentCharCount_; 147 | PutN(Base::stream_, indentChar_, count); 148 | } 149 | 150 | Ch indentChar_; 151 | unsigned indentCharCount_; 152 | }; 153 | 154 | } // namespace rapidjson 155 | 156 | #endif // RAPIDJSON_RAPIDJSON_H_ 157 | -------------------------------------------------------------------------------- /src/lib/rapidjson/stringbuffer.h: -------------------------------------------------------------------------------- 1 | #ifndef RAPIDJSON_STRINGBUFFER_H_ 2 | #define RAPIDJSON_STRINGBUFFER_H_ 3 | 4 | #include "rapidjson.h" 5 | #include "internal/stack.h" 6 | 7 | namespace rapidjson { 8 | 9 | //! Represents an in-memory output stream. 10 | /*! 11 | \tparam Encoding Encoding of the stream. 12 | \tparam Allocator type for allocating memory buffer. 13 | \implements Stream 14 | */ 15 | template 16 | struct GenericStringBuffer { 17 | typedef typename Encoding::Ch Ch; 18 | 19 | GenericStringBuffer(Allocator* allocator = 0, size_t capacity = kDefaultCapacity) : stack_(allocator, capacity) {} 20 | 21 | void Put(Ch c) { *stack_.template Push() = c; } 22 | 23 | void Clear() { stack_.Clear(); } 24 | 25 | const char* GetString() const { 26 | // Push and pop a null terminator. This is safe. 27 | *stack_.template Push() = '\0'; 28 | stack_.template Pop(1); 29 | 30 | return stack_.template Bottom(); 31 | } 32 | 33 | size_t Size() const { return stack_.GetSize(); } 34 | 35 | static const size_t kDefaultCapacity = 256; 36 | mutable internal::Stack stack_; 37 | }; 38 | 39 | typedef GenericStringBuffer > StringBuffer; 40 | 41 | //! Implement specialized version of PutN() with memset() for better performance. 42 | template<> 43 | inline void PutN(GenericStringBuffer >& stream, char c, size_t n) { 44 | memset(stream.stack_.Push(n), c, n * sizeof(c)); 45 | } 46 | 47 | } // namespace rapidjson 48 | 49 | #endif // RAPIDJSON_STRINGBUFFER_H_ 50 | -------------------------------------------------------------------------------- /src/lib/svl/Basics.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: Basics.h 3 | 4 | Function: Basic definitions for all files. Contains type 5 | definitions, assertion and debugging facilities, and 6 | miscellaneous useful template functions. 7 | 8 | This is a cut-down version for SVL, 9 | with additional modifications for Fadecandy. 10 | 11 | Author(s): Andrew Willmott 12 | 13 | Copyright: (c) 1995-2001, Andrew Willmott 14 | 15 | Notes: This header is affected by the following defines: 16 | 17 | VL_CHECKING - Include code for assertions, 18 | range errors and warnings. 19 | VL_DOUBLE - Use doubles for real numbers. (Floats 20 | are the default.) 21 | VL_NO_BOOL - There is no bool type. 22 | VL_NO_TF - true and false are not predefined. 23 | */ 24 | 25 | #pragma once 26 | 27 | #include 28 | #include 29 | 30 | 31 | // --- Basic types ------------------------------------------------------------- 32 | 33 | typedef void Void; 34 | typedef float Float; 35 | typedef double Double; 36 | typedef char Char; 37 | typedef int Short; 38 | typedef int Int; 39 | typedef long Long; 40 | typedef unsigned char Byte; 41 | typedef unsigned int UInt; 42 | 43 | #ifdef VL_DOUBLE 44 | typedef Double Real; 45 | #else 46 | typedef Float Real; 47 | #endif 48 | 49 | #define SELF (*this) // A syntactic convenience. 50 | 51 | 52 | // --- Boolean type ------------------------------------------------------------ 53 | 54 | // X11 #defines 'Bool' -- typical. 55 | 56 | #ifdef Bool 57 | #undef Bool 58 | #endif 59 | 60 | #ifndef VL_NO_BOOL 61 | // if the compiler implements the bool type... 62 | typedef bool Bool; 63 | #else 64 | // if not, make up our own. 65 | class Bool 66 | { 67 | public: 68 | 69 | Bool() : val(0) {}; 70 | Bool(Int b) : val(b) {}; 71 | 72 | operator Int() { return val; }; 73 | 74 | private: 75 | Int val; 76 | }; 77 | #ifdef VL_NO_TF 78 | enum {false, true}; 79 | #endif 80 | #endif 81 | 82 | 83 | // --- Assertions and Range checking ------------------------------------------- 84 | 85 | #define _Error(e) _Assert(false, e, __FILE__, __LINE__) 86 | #define _Warning(w) _Expect(false, w, __FILE__, __LINE__) 87 | 88 | #if defined(VL_CHECKING) 89 | #define Assert(b, e) _Assert(b, e, __FILE__, __LINE__) 90 | // Assert that b is true. e is an error message to be printed if b 91 | // is false. 92 | #define Expect(b, w) _Expect(b, w, __FILE__, __LINE__) 93 | // Prints warning w if b is false 94 | #define CheckRange(i, l, u, r) _CheckRange(i, l, u, r, __FILE__, __LINE__) 95 | // Checks whether i is in the range [lowerBound, upperBound). 96 | #else 97 | #define Assert(b, e) 98 | #define Expect(b, w) 99 | #define CheckRange(a, l, u, r) 100 | #endif 101 | 102 | Void _Assert(Int condition, const Char *errorMessage, const Char *file, Int line); 103 | Void _Expect(Int condition, const Char *warningMessage, const Char *file, Int line); 104 | Void _CheckRange(Int i, Int lowerBound, Int upperBound, const Char *rangeMessage, 105 | const Char *file, Int line); 106 | 107 | 108 | // --- Inlines ----------------------------------------------------------------- 109 | 110 | template 111 | inline Value Min(Value x, Value y) 112 | { 113 | if (x <= y) 114 | return(x); 115 | else 116 | return(y); 117 | }; 118 | 119 | template 120 | inline Value Max(Value x, Value y) 121 | { 122 | if (x >= y) 123 | return(x); 124 | else 125 | return(y); 126 | }; 127 | 128 | template 129 | inline Void Swap(Value &x, Value &y) 130 | { 131 | Value t; 132 | 133 | t = x; 134 | x = y; 135 | y = t; 136 | }; 137 | 138 | template 139 | inline Value Mix(Value x, Value y, Real s) 140 | { 141 | return(x + (y - x) * s); 142 | }; 143 | 144 | template 145 | inline Value Clip(Value x, Value min, Value max) 146 | { 147 | if (x < min) 148 | return(min); 149 | else if (x > max) 150 | return(max); 151 | else 152 | return(x); 153 | }; 154 | 155 | template 156 | inline Value sqr(Value x) 157 | { 158 | return(x * x); 159 | }; 160 | -------------------------------------------------------------------------------- /src/lib/svl/Constants.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: Constants.h 3 | 4 | Function: Contains various constants for VL. 5 | 6 | Author: Andrew Willmott 7 | 8 | Copyright: (c) 1999-2001, Andrew Willmott 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | 15 | 16 | // --- Mathematical constants ------------------------------------------------- 17 | 18 | 19 | #ifdef M_PI 20 | const Real vl_pi = M_PI; 21 | const Real vl_halfPi = M_PI_2; 22 | #elif defined(_PI) 23 | const Real vl_pi = _PI; 24 | const Real vl_halfPi = vl_pi / 2.0; 25 | #else 26 | const Real vl_pi = 3.14159265358979323846; 27 | const Real vl_halfPi = vl_pi / 2.0; 28 | #endif 29 | 30 | #ifdef HUGE_VAL 31 | const Double vl_inf = HUGE_VAL; 32 | #endif 33 | 34 | enum ZeroOrOne { vl_zero = 0, vl_0 = 0, vl_one = 1, vl_I = 1, vl_1 = 1 }; 35 | enum Block { vl_Z = 0, vl_B = 1, vl_block = 1 }; 36 | enum Axis { vl_x, vl_y, vl_z, vl_w }; 37 | typedef Axis vl_axis; 38 | 39 | const UInt VL_REF_FLAG = UInt(1) << (sizeof(UInt) * 8 - 1); 40 | const UInt VL_REF_MASK = (~VL_REF_FLAG); 41 | -------------------------------------------------------------------------------- /src/lib/svl/LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Except where otherwise noted, Copyright (c) 2002 Andrew Willmott. 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions 7 | are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | 12 | 2. Redistributions in binary form have no conditions on them. 13 | 14 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 15 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 16 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN 17 | NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT, 18 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT 19 | NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 20 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 21 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 22 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 23 | THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 | -------------------------------------------------------------------------------- /src/lib/svl/Mat4.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: Mat4.h 3 | 4 | Function: Defines a 4 x 4 matrix. 5 | 6 | Author(s): Andrew Willmott 7 | 8 | Copyright: (c) 1995-2001, Andrew Willmott 9 | */ 10 | 11 | #pragma once 12 | 13 | #include "Vec3.h" 14 | #include "Vec4.h" 15 | 16 | 17 | // --- Mat4 Class ------------------------------------------------------------- 18 | 19 | class Mat4 20 | { 21 | public: 22 | 23 | // Constructors 24 | 25 | Mat4(); 26 | Mat4(Real a, Real b, Real c, Real d, 27 | Real e, Real f, Real g, Real h, 28 | Real i, Real j, Real k, Real l, 29 | Real m, Real n, Real o, Real p); 30 | Mat4(const Mat4 &m); 31 | Mat4(ZeroOrOne k); 32 | Mat4(Block k); 33 | 34 | // Accessor functions 35 | 36 | Int Rows() const { return(4); }; 37 | Int Cols() const { return(4); }; 38 | 39 | Vec4 &operator [] (Int i); 40 | const Vec4 &operator [] (Int i) const; 41 | 42 | Real *Ref() const; 43 | 44 | // Assignment operators 45 | 46 | Mat4 &operator = (const Mat4 &m); 47 | Mat4 &operator = (ZeroOrOne k); 48 | Mat4 &operator = (Block k); 49 | Mat4 &operator += (const Mat4 &m); 50 | Mat4 &operator -= (const Mat4 &m); 51 | Mat4 &operator *= (const Mat4 &m); 52 | Mat4 &operator *= (Real s); 53 | Mat4 &operator /= (Real s); 54 | 55 | // Comparison operators 56 | 57 | Bool operator == (const Mat4 &m) const; // M == N? 58 | Bool operator != (const Mat4 &m) const; // M != N? 59 | 60 | // Arithmetic operators 61 | 62 | Mat4 operator + (const Mat4 &m) const; // M + N 63 | Mat4 operator - (const Mat4 &m) const; // M - N 64 | Mat4 operator - () const; // -M 65 | Mat4 operator * (const Mat4 &m) const; // M * N 66 | Mat4 operator * (Real s) const; // M * s 67 | Mat4 operator / (Real s) const; // M / s 68 | 69 | // Initialisers 70 | 71 | Void MakeZero(); // Zero matrix 72 | Void MakeDiag(Real k = vl_one); // I 73 | Void MakeBlock(Real k = vl_one); // all elts = k 74 | 75 | // Homogeneous Transforms 76 | 77 | Mat4& MakeHRot(const Vec3 &axis, Real theta); 78 | // Rotate by theta radians about axis 79 | Mat4& MakeHRot(const Vec4 &q); // Rotate by quaternion 80 | Mat4& MakeHScale(const Vec3 &s); // Scale by components of s 81 | 82 | Mat4& MakeHTrans(const Vec3 &t); // Translation by t 83 | 84 | Mat4& Transpose(); // transpose in place 85 | Mat4& AddShift(const Vec3 &t); // Concatenate shift 86 | 87 | // Private... 88 | 89 | protected: 90 | 91 | Vec4 row[4]; 92 | }; 93 | 94 | 95 | // --- Matrix operators ------------------------------------------------------- 96 | 97 | Vec4 operator * (const Mat4 &m, const Vec4 &v); // m * v 98 | Vec4 operator * (const Vec4 &v, const Mat4 &m); // v * m 99 | Vec4 &operator *= (Vec4 &a, const Mat4 &m); // v *= m 100 | inline Mat4 operator * (Real s, const Mat4 &m); // s * m 101 | 102 | Mat4 trans(const Mat4 &m); // Transpose 103 | Real trace(const Mat4 &m); // Trace 104 | Mat4 adj(const Mat4 &m); // Adjoint 105 | Real det(const Mat4 &m); // Determinant 106 | Mat4 inv(const Mat4 &m); // Inverse 107 | Mat4 oprod(const Vec4 &a, const Vec4 &b); 108 | // Outer product 109 | 110 | // The xform functions help avoid dependence on whether row or column 111 | // vectors are used to represent points and vectors. 112 | inline Vec4 xform(const Mat4 &m, const Vec4 &v); // Transform of v by m 113 | inline Vec3 xform(const Mat4 &m, const Vec3 &v); // Hom. xform of v by m 114 | inline Mat4 xform(const Mat4 &m, const Mat4 &n); // Xform v -> m(n(v)) 115 | 116 | std::ostream &operator << (std::ostream &s, const Mat4 &m); 117 | std::istream &operator >> (std::istream &s, Mat4 &m); 118 | 119 | 120 | // --- Inlines ---------------------------------------------------------------- 121 | 122 | inline Mat4::Mat4() 123 | { 124 | } 125 | 126 | inline Vec4 &Mat4::operator [] (Int i) 127 | { 128 | CheckRange(i, 0, 4, "(Mat4::[i]) index out of range"); 129 | return(row[i]); 130 | } 131 | 132 | inline const Vec4 &Mat4::operator [] (Int i) const 133 | { 134 | CheckRange(i, 0, 4, "(Mat4::[i]) index out of range"); 135 | return(row[i]); 136 | } 137 | 138 | inline Real *Mat4::Ref() const 139 | { 140 | return((Real *) row); 141 | } 142 | 143 | inline Mat4::Mat4(ZeroOrOne k) 144 | { 145 | MakeDiag(k); 146 | } 147 | 148 | inline Mat4::Mat4(Block k) 149 | { 150 | MakeBlock((ZeroOrOne) k); 151 | } 152 | 153 | inline Mat4 &Mat4::operator = (ZeroOrOne k) 154 | { 155 | MakeDiag(k); 156 | 157 | return(SELF); 158 | } 159 | 160 | inline Mat4 &Mat4::operator = (Block k) 161 | { 162 | MakeBlock((ZeroOrOne) k); 163 | 164 | return(SELF); 165 | } 166 | 167 | inline Mat4 operator * (Real s, const Mat4 &m) 168 | { 169 | return(m * s); 170 | } 171 | 172 | #ifdef VL_ROW_ORIENT 173 | inline Vec3 xform(const Mat4 &m, const Vec3 &v) 174 | { return(proj(Vec4(v, 1.0) * m)); } 175 | inline Vec4 xform(const Mat4 &m, const Vec4 &v) 176 | { return(v * m); } 177 | inline Mat4 xform(const Mat4 &m, const Mat4 &n) 178 | { return(n * m); } 179 | #else 180 | inline Vec3 xform(const Mat4 &m, const Vec3 &v) 181 | { return(proj(m * Vec4(v, 1.0))); } 182 | inline Vec4 xform(const Mat4 &m, const Vec4 &v) 183 | { return(m * v); } 184 | inline Mat4 xform(const Mat4 &m, const Mat4 &n) 185 | { return(m * n); } 186 | #endif 187 | -------------------------------------------------------------------------------- /src/lib/svl/README: -------------------------------------------------------------------------------- 1 | Contents 2 | 3 | The SVL vector & matrix package, version 1.5. 4 | 5 | SVL provides 2-, 3- and 4-vector and matrix types, as well as 6 | arbitrarily-sized vectors and matrices, and various useful functions 7 | and arithmetic operators. 8 | 9 | SVL is free for commercial and non-commercial use; see the LICENSE file 10 | for redistribution conditions. (These apply only to the source code. 11 | Binaries may be freely redistributed, no strings attached.) 12 | 13 | Author 14 | 15 | Andrew Willmott, ajw+svl@cs.cmu.edu 16 | Please send me any suggestions/comments/bug fixes you have. 17 | 18 | History 19 | 20 | Briefly: SVL, and its more complex cousin, VL, have their roots in 21 | an attempt replace the various (inevitably heavily-macroized) 22 | vector/matrix packages used by the members of the CMU graphics group 23 | with a single C++ one, so that people could share code more easily. 24 | SVL makes heavy use of inlines to achieve performance equal to that 25 | of the C macros and functions it replaced. 26 | 27 | To Make 28 | 29 | Running 'make' with no arguments will list possible architectures to 30 | compile for. The makefiles should work with most makes that have the 31 | include directive, but try using gmake if something goes wrong. 32 | 33 | If your architecture is not listed, copy and then modify the config file 34 | in the makefiles directory that's closest to what you need. 35 | 36 | To install, set the DEST variable appropriately and 'make install'. 37 | DEST defaults to /usr/local. 38 | 39 | E.g., to install into /usr on a linux machine: 40 | make DEST=/usr linux install 41 | from this directory. 42 | 43 | To Use 44 | 45 | #include svl/SVL.h, and link with -lsvl. To use in debug mode, add the 46 | switch "-DVL_DEBUG" to your compile line, and link with -lsvl.dbg. See 47 | the documentation for more information. 48 | 49 | Documentation 50 | 51 | Run your favourite web browser with file:doc/svl.html 52 | 53 | Changes 54 | 55 | 1.4 Fixed problem with SVLgl.h -- had some wrappers for OpenGL calls that 56 | don't actually exist(!) 57 | Fixed bad memory problem with Mat::SetSize 58 | Makefile for OSX, split sunos/solaris 59 | 60 | 1.3.2 Fixed minor MSVC warnings 61 | Added windows packaging 62 | 1.3.1 Sunday 11/03/01 63 | Reordered initializers, eliminated signed/unsigned comparisons 64 | Fixed make clean problem 65 | Irix CC is warning that 'Mat2::*' is being called before its inline 66 | definition, but appears to be on crack as the inline '*' is 67 | defined before the xform() that calls it. 68 | Fixed afs-lib dependency for afs build 69 | 1.3 Sunday 11/03/01 70 | Split off from VL 1.3. All VL-dependent code and type 71 | parameterization macros removed to make code more understandable. 72 | Fix for the C++ "standard" no longer allowing stack temporaries to 73 | be passes as non-const refs. (Fixing this for VL requires more 74 | significant changes, so it's proved easier to fork SVL at this 75 | point for the sake of simplicity.) 76 | Renamed files, general cleanups. 77 | Added ">>" operators for Vec and Mat. 78 | Disallowed resize of a vector reference. (This caused more bugs 79 | than it was worth.) 80 | Removed all asserts checking that the return value of 'new' is 81 | not zero. The C++ "standard" has been changed so that new 82 | instead throws an exception in this situation. 83 | Added option to use memcpy for general vector copies: VL_USE_MEMCPY. 84 | It seems that nowadays, on Intel processors at least, using 85 | memcpy is faster than loops for most cases. See note in Vec.cc. 86 | Changed the packaging to match the current vl/gcl scheme. 87 | Updated afs-setup rule to ensure SVLConfig.h winds up in the 88 | architecture-dependent lib directory. 89 | 1.2 Release to match VL 1.2. 90 | 1.1.3 Fixed some windows compile issues under VC++. 91 | 1.1.2 Added comments about the Real, Vec, etc. types to VL.h 92 | 1.1.1 Fixed problem with += operators and gcc under linux. 93 | 1.1 Added oprod operator, irix n32 CC support, changed makefiles & afs 94 | support, eliminated most g++ warnings. -------------------------------------------------------------------------------- /src/lib/svl/SVL.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: SVL.h 3 | 4 | Function: Master header for a simple version of the VL library. 5 | The various classes are named Vec2, Mat3, Vec, etc. 6 | Link with -lsvl, or define the symbol VL_DEBUG and 7 | link with -lsvl.dbg for the debugging version. 8 | 9 | Author(s): Andrew Willmott 10 | 11 | Copyright: (c) 1995-2001, Andrew Willmott 12 | */ 13 | 14 | #pragma once 15 | 16 | #define SVL_VERSION "1.5" 17 | #define SVL_VER_NUM 10500 18 | 19 | #ifdef VL_DEBUG 20 | #define VL_CHECKING 21 | #endif 22 | 23 | #include 24 | 25 | #include "Basics.h" 26 | #include "Constants.h" 27 | #include "Utils.h" 28 | 29 | #include "Vec2.h" 30 | #include "Vec3.h" 31 | #include "Vec4.h" 32 | #include "Vec.h" 33 | 34 | #include "Mat2.h" 35 | #include "Mat3.h" 36 | #include "Mat4.h" 37 | #include "Mat.h" 38 | 39 | #include "Transform.h" 40 | -------------------------------------------------------------------------------- /src/lib/svl/Transform.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: Transform.h 3 | 4 | Function: Provides transformation constructors. 5 | 6 | Author(s): Andrew Willmott 7 | 8 | Copyright: (c) 1995-2001, Andrew Willmott 9 | */ 10 | 11 | #pragma once 12 | 13 | inline Mat2 Rot2(Real theta) 14 | { Mat2 result; result.MakeRot(theta); return(result); } 15 | inline Mat2 Scale2(const Vec2 &s) 16 | { Mat2 result; result.MakeScale(s); return(result); } 17 | 18 | inline Mat3 Rot3(const Vec3 &axis, Real theta) 19 | { Mat3 result; result.MakeRot(axis, theta); return(result); } 20 | inline Mat3 Rot3(const Vec4 &q) 21 | { Mat3 result; result.MakeRot(q); return(result); } 22 | inline Mat3 Scale3(const Vec3 &s) 23 | { Mat3 result; result.MakeScale(s); return(result); } 24 | inline Mat3 HRot3(Real theta) 25 | { Mat3 result; result.MakeHRot(theta); return(result); } 26 | inline Mat3 HScale3(const Vec2 &s) 27 | { Mat3 result; result.MakeHScale(s); return(result); } 28 | inline Mat3 HTrans3(const Vec2 &t) 29 | { Mat3 result; result.MakeHTrans(t); return(result); } 30 | 31 | inline Mat4 HRot4(const Vec3 &axis, Real theta) 32 | { Mat4 result; result.MakeHRot(axis, theta); return(result); } 33 | inline Mat4 HRot4(const Vec4 &q) 34 | { Mat4 result; result.MakeHRot(q); return(result); } 35 | inline Mat4 HScale4(const Vec3 &s) 36 | { Mat4 result; result.MakeHScale(s); return(result); } 37 | inline Mat4 HTrans4(const Vec3 &t) 38 | { Mat4 result; result.MakeHTrans(t); return(result); } 39 | -------------------------------------------------------------------------------- /src/lib/svl/Utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | File: Utils.h 3 | 4 | Function: Various math definitions for VL 5 | 6 | Author(s): Andrew Willmott 7 | 8 | Copyright: (c) 1995-2001, Andrew Willmott 9 | */ 10 | 11 | #pragma once 12 | 13 | #include 14 | 15 | // --- Inlines ---------------------------------------------------------------- 16 | 17 | // additions to arithmetic functions 18 | 19 | #ifdef VL_HAS_IEEEFP 20 | #include 21 | #define vl_is_finite(X) finite(X) 22 | #elif defined (__GNUC__) && defined(__USE_MISC) 23 | #define vl_is_finite(X) finite(X) 24 | #else 25 | #define vl_is_finite(X) (1) 26 | #endif 27 | 28 | #ifdef VL_HAS_DRAND 29 | inline Double vl_rand() 30 | { return(drand48()); } 31 | #else 32 | #ifndef RAND_MAX 33 | // we're on something totally sucky, like SunOS 34 | #define RAND_MAX (Double(1 << 30) * 4.0 - 1.0) 35 | #endif 36 | inline Double vl_rand() 37 | { return(rand() / (RAND_MAX + 1.0)); } 38 | #endif 39 | 40 | #ifndef __CMATH__ 41 | // GNU's complex.h defines its own abs(double) 42 | #ifdef VL_HAS_ABSF 43 | inline Float abs(Float x) 44 | { return (fabsf(x)); } 45 | #endif 46 | inline Double abs(Double x) 47 | { return (fabs(x)); } 48 | #endif 49 | #ifdef VL_HAS_ABSF 50 | inline Float len(Float x) 51 | { return (fabsf(x)); } 52 | #endif 53 | inline Double len(Double x) 54 | { return (fabs(x)); } 55 | 56 | inline Float sqrlen(Float r) 57 | { return(sqr(r)); } 58 | inline Double sqrlen(Double r) 59 | { return(sqr(r)); } 60 | 61 | inline Float mix(Float a, Float b, Float s) 62 | { return((1.0f - s) * a + s * b); } 63 | inline Double mix(Double a, Double b, Double s) 64 | { return((1.0 - s) * a + s * b); } 65 | 66 | inline Double sign(Double d) 67 | { 68 | if (d < 0) 69 | return(-1.0); 70 | else 71 | return(1.0); 72 | } 73 | 74 | // useful routines 75 | 76 | inline Bool IsPowerOfTwo(Int a) 77 | { return((a & -a) == a); }; 78 | 79 | inline Void SetReal(Float &a, Double b) 80 | { a = Float(b); } 81 | inline Void SetReal(Double &a, Double b) 82 | { a = b; } 83 | -------------------------------------------------------------------------------- /src/lib/texture.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Simple 2D texture sampler. 3 | * 4 | * Textures are loaded from PNG files on disk, 5 | * and sampled with bilinear interpolation. 6 | * 7 | * Copyright (c) 2014 Micah Elizabeth Scott 8 | * 9 | * Permission is hereby granted, free of charge, to any person 10 | * obtaining a copy of this software and associated documentation 11 | * files (the "Software"), to deal in the Software without 12 | * restriction, including without limitation the rights to use, 13 | * copy, modify, merge, publish, distribute, sublicense, and/or sell 14 | * copies of the Software, and to permit persons to whom the 15 | * Software is furnished to do so, subject to the following 16 | * conditions: 17 | * 18 | * The above copyright notice and this permission notice shall be 19 | * included in all copies or substantial portions of the Software. 20 | * 21 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 22 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 23 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 24 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 25 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 26 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 27 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 28 | * OTHER DEALINGS IN THE SOFTWARE. 29 | */ 30 | 31 | #pragma once 32 | 33 | #include 34 | #include 35 | #include 36 | #include 37 | 38 | #include "picopng.h" 39 | #include "svl/SVL.h" 40 | 41 | 42 | class Texture { 43 | public: 44 | Texture(); 45 | Texture(const char *filename); 46 | 47 | bool load(const char *filename); 48 | bool load(std::vector png); 49 | bool isLoaded() const; 50 | 51 | // Interpolated sampling. Texture coordinates in the range [0, 1] 52 | Vec3 sample(Vec2 texcoord) const; 53 | Vec3 sample(float x, float y) const; 54 | 55 | // Raw sampling, integer pixel coordinates. 56 | const uint8_t *sampleIntRGBA32(int x, int y) const; 57 | Vec3 sampleInt(int x, int y) const; 58 | 59 | private: 60 | unsigned long width, height; 61 | std::vector pixels; 62 | void init(); 63 | }; 64 | 65 | 66 | /***************************************************************************************** 67 | * Implementation 68 | *****************************************************************************************/ 69 | 70 | 71 | inline Texture::Texture() 72 | { 73 | init(); 74 | } 75 | 76 | inline Texture::Texture(const char *filename) 77 | { 78 | load(filename); 79 | } 80 | 81 | inline void Texture::init() 82 | { 83 | width = 0; 84 | height = 0; 85 | } 86 | 87 | inline bool Texture::load(const char *filename) 88 | { 89 | init(); 90 | 91 | FILE *f = fopen(filename, "rb"); 92 | if (!f) { 93 | fprintf(stderr, "Can't open texture %s\n", filename); 94 | return false; 95 | } 96 | 97 | std::vector buffer; 98 | fseek(f, 0L, SEEK_END); 99 | long size = ftell(f); 100 | fseek(f, 0L, SEEK_SET); 101 | 102 | if (size > 0) { 103 | buffer.resize((size_t)size); 104 | if (fread(&buffer[0], size, 1, f) == 1) { 105 | if (load(buffer)) { 106 | // Success 107 | fclose(f); 108 | return true; 109 | } 110 | } 111 | } 112 | 113 | fprintf(stderr, "Error loading texture PNG from %s\n", filename); 114 | fclose(f); 115 | return false; 116 | } 117 | 118 | inline bool Texture::load(std::vector png) 119 | { 120 | if (decodePNG(pixels, width, height, &png[0], png.size()) != 0) { 121 | init(); 122 | return false; 123 | } 124 | 125 | return true; 126 | } 127 | 128 | inline bool Texture::isLoaded() const 129 | { 130 | return width && height; 131 | } 132 | 133 | inline const uint8_t* Texture::sampleIntRGBA32(int x, int y) const 134 | { 135 | if (!isLoaded()) { 136 | return 0; 137 | } 138 | 139 | x = std::max(0, std::min(width - 1, x)); 140 | y = std::max(0, std::min(height - 1, y)); 141 | return &pixels[ (x + y * width) << 2 ]; 142 | } 143 | 144 | inline Vec3 Texture::sampleInt(int x, int y) const 145 | { 146 | const uint8_t* rgba = sampleIntRGBA32(x, y); 147 | return Vec3( 148 | (rgba[0] & 0xFF) / 255.0f, 149 | (rgba[1] & 0xFF) / 255.0f, 150 | (rgba[2] & 0xFF) / 255.0f ); 151 | } 152 | 153 | inline Vec3 Texture::sample(Vec2 texcoord) const 154 | { 155 | return sample(texcoord[0], texcoord[1]); 156 | } 157 | 158 | inline Vec3 Texture::sample(float x, float y) const 159 | { 160 | float fx = x * width; 161 | float fy = y * height; 162 | 163 | int ix = fx; 164 | int iy = fy; 165 | 166 | // Sample four points 167 | Vec3 aa = sampleInt(ix, iy); 168 | Vec3 ba = sampleInt(ix + 1, iy); 169 | Vec3 ab = sampleInt(ix, iy + 1); 170 | Vec3 bb = sampleInt(ix + 1, iy + 1); 171 | 172 | // X interpolation 173 | Vec3 ca = aa + (ba - aa) * (fx - ix); 174 | Vec3 cb = ab + (bb - ab) * (fx - ix); 175 | 176 | // Y interpolation 177 | return ca + (cb - ca) * (fy - iy); 178 | } 179 | -------------------------------------------------------------------------------- /src/matt-mixer: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpinner/Active/b5e2c9df3a53bc79920fb5f17489296238b898d0/src/matt-mixer -------------------------------------------------------------------------------- /src/matt-mixer.cpp: -------------------------------------------------------------------------------- 1 | // Simple example for EffectMixer. Mixers let you run multiple effects, and they 2 | // handle concurrent rendering on multiple CPU cores. 3 | 4 | #include "lib/effect_runner.h" 5 | #include "lib/effect_mixer.h" 6 | 7 | #include "rings.h" 8 | #include "dot.h" 9 | #include "spokes.h" 10 | 11 | int main(int argc, char **argv) 12 | { 13 | // RingsEffect rings("data/glass.png"); 14 | // DotEffect crash("data/crash.png"); 15 | // DotEffect dance("data/dance-in.png"); 16 | //SpokesEffect spokes; 17 | 18 | 19 | EffectMixer mixer; 20 | /// mixer.add(&rings); 21 | // mixer.add(&crash); 22 | // mixer.add(&dance); 23 | 24 | /* 25 | DotEffect nyan("data/nyan.png"); 26 | mixer.add(&nyan); 27 | 28 | DotEffect crash("data/crash.png"); 29 | mixer.add(&crash); 30 | 31 | DotEffect sky("data/sky.png"); 32 | mixer.add(&sky); 33 | 34 | DotEffect glass("data/glass.png"); 35 | mixer.add(&glass); 36 | 37 | DotEffect dot("data/dot.png"); 38 | mixer.add(&dot); 39 | 40 | DotEffect dance("data/dance.png"); 41 | mixer.add(&dance); 42 | */ 43 | 44 | DotEffect startingcrow("data/startingcrow.png"); 45 | mixer.add(&startingcrow); 46 | 47 | DotEffect crow("data/crow_up.png"); 48 | mixer.add(&crow); 49 | 50 | DotEffect crowUp("data/crow_flying_down.png"); 51 | mixer.add(&crowUp); 52 | 53 | DotEffect gull("data/gull_flying.png"); 54 | mixer.add(&gull); 55 | 56 | DotEffect flying("data/flying-pelican.png"); 57 | mixer.add(&flying); 58 | 59 | 60 | DotEffect bruja("data/bruja.png"); 61 | mixer.add(&bruja); 62 | 63 | DotEffect cat("data/cat.png"); 64 | mixer.add(&cat); 65 | 66 | DotEffect bat("data/bat.png"); 67 | mixer.add(&bat); 68 | 69 | 70 | EffectRunner r; 71 | r.setEffect(&mixer); 72 | r.setLayout("../../../Active/layout/layout-60x24.json"); 73 | if (!r.parseArguments(argc, argv)) { 74 | return 1; 75 | } 76 | 77 | float state = 0; 78 | 79 | while (true) { 80 | EffectRunner::FrameStatus frame = r.doFrame(); 81 | const float speed = 0.1f; 82 | 83 | // Animate the mixer's fader controls 84 | state = fmod(state + frame.timeDelta * speed, 2 * M_PI); 85 | for (int i = 0; i < mixer.numChannels(); i++) { 86 | float theta = state + i * (2 * M_PI) / mixer.numChannels(); 87 | mixer.setFader(i, std::max(0.0f, sinf(theta))); 88 | } 89 | 90 | // Main loops and Effects can both generate verbose debug output (-v command line option) 91 | if (frame.debugOutput) { 92 | fprintf(stderr, "\t[main] state = %f\n", state); 93 | } 94 | } 95 | } -------------------------------------------------------------------------------- /src/mixer: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpinner/Active/b5e2c9df3a53bc79920fb5f17489296238b898d0/src/mixer -------------------------------------------------------------------------------- /src/mixer.cpp: -------------------------------------------------------------------------------- 1 | // Simple example for EffectMixer. Mixers let you run multiple effects, and they 2 | // handle concurrent rendering on multiple CPU cores. 3 | 4 | #include "lib/effect_runner.h" 5 | #include "lib/effect_mixer.h" 6 | 7 | #include "rings.h" 8 | #include "dot.h" 9 | #include "spokes.h" 10 | 11 | #include "snow.h" 12 | #include "ball.h" 13 | #include "video.h" 14 | 15 | #include "particle_trail.h" 16 | 17 | 18 | int main(int argc, char **argv) 19 | { 20 | RingsEffect rings("data/glass.png"); 21 | VideoEffect video("/Users/matt//active/video/queue/"); 22 | SpokesEffect spokes; 23 | SnowEffect snow; 24 | BallEffect ball; 25 | ParticleTrailEffect particles; 26 | 27 | 28 | EffectMixer mixer; 29 | mixer.add(&particles); 30 | mixer.add(&video); 31 | mixer.add(&snow); 32 | mixer.add(&video); 33 | mixer.add(&ball); 34 | mixer.add(&video); 35 | mixer.add(&rings); 36 | mixer.add(&video); 37 | // mixer.add(&spokes); 38 | 39 | EffectRunner r; 40 | r.setMaxFrameRate(30); 41 | r.setEffect(&mixer); 42 | r.setLayout("../../../Active/layout/layout-60x24.json"); 43 | if (!r.parseArguments(argc, argv)) { 44 | return 1; 45 | } 46 | 47 | float state = 0; 48 | 49 | while (true) { 50 | EffectRunner::FrameStatus frame = r.doFrame(); 51 | const float speed = 0.09f; 52 | 53 | // Animate the mixer's fader controls 54 | state = fmod(state + frame.timeDelta * speed, 2 * M_PI); 55 | for (int i = 0; i < mixer.numChannels(); i++) { 56 | float theta = state + i * (2 * M_PI) / mixer.numChannels(); 57 | mixer.setFader(i, std::max(0.0f, sinf(theta))); 58 | } 59 | 60 | // Main loops and Effects can both generate verbose debug output (-v command line option) 61 | if (frame.debugOutput) { 62 | fprintf(stderr, "\t[main] state = %f\n", state); 63 | } 64 | } 65 | } -------------------------------------------------------------------------------- /src/particle_trail: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpinner/Active/b5e2c9df3a53bc79920fb5f17489296238b898d0/src/particle_trail -------------------------------------------------------------------------------- /src/particle_trail.cpp: -------------------------------------------------------------------------------- 1 | #include "lib/effect_runner.h" 2 | #include "particle_trail.h" 3 | 4 | int main(int argc, char **argv) 5 | { 6 | EffectRunner r; 7 | ParticleTrailEffect e; 8 | r.setEffect(&e); 9 | r.setMaxFrameRate(30); 10 | r.setLayout("../layouts/grid32x16z.json"); 11 | return r.main(argc, argv); 12 | } 13 | -------------------------------------------------------------------------------- /src/particle_trail.h: -------------------------------------------------------------------------------- 1 | // Simple particle system example for C++. 2 | 3 | #pragma once 4 | 5 | #include 6 | #include "lib/color.h" 7 | #include "lib/effect.h" 8 | #include "lib/particle.h" 9 | 10 | class ParticleTrailEffect : public ParticleEffect 11 | { 12 | public: 13 | ParticleTrailEffect() 14 | : angle1(0), angle2(0), baseHue(0) 15 | {} 16 | 17 | float angle1; 18 | float angle2; 19 | float angle3; 20 | 21 | float baseHue; 22 | 23 | virtual void beginFrame(const FrameInfo &f) 24 | { 25 | const float tailLength = 4.0f; 26 | // const float speed = 0.01f; //SLOW 27 | const float speed = 0.29f; //FAST 28 | const float lfoRatio = 0.15f; 29 | const float notLfoRatio = 0.30f; 30 | const float hueRate = 0.1f; 31 | const float brightness = 40.0f; 32 | const unsigned numParticles = 15; 33 | 34 | // Low frequency oscillators 35 | angle1 = fmodf(angle1 + f.timeDelta * speed, 2 * M_PI); 36 | angle2 = fmodf(angle2 + f.timeDelta * speed * lfoRatio, 2 * M_PI); 37 | angle3 = fmodf(angle3 + f.timeDelta * speed * notLfoRatio, 2 * M_PI); 38 | baseHue = fmodf(baseHue + f.timeDelta * speed * hueRate, 1.0f); 39 | 40 | appearance.resize(numParticles); 41 | for (unsigned i = 0; i < numParticles; i++) { 42 | float s = float(i) / numParticles; 43 | float tail = s * tailLength; 44 | 45 | float radius = 0.2 + 2.0 * s; 46 | float x = radius * cos(angle1 + tail) * 3.0 + 1.0; 47 | float y = radius * sin(angle1 + tail + 12.0 * sin(angle2 + tail * lfoRatio)); 48 | float z = radius * sin(angle3 + tail); 49 | float hue = baseHue + s * 0.4; 50 | 51 | ParticleAppearance& p = appearance[i]; 52 | p.point = Vec3(x, y, z); 53 | p.intensity = (brightness / numParticles) * s; 54 | p.radius = 0.1 + 1.2f * s; //MADE BIG 55 | hsv2rgb(p.color, hue, 0.5, 1.0); 56 | } 57 | 58 | ParticleEffect::beginFrame(f); 59 | } 60 | }; 61 | -------------------------------------------------------------------------------- /src/rings: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpinner/Active/b5e2c9df3a53bc79920fb5f17489296238b898d0/src/rings -------------------------------------------------------------------------------- /src/rings.cpp: -------------------------------------------------------------------------------- 1 | #include "lib/effect_runner.h" 2 | #include "rings.h" 3 | 4 | int main(int argc, char **argv) 5 | { 6 | RingsEffect e("data/glass.png"); 7 | 8 | EffectRunner r; 9 | r.setEffect(&e); 10 | r.setMaxFrameRate(30); 11 | 12 | r.setLayout("../layouts/grid32x16z.json"); 13 | return r.main(argc, argv); 14 | } 15 | -------------------------------------------------------------------------------- /src/simple: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpinner/Active/b5e2c9df3a53bc79920fb5f17489296238b898d0/src/simple -------------------------------------------------------------------------------- /src/simple.cpp: -------------------------------------------------------------------------------- 1 | // Simple example effect: 2 | // Draws a noise pattern modulated by an expanding sine wave. 3 | 4 | #include 5 | #include "lib/color.h" 6 | #include "lib/effect.h" 7 | #include "lib/effect_runner.h" 8 | #include "lib/noise.h" 9 | 10 | class MyEffect : public Effect 11 | { 12 | public: 13 | MyEffect() 14 | : cycle (0) {} 15 | 16 | float cycle; 17 | 18 | virtual void beginFrame(const FrameInfo &f) 19 | { 20 | const float speed = 10.0; 21 | cycle = fmodf(cycle + f.timeDelta * speed, 2 * M_PI); 22 | } 23 | 24 | virtual void shader(Vec3& rgb, const PixelInfo &p) const 25 | { 26 | float distance = len(p.point); 27 | float wave = sinf(3.0 * distance - cycle) ; //+ noise3(p.point); 28 | hsv2rgb(rgb, 0.2, 0.3, wave); 29 | } 30 | }; 31 | 32 | int main(int argc, char **argv) 33 | { 34 | EffectRunner r; 35 | 36 | MyEffect e; 37 | r.setEffect(&e); 38 | 39 | // Defaults, overridable with command line options 40 | r.setMaxFrameRate(30); 41 | r.setLayout("../layouts/grid32x16z.json"); 42 | 43 | return r.main(argc, argv); 44 | } -------------------------------------------------------------------------------- /src/snow.cpp: -------------------------------------------------------------------------------- 1 | #include "lib/effect_runner.h" 2 | #include "snow.h" 3 | 4 | int main(int argc, char **argv) 5 | { 6 | EffectRunner r; 7 | 8 | SnowEffect e; 9 | r.setEffect(&e); 10 | 11 | // Defaults, overridable with command line options 12 | r.setLayout("../layouts/grid32x16z.json"); 13 | 14 | return r.main(argc, argv); 15 | } 16 | -------------------------------------------------------------------------------- /src/snow.h: -------------------------------------------------------------------------------- 1 | // Snow effect: 2 | 3 | #include 4 | #include "lib/color.h" 5 | #include "lib/effect.h" 6 | #include "lib/effect_runner.h" 7 | #include "lib/noise.h" 8 | 9 | class SnowEffect : public Effect 10 | { 11 | public: 12 | SnowEffect() 13 | : cycle (0) {} 14 | 15 | float cycle; 16 | 17 | virtual void beginFrame(const FrameInfo &f) 18 | { 19 | const float speed = 1.5; 20 | cycle = fmodf(cycle + f.timeDelta * speed, 2 * M_PI); 21 | } 22 | 23 | virtual void shader(Vec3& rgb, const PixelInfo &p) const 24 | { 25 | 26 | float theIndex; 27 | 28 | theIndex = ((int)cycle) % 24; 29 | theIndex -= 12; 30 | theIndex /= 5.0; 31 | 32 | // float distance = len(p.point); 33 | float wave = sinf(0.7 * p.point[2] - cycle) + noise3(p.point); 34 | 35 | 36 | for (int i = 0; i < 3; i++) { 37 | rgb[i] = wave; 38 | } 39 | 40 | 41 | 42 | return; 43 | } 44 | 45 | virtual void debug(const DebugInfo& d) 46 | { 47 | fprintf(stderr, "\t[snow] cycle = %f \n", cycle); 48 | return; 49 | } 50 | 51 | virtual void endFrame(const FrameInfo &f) { 52 | usleep(1e3); 53 | 54 | } 55 | 56 | }; 57 | 58 | 59 | 60 | -------------------------------------------------------------------------------- /src/spokes: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpinner/Active/b5e2c9df3a53bc79920fb5f17489296238b898d0/src/spokes -------------------------------------------------------------------------------- /src/spokes.cpp: -------------------------------------------------------------------------------- 1 | #include "lib/effect_runner.h" 2 | #include "spokes.h" 3 | 4 | int main(int argc, char **argv) 5 | { 6 | SpokesEffect e; 7 | 8 | // Global brightness control 9 | Brightness br(e); 10 | br.set(0.2); 11 | 12 | EffectRunner r; 13 | r.setEffect(&br); 14 | r.setLayout("../layouts/grid32x16z.json"); 15 | return r.main(argc, argv); 16 | } 17 | 18 | -------------------------------------------------------------------------------- /src/spokes.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Radial rotating pattern with noise functions. 3 | * 4 | * 2014 Micah Elizabeth Scott 5 | */ 6 | 7 | #pragma once 8 | 9 | #include 10 | #include "lib/color.h" 11 | #include "lib/effect.h" 12 | #include "lib/noise.h" 13 | #include "lib/brightness.h" 14 | 15 | class SpokesEffect : public Effect 16 | { 17 | public: 18 | SpokesEffect() 19 | : spin(0) {} 20 | 21 | static const float cycleRate = 0.001; 22 | static const float wanderSpeed = 40.0; 23 | static const float wanderSize = 1.8; 24 | static const float hueScale = 5.0; 25 | static const float hueRate = 1.0; 26 | static const float satRate = 10.0; 27 | static const float hueShift = 0.02; 28 | static const float spinSpeed = 3.0; 29 | static const float spinRate = 100.0; 30 | static const float noiseDepth = 3.0; 31 | static const float noiseScale = 0.2; 32 | static const float noiseSpeed = 1000.0; 33 | 34 | // State variables 35 | float spin; 36 | float cycle; 37 | 38 | // Calculated once per frame 39 | float hue, saturation; 40 | Vec3 center, noiseOffset; 41 | 42 | virtual void beginFrame(const FrameInfo &f) 43 | { 44 | // Slow cyclic change. Values stay bounded over time. 45 | cycle = fmodf(cycle + f.timeDelta * cycleRate, 2 * M_PI); 46 | float cyclePos = sinf(cycle); 47 | 48 | noiseOffset[2] = cyclePos * noiseSpeed; 49 | 50 | spin = fmodf(spin + f.timeDelta * noise2(cyclePos * spinRate, 5.8f) * spinSpeed, 2 * M_PI); 51 | 52 | hue = noise2(cyclePos * hueRate, 20.5) * hueScale; 53 | saturation = sq(std::min(std::max(0.7f * (0.5f + noise2(cyclePos * satRate, 0.5)), 0.0f), 1.0f)); 54 | 55 | // Update center position 56 | center = Vec3(noise2(cyclePos * wanderSpeed, 50.9), 0, 57 | noise2(cyclePos * wanderSpeed, 51.7)) * wanderSize; 58 | } 59 | 60 | virtual void shader(Vec3& rgb, const PixelInfo &p) const 61 | { 62 | // Vector to center 63 | Vec3 s = p.point - center; 64 | 65 | // Distort with noise function 66 | s += Vec3(fbm_noise3(p.point * noiseScale + noiseOffset, 4) * noiseDepth, 0, 0); 67 | 68 | float angle = atan2(s[2], s[0]) + spin; 69 | 70 | hsv2rgb(rgb, 71 | hue + angle * hueShift, 72 | saturation, 73 | sq(std::max(0.0f, sinf(angle * 5.0f))) * std::min(0.8f, sqrlen(s)) 74 | ); 75 | } 76 | }; 77 | -------------------------------------------------------------------------------- /src/tlc5947_server.c: -------------------------------------------------------------------------------- 1 | #include "spi.h" 2 | #include "opc.h" 3 | 4 | #define POST_TX_DELAY_USECS 1000 5 | // I'm seeing flickering at speeds above ~6mhz. Although the 6 | // WS2801 datasheet lists a max rate of 25mhz, anecdotal evidence 7 | // from forum posts suggests that most people have had trouble 8 | // obtaining that in practice. 9 | #define WS2801_DEFAULT_SPEED 4000000 10 | 11 | // Different WS2801 strips expect different input color orderings. 12 | typedef enum { RGB=0, GRB=1, BGR=2 } order_t; 13 | #define DEFAULT_INPUT_ORDER RGB 14 | 15 | static int spi_fd = -1; 16 | static u8 spi_data_tx[1 << 16]; 17 | static u32 spi_speed_hz = WS2801_DEFAULT_SPEED; 18 | static order_t rgb_order = DEFAULT_INPUT_ORDER; 19 | 20 | void ws2801_put_pixels(int fd, u8 spi_data_tx[], u32 spi_speed_hz, 21 | u16 count, pixel* pixels, order_t order) { 22 | int i; 23 | pixel* p; 24 | u8* d; 25 | 26 | u16 lower = 0; 27 | 28 | fprintf(stderr, "count : %d \n", count); 29 | 30 | 31 | d = spi_data_tx; 32 | for (i = 0; i < count; i++) { 33 | 34 | int rib = i / 24; 35 | int position = 23 - (i % 24); 36 | int remappedPixel = (rib * 24) + position; 37 | p = &pixels[remappedPixel]; 38 | // p = &pixels[i]; 39 | u16 fullPixel = (p->r+p->r+p->r + p->g+p->g+p->g+p->g + p->b ) << 1; 40 | // fprintf(stderr, "%d : %d, %d, %d \n", i, p->r, p->g, p->b); 41 | fprintf(stderr, "%d -> (%d,%d) -> %d : %d, %d, %d \n", i, rib, position, remappedPixel, p->r, p->g, p->b); 42 | 43 | //although this creates a 16 space the spi out at 12 bits truncates each data value 44 | 45 | *d++ = fullPixel; 46 | *d++ = fullPixel >> 8; 47 | 48 | 49 | 50 | } 51 | spi_transfer(fd, spi_speed_hz, spi_data_tx, 0, 52 | d - spi_data_tx, POST_TX_DELAY_USECS); 53 | } 54 | 55 | 56 | void handler(u8 address, u16 count, pixel* pixels) { 57 | fprintf(stderr, "%d ", count); 58 | fflush(stderr); 59 | ws2801_put_pixels(spi_fd, spi_data_tx, spi_speed_hz, count, 60 | pixels, rgb_order); 61 | } 62 | 63 | order_t get_order(int argc, char** argv) { 64 | order_t order = DEFAULT_INPUT_ORDER; 65 | if (argc > 3) { 66 | if (!strcmp(argv[3], "rgb")) { 67 | order = RGB; 68 | } else if (!strcmp(argv[3], "grb")) { 69 | order = GRB; 70 | } else if (!strcmp(argv[3], "bgr")) { 71 | order = BGR; 72 | } else { 73 | fprintf(stderr, "Did not recognize color order argument - using default\n"); 74 | } 75 | } 76 | return order; 77 | } 78 | 79 | int main(int argc, char** argv) { 80 | u16 port = OPC_DEFAULT_PORT; 81 | 82 | get_speed_and_port(&spi_speed_hz, &port, argc, argv); 83 | rgb_order = get_order(argc, argv); 84 | spi_speed_hz = 4000000; 85 | spi_fd = init_spidev("/dev/spidev1.0", 4000000); 86 | 87 | if (spi_fd < 0) { 88 | return 1; 89 | } 90 | fprintf(stderr, "SPI speed: %.2f MHz, ready...\n", spi_speed_hz*1e-6); 91 | opc_source s = opc_new_source(port); 92 | while (s >= 0 && opc_receive(s, handler, TIMEOUT_MS)); 93 | fprintf(stderr, "Exiting after %d ms of inactivity\n", TIMEOUT_MS); 94 | } 95 | -------------------------------------------------------------------------------- /src/video.cpp: -------------------------------------------------------------------------------- 1 | // Simple example for EffectMixer. Mixers let you run multiple effects, and they 2 | // handle concurrent rendering on multiple CPU cores. 3 | 4 | #include "lib/effect_runner.h" 5 | #include "lib/effect_mixer.h" 6 | #include "lib/tinydir.h" 7 | 8 | #include "video.h" 9 | #include "particle_trail.h" 10 | #include "rings.h" 11 | 12 | int main(int argc, char **argv) 13 | { 14 | 15 | EffectMixer mixer; 16 | 17 | VideoEffect video("/Users/matt//active/video/queue/"); 18 | 19 | mixer.add(&video); 20 | 21 | 22 | EffectRunner r; 23 | r.setEffect(&mixer); 24 | r.setMaxFrameRate(30); 25 | 26 | r.setLayout("../../../Active/layout/layout-60x24.json"); 27 | if (!r.parseArguments(argc, argv)) { 28 | return 1; 29 | } 30 | 31 | float state = 0; 32 | 33 | while (true) { 34 | EffectRunner::FrameStatus frame = r.doFrame(); 35 | const float speed = 10.0f; //FAST 36 | // const float speed = 0.001f; //SLOW 37 | 38 | /* 39 | // Animate the mixer's fader controls 40 | state = fmod(state + frame.timeDelta * speed, 2 * M_PI); 41 | for (int i = 0; i < mixer.numChannels(); i++) { 42 | float theta = state + i * (2 * M_PI) / mixer.numChannels(); 43 | mixer.setFader(i, std::max(0.0f, sinf(theta))); 44 | } 45 | 46 | */ 47 | 48 | // Animate the mixer's fader controls 49 | ///* 50 | state = fmod(state + frame.timeDelta * speed, mixer.numChannels()); 51 | for (int i = 0; i < mixer.numChannels(); i++) { 52 | 53 | mixer.setFader(i, 0.0); 54 | 55 | //float remainder = state - i; 56 | // is this state 57 | if ( i == (int)state) { 58 | mixer.setFader(i, 1.0); 59 | } 60 | 61 | /* // is next state 62 | int nextState = (int) state; 63 | nextState += 1; 64 | nextState % mixer.numChannels(); 65 | if (i == nextState) { 66 | mixer.setFader(i, 1-remainder); 67 | } 68 | */ 69 | // float theta = state + i * (2 * M_PI) / mixer.numChannels(); 70 | // mixer.setFader(i, std::max(0.0f, sinf(theta))); 71 | } 72 | // */ 73 | 74 | // Main loops and Effects can both generate verbose debug output (-v command line option) 75 | if (frame.debugOutput) { 76 | fprintf(stderr, "\t[video] state = %f\n", state); 77 | } 78 | } 79 | 80 | 81 | 82 | } -------------------------------------------------------------------------------- /src/video.h: -------------------------------------------------------------------------------- 1 | // images for movie frames 2 | 3 | #pragma once 4 | 5 | #include "lib/color.h" 6 | #include "lib/effect.h" 7 | #include "lib/texture.h" 8 | #include "lib/tinydir.h" 9 | 10 | 11 | class VideoEffect : public Effect 12 | { 13 | public: 14 | 15 | Texture * dot; 16 | 17 | // should i leave this open? 18 | const char *directoryName; 19 | int imageIndex; 20 | int maxImageIndex; 21 | 22 | float videoFrame; 23 | int loadedFrame; 24 | 25 | VideoEffect(const char *directory) : 26 | imageIndex(0), 27 | maxImageIndex(0), 28 | videoFrame(0), 29 | loadedFrame(-1) 30 | 31 | { 32 | directoryName = directory; 33 | dot = new Texture(); 34 | 35 | // load directory 36 | tinydir_dir dir; 37 | if (tinydir_open(&dir, directoryName) == -1) 38 | { 39 | perror("Error opening directory"); 40 | tinydir_close(&dir); 41 | } 42 | 43 | // count pngs 44 | while (dir.has_next) { 45 | tinydir_file file; 46 | if (tinydir_readfile(&dir, &file) == -1) 47 | { 48 | perror("Error getting file"); 49 | tinydir_close(&dir); 50 | } 51 | 52 | printf("%s", file.name); 53 | if (file.is_dir) 54 | { 55 | printf("/"); 56 | } 57 | printf("\n"); 58 | 59 | if (!strcmp(file.extension, "png")) { 60 | printf("found image %s\n", file.name); 61 | /* 62 | printf("Path: %s\nName: %s\nExtension: %s\nIs dir? %s\nIs regular file? %s\n", 63 | file.path, file.name, file.extension, 64 | file.is_dir?"yes":"no", file.is_reg?"yes":"no"); 65 | */ 66 | 67 | // tmpImage = new DotEffect(file.path); 68 | // DotEffect e("data/dot.png"); 69 | // img[imageIndex] = tmpImage; 70 | // mixer.add(img[imageIndex]); 71 | // mixer.add(tmpImage); 72 | maxImageIndex++; 73 | } 74 | 75 | tinydir_next(&dir); 76 | } 77 | tinydir_close(&dir); 78 | 79 | printf("found %d pngs: \n", maxImageIndex); 80 | 81 | } 82 | 83 | inline void loadFrame(int currentFrame) const 84 | { 85 | if (currentFrame > maxImageIndex) { 86 | printf("cannot load frame %d : \n", currentFrame); 87 | return; 88 | 89 | } 90 | 91 | // debug 92 | //debug 93 | //printf("loading frame %d : \n", currentFrame); 94 | 95 | // load directory 96 | tinydir_dir dir; 97 | 98 | if (tinydir_open(&dir, directoryName) == -1) 99 | { 100 | perror("Error opening directory"); 101 | tinydir_close(&dir); 102 | } 103 | 104 | 105 | // find file 106 | 107 | for (int currentFile = 0; dir.has_next; tinydir_next(&dir)) { 108 | tinydir_file file; 109 | if (tinydir_readfile(&dir, &file) == -1) 110 | { 111 | perror("Error getting file"); 112 | tinydir_close(&dir); 113 | } 114 | 115 | //debug 116 | //printf("%s", file.name); 117 | if (file.is_dir) 118 | { 119 | //debug 120 | // printf("/"); 121 | } 122 | //debug 123 | //printf("\n"); 124 | 125 | if (!strcmp(file.extension, "png")) { 126 | //debug 127 | // printf("found image %s at index %d\n", file.name, currentFile); 128 | 129 | if (currentFile == currentFrame) { 130 | dot->load(file.path); 131 | } 132 | 133 | // tmpImage = new DotEffect(file.path); 134 | // DotEffect e("data/dot.png"); 135 | // img[imageIndex] = tmpImage; 136 | // mixer.add(img[imageIndex]); 137 | // mixer.add(tmpImage); 138 | currentFile++; 139 | } 140 | } 141 | tinydir_close(&dir); 142 | 143 | 144 | 145 | return; 146 | } 147 | 148 | virtual void beginFrame(const FrameInfo &f) 149 | { 150 | 151 | 152 | 153 | // load current Frame 154 | //dot.load(file.path) 155 | 156 | // const float speed = 1.0; // SLOW 157 | const float speed = 1.01; // FAST 158 | 159 | videoFrame = fmod(videoFrame + f.timeDelta * speed, maxImageIndex); 160 | 161 | int currentFrame = ((int) videoFrame); 162 | if (currentFrame != loadedFrame) { 163 | loadFrame(currentFrame); 164 | } 165 | 166 | return; 167 | } 168 | 169 | 170 | virtual void shader(Vec3& rgb, const PixelInfo &p) const 171 | { 172 | // Project onto the XZ plane 173 | // Vec2 plane = Vec2(p.point[0], p.point[2]*-1.0); 174 | Vec2 plane = Vec2(p.point[0]*-0.42, p.point[2]*1.05); 175 | 176 | // rotate this 177 | // plane 178 | 179 | // Moving dot 180 | Vec2 position = Vec2( 1.0, 1.0); 181 | 182 | // Texture geometry 183 | Vec2 center(0.59, 0.47); 184 | float size = 5.0; 185 | 186 | // rgb = dot.sample( (plane + position) / size + center ); 187 | rgb = dot->sample( (plane) / size + center ); 188 | 189 | // rgb = dot.sample( (plane - position) / size + center ); 190 | } 191 | 192 | }; 193 | -------------------------------------------------------------------------------- /streamers/active-streamers.txt: -------------------------------------------------------------------------------- 1 | phased-cycle.py 2 | -------------------------------------------------------------------------------- /streamers/burnin.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # Burn-in test: Keep LEDs at full brightness most of the time, but dim periodically 4 | # so it's clear when there's a problem. 5 | 6 | import opc, time, math, os 7 | 8 | numLEDs = 1440 9 | client = opc.Client(os.getenv('OPC_SERVER')) 10 | 11 | t = 0 12 | 13 | while True: 14 | t += 0.4 15 | brightness = int(min(1, 1.25 + math.sin(t)) * 255) 16 | frame = [ (brightness, brightness, brightness) ] * numLEDs 17 | client.put_pixels(frame) 18 | time.sleep(0.05) 19 | -------------------------------------------------------------------------------- /streamers/cycle.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # Open Pixel Control client: Every other light to solid white, others dark. 4 | 5 | import opc, time, props 6 | 7 | numPairs = props.PIXELS 8 | client = opc.Client(props.OPC_SERVER) 9 | 10 | brightness = props.BRIGHTNESS; 11 | 12 | stepSize = brightness/16 13 | 14 | 15 | pattern = [(0, 0, 0)] * numPairs; 16 | 17 | for phase in range(numPairs/6, 1, -1): 18 | 19 | for i in range(0,numPairs) : 20 | if (0 == i%phase): 21 | pattern[i] = (brightness,brightness,brightness); 22 | else: 23 | current = pattern[i] 24 | step = current[0]-stepSize 25 | step = 0 if step < 0 else step 26 | pattern[i]= (step,step,step); 27 | 28 | # Fade to white 29 | client.put_pixels(pattern) 30 | time.sleep(0.25) 31 | 32 | 33 | for phase in range(1,numPairs/6): 34 | 35 | for i in range(0,numPairs) : 36 | if (0 == i%phase): 37 | pattern[i] = (brightness,brightness,brightness); 38 | else: 39 | current = pattern[i] 40 | step = current[0]-stepSize 41 | step = 0 if step < 0 else step 42 | pattern[i]= (step,step,step); 43 | 44 | # Fade to white 45 | client.put_pixels(pattern) 46 | time.sleep(0.25) 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /streamers/every-another-white.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # Open Pixel Control client: Every other light to solid white, others dark. 4 | 5 | import opc, time, os 6 | 7 | numPairs = 720 8 | client = opc.Client(os.getenv('OPC_SERVER')) 9 | 10 | black = [ (255,255,255), (0,0,0) ] * numPairs 11 | white = [ (0,0,0), (255,255,255) ] * numPairs 12 | 13 | # Fade to white 14 | for i in range(0,100): 15 | client.put_pixels(black) 16 | time.sleep(0.3) 17 | client.put_pixels(white) 18 | time.sleep(0.3) 19 | -------------------------------------------------------------------------------- /streamers/every-other-white.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # Open Pixel Control client: Every other light to solid white, others dark. 4 | 5 | import opc, time, os 6 | 7 | numPairs = 720 8 | client = opc.Client(os.getenv('OPC_SERVER')) 9 | 10 | black = [ (0,0,0), (0,0,0) ] * numPairs 11 | white = [ (255,255,255), (0,0,0) ] * numPairs 12 | 13 | # Fade to white 14 | client.put_pixels(black) 15 | client.put_pixels(black) 16 | time.sleep(0.5) 17 | client.put_pixels(white) 18 | -------------------------------------------------------------------------------- /streamers/map-tlc.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # Open Pixel Control client: Every other light to solid white, others dark. 4 | 5 | import opc, time, props 6 | 7 | pixelCount = 1440 8 | client = opc.Client(props.OPC_SERVER) 9 | 10 | brightness = props.BRIGHTNESS; 11 | 12 | stepSize = brightness/8 13 | 14 | 15 | pattern = [(0, 0, 0)] * pixelCount; 16 | 17 | #while True: 18 | 19 | #for phase in range(0,pixelCount): 20 | 21 | for pixel in range(0,pixelCount) : 22 | 23 | color = 0; 24 | 25 | #if (pixel == phase): 26 | color = 35; 27 | 28 | pattern[pixel] = (color,color,color); 29 | 30 | 31 | # Fade to white 32 | client.put_pixels(pattern) 33 | time.sleep(0.01) 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /streamers/map.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # Open Pixel Control client: Every other light to solid white, others dark. 4 | 5 | import opc, time, props 6 | 7 | pixelCount = 24 8 | client = opc.Client(props.OPC_SERVER) 9 | 10 | brightness = props.BRIGHTNESS; 11 | 12 | stepSize = brightness/8 13 | 14 | 15 | pattern = [(0, 0, 0)] * pixelCount; 16 | 17 | while True: 18 | 19 | for phase in range(0,pixelCount): 20 | 21 | for pixel in range(0,pixelCount) : 22 | 23 | color = 0; 24 | 25 | if (24 == pixel): 26 | color = 255; 27 | 28 | pattern[pixel] = (color,color,color); 29 | 30 | 31 | # Fade to white 32 | client.put_pixels(pattern) 33 | time.sleep(0.4) 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /streamers/opc.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpinner/Active/b5e2c9df3a53bc79920fb5f17489296238b898d0/streamers/opc.pyc -------------------------------------------------------------------------------- /streamers/phased-cycle.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # Open Pixel Control client: Every other light to solid white, others dark. 4 | 5 | import opc, time, props 6 | 7 | numPairs = props.PIXELS 8 | client = opc.Client(props.OPC_SERVER) 9 | 10 | brightness = props.BRIGHTNESS; 11 | 12 | stepSize = brightness/16 13 | 14 | 15 | pattern = [(0, 0, 0)] * numPairs; 16 | 17 | for phase in range(numPairs/6, 1, -1): 18 | 19 | for i in range(0,numPairs) : 20 | if (0 == i%phase): 21 | pattern[i] = (brightness,brightness,brightness); 22 | else: 23 | current = pattern[i] 24 | step = current[0]-stepSize 25 | step = 0 if step < 0 else step 26 | pattern[i]= (step,step,step); 27 | 28 | # Fade to white 29 | client.put_pixels(pattern) 30 | time.sleep(0.13) 31 | 32 | 33 | for phase in range(1,numPairs/6): 34 | 35 | for i in range(0,numPairs) : 36 | if (0 == i%phase): 37 | pattern[i] = (brightness,brightness,brightness); 38 | else: 39 | current = pattern[i] 40 | step = current[0]-stepSize 41 | step = 0 if step < 0 else step 42 | pattern[i]= (step,step,step); 43 | 44 | # Fade to white 45 | client.put_pixels(pattern) 46 | time.sleep(0.13) 47 | 48 | 49 | 50 | -------------------------------------------------------------------------------- /streamers/props.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | BRIGHTNESS=255 4 | OPC_SERVER=os.getenv('OPC_SERVER') 5 | PIXELS=1440 6 | WIDTH=60 7 | COLUMNS=24 8 | LENGTH=24 9 | 10 | -------------------------------------------------------------------------------- /streamers/props.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/mpinner/Active/b5e2c9df3a53bc79920fb5f17489296238b898d0/streamers/props.pyc -------------------------------------------------------------------------------- /streamers/semetry.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # Open Pixel Control client: Every other light to solid white, others dark. 4 | 5 | import opc, time, props 6 | 7 | numPairs = props.PIXELS 8 | client = opc.Client(props.OPC_SERVER) 9 | 10 | brightness = props.BRIGHTNESS; 11 | 12 | stepSize = brightness/8 13 | 14 | 15 | pattern = [(0, 0, 0)] * numPairs; 16 | 17 | 18 | def mirrorX(i, color): 19 | pattern[i] = color; 20 | i/props.COLUMNS 21 | 22 | pattern[] 23 | 24 | def mirrorY(i, color): 25 | def mirrorZ(i, color): 26 | 27 | 28 | for phase in range(1,numPairs/4): 29 | 30 | for i in range(0,numPairs) : 31 | if (0 == i%phase): 32 | pattern[i] = (brightness,brightness,brightness); 33 | else: 34 | current = pattern[i] 35 | step = current[0]-stepSize 36 | step = 0 if step < 0 else step 37 | pattern[i]= (step,step,step); 38 | 39 | # Fade to white 40 | client.put_pixels(pattern) 41 | time.sleep(0.3) 42 | 43 | 44 | -------------------------------------------------------------------------------- /streamers/solid-white.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # Open Pixel Control client: All lights to solid white 4 | 5 | import opc, time, os 6 | 7 | numLEDs = 1440 8 | client = opc.Client(os.getenv('OPC_SERVER')) 9 | 10 | black = [ (0,0,0) ] * numLEDs 11 | white = [ (255,255,255) ] * numLEDs 12 | 13 | # Fade to white 14 | client.put_pixels(black) 15 | client.put_pixels(black) 16 | time.sleep(0.5) 17 | client.put_pixels(white) 18 | -------------------------------------------------------------------------------- /streamers/strobe.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # Open Pixel Control client: All lights to solid white 4 | 5 | import opc, time, os 6 | 7 | numLEDs = 1440 8 | client = opc.Client(os.getenv('OPC_SERVER')) 9 | 10 | black = [ (0,0,0) ] * numLEDs 11 | white = [ (255,255,255) ] * numLEDs 12 | 13 | tempo = opc.Client(os.getenv('OPC_SERVER')); 14 | 15 | 16 | for tempo in range(500, 2000): 17 | bpm = tempo/1000.0 18 | # client.put_pixels(white) 19 | # time.sleep(bpm) 20 | #bet match here!!??!?! 21 | 22 | # client.put_pixels(black) 23 | time.sleep(bpm) 24 | -------------------------------------------------------------------------------- /streamers/testing-fadingaround.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | 3 | # Open Pixel Control client: Every other light to solid white, others dark. 4 | 5 | import opc, time, props 6 | 7 | pixelCount = props.PIXELS 8 | client = opc.Client(props.OPC_SERVER) 9 | 10 | brightness = props.BRIGHTNESS; 11 | 12 | stepSize = brightness/8 13 | 14 | 15 | pattern = [(0, 0, 0)] * pixelCount; 16 | 17 | while True: 18 | 19 | for phase in range(0,brightness): 20 | 21 | for pixel in range(0,pixelCount) : 22 | color = (pixel+phase) % brightness 23 | pattern[pixel] = (color,color,color); 24 | if (0 == (pixel%24) ): 25 | pattern[pixel] = (0,0,color); 26 | if (pixel < 24): 27 | pattern[pixel] = (color,0,color); 28 | 29 | 30 | # Fade to white 31 | client.put_pixels(pattern) 32 | time.sleep(0.001) 33 | 34 | 35 | 36 | --------------------------------------------------------------------------------