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 & HelpPrograms › problem with the Integrator class from VD, by Fry
Page Index Toggle Pages: 1
problem with the Integrator class from VD, by Fry (Read 605 times)
problem with the Integrator class from VD, by Fry
Oct 5th, 2008, 6:09am
 
Hi

I have a sepcific program in mind that I haven trying to implement the Integrator class into - I would like a zooming type of function similar to the example with the zip codes in chapter 6. Mine, I believe, should be much simpler - I am thinking of using an object's position to drive the camera in 3d space...I just want to "integrate" or transition smoothly between the camera's current position and its target.

I have tried it using my sketch and it hasn't worked. I proceeded to try and build a really dumb sketch using Integrator and figure out where I was going wrong but it hasn't helped. There seems to be something wrong with the targets...

import processing.opengl.*;
int H = 600;
int W = 1000;

Integrator cameraX, cameraY;

PFont font;

void setup() {
 size(W,H, OPENGL);
 hint(ENABLE_ACCURATE_TEXTURES);
 frameRate(20);
  camera();
 font = loadFont("Swiss721BT-Light-12.vlw");
 textFont(font, 12);
 
 Integrator cameraX = new Integrator(W/2);
 Integrator cameraY = new Integrator(H/2);
}

void draw() {
 background(0);
 //cameraX.update();
 //cameraY.update();
 rect(30, 20, 55, 55);
 rect(500, 500, 25, 25);
}

void mousePressed() {
 if ((mouseX > 30) && (mouseX <85) && (mouseY > 20) && (mouseY<75)){
   cameraX.target(56);
   cameraY.target(46);
   setCamera();
 }
}

void setCamera(){
 
 camera(cameraX.value, cameraY.value, 100, cameraX.value, cameraY.value, 0, 0, 1, 0);
     cameraX.update();
     cameraY.update();
   
}

and the applet:
oh wait...i just took a look at it and the export option doesnt seem to be working...any advice on that would be a great help too. I have tried others and I'm getting a viewport that doesnt match my sketch and nothing inside...


Re: problem with the Integrator class from VD, by
Reply #1 - Oct 5th, 2008, 10:02pm
 
Is this and Integrator problem or are you just having trouble with the camera() functions? I recommend using OCD to handle the camera work, and use an Integrator to control the options called. Using OCD will insulate you from the trickiness of getting the camera to work.

Export should be just fine, if it's not please file a bug that describes what's happening.
Re: problem with the Integrator class from VD, by
Reply #2 - Oct 6th, 2008, 12:34am
 
I assumed there was some problem with my syntax in implementing the Integrator since I am getting a NullPointerException on the line:
cameraX.target(56);

and this was even before I specified what the cameraX would be used in...I will look into OCD but it seems strange that a variable that I made up - it has nothing to do with native camera functions - would trip things up
Re: problem with the Integrator class from VD, by
Reply #3 - Oct 6th, 2008, 3:07am
 
i am having trouble with the following code i just quickly whipped up to generate a new radius for a circle upon keypress - it's not working in the same way the previous script wasn't working. It seems to trip on the update() part:

int H = 600;
int W = 1000;

Integrator iradius;

void setup() {
 size(W,H, OPENGL);

 frameRate(20);

 Integrator iradius = new Integrator(50);
}

void draw() {
 background(0);
 iradius.update();

 drawCircle();
}

void drawCircle(){
 float radius = iradius.value;
 ellipse (500,500, radius, radius);
}
void keyPressed() {
 if (key == ' '){
   radiusUpdate();
 }
}
void radiusUpdate(){
 float newValue = random(50, 500);
 iradius.target(newValue);
}

Re: problem with the Integrator class from VD, by
Reply #4 - Oct 6th, 2008, 9:08pm
 
figured out what it was...an error with my syntax as i thought:

removed the epeated declaration of Iterator in front of
iradius = new Integrator(50);

oops...
Re: problem with the Integrator class from VD, by
Reply #5 - Oct 6th, 2008, 10:00pm
 
i got it working for the circle but im not having any luck with the camera position...

import damkjer.ocd.*;

Camera camera1;

int H = 400;
int W = 600;

Integrator cxpos;
Integrator cypos;
Integrator czoom;


void setup() {
 size(W,H);
 camera1 = new Camera(this);
 
 cxpos = new Integrator(W/2);
 cypos = new Integrator(H/2);
 czoom = new Integrator (1);
 
 camera1.track(cxpos.value, cypos.value);
 camera1.zoom(czoom.value);
}

void draw() {
 background(0);
 cxpos.update();
 cypos.update();
 czoom.update();

 rect(30, 20, 55, 55);
 rect(500, 500, 25, 25);
}

void targetCamera(){
 float xvalue = random(50,500);
 float yvalue = random(50,500);
 float zoomvalue = random (0.1,1.9);
 cxpos.target(xvalue);
 cypos.target(yvalue);
 czoom.target(zoomvalue);
}

void keyPressed() {
 if (key == ' '){
   targetCamera();  
 }
}

and I looked into the export problem and it looks like the html that is being pumped out is where the problem lies...no matter the size of the sketch, it is always specified as a 100 x 100 window...
Re: problem with the Integrator class from VD, by
Reply #6 - Oct 6th, 2008, 10:06pm
 
though I just checked and it worked when I wasn't using the ocd functions...
Page Index Toggle Pages: 1