Jump to content
  • Advertisement
Sign in to follow this  
Dr_Asik

Fluid Grid (aka Geometry Wars background)

This topic is 3171 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

Hello, I want to implement something like the fluid, elastic grid you can see in Geometry Wars (
). I really need a math primer on that though. I've heard this is implemented using spring constraints, however I didn't find any good articles on that on the internet. Thanks

Share this post


Link to post
Share on other sites
Advertisement
I know this rule but I don't know how to represent a grid of points that can move a bit like a fluid would. What are the inputs? How is the position of a certain point calculated? It certainly takes into account the position of its neighbors as well as some kind of constraints that will move it back to its initial position in a fluid way.

Share this post


Link to post
Share on other sites
Hi,
You have to model every point as a newtonian mass (F=ma) and each spring as a linear(f=kx) spring.
Each point just has position, velocity and mass.
Each spring has a free length and a spring constant and two endpoints, each of which can either be a point mass, or a fixed point (inheritance).
Every time step:
For each spring:
get the distance between the two endpoints, subtract the free length, multiply by the
spring constant, and apply the resulting force to both endpoint objects be sure to take
angle into account, and reverse the direction for one of them. Also you will want to do the
same with some velocity damping or your grid will oscilate and probably blow up.
For each point mass:
just integrate using your favourite method (euler or verlet works well for this, RK4
requires multiple passes each time step).

You'll have to construct a grid with at least 2 fixed points in it (preferably at the edges) to start with, and then apply outside disturbances to it to make it interesting.

And there you go, this thing will have all sorts of fun behaviour, like waves and such.

Hope this helps.

Share this post


Link to post
Share on other sites
Check out:
http://en.wikipedia.org/wiki/Navier%E2%80%93Stokes_equations
And:
http://en.wikipedia.org/wiki/Computational_fluid_dynamics

[edit]Magical time-travelling quote
Quote:
Original post by Sneftel
It's unlikely that that background is using a mass-spring system. The grid lines alias as they distort. More likely, the weapon blasts send out invisible sprites which are used to deform the static texture.
Could be both! I remember in an interview they mention that the background actually takes up the majority of their processing time ;)

Share this post


Link to post
Share on other sites
It's unlikely that that background is using a mass-spring system. The grid lines alias as they distort. More likely, the weapon blasts send out invisible sprites which are used to deform the static texture.

Share this post


Link to post
Share on other sites
Quote:
Original post by Sneftel
It's unlikely that that background is using a mass-spring system. The grid lines alias as they distort. More likely, the weapon blasts send out invisible sprites which are used to deform the static texture.


Really? I recall an interview where the GW developer commented that the background was a mass+spring system tweaked to be "just on the edge of stability" or something like that..

Share this post


Link to post
Share on other sites
I made a little demo trying that effct myself.
the gridcode:

grid.cpp
http://sudi.pastebin.com/f53cb3d0d

grid.h
http://sudi.pastebin.com/f4265ff7b

the game:
http://www.file-upload.net/download-2063014/crazygeo.tar.gz.html

i used the sprin system.

Share this post


Link to post
Share on other sites
Quote:
Original post by Sudi
I made a little demo trying that effct myself.


Neat, but it seems to go unstable in some situations :-)

Share this post


Link to post
Share on other sites
Quote:
Original post by Sneftel
It's unlikely that that background is using a mass-spring system. The grid lines alias as they distort. More likely, the weapon blasts send out invisible sprites which are used to deform the static texture.


That's what I thought too, until I saw how the black-hole "enemies" affected the grid. Then it definitely looked more like a spring system than some kind of shader effect. At 1:34 in the video you can clearly see how the black hole on the left edge is distorting the grid in an extremely spring-like manner.

It looks like an extremely dense spring system (like, one node for every intersection on the highest resolution grid) with low spring constants and a lot of dampening.

Also it looks like they might have disabled the spring force when x < 0.

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!