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 › 3D objects drawn to PDF hide those drawn earlier
Page Index Toggle Pages: 1
3D objects drawn to PDF hide those drawn earlier (Read 1042 times)
3D objects drawn to PDF hide those drawn earlier
Feb 12th, 2010, 7:54am
 
Using P3D, objects are drawn to PDF in the order they occur in the code - if I draw (say) a box with a sphere inside, on saving to PDF the sphere is drawn in front of the box (or vice-versa, depending on their order in the code).

Using OpenGL, fills that failed to appear in the PDF in v1.0 now appear in 1.0.9 but the depth issue remains. Also, polygon artefacts appear with 'ENABLE_DEPTH_SORT' (related to Bug 176?). This illustrates both issues:

Code:

import processing.opengl.*;
import processing.pdf.*;

float yTheta = 0.0;
float xTheta = 0.0;

boolean recordPDF = false;

void setup() {
//  size(400, 400, OPENGL);
 size(400, 400, P3D);
//  hint(ENABLE_OPENGL_4X_SMOOTH);
//  hint(ENABLE_DEPTH_SORT); // polygon artefacts in PDF
}

void draw() {
 if (recordPDF) {
   beginRaw(PDF, "###_3D.pdf");
 }
 background(255);
 translate(width/2, height/2);
 rotateX(xTheta);
 rotateY(yTheta);

//  draw sphere first - or swap with box
 noStroke();
 fill(200);
 sphere(50);

//  draw box - or swap with sphere
 stroke(1, 10);
 noFill();
 box(100); // 'hidden' box strokes appear in front of sphere in PDF

 xTheta += 0.01;
 yTheta += 0.02;
 if(recordPDF) {
   endRaw();
   recordPDF = false;
 }
}

void mousePressed() {
 recordPDF = true;
}

Re: 3D objects drawn later hide those already drawn
Reply #1 - Feb 12th, 2010, 12:54pm
 
What happens if you draw the sphere first?

In 3D (using P3D or OPENGL modes) it shouldn't matter the order they are drawn since it will use depth buffering to decide what is drawn.

Can you post some code for us to see the problem?

Re: 3D objects drawn to PDF hide those drawn earlier
Reply #2 - Feb 21st, 2010, 12:27am
 
Forgot to point out that this occurs when drawing to PDF. Re-posted with code example, and to raise another two issues when using OpenGL. Apologies - my stupid.
Re: 3D objects drawn to PDF hide those drawn earlier
Reply #3 - Feb 21st, 2010, 8:34am
 
I have tried various approaches just as you have but with no luck. I even tried my SHapes3D library but still no luck.
Sad

Perhaps someone else will know if there is a solution.
Page Index Toggle Pages: 1