We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpSyntax Questions › Mesh with object Thanks..
Page Index Toggle Pages: 1
Mesh with object? Thanks.. (Read 428 times)
Mesh with object? Thanks..
May 31st, 2009, 5:39am
 
Guys I'm in crisis Sad 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.
Re: Mesh with object? Thanks..
Reply #1 - May 31st, 2009, 10:14am
 
memberember wrote on May 31st, 2009, 5:39am:
Guys I'm in crisis Sad 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.
Re: Mesh with object? Thanks..
Reply #2 - Jun 1st, 2009, 2:21am
 
Thank you so much, you're very nice.
I had not thought to metaballs; that's interesting. I will try Smiley Bye
Page Index Toggle Pages: 1