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 › nan triangle
Page Index Toggle Pages: 1
nan triangle (Read 551 times)
nan triangle
May 17th, 2007, 11:27pm
 
Has anybody encountered this error before:

Code:

java.lang.RuntimeException: nan triangle
at processing.core.PGraphics3D.depth_sort_triangles_compare(PGraphics3D.java:1316)
at processing.core.PGraphics3D.depth_sort_triangles_partition(PGraphics3D.java:1289)
at processing.core.PGraphics3D.depth_sort_triangles_internal(PGraphics3D.java:1279)
at processing.core.PGraphics3D.depth_sort_triangles(PGraphics3D.java:1272)
at processing.core.PGraphics3D.flush(PGraphics3D.java:406)
at processing.core.PGraphics3D.endDraw(PGraphics3D.java:384)


The pertinent part of the draw loop looks like this:

Code:

background(0);
hint(ENABLE_DEPTH_SORT);
//println(obList.size() + " objects to draw.");
for ( int i = 0; i < obList.size(); i++)
{
ImgObject ob = (ImgObject)obList.get(i);
ob.update();
ob.draw();
}
fill(255);
sphere(10);
cam.feed();


And the draw function of ImgObject looks like this (img is a PImage member variable, x, y, and z are float member variables):

Code:

//println("Drawing object with ID " + ID);
fill(255);
noStroke();
pushMatrix();
translate(x, y, z);
beginShape();
texture(img);
vertex(0, 0, 0, 0, 0);
vertex(0, 0, img.height, 0, 1);
vertex(img.width, 0, img.height, 1, 1);
vertex(img.width, 0, 0, 1, 0);
endShape();
popMatrix();


I tried switching to OPENGL and wound up with a similar error, but a trace from the JOGL functions, of course. So I suspect it is not necessarily a bug in Processing, but merely some sort of mistake on my part.
Re: nan triangle
Reply #1 - May 17th, 2007, 11:59pm
 
Try adding a check on img.width and img.height being "sensible" (i.e. >=0 and <1000 or something) it sounds like one or the other could be NaN somehow, and that is getting passed into triangle.
Re: nan triangle
Reply #2 - May 18th, 2007, 4:01am
 
Actually, I'm pretty sure it was the x, y, z values. In the update function for the object I do some math where there is a potential divide by zero, which would make for some tasty NaN bread.
Page Index Toggle Pages: 1