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 › Issue Printing 3D Shapes
Page Index Toggle Pages: 1
Issue Printing 3D Shapes (Read 1021 times)
Issue Printing 3D Shapes
Aug 26th, 2009, 9:32pm
 
Hello I have been getting results that I like with my code but when I want to Export as PFD file for print it's a mess!!

-Normally I have this code with a P3D render, and I like the traces from  the shapes but I cannont get this shaes to maintain in my PDF file insted ad I get just one frame from the entire code.  Cry
-And also changin' my mode to OPENGL it also gets really different u cannot see anymore the traces.  Cry


HELP!  Shocked
______________________
______________________________

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



boolean dosave=true;
float ang;
int limit = 26;
float t;
boolean active=true;

Triangle[]triangles = new Triangle[limit];

void setup(){
 size(900,600,P3D);
background(170);
 smooth();
  noStroke();
   fill(0);
 for (int i = 0; i< triangles.length; i++){
   triangles[i] = new Triangle(int(random(-20, 20)), int(random(-50, 50)),
   int(random(-40, 40)), int(random(-30, 30)), int(random(-30, 30)),
   int(random(-40, 40)));
 }
 frameRate(30);
}


void draw(){

   
 if(dosave) {
   // set up PGraphicsPDF for use with beginRaw()
   PGraphicsPDF pdf = (PGraphicsPDF)
   beginRaw(PDF, "pdf_complex_out.pdf");

   // set default Illustrator stroke styles and paint background rect.
   pdf.strokeJoin(MITER);
   pdf.strokeCap(SQUARE);
   pdf.fill(170);
   pdf.noStroke();
   pdf.rect(0,0, width,height);

 }
 
 
 t=millis();
 println(t);

rotateY(radians(ang));
rotateX(radians(ang));
 rotateZ(radians(ang));

   translate(mouseX,mouseY,mouseY);

fill(random(255),random(10),random(9),100);


 for (int i = 0; i< triangles.length; i++){
  triangles[i].display();
  triangles[i].moveCorners();
 
 }
     

 ang=ang+.1;
 
 
 if(dosave) {
   endRaw();
   dosave=false;
 }
}

void drawRect(){
  if (active==true){

 rect(0,0,width,height);
 }
 
 
}

void keyPressed() {
 if (key == 's') {
   dosave=true;
 }
}

void mouseReleased() {
 background(170);
}


------------------------------CLASS Triangle------------------------

class Triangle {
 float x1, y1, x2, y2, x3, y3;
 color c= color(10);
 float time;
 float increment= 0.03;
 float n;
 int r;

 Triangle(float tempx1, float tempy1, float tempx2, float tempy2, float tempx3, float tempy3){
   x1= tempx1;
   y1= tempy1;
   x2= tempx2;
   y2= tempy2;
   x3= tempx3;
   y3= tempy3;
   
 }

 void display(){
 
   rotateY(radians(r));
   rotateX(radians(r));
   rotateZ(radians(r));
   triangle(x1+n, y1+n, x2+n, y2+n, x3, y3);  
   r++;
 }

 void moveCorners(){

   n= noise(time)*100;

   time +=increment;

 }


}



Re: Issue Printing 3D Shapes
Reply #1 - Oct 7th, 2009, 9:44pm
 
HELP HELP!!!! Sad
Re: Issue Printing 3D Shapes
Reply #2 - Oct 8th, 2009, 12:22am
 
As it is, you have a chunk of code that starts your pdf saving.  That runs when you press "S" because "S" flags your "dosave" boolean, and draw() says "If the 'dosave' boolean is true, then start the pdf process."  Then, at the end of that same draw frame, it says "if dosave is true, set it to false and close the pdf."

So, that's not going to capture anything that happens before you press S, and it's closing the pdf in that same frame.  The pdf setup block needs to be moved in order to record first: either to setup(), or with a new keypress, or whatever.  Then "s" should call endRaw(), which will save the pdf.

--Ben
Page Index Toggle Pages: 1