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

Pozyx Ready to Localize question

$
0
0

Hi,

I have been trying to run the program for the 'ready to localize' example on processing but it keeps giving me the same issues and I have no idea how to solve it.

It says 'Could not run the sketch (Target VM failed to initialize). For more information, read revisions.txt and Help ? Troubleshooting.' for the console tab and for the error tab, it says 'the value of the parameter p is not used'.

Can anyone help me with that?

Thank you! :)


Sensible to use Maxlink (with MSP) to control values within Processing 3.x sketches

$
0
0

Hi, I wish to explore interactive control of 3.x Processing sketches. Is MaxMSP a good way to go? And if it IS, is Maxlink a good way to harness it to control values within Processing sketches?

Music Play/Pause Button

$
0
0

Hey i want a Play/Pause button in my Visualizer can you help me??

import ddf.minim.*;
import ddf.minim.analysis.*;
import ddf.minim.effects.*;
import ddf.minim.signals.*;
import ddf.minim.spi.*;
import ddf.minim.ugens.*;

PImage hintergrund;

Minim minim;
AudioPlayer Player;
FFT fft;
int w;
int farbe;


void setup()
{
  size(500,300,P3D);
  minim = new Minim(this);
  Player = minim.loadFile("bla.mp3"); // Spielt die Mp3 datei ab
  Player.loop(); // Wiederholt den aktuellen Song
  fft = new FFT(Player.bufferSize(), Player.sampleRate());
  fft.logAverages(60, 7);
  stroke(255);
  w = width/fft.avgSize();
  strokeWeight(w);
  strokeCap(SQUARE);
  farbe = 0;

}

void draw()
{
  hintergrund = loadImage("hintergrund.jpg");
  image(hintergrund,0,0);

  fft.forward(Player.mix);

  colorMode(HSB);
  stroke(farbe, 255, 255);
  colorMode(RGB);

  for(int i = 0; i < fft.avgSize(); i++){
    line((i * w)*3, height/1.1, (i * w)*3, height/1.1 - fft.getAvg(i) * 0.5);

}

  farbe += 5;
  if( farbe > 255)
  {
    farbe = 0;
  }
}

This is atm my Code also i would donate a few euro if you can help me :)

2d GUI Libraries

$
0
0

My stick and circle figures for speedometers, elevations, compass, etc are getting boring. Can someone steer me to some 2d graphic libraries that I might use to make my stuff a bit fancier? I am developing a railroad monitoring system that will have a speedometer, grade, elevation, curvature, etc.

How to make sound from image?Take a photo and turn it into sound wave?

Locate tag in threedimensional space

$
0
0

Hi! I need to locate a sheet of paper. My idea was to have one or more qr-like tags on the paper and process the webcam input to find the position relative to the cam. How can I do that? Thank you all

How to make a projectile get thrown by your character like it was thrown by a slingshot?

$
0
0

Hello, I'm new here so excuse me if i do anything wrong. I'm trying to program a "Worms" like game, where you have a character in one side and you want to hit the other player in the other side of the map. I was trying to throw a projectile by clicking on my player1 body and then dragging the mouse back and releasing it so the projectile had a different angle and velocity depending on the position of the mouse in relation to the player 1 body. I'm using the box2D physiscs library in my project. If anyone could help me trying to understand how this would work i really appreciate it. Thank you.

Visualizer dont work

$
0
0

Hey i got a problem with my visualizer

