memberember wrote on May 31st, 2009, 5:39am:Guys I'm in crisis
I wanted to know how it was possible to create an object each time processing receives an input (eg. pressing the mouse). And in last, the objects created when touching others (objects) are united, to form a reticulate or mesh.
Thank you in advance for your patience..
G.
The first one is easy. I do it all the time with sprites. Something like;
class myObject{
PImage graphics;
float _x;
float _y;
myObject(String imageFileLocation, float myX, float myY){
graphics = loadImage(imageFileLocation);
_x = myX;
_y = myY;
image(graphics,_x,_y);
}
}
This is just an object that displays an image, but you can have it do whatever you want.
So you'll also have your main loops:
void setup(){
//set your screen size, etc
r
}
void draw(){
//whatever you want to be executed each time the screen is drawn
}
void mouseReleased(){
myObject thing;
thing = new myObject("picture.jpg", mouseX,mouseY);
}
That's it, really, everytime you release the mouse a new object is made. Having played with it for a while, it doesn't seem necessary to increment the name or anything. Now you may discover you have to properly account for each object by incrementing it's id with like an interger (thing1, thing2, thing3), which I don't know how to do in Java. In actionScript you'd do something like thing[i]=new myObject but Java doesn't like that.
For the second part of your question, I have no idea. Google "Metaballs" and see if you can't find some code examples.