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 & HelpSyntax Questions › can't set size(1024,728,P3D )
Page Index Toggle Pages: 1
can't set size(1024,728,P3D ) (Read 1451 times)
can't set size(1024,728,P3D )
Dec 27th, 2009, 4:25am
 
im trying to import a svg file to the processing stage. when i set size(1024,670,P3D) its working.
but if i increase height ( >670 ) . the svg file disappears

Code:

import processing.core.*;
import processing.xml.*;

public class svgtest extends PApplet {

int svgWidth, svgHeight;
Shape3D[] shapes;
int num;

public void setup() {
 
 size(1024, 728, P3D);

 XMLElement xml = new XMLElement(this, "testdrawing.svg");
 
  svgWidth = xml.getIntAttribute("width");
  svgHeight = xml.getIntAttribute("height");
 
  // create 3d SVG shapes
  XMLElement[] kids = xml.getChild(0).getChildren();
  num = kids.length;
  System.out.println("no of children"+num);
  shapes = new Shape3D[num];
 
  for(int i=0; i<num; i++) {
    String id = kids[i].getStringAttribute("id");
    shapes[i] = new Shape3D(id, kids[i]);
  }
 
  colorMode(HSB, num);
  noStroke();
 
 
 
}


public void draw() {

 background(0);
   
 // draw 3d shapes
 for(int i=0; i<num; i++) {

   Shape3D s = shapes[i];
   int c;
   
   pushMatrix();
   c=color(i,128,255);
   
     // draw shape with custom color
     s.disableStyle();
     fill(c);
     shape(s, 0, 0);
   
   popMatrix();
 }
}


}



this is the Shape3D class

Code:

import processing.core.PGraphics;
import processing.core.PShapeSVG;
import processing.xml.XMLElement;

class Shape3D extends PShapeSVG {

 String id;  
 float depth;

 Shape3D(String _id, XMLElement xml) {
   super(null, xml);
   parsePath();  //  create vertices
   id = _id;
 }
 
 public void draw(PGraphics g) {
 
   // draw bottom
   quickDraw(g);
   
   if(depth > 0) {  
     
     // draw top
     g.pushMatrix();
     g.translate(0, 0, depth);
     quickDraw(g);
     g.popMatrix();
     
     // draw side faces
     g.beginShape(QUAD_STRIP);
     for(int i=0; i<vertexCount; i++) {
       float[] v = vertices[i];
       g.vertex(v[0], v[1], 0);
       g.vertex(v[0], v[1], depth);
     }
     g.endShape();
   }
   
 }
 
 // quick and dirty - no curves just straight lines
 public void quickDraw(PGraphics g) {
   g.beginShape();
   for(int i=0; i<vertexCount; i++)
     g.vertex(vertices[i][0], vertices[i][1]);
   g.endShape();
 }

}




actually this is a example which i found in some site. i tried to increase the screen resolution. but it didnt work.

any suggestions ?
Re: can't set size(1024,728 )
Reply #1 - Dec 27th, 2009, 5:01am
 
i changed the mode from P3D to P2D then its working. but i want the 3D mode.
is there any screen size limitation when using P3D. ?
Re: can't set size(1024,728,P3D )
Reply #2 - Dec 27th, 2009, 5:10am
 
I don't know of any, but you could also try OPENGL mode.
Re: can't set size(1024,728,P3D )
Reply #3 - Dec 27th, 2009, 5:29am
 
im using eclipse..  tried to configure OPENGL. but couldnt .. gives alot of errors..
Re: can't set size(1024,728,P3D )
Reply #4 - Dec 27th, 2009, 10:31am
 
I tried OPENGL mode also same result.. cant increase the height more than 670 . .
but this time since i specified the source of the jogl.jar it shows me the error
it is
   throw new GLException("Can not destroy context while it is current");

is it becos of ubuntu ?
Re: can't set size(1024,728,P3D )
Reply #5 - Dec 28th, 2009, 10:17am
 
i tried various methods to gt this done
i ws using eclipse+ubuntu
i couldnt set height >670

i tried using eclipse+windows 7
i could set a max height of  707

but in both OS s when i tried the same example using PROCESSING IDE.. it worked for any size

pretty confusing Sad

for now decided to use windows 7 and continue my project
Re: can't set size(1024,728,P3D )
Reply #6 - Dec 30th, 2009, 11:08am
 
found the answer
http://processing.org/discourse/yabb2/num_1262185526.html#4
Page Index Toggle Pages: 1