When i use this code I can select a MP3 file but the Visualizer didn´t show the line and only play the Sound

  import ddf.minim.*;
  import ddf.minim.analysis.*;
  import ddf.minim.effects.*;
  import ddf.minim.signals.*;
  import ddf.minim.spi.*;
  import ddf.minim.ugens.*;
  String path;

  Minim minim;
  AudioPlayer Player;
  int farbe;
  PImage playPause;
  PImage hintergrund;

  void setup() {
    size(500,400);
    background(0);
    minim = new Minim(this);
    //Player = minim.loadFile(path); // Spielt die Mp3 datei ab
    //Player.loop(); // Wiederholt den aktuellen Song
    farbe = 0;
    smooth();
    playPause = loadImage("play3.jpg");
    hintergrund = loadImage("hintergrund2.jpg");
  }

  void selected(File song){
    path = song.getAbsolutePath();
    }

  void interrupt(){
    while (path == null){
      loop();
    }
     noLoop();
    }

  void draw()  {
    selectInput("Suche einen Song aus","selected");
    interrupt();
    background(0);
    Player = minim.loadFile(path); // Spielt die Mp3 datei ab
    Player.play();
    image(hintergrund,0,0);
    image(playPause,25,25);
    translate(width/2, height/2);
    rotate(radians(frameCount % 360 * 2));
    colorMode(HSB);
    stroke(farbe, 255, 255);
    colorMode(RGB);

    for(int j = 0; j < 360; j++){

      if(Player.mix.get(j)*200 > 50) {
        colorMode(HSB);
        stroke(farbe, 255,255);
        colorMode(RGB);
      }
      else {
        colorMode(HSB);
        stroke(farbe,255,255);
        colorMode(RGB);
      }
      line(cos(j)*100, sin(j)*100, cos(j)*abs(Player.left.get(j))*250 + cos(j)*100, sin(j)*abs(Player.right.get(j))*250 + sin(j)*100);
    }

      //for(int i = 0; i < fft.avgSize(); i++){
      //line((i * w)*3, height/1.1, (i * w)*3, height/1.1 - fft.getAvg(i) * 0.5);

    farbe += 2;
    if( farbe > 255)
    {
      farbe = 0;
    }
  // #########MOUSE############
      if (mousePressed && (mouseButton == LEFT)) {
      Player.pause();
    } else if (mousePressed && (mouseButton == RIGHT)) {
      Player.play();
    }

    }

But when i use this code Visualizer show me lines and effects why? here the visualizer got a MP3 in the loadFile but i need a way to choose the mp3 file

      import ddf.minim.*;
      import ddf.minim.analysis.*;
      import ddf.minim.effects.*;
      import ddf.minim.signals.*;
      import ddf.minim.spi.*;
      import ddf.minim.ugens.*;
      String path;

      Minim minim;
      AudioPlayer Player;
      int farbe;
      PImage playPause;
      PImage hintergrund;

      void setup() {
        size(500,400);
        background(0);
        minim = new Minim(this);
        Player = minim.loadFile("bla.mp3"); // Spielt die Mp3 datei ab
        Player.loop(); // Wiederholt den aktuellen Song
        farbe = 0;
        smooth();
        playPause = loadImage("play3.jpg");
        hintergrund = loadImage("hintergrund2.jpg");
      }

     /* void selected(File song){
        path = song.getAbsolutePath();
        }

      void interrupt(){
        while (path == null){
          loop();
        }
         noLoop();
        } */

      void draw()  {
        //selectInput("Suche einen Song aus","selected");
        //interrupt();
        background(0);
       // Player = minim.loadFile(path); // Spielt die Mp3 datei ab
      //  Player.play();
        image(hintergrund,0,0);
        image(playPause,25,25);
        translate(width/2, height/2);
        rotate(radians(frameCount % 360 * 2));
        colorMode(HSB);
        stroke(farbe, 255, 255);
        colorMode(RGB);

        for(int j = 0; j < 360; j++){

          if(Player.mix.get(j)*200 > 50) {
            colorMode(HSB);
            stroke(farbe, 255,255);
            colorMode(RGB);
          }
          else {
            colorMode(HSB);
            stroke(farbe,255,255);
            colorMode(RGB);
          }
          line(cos(j)*100, sin(j)*100, cos(j)*abs(Player.left.get(j))*250 + cos(j)*100, sin(j)*abs(Player.right.get(j))*250 + sin(j)*100);
        }

          //for(int i = 0; i < fft.avgSize(); i++){
          //line((i * w)*3, height/1.1, (i * w)*3, height/1.1 - fft.getAvg(i) * 0.5);

        farbe += 2;
        if( farbe > 255)
        {
          farbe = 0;
        }
      // #########MOUSE############
          if (mousePressed && (mouseButton == LEFT)) {
          Player.pause();
        } else if (mousePressed && (mouseButton == RIGHT)) {
          Player.play();
        }
        }

