Mother/Foetus sketch troubleshooting
in
Contributed Library Questions
•
3 years ago
following up
my thread from the old forum
Ok, so I found out why I got a black screen in Mother and not in processing. It seems that Mother overrides colorMode() if it is set in the sketch. I had called colorMode(RGB, 2) to put the range of color() values to 0.0 - 2.0, but when opened in Mother and it sets it back to default values (0-255) my colors are of too low values to be seen.
Now I am facing another problem. When I run the sketch in Processing it looks smooth, like this:
But when I run it in Mother the rendering gets slow and choppy, like this:
I'm very happy for any input.
cheers!
Ok, so I found out why I got a black screen in Mother and not in processing. It seems that Mother overrides colorMode() if it is set in the sketch. I had called colorMode(RGB, 2) to put the range of color() values to 0.0 - 2.0, but when opened in Mother and it sets it back to default values (0-255) my colors are of too low values to be seen.
Now I am facing another problem. When I run the sketch in Processing it looks smooth, like this:
But when I run it in Mother the rendering gets slow and choppy, like this:
I'm very happy for any input.
cheers!
- import megamu.shapetween.*;
import oscP5.*;
import netP5.*;
import processing.opengl.*;
import foetus.*;
import processing.core.*;
import processing.core.PApplet.RegisteredMethods;
import java.util.*;
import javax.media.opengl.*;
import javax.media.opengl.glu.*;
// Log Starburst
// - Jim Bumgardner, Ryan Govostoes
// using a formula from Bumgardner's "Pixel Magic" - 1992.
float sineTable[];
float dTable[];
float aTable[];
float dMult = 2;
float aMult = 2;
int cMode = RGB;
//int w= 300, h= 300;
public Foetus f;
void setup()
{
// When run as a synth, setup() is never called!
// put the necessary initialization code in a method named initializeFoetus().
// The necessary Processing initialization calls are called by Mother, and so should be left out from
// initializeFoetus().
// Finally, for the synth to work as a processing sketch within the PDE, call initializeFoetus() from within
// setup().
size(1280, 800, OPENGL);
initializeFoetus();
}
void initializeFoetus()
{
// Instantiate foetus object here
f = new Foetus(this);
//size(300, 300);
colorMode(cMode, 255);
// precalculate 1 period of the sine wave (360 degrees)
sineTable = new float[360];
for (int i = 0; i < 360; i ++)
sineTable[i] = sin(radians(i));
// precalculate polar coords
dTable = new float[width * height];
aTable = new float[width * height];
float cx = width / 2;
float cy = height / 2;
int i = 0;
for (int y = 0; y < height; y ++) {
for (int x = 0; x < width; x ++) {
if (x != cx || y != cy) {
dTable[i] = 359-posDegrees( 0.5 * log(sq(x - cx) + sq(y - cy)) );
aTable[i] = posDegrees( atan2(y - cy, x - cx) );
}
i ++;
}
}
}
void draw()
{
loadPixels();
float tb = millis()*.2;
float tg = tb*.25;
for(int i = 0; i < (width * height); i ++) {
float a = sineTable[(int)(aTable[i] * aMult) % 360];
float da = dTable[i] * dMult + aTable[i];
float r = 1 + a * sineTable[abs((int)da) % 360];
// float g = 2 - r;
float g = 1 + a * sineTable[(int)(da + tg) % 360];
float b = 1 + a * sineTable[(int)(da + tb) % 360];
pixels[i] = color(r*127.5, g*127.5, b*127.5);
}
updatePixels();
fpscalc();
}
float fps;
int fpsN;
void fpscalc() {
fps += frameRate;
fpsN ++;
if((fpsN % 60) == 0)
print((fps / fpsN) + " ");
}
float posDegrees(float rad) {
float deg = degrees(rad) % 360;
if(deg < 0) deg += 360;
return deg;
}