Loading...
Logo
Processing Forum
sachaamm's Profile
44 Posts
49 Responses
0 Followers

Activity Trend

Last 30 days
Show:
Private Message
    PGraphics can only use native Processing method or i can implerments method from my own classes  on it?
    How i can implements own class method on it? 

    More precisely, I want to use HE Mesh library to draw meshs on P3D Graphics.
    So how i can assimilate the drawing of meshes to the pGraphics render?

    Any hint is welcome ! 
    Thank for your help


    Sacha


    hi,
    i want to use simple openni in processing 2.0. get kinect sdk 1.0 in my computer
    i get this error message :

    java.lang.UnsatisfiedLinkError: C:\Users\Alexandre\Documents\Processing\libraries\SimpleOpenNI\library\win64\OpenNI2.dll: %1 is not a win32 valid application

    anyone get ideas about how i can solve it and tell me more about this error message meaning?

    cheers
    Hi ! 

    I try to use copy() with PGraphics. 
    My main idea will be to share the screen displayed as a PImage 
    I solved it with save() and saveFrame() and after using the frame saved. But the compression destroy the quality of the image.


    the best will be to store it directly in a PGraphics.

    I tried to use copy in the first way : 

    copy(sx, sy, sw, sh, dx, dy, dw, dh)
    but i can't solve the use of this copy, 
    i use a very simple code using PGraphics without succes
    PGraphics pg; PGraphics ph; PImage img; void setup() { size(100, 100); pg = createGraphics(40, 40); ph=createGraphics(40, 40); } void draw() { pg.beginDraw(); pg.background(100); pg.stroke(255); pg.line(20, 20, mouseX, mouseY); pg.endDraw(); image(pg, 9, 30); ph.beginDraw(); ph.copy(9, 30, 40, 40, 51, 30, 40, 40); ph.endDraw(); image(ph, 51, 30); }
    

    the second pgraphics doesnt appeears so i conclude the copy() method is inefficient.
    Could you give me some hints to understand how use copy() in a efficient way to store the screen in a PGraphics?

    Thx in advance 
    Sacha

    Hi
    I'm making an interactive map using wikimedia world map empty.
    The svg file is 1.5 mb size, and when i use the basic method loadShape(); and shape() in draw my sketch turn around 10 fps...

    I tried also to use p8 graphics svg library builded by philho but i get 404. Does the library stay availble?
    Do you have any advices to get the fastest efficient way to display svg map?


    EDIT: the library stay available by this link http://phi.lho.free.fr/programming/Processing/P8gGraphicsSVG/
    the link is dead in the library main processing page


    Thanks in advance
    Hi processing
    I work on a basic code to check if one string exist in on other.
    i made one sketch working just the two strings begins with the same chars.
    I know a bit regex, but not enough to solve my problem.
    what i want is :

    check if one string contains an other AND at which index ( how use regex to solve it? )
    i want to override some specific part at one specific index of a string
    i can take the example

    String s = "Inside tags, you will find <tag>multiple</tag> ";
    s += "<tag>pieces</tag> of <tag>content</tag>.";
    String[][] m = matchAll(s, "<tag>(.*?)</tag>");
    for (int i = 0; i < m.length; i++) {
      println("Found '" + m[i][1] + "' inside a tag.");
    }



    how can I delete outside from the < and > char?
    I know there is a lot of questions, but i work so hard and
     now i really need help.Thx!



    hi

    i'm dissapointed of my misunderstanding, i start with he_mesh powerful library and i try maybe the simplest custom example
    i use render.drawSegment but nothing appears on the screen

    /////


    import wblut.math.*;
    import wblut.processing.*;
    import wblut.core.*;
    import wblut.hemesh.*;
    import wblut.geom.*;

    import processing.opengl.*;


    WB_Render render;
    WB_ExplicitSegment segment;


    void setup() {
      size(600, 600, OPENGL);

      segment = new WB_ExplicitSegment(0, 0, 0, 100, 100, 0);

      render=new WB_Render(this); 
    }

    void draw() {


      render.drawSegment(segment);
    }



    ////

    Best regards
    Hello guys

    can i use a string as an execution to process?
    obviously i can use a string in processing used function like this:

    void imageBank(String index, int filecount) {
      

     images= new PImage[filecount];
    for ( int i = 10; i< images.length; i++ ){
    images[i] = loadImage(index + (i+1) + ".jpg" ); 


    }

    but i ask if i can call processing function in a string as an individual execution:

    like this: 

      String str = "rect(50,50,50,50);";   str; // use str to call the rect method

     it's a so basic example so maybe it appears stupid to you  , i try to use the fastest and the simplest way to illustrate my question


    i wait patiently to your answers

    Cheers
                         
    Hello

    can i use curvevertex in a pshape?

    the getVertexCount doesnt recognize curveVertex as a vertex in a pshape.
    i can set curveVertex in a pshape but it didnt affect the pshape

    i want to build smooth textures.
    i use beziervertex in a texture and it still work but can i access and modify the curve of a vertex in using 
    setVertex method in draw?
    because the getVertexcount method reveals that a bezierVertex store 20 vertices in a pshape

    thanks so much for your answers
    hi Processing, 
    since few days i get a serious problem i can't run any sketch of processing 1.5.1
    i think it's about a 32 bit java version missing but i get Java 7 update 13 in my computer...
    i try to unistall processing 1.5.1 and redownload it but the problem stay

    the problem is the same with 2.0b7 and 2.0 b8


    may you give me some help?
    thanks in advance.

    Oh, i show the error message if it could help you:

    /////////////////

    com.sun.jdi.connect.VMStartException: VM initialization failed for: java -Xrunjdwp:transport=dt_shmem,address=127.0.0.1:8561,suspend=y -Xms64m -Xmx3200m -Djava.library.path=;C:\Users\Alexandre\processing-1.5.1\java\bin;.;C:\Windows\system32;C:\Windows;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0;C:\Program Files (x86)\PrimeSense\NITE\bin;C:\Program Files (x86)\MySQL\MySQL Server 5.5\bin;C:\Program Files (x86)\Git\cmd;C:\Program Files (x86)\OpenNI\Bin;C:\Program Files (x86)\QuickTime\QTSystem;C:\Program Files (x86)\OpenCV\bin;C:\Users\Alexandre\processing-1.5.1\java\bin -cp C:\Users\ALEXAN~1\AppData\Local\Temp\utiliser_map_pour_rotate7082953574206273544temp;lib;C:\Users\Alexandre\processing-1.5.1\java\lib\tools.jar;lib\pde.jar;lib\core.jar;lib\jna.jar;lib\ecj.jar;lib\antlr.jar;lib\ant.jar;lib\ant-launcher.jar;C:\Program Files (x86)\QuickTime\QTSystem\QTJava.zip -ea processing.core.PApplet --editor-location=760,290 --external --display=0 --sketch-path=C:\Users\Alexandre\Documents\Processing\utiliser_map_pour_rotate utiliser_map_pour_rotate
    at com.sun.tools.jdi.AbstractLauncher$Helper.launchAndAccept(AbstractLauncher.java:174)
    at com.sun.tools.jdi.AbstractLauncher.launch(AbstractLauncher.java:114)
    at com.sun.tools.jdi.RawCommandLineLauncher.launch(RawCommandLineLauncher.java:100)
    at processing.mode.java.runner.Runner.launchVirtualMachine(Runner.java:315)
    at processing.mode.java.runner.Runner.launch(Runner.java:118)
    at processing.mode.java.JavaMode$1.run(JavaMode.java:181)
    at java.lang.Thread.run(Thread.java:662)
    Could not run the sketch (Target VM failed to initialize). // What's Target VM???



    Hello guys

    just one question : im in trouble with the createShape function (void)
      createShape();

    i call an pshape array
    PShape[] test = new PShape [20];
    in a class 
    class ShapeClass
    when i assign vertex to a custom PShape created from the PShape array i can't only initialise in the class the createShape function like this:



    class Ball {
      float x;
      float y;
      float w;
      float h;


      final float fx=0;
      final float fy=0;

      int index = 0;
      PShape[] test = new PShape[8] ;

      Ball(float tempX, float tempY, float tempW, float tempH, int index_) {
        x = tempX;
        y = tempY;
        w = tempW;
        h = tempH;
        index = index_;
      }


      void initShape() {
        for (int i = 0; i<8; i++) { 
          test[i] = createShape();
          test[i].fill(0);
        }
      }



      void setShape(int currentNombre, boolean start) {


        currentNombre = index+1;
        println(currentNombre);




        for (int i=0; i<currentNombre; i++) {


          if (currentNombre>= 0) {
            //test[currentNombre]=createShape();
            test[currentNombre].vertex(this.x, this.y);
            test[currentNombre].vertex(this.x+20, this.y);
            test[currentNombre].vertex(this.x+20, this.y+20);
            test[currentNombre].vertex(this.x, this.y+20);
          }
          test[currentNombre].end(CLOSE);
          shape(test[currentNombre]);
        }
      }





    i call initshape() in void setup() and setShape() in void draw(); but it still doesn't work : i get a NPE...
    Need I use createShape() in each frame?

    So i can't assign createShape to my pshape array in void setup()? This is a serious issue because he burns so much memory ...



    Please, I need your help sir
    Thanks in advance.
    Hello Processing,
    i know this title could seem to be confused but i want to build a simply origami sketch builder.
    For this action, i try to use bassicly setVertex powerfull method assigned to a texture with an array of selection objects.

    The difficulty will be like this:
    I need to assign setVertex method to the selected object from my array by mousePressed.
    This explanation coulnd't be sufficient so there is my short sketch:


    PShape test;
    int Ax, Ay, Aw, Ah;
    Control[] Rect;

    void setup() {
      size(800, 500, P3D);

      PImage tex = loadImage("333.jpg");


      Rect = new Control[3];


      Ax=120-25;
      Ay=120-5;
      Aw=Ah=25;

      test = createShape();
      test.noStroke();
      test.texture(tex);
      test.tint(255);
      test.vertex(120, 120, 0, 0, 0);
      test.vertex(width-20, 120, 0, tex.width, 0);
      test.vertex(width-20, height-20, 0, tex.width, tex.height);
      test.vertex(120, height-20, 0, 0, tex.height);

      test.end(); 


      for (int i = 0; i<3;i++) {
        Rect[i] = new Control(120+int(random(width-240)), 120+int(random(height-240)));
      }
    }

    void draw() {

      background(255); 



      for (int i = 0; i<3;i++) {

        Rect[i].Check(test);
        Rect[i].display();
      }


      //  for(Control control : Rect){

      // control.display();

      // }

      pushStyle();
      noFill();
      rect(Ax, Ay, Aw, Ah);
      popStyle();  




      if (keyPressed&&key=='1') {
        Rect[1] = new Control(mouseX, mouseY);
      }


      if (pressA()) {
        Ax = mouseX-10;
        Ay=mouseY-10;
        test.setVertex(0, mouseX, mouseY, 0);
      }


      shape(test);
    }

    boolean  pressA() {
      if (mousePressed&&mouseX>Ax&&mouseY>Ay&&mouseX<Ax+Aw&&mouseY<Ay+Ah) {
        return true;
      }
      else {
        return false;
      }
    }


    class Control {

      int mx;
      int my;

      Control(int mx_, int my_) {

        mx=  mx_;
        my = my_;
      }



      boolean Check(PShape test) {
        int Rectselected = 1;
        if (mousePressed&&mouseX>this.mx&&this.mx+25>mouseX&&mouseY<this.my+25&&this.my<mouseY) {
          this.mx=mouseX-10;
          this.my=mouseY-10;
          test.setVertex(Rectselected, mouseX-10, mouseY-10, 0);// there is the problem I need to be able at this point to explain to Processing which Rect[] is selected
          return true;
        }
        else {
          return false;
        }
      }

      void display() {
        noFill();
        stroke(255, 0, 0);
        rect(mx, my, 25, 25);
      }
    }


    Thanks in advance 



    A basic question but i don't know it. 
    the example is simple:



    Car myCar;


    void setup() {
      size(300, 300);

      myCar = new Car();
    }

    void draw() {  
      myCar.test();

      println(test);
    }


    class Car {


      int test() {
        background(0);
        return 180;
      }
    }

    do yoy know how i could return my value outside of my class?
    thanks in advance :)
    hello
    there is a fragment from simple open ni library example : alternative 3d viewpoint.
    In this , i simply want to use the nearest 3d point value from the kinect.
    ------------------------------------------

      PImage  rgbImage = context.rgbImage();
      int[]   depthMap = context.depthMap();
      int     steps   = 3;  // to speed up the drawing, draw every third point
      int     index;
      PVector realWorldPoint;
      color   pixelColor;
     
      strokeWeight(steps);

      translate(0,0,-1000);  // set the rotation center of the scene 1000 infront of the camera

      PVector[] realWorldMap = context.depthMapRealWorld();
      for(int y=0;y < context.depthHeight();y+=steps)
      {
        for(int x=0;x < context.depthWidth();x+=steps)
        {
          index = x + y * context.depthWidth();
          if(depthMap[index] > 0)
          { 
            // get the color of the point
            pixelColor = rgbImage.pixels[index];
            stroke(pixelColor);
            
            // draw the projected point
            realWorldPoint = realWorldMap[index];
            point(realWorldPoint.x,realWorldPoint.y,realWorldPoint.z);
          
            // make realworld z negative, in the 3d drawing coordsystem +z points in the direction of the eye
         println(max(realWorldPoint.z));


        }
        }
      } 

      // draw the kinect cam
      context.drawCamFrustum();
    }

    ---------------------

    i use realWorldPoint in this case, but realWorldPoint is a PVector array.
    max using is for float[] and int[] , i can't use it with realWorldPoint.z ? realWorldPoint.z is a float array, isn't it?

    thanks for your attention
    hello
    i learn to use simple openNi library but i can't run example "User" "User3D" "User callback" etc...
    i get this error message:
    runtime error!
    Program:...p/processing-1.5.1/java/bin/java.exe

    this application has requested the Runtime to terminate it in an usual way.
    Please contact the application's support team for more information."

    so it's maybe a wrong version of my microsoft visual c++??
    i run on windows 7 64bit+ processing 1.51 open ni 1.5.4 nite 1.3.0 + microsoft visual c++ 2010 x86
              
    thanks
    hi,

    I got a Kinect and i would test the examples from the contributed library simpleopenNI but i can't run any examples.
    I got the same message error:

    I got on my computer openNI 1.0.0 for windows(remove only), Prime Sense package+ drivers for kinect : i can run the openNi test application like (simpeNiviewer) the kinect got the green light turning on. 
    I give you the error message, it could be explain my misunderstanding:

    Exception in thread "Animation Thread" java.lang.UnsatisfiedLinkError: SimpleOpenNI.SimpleOpenNIJNI.swig_module_init()V
      at SimpleOpenNI.SimpleOpenNIJNI.swig_module_init(Native Method)
      at SimpleOpenNI.SimpleOpenNIJNI.<clinit>(SimpleOpenNIJNI.java:1575)
      at SimpleOpenNI.ContextWrapper.<init>(ContextWrapper.java:54)
      at SimpleOpenNI.SimpleOpenNI.<init>(SimpleOpenNI.java:212)
      at AlternativeViewpoint3d.setup(AlternativeViewpoint3d.java:44)

    thank you
    hi,
    I got a Kinect and i would test the examples from the contributed library simpleopenNI but i can't run any examples.
    I got the same message error:

    I got on my computer openNI 1.0.0 for windows(remove only), Prime Sense package+ drivers for kinect : i can run the openNi test application like (simpeNiviewer) the kinect got the green light turning on. 
    I give you the error message, it could be explain my misunderstanding:

    Exception in thread "Animation Thread" java.lang.UnsatisfiedLinkError: SimpleOpenNI.SimpleOpenNIJNI.swig_module_init()V
      at SimpleOpenNI.SimpleOpenNIJNI.swig_module_init(Native Method)
      at SimpleOpenNI.SimpleOpenNIJNI.<clinit>(SimpleOpenNIJNI.java:1575)
      at SimpleOpenNI.ContextWrapper.<init>(ContextWrapper.java:54)
      at SimpleOpenNI.SimpleOpenNI.<init>(SimpleOpenNI.java:212)
      at AlternativeViewpoint3d.setup(AlternativeViewpoint3d.java:44)

    thank you
    can i convert a dynamic value in a final value?
    In this case, i try with a basic example ( based on arraylist class example) i just want to , when using keyPress event lock the dimensions of the rect: so i need to change the constructor value x and y into final values.
    Maybe there are other ways to lock these values, using an array or something like that, i think it's a problem of formulation

    error message is : "the final field arraylistclassball cannot be assigned"

    ----------------------------------------

    ArrayList balls;
    int ballWidth = 48;

    void setup() {
      size(200, 200);
      smooth();
      noStroke();


      balls = new ArrayList();
      

      balls.add(new Ball(width/2, 0, ballWidth));
    }

    void draw() {
      background(255);


      for (int i = balls.size()-1; i >= 0; i--) { 
       
        Ball ball = (Ball) balls.get(i);
       
        
        ball.display();
      
      }  
      
    }

    void mousePressed() {
      
      balls.add(new Ball(mouseX, mouseY, ballWidth));
    }

    class Ball {
      
      float x;
      float y;

      float w;

      final float fx=0;
      final float fy=0;
      
      Ball(float tempX, float tempY, float tempW) {
        x = tempX;
        y = tempY;
        w = tempW;
       
      }
      

      
      void fix(){
        if(keyPressed){fx=this.x;fy=this.y; this.x=fx; this.y=fy;}        //CRASH
      }
      
     
      
      void display() {

        fill(0);

        rect(x,y,mouseX,mouseY);
      }
    }  

    hello

    i saw a recent code replied by amnon owed 
    it's:

    1. int gridDim = 15;
    2. int numCharges = 3;
    3. float maxStrengthPerCharge = 100/numCharges;
    4. ArrayList <Vector> field = new ArrayList <Vector> ();
    5. ArrayList <Electron> charges = new ArrayList<Electron>();
    6. float value;
    7.  
    8. void setup() {
    9.   size(600, 600);
    10.   smooth();
    11.   strokeWeight(0.5);
    12.   int w = width/gridDim;
    13.   int h = height/gridDim;
    14.   for (int y = 0; y<gridDim; y++) {
    15.     for (int x = 0; x<gridDim; x++) {
    16.       field.add(new Vector((x+0.5)*w, (y+0.5)*h));//ARRAY OF GRID POINTS
    17.     }
    18.   }
    19.   charges.add(new Electron(400, 400, 20));
    20.   charges.add(new Electron(200, 300, 20));
    21.   charges.add(new Electron(500, 200, 20));
    22. }
    23.  
    24. void draw() {
    25.   background(255);
    26.   for (Electron e : charges) { e.display(); }
    27.   for (Vector v : field) { v.update(); }
    28.   for (Vector v : field) { v.display(); }
    29.   value = 0.5+sin(frameCount*0.01);
    30. }
    31.  
    32. class Electron {
    33.   PVector pos;
    34.   float charge;
    35.  
    36.   Electron(float x, float y, float charge) {
    37.     pos = new PVector (x, y);
    38.     this.charge=charge;
    39.   }
    40.  
    41.   void display() {
    42.     pushMatrix();
    43.     translate(pos.x, pos.y);
    44.     noStroke();
    45.     fill(0);
    46.     ellipse(0, 0, charge, charge);
    47.     popMatrix();
    48.   }
    49. }
    50.  
    51. class Vector {
    52.   PVector pos, dir, fin;
    53.  
    54.   Vector(float x, float y) {
    55.     pos = new PVector(x, y);
    56.     dir = new PVector();
    57.   }
    58.  
    59.   void update() {
    60.     dir.set(0, 0, 0);
    61.     for (Electron e : charges) {
    62.       PVector currentDir = e.pos.get();
    63.       float magnitude = map(currentDir.dist(pos), 0, width, maxStrengthPerCharge, 0);
    64.       currentDir.sub(pos);
    65.       currentDir.normalize();
    66.       currentDir.mult(magnitude);
    67.       dir.add(currentDir);
    68.       dir.mult(value);
    69.       fin = PVector.add(pos, dir);
    70.     }
    71.   }
    72.  
    73.   void display() {
    74.     fill(0);
    75.     ellipse(fin.x, fin.y, 10, 10);
    76.     stroke(0);
    77.     for (Vector v : field) {
    78.       if (v.fin.dist(fin) < 50) {
    79.         line(v.fin.x, v.fin.y, fin.x, fin.y);
    80.       }
    81.     }
    82.   }
    83. }

    ///////////////////////////

    i dont know this type of formulation "    for (Electron e : charges) { "
    could you explain me how function this formulation and why we use it

    many thanks
    hi
    whats the difference in 

    class Aclass{
    int x, y;

    Aclass(int x_, int y_ ){
    x=x_;
    y=y_;

    and

    class Aclass{
    int x,y;

    Aclass(int x, int y){
    this.x = x;
    this.y = y;

    }