Please help me guys i need the filepath way for my university plx plx plx :(


JSON in POST request

$
0
0

First off I'm sorry if this has already been asked or answered. I have tried searching here but haven't found anything that answers it adequately enough for me to figure out my problem. So there is a couple servlets on the web that I have been given access to in order to make a program that will generate stats based on the data. As this has been given to me out of the kindness of their hearts I would rather not bother them with my inadequacies as a coder. So now onto my question...

All requests must include a POST parameter called “json” containing a JSON representation of the data to send to the servlet. All requests must look like this:

json = {
  "version" : "xx",
  "game" : "xxxxxxxxxxxxxx",
  "platform" : "xxxxxxxx",
  "userId" : <your user id>,
  "password" : <your password>,
  "data" : { <json data to send to the specific servlet> }
}

In Processing I have downloaded the HTTP Request library by Rune Madsen and Daniel Shiffman. I guess my main problem is I am unsure as to the correct way to send JSON in the POST request. Any help would be greatly appreciated. Thank you.

G4P Custom Scrollbar and Text Anti-Aliasing

$
0
0

Hello everyone, I am a newbie programmer trying out Processing to make my own program to calculate some values for a game. I am using G4P library and G4P GUI Buiilder for the user interface.

Firstly, why do text on labels appear to have aliasing when the background is set to not opaque in the GUI builder (Look at 1 in the image)? I need to make the background of all labels opaque with the same colour as my sketch background to get smooth, anti-aliased text (the rest of the labels in the image). Is there a way to have transparent background and smooth text at the same time?

Secondly, is there any way to change the look of the scrollbar in a text area (Look at 2 in the image)? I am looking at plain square thumb and arrows buttons with no or light colour border instead of the default rounded ones with black outline. The user defined palette doesn't seem to change the colour of the outline out the scrollbar, it seems to be always black. Unchecking rounded corners in the GUI builder does not seem to change the shape of the scrollbar.

Thanks!

@quark

Proscene Help

$
0
0

I have to say this is a very high quality library - commercial quality. I'm getting stuck due to my own ignorance in getting it to work the way I want. I am trying to create mouse and key bindings to allow user to look around my 3D scene. I can't figure out how to set up bindings so camera will rotate in place in all dimensions - something like peasycam. Zooming and moving forward and back works but not rotate. I've tried code from most of the samples but I get the same results in all cases.

Any suggestions are appreciated.

3d and 2d coordinates

$
0
0

coords

In 3d sketches null of coordinares begins here (green number "1"), how to make it begin there (green number "2"), like in 2d sketches? I realize that mouseX and mouseY not working properly because beginning of coordinates is not in the upper left corner.

manipulate consecutive videos

$
0
0

Hi. I am trying to write a sketch that manipulates two consecutive videos. When the value of val is equal to 0, video “0a.mp4” starts to play and stops at the last scene, and when val is equal to 1, video “0b.mp4” starts to play and stops at the last scene. When the value of val becomes 0 again, video “0a.mp4” starts again.

Val takes the value 0 when the mouse is on the left side of the window and 0 when it is on the right. I will change that when I will send some data from Arduino through serial port.

My problem is that when the value of val becomes again 0, I want the program to pick a random video from the String moviesa (like “5a.mp4”) and play this instead of “0a.mp4” (and then if the value of val becames 1, play “5b.mp4”).

I tried to put the command : index=int(random(num)); between lines 43 and 44 but the program got stuck.

Thank you.

Script

import processing.video.*;
int index=0;
int num=3;

Movie[] moviesa=new Movie[num];
Movie[] moviesb=new Movie[num];

int val;

void setup() {
size(1280,720,P2D);

for (int i=0; i<num; i++)
{
moviesa[i]=new Movie(this,i+"a"+".mp4");
}
for(int k=0; k<num; k++)
{
moviesb[k]=new Movie(this,k+"b"+".mp4");
}

}

void movieEvent(Movie movie) {
for (int i=0; i<num; i++)
{
moviesa[i].read();
}
for (int k=0; k<num; k++)
{
moviesb[k].read();
}
}

void draw() {
if (mouseX>width/2)
{val=0;}
else
{val=1;}

if(val==0) {
moviesb[index].stop();
moviesa[index].play();
image(moviesa[index], 0, 0);
}
else {
moviesa[index].stop();
moviesb[index].play();
image(moviesb[index], 0, 0);
}
}

Need a better way of creating a list of text field objects

$
0
0

Hi there,

Have constructed a bit of code that creates say 5 text fields along with corresponding submit buttons.

Have managed this with For Loops. Is there a more elegant way to do this?

I feel my code can be improved as it would be very cumbersome to keep copy-pasting and changing the relative numbers especially for the submit() function. The overall code would take up too much space.

Can the submit function reside within a for loop as well?

Would love to hear some ideas so that I can take it forward. Thanks!

Here is the code I'm using:

import controlP5.*;

ControlP5 cp5;

// Should we do an array for this initialization?
// I don't want to type out say 30 textValues. What is the more elegant way to represent this?
// Arrays.fill()??

String textValue_1 = "";
String textValue_2 = "";
String textValue_3 = "";
String textValue_4 = "";
String textValue_5 = "";

void setup() {
  size(800, 1000);
  cp5 = new ControlP5(this);

  for (int i = 1; i < 6; ++i) {
    cp5.addTextfield("textValue" + "_" + i)
      .setPosition(20, 80*i)
        .setSize(200, 40)
          .setFont(createFont("arial", 20))
            .setCaptionLabel("Enter Text for field " + i)
              .setAutoClear(false)
                ;

    cp5.addButton("submit"+ "_" + i)
      .setPosition(240, 80*i)
        .setSize(80, 40)
          .setCaptionLabel("submit")
            .getCaptionLabel().align(ControlP5.CENTER, ControlP5.CENTER)
              ;
  }
}

void draw() {
  background(0);
}

// The function for submit... can this be done in a for loop?
// I may want a large number of text fields
// and it can get tedious typing it all out every time I change the number


public void submit_1() {
  cp5.get(Textfield.class, "textValue_1").submit();
}

public void submit_2() {
  cp5.get(Textfield.class, "textValue_2").submit();
}

public void submit_3() {
  cp5.get(Textfield.class, "textValue_3").submit();
}

public void submit_4() {
  cp5.get(Textfield.class, "textValue_4").submit();
}

public void submit_5() {
  cp5.get(Textfield.class, "textValue_5").submit();
}


void controlEvent(ControlEvent theEvent) {
  if (theEvent.isAssignableFrom(Textfield.class)) {
    println("controlEvent: accessing a string from controller '"
      +theEvent.getName()+"': "
      +theEvent.getStringValue()
      );
  }
}

OSC Reciever Issue

$
0
0

Hello processing world! (this is my first post here)

I have a problem with the OSC reciever of oscP5 library. I can see the messges I'm receiving from SuperCollider. I can set variables in processig. Also I can send back the recieved messages. But unfortunetly I can not draw anything with that messages. I tried 4 different methods and still nothing. Please some help!

Thanks a lot..!

    import oscP5.*;
    import netP5.*;

    OscP5 oscP5;
    NetAddress myRemoteLocation;
    NetAddress superCollider;

    void setup() {
      size(700, 500);
      background(0);

      oscP5 = new OscP5(this, 12000);
      myRemoteLocation = new NetAddress("127.0.0.2", 12000);
      superCollider = new NetAddress("192.168.1.4", 57120);

      oscP5.plug(this, "test3", "/test3");
    }

    void draw() {
    }

    void mousePressed() {

      fill(250);
      rect(random(0, width), random(0, height), random(50, 200), random(50, 200));
    }

    void oscEvent(OscMessage theOscMessage) {
      /* check if theOscMessage has the address pattern we are looking for. */
      if (theOscMessage.checkAddrPattern("/test")==true) {
        /* check if the typetag is the right one. */
        if (theOscMessage.checkTypetag("ii")) {

          /* parse theOscMessage and extract the values from the osc message arguments. */
          int val01 = theOscMessage.get(0).intValue();  // get the first osc argument
          int val02 = theOscMessage.get(1).intValue(); // get the second osc argument


          fill(250);
          rect(random(0, width), random(0, height), random(50, 200), random(50, 200));

          OscMessage myMessage = new OscMessage("/testBack");
          myMessage.add(val01); /* add an int to the osc message */
          myMessage.add(val02);
          oscP5.send(myMessage, superCollider);
        }
      }

      /* check if theOscMessage has the address pattern we are looking for. */
      String addr = theOscMessage.addrPattern();
      int val0 = theOscMessage.get(0).intValue();
      if (addr.equals("/test2")) {
        fill(250);
        rect(random(0, width), random(0, height), random(50, 200), random(50, 200));
      }
      if (theOscMessage.checkAddrPattern("/test4")==true) {
        /* parse theOscMessage and extract the values from the osc message arguments. */
        int val01 = theOscMessage.get(0).intValue();  // get the first osc argument
        int val02 = theOscMessage.get(1).intValue(); // get the second osc argument
        fill(150);
        ellipse(20, 20, 50, 50);


        OscMessage myMessage = new OscMessage("/testBack4");
        myMessage.add(val01); /* add an int to the osc message */
        myMessage.add(val02);
        oscP5.send(myMessage, superCollider);
      }
    }

    public void test3(int theA, int theB) {
      println("### plug event method. received a message /test3.");
      println(" 2 ints received: " +theA+ ", " +theB);

      fill(250);
      rect(random(0, width), random(0, height), random(50, 200), random(50, 200));
    }

How to save colored OBJ mesh with Toxiclibs.

running teapot.pde on windows 10

$
0
0

while trying to run mputeapot i receive the error toxi.geom and toxi.processing not found thank you

Is mouse over sphere in 3D?

$
0
0

I have a sphere somewhere, and its location is known. However, I'm also using PeasyCam, so a problem remains - I don't know the camera vectors. So, how to check if the mouse (or any other vector for that) is over the sphere?

My code so far-

import peasy.*;

PeasyCam cam;

float x = 0, y = 0,z = 0;

void setup(){
  size(720, 720, P3D);
  cam = new PeasyCam(this, 200);
}

void draw(){
  translate(x, y, z);
  sphere(100);//being minimalistic

  x += sin(y);//random methods, real code is different
  y += cos(z);
  z += random(1);

  println(mouseOverSphere(x, y, z, 100);
}

boolean mouseOverSphere(float posX, float posY, float posZ, float size){
  //What to do here??
}

Sending a variabel between sketches

$
0
0

Hi again i´m working on a project that consists of three sketches each one is using a different kind of data from three arrays that all represent the same thing but in a different form (Pic, word, rect). The sketches would run on the same computer at the same time. As i understand it sending and reading it from a serialport doesn´t work.

is there a lib or something smart to do it with?

Proscene Keyboard Control

$
0
0

The ConstrainedEye example demonstrates exactly the kind of camera control I need.

My question is how do I enable only the default keyboard handling for the arrow keys but disable all other keyboard shortcuts?

Viewing all 2896 articles
Browse latest View live