This visual side of this project was done completely in Processing, 1 master computer sending data over osc to four computers rendering the four projections. Very pleased with the stability of Processing.
Explorations following the discovery of Ricard Marxter's Geomerative library, illustrating the result of different mathematical treatments of a set of points.
Let me know what you think. Always keen to hear feedback, both positive and constructively negative ;-)
About a year ago, I flagged this issue, where all of a sudden, all my Processing sketches running the standard P2D renderer slowed down to an unusable rate. Due to invisible pixie objects, as PhiLo named them:
I filed a bug report, but this was dismissed as a known problem of medium priority (?) and the problem persists, even on a brand new machine running a different os and everything.
Now I noticed recently that all my processing sketches using OPENGL have been showing slowdowns too, though at regular intervals. Even when not drawing anything, framerate drops to about 30 almost every 15 seconds with a full screen window:
Running this on a macbook pro i7, v1.5.1:
import processing.opengl.*;
boolean below = false;
float last;
void setup()
{
size(screen.width, screen.height, OPENGL);
}
void draw()
{
if(frameRate < 40) {
if(!below) {
float t = millis()/1000.0;
println("Slowing down below 40 at: "+nf(t, 1, 2)+" sec, "+nf(t-last, 1, 2)+" sec since last time");
last = t;
}
below = true;
} else {
below = false;
}
//println(frameRate);
}
Results in this output:
Slowing down below 40 at: 1.55 sec, 1.55 sec since last time
Slowing down below 40 at: 8.99 sec, 7.44 sec since last time
Slowing down below 40 at: 23.87 sec, 14.88 sec since last time
Slowing down below 40 at: 38.81 sec, 14.95 sec since last time
Slowing down below 40 at: 53.83 sec, 15.01 sec since last time
Slowing down below 40 at: 68.74 sec, 14.91 sec since last time
Slowing down below 40 at: 83.68 sec, 14.95 sec since last time
Slowing down below 40 at: 98.66 sec, 14.98 sec since last time
Slowing down below 40 at: 113.59 sec, 14.93 sec since last time
Slowing down below 40 at: 128.50 sec, 14.91 sec since last time
We're setting up a simple video projection, or so I thought.
I'd like to setup two projectors, each projecting on a different wall, meeting in the corner.
As their angle is orthogonal, I figured their fov to be 360/4 = 90 degrees, or half Pi.
They simply look along the two axes, with y axis up, this would be for left wall: 1, 0, 0 and for the right 0, 0, 1.
With my eye in 0, 0, 0, their projection should perhaps be dollied a little along their respective axes. But no matter the value I translate along the axis, the image will not match perfectly.
I've used both the core camera() function and OCD's implementation:
Left projection:
// setup perspective
float cameraX = 0;
float cameraY = 0;
float cameraZ = 0;
float targetX = 1;
float targetY = 0;
float targetZ = 0;
float upX = 0;
float upY = 1;
float upZ = 0;
float fov = PI/2.0;
float nearClip = 0.001;
float farClip = 2000;
float aspect = 4/3.0;
cam = new Camera(this,
cameraX, cameraY, cameraZ,
targetX, targetY, targetZ,
upX, upY, upZ,
fov, aspect, nearClip, farClip);
cam.dolly(halfroomsize);
Right:
// setup perspective
float cameraX = 0;
float cameraY = 0;
float cameraZ = 0;
float targetX = 0;
float targetY = 0;
float targetZ = 1;
float upX = 0;
float upY = 1;
float upZ = 0;
float fov = PI/2.0;
float nearClip = 0.001;
float farClip = 2000;
float aspect = 4/3.0;
cam = new Camera(this,
cameraX, cameraY, cameraZ,
targetX, targetY, targetZ,
upX, upY, upZ,
fov, aspect, nearClip, farClip);
cam.dolly(halfroomsize);
Previously, we have achieved pretty good results with the standard 60 degrees (PI/3.0) perspective and 30 degree camera rotation(PeasyCam.rotateY()).Which is odd isn't it? Shouldn't that have been rotateY(fov)?
Exploring Andres great GLGraphics library, I'm trying to get a dynamic mesh to display. One in which I can map the model's z values to an arbitrary value, to be updated every frame. Shouldn't be too difficult, but I ran aground trying to access the vertex values stored in the model. A Floatbuffer? How does that work? :)
I was thinking of something like this, where "mesh" is a static glmodel with normalised z-values, and display is a dynamic/stream version that maps the normalised z-values of the static model to a dynamic value. In this code I presumed a ArrayList style list of vertices.
void update() { float x, y, z; display.beginUpdateVertices(); for (int i = 0; i < display.vertices.size(); i++) { x = mesh.get(i).vertices.x; y = mesh.get(i).vertices.y; z = mesh.get(i).vertices.z*displayHeight; // mapped display.updateVertex(index, x, y, z); } display.endUpdateVertices(); }
We've been experimenting with OscP5 to broadcast data (14 parameters only) across a network where x slave computers are listening in and using these parameters to render the same scene from several perspectives. Which kinda works.
The thing is that these values don't come across smooth, consistently. Sometimes the animation as broadcasted from the master computer is rendered smoothly by the slaves, but most of the time, they jerk a little. It seems frames are dropped in the broadcasting, as if both framerates don't align properly. Which they indeed probably don't, but I didn't expect this kind of lagging with both broadcaster and slave running at 40+ frames.
Any ideas? Or perhaps a better way to sync multiple slave computers?
Using a custom colormode set as colorMode(HSB, 360, 100, 255) (which I happen to find intuitive..) it seems that values returned by these functions are set 'according to the current colorMode' which ends up with bizarrely mapped values: red(0-360), green(0-100) and blue(0-255).
Although I understand that a seed is used to
initialize a number generator (Wikipedia), a randomSeed basically implies that the random() function is sort of accessing an array of generated numbers in a [i++] kind of way? Or some sort of random(seed).get() function.
As
randomSeed(1);
float f = random(10); f = random(10); f = random(10);
println(f);
Will always return the same number.
It would be nice however if you access the value returned from a n-th time a random() call is made directly, say:
float f = random(10)[3];
Or at least keep track of n; how many times has random() been called?
Of course you could make your own and do something like:
mx, my and mz are the saved modelXYZ coordinates of the points. They've been updated in the first loop.
--
Please see the simple example above. It is drawing lines between points in a environment explored via peasycam. I'm using the standard method to revert to a 2d representation of the space, but somehow the above only works when peasycam is not tweening. While rotating the scene, the point around which the lines rotate seems to be offset to the camera position. When the tween ends, and the scene has become static, everything is drawn like it should.
I'm looking into the different image file formats, to try to generate/convert some of them myself, ie. not using processing's save()/saveFrame() functions but writing to the file using my own code. (For instance generating images of undefined scale, created by a PrintWriter or something. But I have no clue how to write binary data etc. like described here:
http://www.ucancode.net/Visual_C_Codes/Read_Wirte_Create_Tiff_File_VC_Source_Code_Example.htm
at processing.app.Sketch.placeException(Sketch.java:1565)
at processing.app.debug.Runner.findException(Runner.java:568)
at processing.app.debug.Runner.reportException(Runner.java:543)
at processing.app.debug.Runner.exception(Runner.java:498)
at processing.app.debug.EventThread.exceptionEvent(EventThread.java:367)
at processing.app.debug.EventThread.handleEvent(EventThread.java:255)
at processing.app.debug.EventThread.run(EventThread.java:89)
Exception in thread "Animation Thread" java.lang.ArrayIndexOutOfBoundsException: -1
at geomerative.RSVG.getPolyline(RSVG.java:473)
at geomerative.RSVG.elemToPolyline(RSVG.java:338)
at geomerative.RSVG.elemToPolygon(RSVG.java:350)
at geomerative.RSVG.elemToCompositeShape(RSVG.java:240)
at geomerative.RSVG.elemToCompositeShape(RSVG.java:234)
at geomerative.RSVG.elemToCompositeShape(RSVG.java:234)
at geomerative.RSVG.elemToCompositeShape(RSVG.java:234)
at geomerative.RSVG.toShape(RSVG.java:63)
at geomerative.RG.loadShape(RG.java:242)
at palestine_svg.loadMap(palestine_svg.java:228)
at palestine_svg.setup(palestine_svg.java:70)
at processing.core.PApplet.handleDraw(PApplet.java:1571)
at processing.core.PApplet.run(PApplet.java:1496)
at java.lang.Thread.run(Thread.java:637)
This only happens at one of the 6 different files that are being loaded, which all have been created by the same program, and all have been edited by Illustrator and resaved.
The funny thing is that this happened AFTER I opened a SVG that was exported by a GIS program in Illustrator, cleaned it up (removed fills) and saved it again as SVG 1.0. Before this, it loaded fine.
Previously, one of the files that came directly from the GIS program immediately throwed this exact same error, and I solved this by doing exactly the same as what now causes it: editing it in Illustrator, removing fills and resaving it.