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.
IndexSuggestions & BugsSoftware Bugs › Lighting bug in processing >=0109 with OCD libr
Page Index Toggle Pages: 1
Lighting bug in processing >=0109 with OCD libr (Read 701 times)
Lighting bug in processing >=0109 with OCD libr
Mar 31st, 2006, 9:00am
 
I have some code that uses the OCD library. It works fine in processing versions 0103 through 0108, but breaks in 0109 and remains broken in later versions. I don't know if the bug is in Processing or OCD; perhaps it should be discussed here before filing a bug report?

I've simplified the code as much as possible to isolate the bug, and the code is attached below.

There's a basic setup() which creates a Camera; a draw() which simply puts a sphere in the center of the world, lit by a single light; and a mouseDragged() function that allows rotating and viewing the model. (This last function is unnecessary to reproduce the bug, but useful to explore its nature.)

In versions of processing after 0109, the light moves, somewhat chaotically, after every frame. The movement gets more stranger after moving the camera (by dragging iwht the mouse). Uncomment the framerate(4) line to get a better view of what's happening. Before version 0109, the light remains still, as expected.

Specifically, the light moves every time camera1.feed() is called. If this function is moved into mouseDragged(), for example, the light only moves unexpectedly when the mouse is dragged to move the camera.

The only relevant change I see in version 0109 is this one:
+ fixes contributed by willis morse to deal with memory wastefulness.
 these should help speed up some types of OPENGL and P3D mode sketches,
 thanks willis!

I wonder if a bug was introduced here, or if this fix (or some other) revealed a bug in the OCD code.

If it matters, I'm running Processing on a Mac OS X machine.

Here's the code:

Quote:
 
import damkjer.ocd.*;

Camera camera1;

void setup() {
 size(640, 480, P3D);
 stroke(50,50,50,50);
 fill(200,200,200);
 camera1 = new Camera(this, 20, 20, 20, 0, 0, 0);
 //framerate(4);
}

void draw() {
 camera1.feed();
 background(255);
 directionalLight(200, 0, 0, -1, 0, 0);
 sphere(10);  
}

void mouseDragged() {
 if (mouseButton == LEFT) {
   camera1.tumble(radians(mouseX - pmouseX), radians(mouseY - pmouseY));
 }
 else if (mouseButton == RIGHT) {
   camera1.track(mouseX - pmouseX, mouseY - pmouseY);
 }
 else if (mouseButton == CENTER) {
   camera1.dolly(mouseY - pmouseY);
 }
}
Re: Lighting bug in processing >=0109 with OCD
Reply #1 - Mar 31st, 2006, 3:22pm
 
are you sure it's 109 that breaks (not say 110, which had a lot more changes) i looked at the differences in the code for P3D between the two and it all seems to be correct (with regards to lighting at least). i don't doubt it's an issue, one of the other examples was causing trouble but i was thinking it was OPENGL causing the trouble.
Re: Lighting bug in processing >=0109 with OCD
Reply #2 - Apr 2nd, 2006, 1:59am
 
Yep, just re-tested it. The code works fine in 108, not in 109. FWIW, the same unexpected behavior occurs in either P3D or OPENGL mode.
Re: Lighting bug in processing >=0109 with OCD
Reply #3 - Apr 2nd, 2006, 8:36pm
 
k, will check into it. now tracking here:
http://dev.processing.org/bugs/show_bug.cgi?id=316
Page Index Toggle Pages: 1