Quantcast
Channel: Library Questions - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 2896

Fisica library - exporting results in vector ( PDF or SVG)?

$
0
0

hello all, i am new to processing and Fisica library. i wrote a little program for simulating bodies falling on a static one. ( very simple one), the shapes are geometric SVG that i import ( using lines from an existing example). everything is working fine, at the end of the simulation i am trying to export the result to vector file ( PDF would be perfect). exporting PDF is not working and i can figure out how to do it , is there any possible solution?) i thought about solving the problem by myself, so the solution i thought about is getting the position , rotation , and scale of every existing body in the simulation and redrawing everything as polygons which will get me the same result but with the possibility of exporting to PDF this time. when i use the Fpoly.getX() in the draw loop i get a nullPointerException. so my question is : - is there a way to export to PDF in Fisica? - if not, can you help me with the coordinate thing at the end of my simulation, getX(), getY(),...

to make it simple i wrote the sketch with just one shape.

        import processing.pdf.*;

        import fisica.*;
        import geomerative.*;


        FWorld world;
        FPoly poly;

        String filename = "zel1.svg";
        RShape m_shape;
        RShape fullSvg;
        RShape outline;
        RPoint[] points;

        float xx,yy;


        void setup(){
         size(400,400);
         smooth();
         frameRate(60);
         Fisica.init(this);
         Fisica.setScale(10);
         RG.init(this);
         RG.setPolygonizer(RG.ADAPTATIVE);
         FPoly poly = new FPoly();
         world = new FWorld();
         world.setEdges(this,color(0));
         world.setGravity(0,300);
         RShape fullSvg = RG.loadShape(filename);
         RShape outline = fullSvg.getChild("outline");


         RPoint[] points = outline.getPoints();

         for (int i=0; i<points.length; i++) { poly.vertex(points[i].x, points[i].y);}


          poly.setFill(120, 30, 90);
          poly.setPosition(width/2,50);
          poly.setDensity(10);
          poly.setRestitution(0.5);



              world.add(poly);
                xx=poly.getX(); // it is working here
                println(xx);

        }

        void draw() {


          background(255);

          world.step();

          world.draw(this);
          yy=poly.getY(); // getting an NPE erro here
          xx= poly.getX();// getting an NPE erro here


        }

Viewing all articles
Browse latest Browse all 2896

Trending Articles