Loading...
Logo
Processing Forum
robbby's Profile
25 Posts
44 Responses
0 Followers

Activity Trend

Last 30 days
Show:
Private Message
    My assumption is that the lattice modifier uses the edges of the mesh to make the lattice.  I'm wondering if there's a way to give the modifier a list of lines(all connected) and derive a lattice structure from them.  My aim is to build a structure in wire-frame, make a lattice, smooth it and export it as an STL file.  Any ideas?
    I'm using processing 1.5 in Win XP and I've started to get some strange errors:
    The type toxi.geom.Mesh3D cannot be resolved. It is indirectly referenced from required.class files

    I know there's nothing wrong with the sketch, it's direct from Toxi (posted here) and I'm using the latest library (0020)
    any ideas what I might be doing wrong?
    PixelBender is a great implementation for Adobe products, I'm wondering if anyone has made a translater to use it with processing.  I think that would be awesome.  I know Processing can do anything PB can do, but being able to make and use plugins would be great
    I've found the wiki article... http://wiki.processing.org/w/Saving_files_to_a_web-server
    It wants a byte array.
    I've got an example code from Toxi..

    .import toxi.geom.*;
    import toxi.geom.mesh.*;

    void setup() {
      // define a rounded cube using the SuperEllipsoid surface function
      SurfaceFunction functor=new SuperEllipsoid(0.3,0.3);
      SurfaceMeshBuilder b = new SurfaceMeshBuilder(functor);
      // execute the mesh (resolution=80, radius=100)
      TriangleMesh mesh = (TriangleMesh)b.createMesh(null, 80, 100);
      // attempt to create a FileOutputStream and save to it
      try {
        String fileID="superellipsoid-"+(System.currentTimeMillis()/1000);
        FileOutputStream fs;
        fs=new FileOutputStream(sketchPath(fileID+".stl"));
        mesh.saveAsSTL(fs);
        fs=new FileOutputStream(sketchPath(fileID+".obj"));
        mesh.saveAsOBJ(fs);
      }
      catch(Exception e) {
        e.printStackTrace();
      }
      exit();
    }

     which gives me a FileOutputStream.  How would I convert the FileOutputStream into a byte array so that I can save it to my server?  Or, is there a better way?
    I'm wondering if there's a library for Processing that will help me efficiently triangulate the area inside a blob.  I want to detect a blob( there are libraries for that) and then create a triangle network that will keep the curve of the blob outline smooth.  I hope I'm being clear enough.
    Using the controlP5 library, I'm having trouble.  The sliders work alone, as do the radio buttons; But I can't get them to play together: I get this error message....



    Jan 19, 2011 11:34:34 PM controlP5.ControlBroadcaster printMethodError
    SEVERE: An error occured while forwarding a Controller value
     to a method in your program. Please check your code for any
    possible errors that might occur in this method .
     e.g. check for casting errors, possible nullpointers, array overflows ... .
    method: controlEvent
    exception:  java.lang.reflect.InvocationTargetException


    From this code...


    void drawGUI(){
     controlP5 = new ControlP5(this);
      controlP5.addSlider("turnup",-5.0,5.0,0,10,140,10,200);//.setId(2);
      Slider s1 = (Slider)controlP5.controller("turnup");
      s1.setSliderMode(Slider.FLEXIBLE);
      controlP5.addSlider("turnside",-5.0,5.0,0,30,110,200,10);//.setId(3);
      Slider s2 = (Slider)controlP5.controller("turnside");
      s2.setSliderMode(Slider.FLEXIBLE);
      controlP5.addSlider("linewidth",3.0,10.0,6.0,260,20,50,10);//.setId(4);
      Slider s3 = (Slider)controlP5.controller("linewidth");
      s3.setSliderMode(Slider.FLEXIBLE);

     r = controlP5.addRadioButton("radioButton",260,35);
      r.setColorForeground(color(120));
      r.setColorActive(color(255,0,0));
      r.setColorLabel(color(255));
      r.setItemsPerRow(3);
      r.setSpacingColumn(40);

      addToRadioButton(r,"Black",1);
      addToRadioButton(r,"Gray",2);
      addToRadioButton(r,"Erase",3);
      addToRadioButton(r,"Lt_Gray",4);
      addToRadioButton(r,"Dk_Gray",5);
    }


    void addToRadioButton(RadioButton theRadioButton, String theName, int theValue ) {
      Toggle t = theRadioButton.addItem(theName,theValue);
      t.captionLabel().setColorBackground(color(80));
      t.captionLabel().style().movePadding(2,0,-1,2);
      t.captionLabel().style().moveMargin(-2,0,0,-3);
      t.captionLabel().style().backgroundWidth = 36;
    }


    void controlEvent(ControlEvent theEvent) {
      for(int i=0;i<theEvent.arrayValue().length;i++) {
       print(int(theEvent.group().arrayValue()[i]));
     }
      println("\t "+theEvent.value());
     
    }
    I'm working on a sketch that requires P3D, I need a menu but fonts do badly in P3D.  I'd like to put my controlP5 components in an offscreen buffer and draw the buffer to the main sketch but I can't figure out how this might be accomplished.  Any ideas?
    I'm working on a sketch in which I must compare a series of points against a series of line segments and determine if the points lie within x distance of the lines, or not. I'm having trouble with the math.  I'm guessing that many of you have solved this efficiently, any help is greatly appreciated.
    I'm still fairly new at processing and even newer at 3D object creation.  I've successfully created a 3d mesh in processing.  I now want to apply some modifiers using the HEMESH library.  The library uses HEMESH objects and has a method to create these objects from ordinary meshes.  The javadocs say that  HEC_FromSimpleMesh Creates a new mesh from a list of vertices and faces.  Here is the method:

    public HEC_FromSimpleMesh setSource(wblut.geom.WB_SimpleMesh simpleMesh)

        Set simpleMesh source

        Parameters:
            simpleMesh - source
        Returns:
            self


    My problem is that I don't know what format to use in setSource.  Should I use a mesh object, a 2d array, 2 arrays....I just don't know.

    I would appreciate any help.

    Using 1.2.1 on a pc with XP I'm trying to run the included PDF sketches in the examples folder and get these error messages:
     You need to use "Import Library" to add processing.pdf.PGraphicsPDF to your sketch.
    cannot find a class or type named :PGraphicsPDF"

    Is this a problem with my installation or something else?  Anyone else having this problem?
    I'm hoping someone has already done the math on this one.  I know that it can't be solved perfectly, but close would be nice. Suppose I have a sphere, it's covered in square pixels.  At the equater there might be 360, at the pole 3.  Now I want to address each pixel in a 2-dimensional array so that I can calculate a reaction-diffusion equation on the surface of a sphere.  This equation requires consulting adjoining pixels. Can anyone give me a place to start, my math is very weak.
    I can't find the error here!


    import processing.dxf.*;
    import controlP5.*;
    import peasy.org.apache.commons.math.*;
    import peasy.*;
    import peasy.org.apache.commons.math.geometry.*;
    import processing.opengl.*;
    import traer.physics.*;
    import javax.media.opengl.*;
    import nervoussystem.obj.*;

    GL gl;
    PGraphicsOpenGL pgl;
    PGraphics mySave;
    float fMag = .05;
    float K = .2;
    float D = 1.5;
    float rest = .3;
    float tick = .1;
    float scaler = 5;
    int controlHeight = 500;
    int controlWidth = 200;
    //data structures
    ParticleSystem pSys = new ParticleSystem(0,.25);
    Spring[] springs = new Spring[0];
    ArrayList forces = new ArrayList();
    MyParticle[] particles = new MyParticle[0];
    Spring[] springs2 = new Spring[0];
    MyParticle[] particles2 = new MyParticle[0];
    ControlP5 cp5;
    ControlGroup menu;

    //all have to be even
    int x_divs = 22;//14 //30 radial divisions on inside and outside
    int y_divs = 8; // 6 vertical divisions outside
    int y_divs2 = 10; //vertical divisions inside

    MyParticle grid[][];
    MyParticle grid2[][];

    Face faces[] = new Face[0];
    Face faces2[] = new Face[0];

    ArrayList shape_outline = new ArrayList();

    PGraphics3D pg;

    //initial ring shape in mm
    //small 35.2
    //medium 35.65
    //large 38.32
    float rad = 38.32;//10 //18
    float prad = rad;
    float minZ = -15;
    float maxZ = 15; // 30 35
    float pmaxZ = maxZ;

    //to deform boundarys
    float amp1 = 0;//8
    float amp2 = 0;//8
    float pamp1 = amp1;
    float pamp2 = amp2;
    float phase = 0;
    float pPhase = phase;
    float phase2 = PI/2;
    float pPhase2 = phase2;
    int freq1 = 2;
    int freq2 = 2;//1
    int pFreq1 = freq1;
    int pFreq2 = freq2;//1
    float pow1 = 2;
    float pPow1 = pow1;
    float pow2 = 2;

    int twist = 0;
    float cTwist = 0;
    float pTwist = 0;

    float thickness = 2.55; //thicknesss of biggest members 2.05
    float minThick = 1.0;
    //donut control, smaller less donuty
    float rScale=.5; //outside 1
    float rScale2=.5; //inside .5
    float rSep = 3; //separation between two layers
    int maxGen = 3; //max number of subdivisions
    //variables

    boolean paused = false;
    boolean record = false;
    int view = 0;
    boolean preview = false;
    boolean build = false;
    boolean drawDimensions = true;

    float view_offset=0;
    PeasyCam camera1;
    boolean cameraListen = true;
    String[] output;
    int outLine = 0;
    runPSys rps;
    color bg; //background color

    float meshVolume = 0;
    float price = 0;
    float innerDiameter = 0;
    float outerDiameter = 0;
    float totalHeight = 0;
    PVector appCenter = new PVector();

    PFont mFont;

    String saveFile = "";
    void setup() {
    In using Traer physics, I want to add two integer values to class particle and be able to access them but I don't know how; can someone help me.
    Here is the source: particle.java


    package traer.physics;

    public class Particle
    {
      protected Vector3D position;
      protected Vector3D velocity;
      protected Vector3D force;
      protected float mass;
      protected float age;
      protected boolean dead;
     
      boolean fixed;
       
      public Particle( float m )
      {
          position = new Vector3D();
          velocity = new Vector3D();
          force = new Vector3D();
          mass = m;
          fixed = false;
          age = 0;
          dead = false;
      }
     
      /* (non-Javadoc)
     * @see traer.physics.AbstractParticle#distanceTo(traer.physics.Particle)
     */
    public final float distanceTo( Particle p )
      {
          return this.position().distanceTo( p.position() );
      }
     
      /* (non-Javadoc)
     * @see traer.physics.AbstractParticle#makeFixed()
     */
    public final void makeFixed()
      {
          fixed = true;
          velocity.clear();
      }
     
      /* (non-Javadoc)
     * @see traer.physics.AbstractParticle#isFixed()
     */
    public final boolean isFixed()
      {
          return fixed;
      }
     
      /* (non-Javadoc)
     * @see traer.physics.AbstractParticle#isFree()
     */
    public final boolean isFree()
      {
          return !fixed;
      }
     
      /* (non-Javadoc)
     * @see traer.physics.AbstractParticle#makeFree()
     */
    public final void makeFree()
      {
          fixed = false;
      }
     
      /* (non-Javadoc)
     * @see traer.physics.AbstractParticle#position()
     */
    public final Vector3D position()
      {
          return position;
      }
     
      public final Vector3D velocity()
      {
          return velocity;
      }
     
      /* (non-Javadoc)
     * @see traer.physics.AbstractParticle#mass()
     */
    public final float mass()
      {
          return mass;
      }
     
      /* (non-Javadoc)
     * @see traer.physics.AbstractParticle#setMass(float)
     */
    public final void setMass( float m )
      {
          mass = m;
      }
     
      /* (non-Javadoc)
     * @see traer.physics.AbstractParticle#force()
     */
    public final Vector3D force()
      {
          return force;
      }
     
      /* (non-Javadoc)
     * @see traer.physics.AbstractParticle#age()
     */
    public final float age()
      {
          return age;
      }
     
      protected void reset()
      {
          age = 0;
          dead = false;
          position.clear();
          velocity.clear();
          force.clear();
          mass = 1f;
      }
    }
    my math visualization skills are shaky, I'm hoping someone can help me out.

    the problem: I have have a 3D shape I've built on the x-y plane and I have a truncated cone whose axis is z.  I want to wrap the 3D object around the cone.
    I assume that I'll want to normalize the u-v of both the object and the cone.  Then convert the object vertex and face coordinates to u-v-w vectors.  Then, I'll want to copy those vertexes and faces in relation to the cone surface, allowing for the spread resulting from the curved surface and render them in world coordinates.  Is that about right?
    Can someone help me with the math? Especially allowing for the spread due to the curve.
    OK, I have a question and I'm not sure I can even ask it properly.  I'm pretty new at processing and deficient in 3D math.  Imagine I had line emanating from 0,0,0 and then a spiral from the end...that's not hard.  Now, imagine I had a series of these, lets say 12 so that each passed through the center of a face of a dodecahedron.  I don't know, to what or how to orient the vectors so that the spirals will be uniform; that is, so they will intersect a corner of each's pentagon uniformly.  Does the question make sense to anyone?  Can anyone help?
    I'm using the supplied example DropFilesAndFolders.pde
    the way I'm reading it, myFile should be an array with the names of the files in the directory I dropped onto the sketch but I can't access it as an array; myFile.length() returns 0.0.;
    I'd like an array of the filenames so that I can work with the files.  Any ideas?




    /**
     * DropFilesAndFolders demonstrates how to access the information of
     * a file or folder that has been dragged into the sketch.
     * code by andreas schlegel. http://www.sojamo.de/libraries/drop
    */
    import sojamo.drop.*;

    SDrop drop;

    void setup() {
      size(400,400);
      drop = new SDrop(this);
    }

    void draw() {
    background(0);
    }


    void dropEvent(DropEvent theDropEvent) {
      if(theDropEvent.isFile()) {
        // for further information see
        // http://java.sun.com/j2se/1.4.2/docs/api/java/io/File.html
        File myFile = theDropEvent.file();
        println("\nisDirectory ? "+myFile.isDirectory()+"  /  isFile ? "+myFile.isFile());
        if(myFile.isDirectory()) {
          println("listing the directory");
         
          // list the directory, not recursive, with the File api. returns File[].
          println("\n\n### listFiles #############################\n");
          println(myFile.listFiles());

         
          // list the directory recursively with listFilesAsArray. returns File[]
          println("\n\n### listFilesAsArray recursive #############################\n");
          println(theDropEvent.listFilesAsArray(myFile,true));
         
         
          // list the directory and control the depth of the search. returns File[]
          println("\n\n### listFilesAsArray depth #############################\n");
          println(theDropEvent.listFilesAsArray(myFile,2));
        }
      }
    }

    I've run into this several times trying to use and understand other people's code.  Since the code was posted, I assume it used to work, but won't now.  What does this mean and how can I fix it?


    /**
     * a very light wrapper around a PImage that tracks the mouse
     */
    class MouseImage {
      PImage img;
      MouseImage(String filename) {
        img = loadImage(filename);
      }
      void draw() {
        translate(mouseX-img.width/2f, mouseY-img.height/2f, 0.1f);
        image(img, 0, 0);
      }
    }

    I'm still very new at processing, but I've been learning from you all.
    what I want to do is import an object into volumetric space.  I then want to create an array corresponding to that volumetric space; setting each array element to either 1 or 0, depending on whether the model is present at that point in volumetric space.  I don't know how to test whether a point is inside a model.  Help would be appreciated.
    I'm still new to Processing, but I'm learning from people at the forum.
    I've written a sketch and With Toxi's help, it now creates an STL.  I'd like to make it an applet and save the STL to my server, is that possible?  You've helped me learn to save image files, I can do that, but a data(STL) how can we do that?