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 › fly thru error
Page Index Toggle Pages: 1
fly thru error? (Read 341 times)
fly thru error?
Jul 30th, 2009, 9:51am
 
Hello!

I produced a simple code that flies a 3D camera through a box when you press cursor UP.
The eye flies into the screen through the box.
The position of the center (LookAt ) is always 12 pixels in front of the eye.
You move the camera via cursor UP and DOWN.
But at the center of the box all kinds of weired stuff happens to the box (diagonal lines and stuff). Why? Program error?
Code below.

Thanks!

Greetings to all,

Chris



float fillValX = 2;  
float CameraAdd = 5;

void setup()
{
 size(1100, 900, P3D);
 background(100);
 smooth();
 noFill();
 stroke(256, 0, 0);
} // setup

void draw()
{
 camera ( width/2.0, height/2.0, fillValX,
 width/2.0+1, height/2.0+1, fillValX+12,
 0, 1, 0 ) ;              
 background(0);
 translate(458, 428, 1320);
 box(440);
 translate(458, 428, 1620);
 box(40);
 println(fillValX);
} // draw

void keyPressed() {
 if (key == CODED) {

   if (keyCode == UP) {
     fillValX += CameraAdd;
   }
   else if (keyCode == DOWN) {
     fillValX += -CameraAdd;
   }
 }
 else {  
   // not key == CODED
 }
} // keyPressed



Page Index Toggle Pages: 1