├── LICENSE
├── Processing-to-TouchDesigner
├── processing_example.pde
└── spout_rcvr.toe
├── README.md
└── openFrameworks-to-TouchDesigner
├── .vs
└── oF_TD_data
│ └── v14
│ └── .suo
├── addons.make
├── bin
├── FreeImage.dll
├── Spout32.dll
├── Zlib.dll
├── assimp.dll
├── fmodex.dll
├── fmodexL.dll
├── freetype.dll
├── glut32.dll
├── libeay32.dll
├── oF_TD_data_debug.exe
├── oF_TD_data_debug.exp
├── oF_TD_data_debug.ilk
├── oF_TD_data_debug.lib
├── oF_TD_data_debug.pdb
├── spout_rcvr.toe
└── ssleay32.dll
├── icon.rc
├── oF_TD_data.sdf
├── oF_TD_data.sln
├── oF_TD_data.vcxproj
├── oF_TD_data.vcxproj.filters
├── obj
└── Debug
│ ├── Ball.obj
│ ├── icon.res
│ ├── main.obj
│ ├── oF_TD_data.log
│ ├── oF_TD_data.tlog
│ ├── CL.command.1.tlog
│ ├── CL.read.1.tlog
│ ├── CL.write.1.tlog
│ ├── link.command.1.tlog
│ ├── link.read.1.tlog
│ ├── link.write.1.tlog
│ ├── oF_TD_data.lastbuildstate
│ ├── oF_TD_data.write.1u.tlog
│ ├── rc.command.1.tlog
│ ├── rc.read.1.tlog
│ └── rc.write.1.tlog
│ ├── oF_TD_data.vcxprojResolveAssemblyReference.cache
│ ├── ofApp.obj
│ ├── ofxSpout.obj
│ └── vc140.pdb
└── src
├── Ball.cpp
├── Ball.h
├── main.cpp
├── ofApp.cpp
└── ofApp.h
/LICENSE:
--------------------------------------------------------------------------------
1 | MIT License
2 |
3 | Copyright (c) 2017 nVoid Art-Tech Limited
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.
22 |
--------------------------------------------------------------------------------
/Processing-to-TouchDesigner/processing_example.pde:
--------------------------------------------------------------------------------
1 | // Combination of Bouncy Bubbles based on code from Keith Peters
2 | // and the SpoutSender example to create a Processing App
3 | // that calculates object positions and then packs the 32 bit values
4 | // into 4 channels of a regular 8-bit RGBA pixel, which is then
5 | // sent over Spout to TouchDesigner, where it is unpacked and the data used for drawing.
6 | // This allows you to use the existing physics and simulation libraries within
7 | // Processing and send the computed data to TouchDesigner.
8 |
9 | import spout.*;
10 | Spout spout;
11 |
12 | // set resolution of spout texture to hold our data
13 | int spoutX = 16;
14 | int spoutY = 4;
15 |
16 | // PImage keeps alpha channel intact, unlike other drawing methods in Processing
17 | PImage data;
18 |
19 | // set simulation variables
20 | int numBalls = 12;
21 | float spring = 0.05;
22 | float gravity = 0.03;
23 | float friction = -0.9;
24 |
25 | // because the window is 16x4 for Spout, we need to define our simulation resolution
26 | // separately as variables, since we cant use references to window size
27 | int resX = 1280;
28 | int resY = 720;
29 |
30 | // make a bunch of balls
31 | Ball[] balls = new Ball[numBalls];
32 |
33 | int row;
34 | int pixel_index;
35 |
36 | void setup() {
37 |
38 | // Initial window size
39 | size(16, 4, P2D);
40 | frameRate(60);
41 |
42 | // spout object
43 | spout = new Spout(this);
44 |
45 | // name sender
46 | spout.createSender("Spout Processing");
47 |
48 | // init all the balls
49 | for (int i = 0; i < numBalls; i++) {
50 | balls[i] = new Ball(random(resX), random(resY), random(30, 70), i, balls);
51 | }
52 | noStroke();
53 |
54 | }
55 |
56 | void draw() {
57 |
58 | // intialize the texture
59 | data = createImage(spoutX, spoutY, ARGB);
60 | data.loadPixels();
61 |
62 | // iterate through the balls and calculate position and collisions
63 | for (Ball ball : balls) {
64 | ball.collide();
65 | ball.move();
66 |
67 | // write the X position into an 8-bit RGBA pixel
68 | // using the pixelPacker() helper method
69 | // here we're writing to the first row of pixels in our 16x4 texture
70 | row = 0;
71 | pixel_index = row * spoutX + ball.id;
72 | color ballX = pixelPacker(ball.x);
73 | data.pixels[pixel_index] = ballX;
74 |
75 |
76 | // write the Y position into an 8-bit RGBA pixel
77 | // using the pixelPacker() helper method
78 | // here we're writing to the second row of pixels in our 16x4 texture
79 | row = 1;
80 | pixel_index = row * spoutX + ball.id;
81 | color ballY = pixelPacker(ball.y);
82 | data.pixels[pixel_index] = ballY;
83 |
84 | // write the radius of each ball into an 8-bit RGBA pixel
85 | // using the pixelPacker() helper method
86 | // here we're writing to the third row of pixels in our 16x4 texture
87 | row = 2;
88 | pixel_index = row * spoutX + ball.id;
89 | color ballDiam = pixelPacker(ball.diameter);
90 | data.pixels[pixel_index] = ballDiam;
91 | }
92 |
93 | // send the texture over Spout
94 | spout.sendTexture(data);
95 | image(data,0,0);
96 | }
97 |
98 | // class for each Ball with attribute and methods for setup, collision, and movement
99 | class Ball {
100 |
101 | float x, y;
102 | float diameter;
103 | float vx = 0;
104 | float vy = 0;
105 | int id;
106 | Ball[] others;
107 |
108 | Ball(float xin, float yin, float din, int idin, Ball[] oin) {
109 | x = xin;
110 | y = yin;
111 | diameter = din;
112 | id = idin;
113 | others = oin;
114 | }
115 |
116 | // calculate distance between all balls and detect collision
117 | void collide() {
118 | for (int i = id + 1; i < numBalls; i++) {
119 | float dx = others[i].x - x;
120 | float dy = others[i].y - y;
121 | float distance = sqrt(dx*dx + dy*dy);
122 | float minDist = others[i].diameter/2 + diameter/2;
123 | if (distance < minDist) {
124 | float angle = atan2(dy, dx);
125 | float targetX = x + cos(angle) * minDist;
126 | float targetY = y + sin(angle) * minDist;
127 | float ax = (targetX - others[i].x) * spring;
128 | float ay = (targetY - others[i].y) * spring;
129 | vx -= ax;
130 | vy -= ay;
131 | others[i].vx += ax;
132 | others[i].vy += ay;
133 | }
134 | }
135 | }
136 |
137 | // calculate balls motion
138 | void move() {
139 | vy += gravity;
140 | x += vx;
141 | y += vy;
142 | if (x + diameter/2 > resX) {
143 | x = resX - diameter/2;
144 | vx *= friction;
145 | }
146 | else if (x - diameter/2 < 0) {
147 | x = diameter/2;
148 | vx *= friction;
149 | }
150 | if (y + diameter/2 > resY) {
151 | y = resY - diameter/2;
152 | vy *= friction;
153 | }
154 | else if (y - diameter/2 < 0) {
155 | y = diameter/2;
156 | vy *= friction;
157 | }
158 | }
159 | }
160 |
161 | // this helper function uses bit shifting to take a single 32-bit float
162 | // and convert it into four 8-bit values which can then be used for
163 | // the 4 colors (RGBA) of a regular Processing color
164 | color pixelPacker(float val){
165 |
166 | // bit shift val into 4 8-bit values
167 | int num = int(val);
168 | int r = (num >> 0) & 255;
169 | int g = (num >> 8) & 255;
170 | int b = (num >> 16) & 255;
171 | int a = (num >> 24) & 255;
172 |
173 | // the RGBA chans are used to return a color for the fill
174 | return color(r,g,b,a);
175 | }
--------------------------------------------------------------------------------
/Processing-to-TouchDesigner/spout_rcvr.toe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interactiveimmersivehq/Pixel-Packing-Examples/eda6e9ae707f932d4c39aa9383038acb926dac9a/Processing-to-TouchDesigner/spout_rcvr.toe
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Pixel Packing Data Transfer with TouchDesigner, openFrameworks, and Processing
2 |
3 | Examples of sending data from OpenFrameworks and Processing to TouchDesigner via textures.
4 |
5 | ## Build and Version
6 | These examples were written in Processing 3.2.1, openFrameworks v0.9.7 using Visual Studio 2015, and in 64-bit build 61480 of TouchDesigner088.
7 |
8 | ## Installation
9 | ### Processing :
10 | This example requires the Spout for Processing 3rd Party library. To install this go to the ```Sketch``` menu, hover over ```Import Library...``` and click on ```Add Library...``` Search for 'Spout' in the ```Libraries``` search field, click on ```Spout for Processing``` by Lynn Jarvis and Martin Froelich. Click ```Install``` at the bottom.
11 |
12 | ### openFrameworks :
13 | This example requires the ofxSpout library. The link to the [build used in the example is here](https://github.com/Mat-Loz/ofxSpout/tree/4cd68630c72e7f7fb1a1634fde1577fa5920ca14).
14 | After adding the ofxSpout folder to your addons, you'll need to update a few paths in your Visual Studio 2015 solution. For directions follow the steps described in [this Github Issue](https://github.com/Mat-Loz/ofxSpout/issues/1).
15 |
16 | ## Code
17 | These examples demonstrate the use of bit-shifting to convert a single 32-bit value into a single RGBA pixel, then transfer the data through Spout to TouchDesigner. This is a useful technique for transmitting large amounts of data as Spout has a lower overhead than other protocols as the size of data becomes larger. Workflows become even more optimized when you're able to use the data in it's texture form in a shader without needing to convert it back into other data types on the CPU.
18 |
19 | For an indepth walkthrough see this post about [pixel packing on Elburz.io](http://elburz.io/pixel-packing).
20 |
21 | The size of the texture sent over Spout is 16 x 4, which provides 3 rows of 16 pixels (X position, Y position, and diameter for each of the 12 balls). The texture size is then rounded up to nearest power of 2 for more efficient GPU processing.
22 |
23 | ### Processing Notes :
24 | - The native Processing surface automatically multiplies the RGB values by the Alpha, so it requires the use of the ```PImage``` datatype to retain the RGB and A as seperate values.
25 |
26 | ### openFrameworks Notes :
27 | - To keep the RGB values from being multiplied with the Alpha channel, make sure to include ```ofDisableAlphaBlending();```
28 |
29 | ### TouchDesigner Notes :
30 | - A Crop TOP was added since openFrameworks sends a texture no smaller than 116 pixels wide.
31 |
32 | ## Attribution
33 | - The code in both Processing and openFrameworks are the Bouncy Bubbles Processing example written by Keith Peters
34 | - Spout example code used is in both Processing and openFrameworks examples was provided by the Spout libraries.
35 | - Thanks to Derivative's support
36 |
37 | If you use this in one of your projects, feel free to give us (nVoid) a shoutout or just let us know what you're up to!
38 |
--------------------------------------------------------------------------------
/openFrameworks-to-TouchDesigner/.vs/oF_TD_data/v14/.suo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interactiveimmersivehq/Pixel-Packing-Examples/eda6e9ae707f932d4c39aa9383038acb926dac9a/openFrameworks-to-TouchDesigner/.vs/oF_TD_data/v14/.suo
--------------------------------------------------------------------------------
/openFrameworks-to-TouchDesigner/addons.make:
--------------------------------------------------------------------------------
1 | ofxSpout
2 |
--------------------------------------------------------------------------------
/openFrameworks-to-TouchDesigner/bin/FreeImage.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interactiveimmersivehq/Pixel-Packing-Examples/eda6e9ae707f932d4c39aa9383038acb926dac9a/openFrameworks-to-TouchDesigner/bin/FreeImage.dll
--------------------------------------------------------------------------------
/openFrameworks-to-TouchDesigner/bin/Spout32.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interactiveimmersivehq/Pixel-Packing-Examples/eda6e9ae707f932d4c39aa9383038acb926dac9a/openFrameworks-to-TouchDesigner/bin/Spout32.dll
--------------------------------------------------------------------------------
/openFrameworks-to-TouchDesigner/bin/Zlib.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interactiveimmersivehq/Pixel-Packing-Examples/eda6e9ae707f932d4c39aa9383038acb926dac9a/openFrameworks-to-TouchDesigner/bin/Zlib.dll
--------------------------------------------------------------------------------
/openFrameworks-to-TouchDesigner/bin/assimp.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interactiveimmersivehq/Pixel-Packing-Examples/eda6e9ae707f932d4c39aa9383038acb926dac9a/openFrameworks-to-TouchDesigner/bin/assimp.dll
--------------------------------------------------------------------------------
/openFrameworks-to-TouchDesigner/bin/fmodex.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interactiveimmersivehq/Pixel-Packing-Examples/eda6e9ae707f932d4c39aa9383038acb926dac9a/openFrameworks-to-TouchDesigner/bin/fmodex.dll
--------------------------------------------------------------------------------
/openFrameworks-to-TouchDesigner/bin/fmodexL.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interactiveimmersivehq/Pixel-Packing-Examples/eda6e9ae707f932d4c39aa9383038acb926dac9a/openFrameworks-to-TouchDesigner/bin/fmodexL.dll
--------------------------------------------------------------------------------
/openFrameworks-to-TouchDesigner/bin/freetype.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interactiveimmersivehq/Pixel-Packing-Examples/eda6e9ae707f932d4c39aa9383038acb926dac9a/openFrameworks-to-TouchDesigner/bin/freetype.dll
--------------------------------------------------------------------------------
/openFrameworks-to-TouchDesigner/bin/glut32.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interactiveimmersivehq/Pixel-Packing-Examples/eda6e9ae707f932d4c39aa9383038acb926dac9a/openFrameworks-to-TouchDesigner/bin/glut32.dll
--------------------------------------------------------------------------------
/openFrameworks-to-TouchDesigner/bin/libeay32.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interactiveimmersivehq/Pixel-Packing-Examples/eda6e9ae707f932d4c39aa9383038acb926dac9a/openFrameworks-to-TouchDesigner/bin/libeay32.dll
--------------------------------------------------------------------------------
/openFrameworks-to-TouchDesigner/bin/oF_TD_data_debug.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interactiveimmersivehq/Pixel-Packing-Examples/eda6e9ae707f932d4c39aa9383038acb926dac9a/openFrameworks-to-TouchDesigner/bin/oF_TD_data_debug.exe
--------------------------------------------------------------------------------
/openFrameworks-to-TouchDesigner/bin/oF_TD_data_debug.exp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interactiveimmersivehq/Pixel-Packing-Examples/eda6e9ae707f932d4c39aa9383038acb926dac9a/openFrameworks-to-TouchDesigner/bin/oF_TD_data_debug.exp
--------------------------------------------------------------------------------
/openFrameworks-to-TouchDesigner/bin/oF_TD_data_debug.ilk:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interactiveimmersivehq/Pixel-Packing-Examples/eda6e9ae707f932d4c39aa9383038acb926dac9a/openFrameworks-to-TouchDesigner/bin/oF_TD_data_debug.ilk
--------------------------------------------------------------------------------
/openFrameworks-to-TouchDesigner/bin/oF_TD_data_debug.lib:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interactiveimmersivehq/Pixel-Packing-Examples/eda6e9ae707f932d4c39aa9383038acb926dac9a/openFrameworks-to-TouchDesigner/bin/oF_TD_data_debug.lib
--------------------------------------------------------------------------------
/openFrameworks-to-TouchDesigner/bin/oF_TD_data_debug.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interactiveimmersivehq/Pixel-Packing-Examples/eda6e9ae707f932d4c39aa9383038acb926dac9a/openFrameworks-to-TouchDesigner/bin/oF_TD_data_debug.pdb
--------------------------------------------------------------------------------
/openFrameworks-to-TouchDesigner/bin/spout_rcvr.toe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interactiveimmersivehq/Pixel-Packing-Examples/eda6e9ae707f932d4c39aa9383038acb926dac9a/openFrameworks-to-TouchDesigner/bin/spout_rcvr.toe
--------------------------------------------------------------------------------
/openFrameworks-to-TouchDesigner/bin/ssleay32.dll:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interactiveimmersivehq/Pixel-Packing-Examples/eda6e9ae707f932d4c39aa9383038acb926dac9a/openFrameworks-to-TouchDesigner/bin/ssleay32.dll
--------------------------------------------------------------------------------
/openFrameworks-to-TouchDesigner/icon.rc:
--------------------------------------------------------------------------------
1 | // Icon Resource Definition
2 | #define MAIN_ICON 102
3 |
4 | #if defined(_DEBUG)
5 | MAIN_ICON ICON "icon_debug.ico"
6 | #else
7 | MAIN_ICON ICON "icon.ico"
8 | #endif
9 |
--------------------------------------------------------------------------------
/openFrameworks-to-TouchDesigner/oF_TD_data.sdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interactiveimmersivehq/Pixel-Packing-Examples/eda6e9ae707f932d4c39aa9383038acb926dac9a/openFrameworks-to-TouchDesigner/oF_TD_data.sdf
--------------------------------------------------------------------------------
/openFrameworks-to-TouchDesigner/oF_TD_data.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.24720.0
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "oF_TD_data", "oF_TD_data.vcxproj", "{7FD42DF7-442E-479A-BA76-D0022F99702A}"
7 | EndProject
8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "openFrameworksLib", "..\..\..\libs\openFrameworksCompiled\project\vs\openFrameworksLib.vcxproj", "{5837595D-ACA9-485C-8E76-729040CE4B0B}"
9 | EndProject
10 | Global
11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
12 | Debug|x64 = Debug|x64
13 | Debug|x86 = Debug|x86
14 | Release|x64 = Release|x64
15 | Release|x86 = Release|x86
16 | EndGlobalSection
17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
18 | {7FD42DF7-442E-479A-BA76-D0022F99702A}.Debug|x64.ActiveCfg = Debug|x64
19 | {7FD42DF7-442E-479A-BA76-D0022F99702A}.Debug|x64.Build.0 = Debug|x64
20 | {7FD42DF7-442E-479A-BA76-D0022F99702A}.Debug|x86.ActiveCfg = Debug|Win32
21 | {7FD42DF7-442E-479A-BA76-D0022F99702A}.Debug|x86.Build.0 = Debug|Win32
22 | {7FD42DF7-442E-479A-BA76-D0022F99702A}.Release|x64.ActiveCfg = Release|x64
23 | {7FD42DF7-442E-479A-BA76-D0022F99702A}.Release|x64.Build.0 = Release|x64
24 | {7FD42DF7-442E-479A-BA76-D0022F99702A}.Release|x86.ActiveCfg = Release|Win32
25 | {7FD42DF7-442E-479A-BA76-D0022F99702A}.Release|x86.Build.0 = Release|Win32
26 | {5837595D-ACA9-485C-8E76-729040CE4B0B}.Debug|x64.ActiveCfg = Debug|x64
27 | {5837595D-ACA9-485C-8E76-729040CE4B0B}.Debug|x64.Build.0 = Debug|x64
28 | {5837595D-ACA9-485C-8E76-729040CE4B0B}.Debug|x86.ActiveCfg = Debug|Win32
29 | {5837595D-ACA9-485C-8E76-729040CE4B0B}.Debug|x86.Build.0 = Debug|Win32
30 | {5837595D-ACA9-485C-8E76-729040CE4B0B}.Release|x64.ActiveCfg = Release|x64
31 | {5837595D-ACA9-485C-8E76-729040CE4B0B}.Release|x64.Build.0 = Release|x64
32 | {5837595D-ACA9-485C-8E76-729040CE4B0B}.Release|x86.ActiveCfg = Release|Win32
33 | {5837595D-ACA9-485C-8E76-729040CE4B0B}.Release|x86.Build.0 = Release|Win32
34 | EndGlobalSection
35 | GlobalSection(SolutionProperties) = preSolution
36 | HideSolutionNode = FALSE
37 | EndGlobalSection
38 | EndGlobal
39 |
--------------------------------------------------------------------------------
/openFrameworks-to-TouchDesigner/oF_TD_data.vcxproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | Win32
7 |
8 |
9 | Debug
10 | x64
11 |
12 |
13 | Release
14 | Win32
15 |
16 |
17 | Release
18 | x64
19 |
20 |
21 |
22 | {7FD42DF7-442E-479A-BA76-D0022F99702A}
23 | Win32Proj
24 | oF_TD_data
25 |
26 |
27 |
28 | Application
29 | Unicode
30 | v140
31 |
32 |
33 | Application
34 | Unicode
35 | v140
36 |
37 |
38 | Application
39 | Unicode
40 | true
41 | v140
42 |
43 |
44 | Application
45 | Unicode
46 | true
47 | v140
48 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 |
61 |
62 |
63 |
64 |
65 |
66 |
67 |
68 | bin\
69 | obj\$(Configuration)\
70 | $(ProjectName)_debug
71 | true
72 | true
73 |
74 |
75 | bin\
76 | obj\$(Configuration)\
77 | $(ProjectName)_debug
78 | true
79 | true
80 |
81 |
82 | bin\
83 | obj\$(Configuration)\
84 | false
85 |
86 |
87 | bin\
88 | obj\$(Configuration)\
89 | false
90 |
91 |
92 |
93 | Disabled
94 | EnableFastChecks
95 | %(PreprocessorDefinitions)
96 | MultiThreadedDebugDLL
97 | Level3
98 |
99 | ..\..\..\addons\ofxSpout\src;
100 | ..\..\..\addons\ofxSpout\libs\include;
101 | ..\..\..\addons\ofxSpout\libs\lib;
102 | ..\..\..\addons\ofxSpout\libs\lib\vs;%(AdditionalIncludeDirectories)
103 | CompileAsCpp
104 |
105 |
106 | true
107 | Console
108 | false
109 | %(AdditionalDependencies);Spout32.lib
110 | %(AdditionalLibraryDirectories);..\..\..\addons\ofxSpout\src;
111 | ..\..\..\addons\ofxSpout\libs\include;
112 | ..\..\..\addons\ofxSpout\libs\lib;
113 | ..\..\..\addons\ofxSpout\libs\lib\vs;
114 |
115 |
116 |
117 |
118 |
119 |
120 | Disabled
121 | EnableFastChecks
122 | %(PreprocessorDefinitions)
123 | MultiThreadedDebugDLL
124 | Level3
125 |
126 | ..\..\..\addons\ofxSpout\src;
127 | ..\..\..\addons\ofxSpout\libs\include;
128 | ..\..\..\addons\ofxSpout\libs\lib;
129 | ..\..\..\addons\ofxSpout\libs\lib\vs;%(AdditionalIncludeDirectories)
130 | CompileAsCpp
131 | true
132 |
133 |
134 | true
135 | Console
136 | false
137 | %(AdditionalDependencies)
138 | %(AdditionalLibraryDirectories)
139 |
140 |
141 |
142 |
143 |
144 |
145 | false
146 | %(PreprocessorDefinitions)
147 | MultiThreadedDLL
148 | Level3
149 |
150 | ..\..\..\addons\ofxSpout\src;
151 | ..\..\..\addons\ofxSpout\libs\include;
152 | ..\..\..\addons\ofxSpout\libs\lib;
153 | ..\..\..\addons\ofxSpout\libs\lib\vs;%(AdditionalIncludeDirectories)
154 | CompileAsCpp
155 | true
156 |
157 |
158 | false
159 | false
160 | Console
161 | true
162 | true
163 | false
164 | %(AdditionalDependencies)
165 | %(AdditionalLibraryDirectories)
166 |
167 |
168 |
169 |
170 |
171 |
172 | false
173 | %(PreprocessorDefinitions)
174 | MultiThreadedDLL
175 | Level3
176 |
177 | ..\..\..\addons\ofxSpout\src;
178 | ..\..\..\addons\ofxSpout\libs\include;
179 | ..\..\..\addons\ofxSpout\libs\lib;
180 | ..\..\..\addons\ofxSpout\libs\lib\vs;%(AdditionalIncludeDirectories)
181 | CompileAsCpp
182 |
183 |
184 | false
185 | false
186 | Console
187 | true
188 | true
189 | false
190 | %(AdditionalDependencies)
191 | %(AdditionalLibraryDirectories)
192 |
193 |
194 |
195 |
196 |
197 |
198 |
199 |
200 |
201 |
202 |
203 |
204 |
205 |
206 |
207 |
208 |
209 |
210 |
211 | {5837595d-aca9-485c-8e76-729040ce4b0b}
212 |
213 |
214 |
215 |
216 | /D_DEBUG %(AdditionalOptions)
217 | /D_DEBUG %(AdditionalOptions)
218 | $(OF_ROOT)\libs\openFrameworksCompiled\project\vs
219 |
220 |
221 |
222 |
223 |
224 |
225 |
226 |
227 |
--------------------------------------------------------------------------------
/openFrameworks-to-TouchDesigner/oF_TD_data.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | src
6 |
7 |
8 | src
9 |
10 |
11 | addons\ofxSpout\src
12 |
13 |
14 | src
15 |
16 |
17 |
18 |
19 | {d8376475-7454-4a24-b08a-aac121d3ad6f}
20 |
21 |
22 | {2fd8e88a-58f3-4237-9dd7-6388760f272f}
23 |
24 |
25 | {ba4e8ce6-a088-4a12-a1d4-fb410c40a8a6}
26 |
27 |
28 | {a1a7746f-2b0d-47b7-a7a3-3f8a8d4d071f}
29 |
30 |
31 | {b56bb100-5b03-4c67-8805-e0500abe1955}
32 |
33 |
34 | {8936f5b1-6da2-49d8-80cf-6c3ff538979d}
35 |
36 |
37 |
38 |
39 | src
40 |
41 |
42 | addons\ofxSpout\src
43 |
44 |
45 | addons\ofxSpout\src
46 |
47 |
48 | addons\ofxSpout\libs\include
49 |
50 |
51 | src
52 |
53 |
54 |
55 |
56 |
57 |
--------------------------------------------------------------------------------
/openFrameworks-to-TouchDesigner/obj/Debug/Ball.obj:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interactiveimmersivehq/Pixel-Packing-Examples/eda6e9ae707f932d4c39aa9383038acb926dac9a/openFrameworks-to-TouchDesigner/obj/Debug/Ball.obj
--------------------------------------------------------------------------------
/openFrameworks-to-TouchDesigner/obj/Debug/icon.res:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interactiveimmersivehq/Pixel-Packing-Examples/eda6e9ae707f932d4c39aa9383038acb926dac9a/openFrameworks-to-TouchDesigner/obj/Debug/icon.res
--------------------------------------------------------------------------------
/openFrameworks-to-TouchDesigner/obj/Debug/main.obj:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interactiveimmersivehq/Pixel-Packing-Examples/eda6e9ae707f932d4c39aa9383038acb926dac9a/openFrameworks-to-TouchDesigner/obj/Debug/main.obj
--------------------------------------------------------------------------------
/openFrameworks-to-TouchDesigner/obj/Debug/oF_TD_data.log:
--------------------------------------------------------------------------------
1 | main.cpp
2 | oF_TD_data.vcxproj -> D:\oF\of_v0.9.7_vs_release\apps\myApps\oF_TD_data\bin\oF_TD_data_debug.exe
3 |
4 | 9 D:\oF\of_v0.9.7_vs_release\export\vs\Win32\
5 | *EXTRA File 86016 D:\oF\of_v0.9.7_vs_release\apps\myApps\oF_TD_data\bin\Spout32.dll
6 |
--------------------------------------------------------------------------------
/openFrameworks-to-TouchDesigner/obj/Debug/oF_TD_data.tlog/CL.command.1.tlog:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interactiveimmersivehq/Pixel-Packing-Examples/eda6e9ae707f932d4c39aa9383038acb926dac9a/openFrameworks-to-TouchDesigner/obj/Debug/oF_TD_data.tlog/CL.command.1.tlog
--------------------------------------------------------------------------------
/openFrameworks-to-TouchDesigner/obj/Debug/oF_TD_data.tlog/CL.read.1.tlog:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interactiveimmersivehq/Pixel-Packing-Examples/eda6e9ae707f932d4c39aa9383038acb926dac9a/openFrameworks-to-TouchDesigner/obj/Debug/oF_TD_data.tlog/CL.read.1.tlog
--------------------------------------------------------------------------------
/openFrameworks-to-TouchDesigner/obj/Debug/oF_TD_data.tlog/CL.write.1.tlog:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interactiveimmersivehq/Pixel-Packing-Examples/eda6e9ae707f932d4c39aa9383038acb926dac9a/openFrameworks-to-TouchDesigner/obj/Debug/oF_TD_data.tlog/CL.write.1.tlog
--------------------------------------------------------------------------------
/openFrameworks-to-TouchDesigner/obj/Debug/oF_TD_data.tlog/link.command.1.tlog:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interactiveimmersivehq/Pixel-Packing-Examples/eda6e9ae707f932d4c39aa9383038acb926dac9a/openFrameworks-to-TouchDesigner/obj/Debug/oF_TD_data.tlog/link.command.1.tlog
--------------------------------------------------------------------------------
/openFrameworks-to-TouchDesigner/obj/Debug/oF_TD_data.tlog/link.read.1.tlog:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interactiveimmersivehq/Pixel-Packing-Examples/eda6e9ae707f932d4c39aa9383038acb926dac9a/openFrameworks-to-TouchDesigner/obj/Debug/oF_TD_data.tlog/link.read.1.tlog
--------------------------------------------------------------------------------
/openFrameworks-to-TouchDesigner/obj/Debug/oF_TD_data.tlog/link.write.1.tlog:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interactiveimmersivehq/Pixel-Packing-Examples/eda6e9ae707f932d4c39aa9383038acb926dac9a/openFrameworks-to-TouchDesigner/obj/Debug/oF_TD_data.tlog/link.write.1.tlog
--------------------------------------------------------------------------------
/openFrameworks-to-TouchDesigner/obj/Debug/oF_TD_data.tlog/oF_TD_data.lastbuildstate:
--------------------------------------------------------------------------------
1 | #TargetFrameworkVersion=v4.0:PlatformToolSet=v140:EnableManagedIncrementalBuild=false:VCToolArchitecture=Native32Bit:WindowsTargetPlatformVersion=8.1
2 | Debug|Win32|D:\oF\of_v0.9.7_vs_release\apps\myApps\oF_TD_data\|
3 |
--------------------------------------------------------------------------------
/openFrameworks-to-TouchDesigner/obj/Debug/oF_TD_data.tlog/oF_TD_data.write.1u.tlog:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interactiveimmersivehq/Pixel-Packing-Examples/eda6e9ae707f932d4c39aa9383038acb926dac9a/openFrameworks-to-TouchDesigner/obj/Debug/oF_TD_data.tlog/oF_TD_data.write.1u.tlog
--------------------------------------------------------------------------------
/openFrameworks-to-TouchDesigner/obj/Debug/oF_TD_data.tlog/rc.command.1.tlog:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interactiveimmersivehq/Pixel-Packing-Examples/eda6e9ae707f932d4c39aa9383038acb926dac9a/openFrameworks-to-TouchDesigner/obj/Debug/oF_TD_data.tlog/rc.command.1.tlog
--------------------------------------------------------------------------------
/openFrameworks-to-TouchDesigner/obj/Debug/oF_TD_data.tlog/rc.read.1.tlog:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interactiveimmersivehq/Pixel-Packing-Examples/eda6e9ae707f932d4c39aa9383038acb926dac9a/openFrameworks-to-TouchDesigner/obj/Debug/oF_TD_data.tlog/rc.read.1.tlog
--------------------------------------------------------------------------------
/openFrameworks-to-TouchDesigner/obj/Debug/oF_TD_data.tlog/rc.write.1.tlog:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interactiveimmersivehq/Pixel-Packing-Examples/eda6e9ae707f932d4c39aa9383038acb926dac9a/openFrameworks-to-TouchDesigner/obj/Debug/oF_TD_data.tlog/rc.write.1.tlog
--------------------------------------------------------------------------------
/openFrameworks-to-TouchDesigner/obj/Debug/oF_TD_data.vcxprojResolveAssemblyReference.cache:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interactiveimmersivehq/Pixel-Packing-Examples/eda6e9ae707f932d4c39aa9383038acb926dac9a/openFrameworks-to-TouchDesigner/obj/Debug/oF_TD_data.vcxprojResolveAssemblyReference.cache
--------------------------------------------------------------------------------
/openFrameworks-to-TouchDesigner/obj/Debug/ofApp.obj:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interactiveimmersivehq/Pixel-Packing-Examples/eda6e9ae707f932d4c39aa9383038acb926dac9a/openFrameworks-to-TouchDesigner/obj/Debug/ofApp.obj
--------------------------------------------------------------------------------
/openFrameworks-to-TouchDesigner/obj/Debug/ofxSpout.obj:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interactiveimmersivehq/Pixel-Packing-Examples/eda6e9ae707f932d4c39aa9383038acb926dac9a/openFrameworks-to-TouchDesigner/obj/Debug/ofxSpout.obj
--------------------------------------------------------------------------------
/openFrameworks-to-TouchDesigner/obj/Debug/vc140.pdb:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/interactiveimmersivehq/Pixel-Packing-Examples/eda6e9ae707f932d4c39aa9383038acb926dac9a/openFrameworks-to-TouchDesigner/obj/Debug/vc140.pdb
--------------------------------------------------------------------------------
/openFrameworks-to-TouchDesigner/src/Ball.cpp:
--------------------------------------------------------------------------------
1 | #include "Ball.h"
2 | #include
3 |
4 | // define movement parameters
5 | #define SPRING 0.05
6 | #define GRAVITY 0.03
7 | #define FRICTION -0.9
8 |
9 |
10 | Ball::Ball() {
11 | }
12 |
13 | // ball setup function
14 | void Ball::setup(int idin, vector *oin)
15 | {
16 | x = ofRandom(RES_X);
17 | y = ofRandom(RES_Y);
18 | diameter = ofRandom(30, 70);
19 | id = idin;
20 | others = oin;
21 | }
22 |
23 | // function to check for ball collisions against other balls
24 | void Ball::collide() {
25 | for (int i = id + 1; i < NUM_BALLS; i++) {
26 | float dx = others->at(i).x - x;
27 | float dy = others->at(i).y - y;
28 | float distance = sqrt(dx*dx + dy*dy);
29 | float minDist = others->at(i).diameter / 2 + diameter / 2;
30 | if (distance < minDist) {
31 | float angle = atan2(dy, dx);
32 | float targetX = x + cos(angle) * minDist;
33 | float targetY = y + sin(angle) * minDist;
34 | float ax = (targetX - others->at(i).x) * SPRING;
35 | float ay = (targetY - others->at(i).y) * SPRING;
36 | vx -= ax;
37 | vy -= ay;
38 | others->at(i).vx += ax;
39 | others->at(i).vy += ay;
40 | }
41 | }
42 | }
43 |
44 | // function to move the ball every frame
45 | void Ball::move() {
46 | float gravity = 0.03;
47 | float friction = -0.9;
48 |
49 | int resX = RES_X;
50 | int resY = RES_Y;
51 |
52 | vy += gravity;
53 | x += vx;
54 | y += vy;
55 | if (x + diameter/2 > resX) {
56 | x = resX - diameter/2;
57 | vx *= friction;
58 | }
59 | else if (x - diameter/2 < 0) {
60 | x = diameter/2;
61 | vx *= friction;
62 | }
63 | if (y + diameter/2 > resY) {
64 | y = resY - diameter/2;
65 | vy *= friction;
66 | }
67 | else if (y - diameter/2 < 0) {
68 | y = diameter/2;
69 | vy *= friction;
70 | }
71 | }
72 |
73 |
74 |
75 |
76 |
--------------------------------------------------------------------------------
/openFrameworks-to-TouchDesigner/src/Ball.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 | #include "ofMain.h"
3 | #include
4 |
5 | using namespace std;
6 |
7 | // define the number of balls and screen size
8 | #define NUM_BALLS 12
9 | #define RES_X 1280
10 | #define RES_Y 720
11 |
12 | class Ball
13 | {
14 | public:
15 | Ball();
16 |
17 | // variables needed per ball
18 | float x, y;
19 | float diameter;
20 | float vx;
21 | float vy;
22 | int id;
23 | std::vector *others;
24 |
25 | // variables needed for collision detection
26 | float dx;
27 | float dy;
28 | float distance;
29 | float minDist;
30 | float angle;
31 | float targetX;
32 | float targetY;
33 |
34 | // ball functions
35 | void collide();
36 | void setup(int idin, vector *oin);
37 | void move();
38 |
39 | };
40 |
41 |
--------------------------------------------------------------------------------
/openFrameworks-to-TouchDesigner/src/main.cpp:
--------------------------------------------------------------------------------
1 | #include "ofMain.h"
2 | #include "ofApp.h"
3 |
4 | //========================================================================
5 | int main()
6 | {
7 | // set window size to be same as spout texture
8 | ofSetupOpenGL(114, 4, OF_WINDOW);
9 | ofRunApp(new ofApp());
10 | }
11 |
--------------------------------------------------------------------------------
/openFrameworks-to-TouchDesigner/src/ofApp.cpp:
--------------------------------------------------------------------------------
1 | #include "ofApp.h"
2 |
3 | //--------------------------------------------------------------
4 | void ofApp::setup()
5 | {
6 | ofSetWindowTitle("nVoid oF to TouchDesigner");
7 | ofSetFrameRate(60);
8 |
9 | // disables the blending, or multiplication, of alpha with the r,g, and b channels
10 | ofDisableAlphaBlending();
11 |
12 | // background set to transparent
13 | ofBackground(0,0,0,0);
14 |
15 | // set size of spout texture
16 | spoutX = 16;
17 | spoutY = 4;
18 |
19 | // allocate memory and initialize the vector of ball objects
20 | ball_vec.reserve(NUM_BALLS);
21 | for (int i = 0; i < NUM_BALLS; i++) {
22 | tempBall.setup(i, &ball_vec);
23 | ball_vec.push_back(tempBall);
24 | }
25 |
26 |
27 | // initialize Spout with a sender name, and a texture size
28 | ofxSpout::init("oF to TouchDesigner", screen_tex, ofGetWidth(), ofGetHeight(), true);
29 | }
30 |
31 | //--------------------------------------------------------------
32 | void ofApp::draw()
33 | {
34 |
35 | // init sender if it's not already initialized
36 | ofxSpout::initSender();
37 |
38 | // iterate through balls to check for collisions and move accordingly, and draw the data for spout
39 | for (int i = 0; i < NUM_BALLS; i++) {
40 | ball_vec[i].collide();
41 | ball_vec[i].move();
42 |
43 | // set up data to be written to spout texture
44 | // balls x values
45 | row = 0;
46 | col = ball_vec[i].id;
47 | ballX = pixelPacker(ball_vec[i].x);
48 | ofSetColor(ballX.x, ballX.y, ballX.z, ballX.w);
49 | ofFill();
50 | ofDrawRectangle(col, row, 1, 1);
51 |
52 | // balls y values
53 | row = 1;
54 | col = ball_vec[i].id;
55 | ballY = pixelPacker(ball_vec[i].y);
56 | ofSetColor(ballY.x, ballY.y, ballY.z, ballY.w);
57 | ofFill();
58 | ofDrawRectangle(col, row, 1, 1);
59 |
60 | // balls diameter
61 | row = 2;
62 | col = ball_vec[i].id;
63 | ballD = pixelPacker(ball_vec[i].diameter);
64 | ofSetColor(ballD.x, ballD.y, ballD.z, ballD.w);
65 | ofFill();
66 | ofDrawRectangle(col, row, 1, 1);
67 |
68 | }
69 |
70 | // send screen to Spout
71 | ofxSpout::sendTexture();
72 |
73 | }
74 |
75 | //--------------------------------------------------------------
76 | // this helper function uses bit shifting to take a single 32-bit float
77 | // and convert it into four 8-bit values and returned as an ofVec4f
78 |
79 | ofVec4f ofApp::pixelPacker(float val) {
80 | // bit shift val into 4 8-bit values
81 | int num = int(val);
82 | int r = (num >> 0) & 255;
83 | int g = (num >> 8) & 255;
84 | int b = (num >> 16) & 255;
85 | int a = (num >> 24) & 255;
86 |
87 | // the RGBA chans are used to return a color for the fill
88 | return ofVec4f(r, g, b, a);
89 | }
90 |
91 | //--------------------------------------------------------------
92 | void ofApp::exit()
93 | {
94 | // exit spout
95 | ofxSpout::exit();
96 | }
97 |
98 |
--------------------------------------------------------------------------------
/openFrameworks-to-TouchDesigner/src/ofApp.h:
--------------------------------------------------------------------------------
1 | #pragma once
2 |
3 | #include "ofMain.h"
4 | #include "ofxSpout.h"
5 | #include "Ball.h"
6 |
7 | class ofApp : public ofBaseApp
8 | {
9 | public:
10 | void setup();
11 | void draw();
12 | void exit();
13 |
14 | // function to create a vec4 from a 32bit value
15 | ofVec4f pixelPacker(float val);
16 |
17 | // list of balls and a temp ball for setup
18 | std::vector ball_vec;
19 | Ball tempBall;
20 |
21 | // textures for writing data to
22 | ofTexture screen_tex;
23 |
24 | // variables to navigate the ofPixels
25 | int i;
26 | int spoutX;
27 | int spoutY;
28 | int row;
29 | int col;
30 |
31 | // vec4s that get written to before data transmission
32 | ofVec4f ballX;
33 | ofVec4f ballY;
34 | ofVec4f ballD;
35 |
36 | };
37 |
--------------------------------------------------------------------------------