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.
Page Index Toggle Pages: 1
Camera headbugs (Read 501 times)
Camera headbugs
Oct 30th, 2005, 8:03pm
 
I'm calling out for help. The brainbugs are stalling my brain at the moment.
This code draws out n-amount of rows with ellipses.
How can I have the camera following the newest drawn row of ellipses?  

import processing.opengl.*;
import damkjer.ocd.*;

float y = 0;
Camera camera1;

void setup()
{
  size(512,400, OPENGL);
  background(0,0,0);
  noStroke();

   camera1 = new Camera(this,
      -0, 0, 300,
       0, 0, 0
      );
}

void draw()
{
camera1.feed();

  pushMatrix();
  translate(0,y,0);
  for ( int i = 0; i < 20; i++)
  {
    fill(i*10+random(10));
    ellipse(i*10, 180, 10, 10);

  }
  y-=10;
  popMatrix();

  setCamera(y);
}

void setCamera(float y)
{
beginCamera();
 pushMatrix();
  translate(0,y,0);
 popMatrix();
endCamera();
}


Everything I've come up with affects the drawing.
For instance, if I replace the translation with a camera1.zoom(y) in the setCamera function it doesnt just move the camera, it moves everything that is drawn.
Page Index Toggle Pages: 1