Jump to content
  • Advertisement
Sign in to follow this  
j14rk1n

[java] Java particle engine

This topic is 4801 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I've been programming in java for around 6 months, and just got into graphics. (Finally!) I finished a particle engine, in which there's simulated gravity that affects the particles in different ways. I've been able to get basic physics working(bouncing/reflection), but that's where I'm stuck. I'd like to start on a physics engine/particle editor now, but I'm lost when it comes to the math behind it all. I have a few questions before I start though: Do physics engines run on timers or a timing system? If so, I guess that's what I'd use to calculate motion and properties. Are there any good physics sites with computer-oriented formulas? Like... stuff I'd find in a physics 101 textbook. Do you like my particle engine? You can use the directional keys to set the gravity, and space resets it all. http://johnlarkin.f2g.net/CrazyParticles/main.html Thanks in advance for answers :)

Share this post


Link to post
Share on other sites
Advertisement
I got this error from it: (could just be my browser)

java.lang.UnsupportedClassVersionError: ParticleTester (Unsupported major.minor version 49.0)

Volume 10 issue 6 of the magazine JDJ (http://jdj.sys-con.com/) had an article on building a particle system for java3d.

I wrote a tutorial on building a particle engine which used a time value to determine position. I wrote it for DarkBasic users though. Here's the basic equation I used:

x = v*cos(a)*t
y = v*sin(a)*t - ½gt²

If you wanted to do this in 3D, "x" would basically be the distance from the emitter, so you'd have:

d = v*cos(a)*t
x = cos(da)*d
y = v*sin(a)*t - ½gt²
z = sin(da)*d

Not a very fancy particle engine, but gives a nice fountain effect. Angles "a" and "da" control the angle of elevation and Y-rotation around the emitter, respectively.

Share this post


Link to post
Share on other sites
Quote:
Original post by j14rk1n
Do physics engines run on timers or a timing system? If so, I guess that's what I'd use to calculate motion and properties.


Yes, they rely heavily on that. On most cases, you "preview" what's going to happen in a space, spliting your time variable in fixed intervals, checking each one of them to identify if a certain phenomenon (?) happens. Geez, my english is terrible...

Quote:
Original post by j14rk1n
Are there any good physics sites with computer-oriented formulas? Like... stuff I'd find in a physics 101 textbook.


Not sure about sites, but there's one engine called jME that has physics support. You might want to take a look at it.

Quote:
Original post by j14rk1n
Do you like my particle engine? You can use the directional keys to set the gravity, and space resets it all.
http://johnlarkin.f2g.net/CrazyParticles/main.html

Thanks in advance for answers :)


Hey, nice work! Congrats! ;)

Son Of Cain

Share this post


Link to post
Share on other sites
Thanks for the info and compliments.

As for the 'java.lang.UnsupportedClassVersion' error:
I compiled it all with Java 5 (1.5), which if pretty new still, so you may need that to run it. Also, if you're on a mac, that could be an issue. I don't own one, so I've been asking my friends to test it on theirs with overall success.
Thanks again :)

[Edited by - j14rk1n on September 15, 2005 6:51:21 PM]

Share this post


Link to post
Share on other sites
i like your particle system, but i couldn't get the gravity thing working. using the keys didn't result in any change of the particle system only moving the mouse over the applet changed the source of the particles. apart from that, nice work :)

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Hey that's cool.

Share this post


Link to post
Share on other sites
When it comes to computing velocity and position in a particle system, be sure to research Euler's approach. Essentially your particle system manipulates particles in terms of the acceleration. Your particle system updates the particles every frame or every X milliseconds. The external forces like gravity should be applied to the particles in the form of accelerations. You then compute the new velocity of the particles using this short time differential (dt) like this:

vx = vx + ax*dt; // vx = velocity in x direction, ax = acceleration in x dir
vy = vy + ay*dt;

after figuring out the new velocity, you can calculate the new position:

x = x + vx*dt;
y = y + vy*dt;

Rotation is a another set of equations, but these are the basic linear equations.

Mike
indie technologies - particle effects for java games

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!