We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOther Libraries › Mother/Foetus sketch troubleshooting
Page Index Toggle Pages: 1
Mother/Foetus sketch troubleshooting (Read 2518 times)
Mother/Foetus sketch troubleshooting
Jun 12th, 2010, 2:56pm
 
Just been trying out Mother (www.onar3d.com/mother/) today and it seems very nice, although I miss more documentation and a way to debug.

I have been running some simple exported sketches that have worked nicely, but I seem to be doing something wrong with this one. This code runs fine in Processing but makes Mother crash. Anyone got any idea?

cheers!

Code:

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;

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().


initializeFoetus();
}

void initializeFoetus()
{

// Instantiate foetus object here
f = new Foetus(this);

size(300, 300, P2D);
colorMode(cMode, 2);

// 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[(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, g, b);
}

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;
}
Re: Mother/Foetus sketch troubleshooting
Reply #1 - Jun 13th, 2010, 1:36am
 
Moved from Programs to Other Libraries as it seems to be an issue with Mother library.
"makes Mother crash" Some details might help those knowing this library. Any error message in sight?
Re: Mother/Foetus sketch troubleshooting
Reply #2 - Jun 13th, 2010, 3:27am
 
Well, Mother is not a library but a standanlone program to VJ .jar files made in Processing. It has a library called Foetus when used in Processing - but I agree, its probably more correct to place it here. Thanks.

Quote:
Any error message in sight?


no, thats the problem. The code runs fine in Processing, but not in Mother. And there are no error messages to be seen from Mother. I dont believe Mother has any error reporting system. postln() messages does not get through to the client (MaxMSP / PureData) used to control Mother either.

I thought that there maybe was something simple I was overlooking that someone with sharp eyes could point out....
Re: Mother/Foetus sketch troubleshooting
Reply #3 - Jun 16th, 2010, 2:11pm
 
ok, so I found out after a while that size() should not be defined in initializeFoetus(), and that P2D + P3D is not supported in Mother.

Most importantly: I had not copied the rest of the .jar files into the ../Synths/libraries/ folder after exporting. That solved most of the problems.

It seems one can get debugging info from Mother by running it from source in Eclipse. If anyone got pointers on how to do this I'd be very grateful as I've never touched Eclipse.
Re: Mother/Foetus sketch troubleshooting
Reply #4 - Jun 16th, 2010, 3:41pm
 
ok, so now my code doesn't crash Mother but it only shows as a black layer. Running it in processing in the same size gives no error and runs smooth.

Im very happy for any input!

cheers,
g

Code:

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, 2);

// 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, g, b);
}

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;
}
Page Index Toggle Pages: 1