FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Topics & Contributions
   Simulation, Artificial Life
(Moderator: REAS)
   water sim
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: water sim  (Read 3080 times)
setpixel

WWW
water sim
« on: Sep 7th, 2004, 10:10pm »

pretty oldschool: water ripple with some reflection and some particles all up in there.
 
its using an image class based on toxi's image class in one of the examples. yoyoyo toxi. havent talked to you in a long time.  
 
move your mouse.
 
http://www.setpixel.com/test/p5/water_ripple/
 
my 3rd processing joint to mess around. kinda slow.  
 
I tried doing saveframes at the end of the loop to make a video. all i get is black. Im using pixels[] = image.pixels[] to draw the screen. Im guessing that I have to set each pixel on the screen.
 
oh and glen murphy... are you reading this? I responded to your email like 8 months ago but your spam filter is rejecting me. do you use msn? rekimoto has been dead for about a year but hes chillin in the freezer.
 
rgovostes

rgovostes
Re: water sim
« Reply #1 on: Sep 8th, 2004, 3:07am »

awesome
 
setpixel

WWW
Re: water sim
« Reply #2 on: Sep 8th, 2004, 7:42pm »

I made a video..  
 
http://www.setpixel.com/test/p5/water_ripple/water_ripple.mov (20M)
 
has anyone made thier own function that blits from a bitmap to a polygon(quad)?
 
JohnG

WWW
Re: water sim
« Reply #3 on: Sep 9th, 2004, 12:44pm »

You can just do:
 
texture(mytexture);
beginShape(QUADS);
vertex(xpos, ypos, zpos, texturexpos, textureypos);
vertex(xpos2, ypos2, zpos2, texturexpos2, textureypos2);
...
endShape();
 
or, if you want more homegrown ways of working texels etc out, you could check:
http://www.hardcorepawn.com/Bump/
 
That uses realspace-texturespace conversions to do the bump mapping
 
vent

WWW
Re: water sim
« Reply #4 on: Sep 9th, 2004, 12:45pm »

Nice.
 
No need to create your own function. Just do something like this:
http://proce55ing.beyondthree.com/sketch/texturemapping/index.html
 
 

http://www.shapevent.com/
setpixel

WWW
Re: water sim
« Reply #5 on: Sep 9th, 2004, 3:17pm »

great! thanks!  
 
completely unrelated... Im about 6 days into messing with processing and I was pretty upset that there is no hashtable. but then im looking at toxi's demos and I see a hashtable. how come there is no mention of this in the language reference? Its now clear to me that processing is extended by existing java classes. but man - its not very clear at all! also - the whole language reference in general seems a bit weak. user notes would be cool on each page too. i know.. everything is in progress. surely there is someone with enough freetime to make a proper reference!
 
i live in korea. i started messing with processing because i went to a workshop here (nabi) on it. i asked the instructor about hashtables. he told me that hashtables were not possible...yet. i know his misunderstanding is due partly to language barrier. however, from my perspective, a localized language reference would be really nice, especially since there are many people interested in non-english speaking countries like korea.
 
TomC

WWW
Re: water sim
« Reply #6 on: Sep 9th, 2004, 3:52pm »

Maybe I misunderstand what you're saying, but there is a Korean translation of the reference here: http://www.nabi.or.kr/processing/
 
Also, as far as extending Processing using Java classes like Hashtable goes, you should probably be looking at things like the docs for the Java API.
Every current Java class is listed here: http://java.sun.com/j2se/1.4.2/docs/api/
I would be surprised if there isn't a translation of most of this somewhere.
 
There are some things to be aware of though. If you want your applets to work for as many people as possible, only use Java 1.1-compatible classes and methods.  The full Java docs will tell you when a class or method was introduced.  The Java Collections Framework is actually not 1.1 compatible, so you can only use older collection objects like Vector and Hashtable, and older methods like addElement, and not add.  In addition, Java collections are for generic Objects, and so you need to cast objects back to the correct type when you get them out of a collection.
 
e.g.  Here's an example of using Vector.
 
Code:

 
 
class Particle {
  float x,y;
  Particle(float x, float y) {
    this.x=x;
    this.y=y;
  }
  void move() {
    x+=random(-2,2);
    y+=random(-2,2);
    if (x > width) x-=width;
    if (x < 0) x+=width;
    if (y > height) y-=height;
    if (y < 0) y+=height;
  }
  void draw() {
    point(x,y);
  }
}
 
