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 & HelpOpenGL and 3D Libraries › Can anyone explain this 3D Objects disappear
Page Index Toggle Pages: 1
Can anyone explain this? 3D Objects disappear (Read 712 times)
Can anyone explain this? 3D Objects disappear
Jan 8th, 2010, 6:49pm
 
I'm creating a script that causes a box to approach the camera, but in a spiral. I thought the idea would look neat, but for some reason it disappears after about half way and then reappears. Does anyone understand why it would do this? I have no problem creating boxes anywhere I want but once I start using the spirals, it starts doing this:

Code:
import processing.opengl.*;
import javax.media.opengl.*;
//import peasy.*;

//PeasyCam cam;

void setup() {
 size(800, 600, OPENGL);
//  cam = new PeasyCam(this, width);
 location = new PVector(100, 100, 0);
}

PVector location;

void draw() {
 background(0);
 location.z += 5;
 float distance = sqrt(location.x*location.x + location.y*location.y);
 float angle    = atan(location.y/location.x);
 location.x     = distance*cos(angle+PI/48);
 location.y     = distance*sin(angle+PI/48);  
 translate(location.x, location.y, location.z);
 box(50);
}



Re: Can anyone explain this? 3D Objects disappear
Reply #1 - Jan 8th, 2010, 7:09pm
 
crappity smackin' A.. It was my use of atan.. I switched to atan2 and it fixed the problem. Let that be a word of caution for the rest of you! Smiley
Page Index Toggle Pages: 1