Vector myParticles = new Vector();
 
void setup() {
  size(400,400);
  background(255);
  stroke(color(10,5,0,40));
}
 
void loop() {
  for (int i = 0; i < myParticles.size(); i++) {
    Particle theParticle = (Particle)myParticles.elementAt(i);
    theParticle.move();
    theParticle.draw();
  }
}
 
void mousePressed() {
  Particle myParticle = new Particle(mouseX,mouseY);
  myParticles.addElement(myParticle);    
}
 

 
Hashtable works in a similar way, only with keys and values.  The documentation for Hashtable is here: http://java.sun.com/j2se/1.4.2/docs/api/java/util/Hashtable.html
« Last Edit: Sep 9th, 2004, 3:54pm by TomC »  
setpixel

WWW
Re: water sim
« Reply #7 on: Sep 9th, 2004, 4:52pm »

ah you misunderstood, but perhaps i wasnt so clear. of course i'm aware of the korean translation (the translator is my friend). my point is that korean-only speaking people dont have the luxury of reading message boards. they rely heavily on thier own very small community and the translated documentation.  
 
an example of some confusion is when a korean speaking instructor tells me that hashtables arent availible in processing.  
 
over time, the processing language reference will surely change. my thinking is just that as those little changes happen, the translations will be neglected, and each translation may fall out of date.  
 
im just raising a small concern for people who cant raise the concern.
 
TomC

WWW
Re: water sim
« Reply #8 on: Sep 9th, 2004, 5:09pm »

OK.  I thought that was what you meant, but I wasn't sure.  (What a perfect example of the problem you are highlighting!)
 
Hopefully Processing's use in teaching will mean that the documentation remains high quality.  I assume the API will settle down when Processing reaches 1.0 - and maybe that would be a good time to get all the translations up to date.  Until then, it looks like the project is going to rely on people like you to help out where you can!
 
setpixel

WWW
Re: water sim
« Reply #9 on: Sep 9th, 2004, 7:57pm »

cool. great. i think i might put together a a little reference/examples of some common java classes/methods that are handy to extend processing not listed in the language reference. or - does one already exist? some things that quickly come to mind:
 
string methods like substring
hashtable class/methods
system.arraycopy
array methods
vector class/methods
 
another sidenote: i think about 60 people came to the processing workshop at nabi in seoul. maybe more. from what i could observe, most people were graphic designers with very little programming experience. everyone was very enthusiastic though. they seemed very excited with point(10,10);. one girl spent about 30 minutes plotting tons of points to make a smile face. she was really pissed off when she found out about line. haha. by the second workshop, people were making some interesting things. another interesting note is that the attendees were at least 50% female. perhaps it was just the group, the majority of the females seemed to grasp the concept easier than the males. interesting stuff.
 
flight404

WWW Email
Re: water sim
« Reply #10 on: Sep 21st, 2004, 12:00am »

Very nice.  Love the little blurry creatures in the water...
 
Decided to revisit my ripple engine to see where i could improve upon the last version.
 
Aside from having issues with diagonal banding, things are going well...
 
http://www.flight404.com/p5/video/water_balls.mov
 
9 balls.  Each with bouyancy and gravity.  When in the water, each produces ripples based on a specific frequency of audio coming through the microphone.  X wave and circular wave are added through manual input.
 
Tried to figure out how to get color to spread through the liquid so I could, in theory, change the color of a specific ball and have that new color leech out into the surrounding water.  Didn't have much luck though.
 
setpixel

WWW
Re: water sim
« Reply #11 on: Sep 21st, 2004, 6:30am »

ooooooh nice. way to go and make everyone else look bad. haha.  
 
i really like the red paining on the water surface... it looks like blood.  
 
actually... that would look really cool.. simulating a drop of blood or paint in water.
 
 
flight404

WWW Email
Re: water sim
« Reply #12 on: Sep 21st, 2004, 6:45am »


 
Well, I just need to figure out how your ripple produces such smooth curves whereas mine creates pointy peaks.  Is it purely a resolution issue?
 
And for the paint/blood in water effect, if you figure it out be sure to let me know.  
 
Pages: 1 

« Previous topic | Next topic »