Physics Toy

Last post 05-11-2008, 7:59 PM by kotsoft. 24 replies.
Sort Posts: Previous Next
  •  03-21-2008, 6:21 PM

    Physics Toy

    Hi, I've created this goo simulation that I wanted to show off:

    It starts with a familiar windows background image and lets you apply forces to tear it up and stick it back together.

    Use the Left, Middle, and Mouse buttons to Repel, Spin, and Attract particles.

    Goo Simulator


  •  03-21-2008, 8:29 PM

    Re: Textured fluid simulation

    that is really cool... I'm always impressed by your soft-body physics simulations.  when are you going to make a "proper game" out of all this tech that you've developed? :P

    Go Go Gadget XNA!
  •  03-21-2008, 9:25 PM

    Re: Textured fluid simulation

    well, i did just make this really fast verlet simulator, utilizing the same tech in my fluid demos to speed up collision checking drastically. as you can see, stacking works too (luckily :)). i'm going to try and make something kind of like powder game.


  •  03-23-2008, 11:00 AM

    Re: Textured fluid simulation

    can you explain in details, how did you do that?
    did you use some kind of physics engine?

    even if so, can you explain , how it wokrs?

    thank you very much


  •  03-23-2008, 1:39 PM

    Re: Textured fluid simulation

    well, there's not much. i figured instead of drawing every sprite with just Color.White, i would mix it up a bit and draw particles with a specific color.
  •  03-23-2008, 2:19 PM

    Re: Textured fluid simulation

    That's cool!  Gooey gravitating goop!  How do I grab the pieces?
  •  03-24-2008, 8:25 AM

    Re: Physics Toy

    here's a new version of the physics toy with shaders.

    you can use the left, middle, and right mouse buttons to create the different materials.

    you can use the mouse buttons while holding down the key F to repel, spin, and attract particles.

    download here


  •  03-25-2008, 12:40 AM

    Re: Textured fluid simulation

    This is great. How long did it take you to make this? I'm new to particle systems so where would you recommend I start if I wanted to do something like this?
  •  03-25-2008, 12:34 PM

    Re: Textured fluid simulation

    kotsoft, you should consider releasing your source.  Big Smile lol
  •  03-25-2008, 1:23 PM

    Re: Textured fluid simulation

    This is a really good article about fluid simulation. It gives you all the pseudocode, so you should have no trouble implementing it. In fact, it's one of the only physics papers I understand. :) They all have these complex equations with symbols I don't know.

    http://www.iro.umontreal.ca/labs/infographie/papers/Clavet-2005-PVFS/pvfs.pdf
  •  03-26-2008, 12:30 PM

    Re: Textured fluid simulation

    Thanks!  The paper is just as good as source!
  •  03-26-2008, 10:39 PM

    Re: Textured fluid simulation

  •  04-10-2008, 10:40 AM

    Re: Textured fluid simulation

    I have read over and over this paper and whilst I am confident I can implement the psuedocode I just can't seem to understand how it applies to three or even two dimensional space.

    Both velocity and position seem to be calculated in one vector only- how does this translate to movement on a 2d or 3d plane?

    I may be jumping in the deep end somewhat by challening myself to produce an XNA implementation of the psuedocode but any help you could give me to better understand the concepts and how they apply would be greatly appreciated.
  •  04-23-2008, 6:52 PM

    Re: Textured fluid simulation

    The paper is a great find! I sort of understand this although there is some calc involved. I've read a couple other papers too. If you guys want to check out another really nice fluid simulation, check out the sandbox in plasma pong. Its pretty amazing.

  •  04-25-2008, 8:32 AM

    Re: Textured fluid simulation

    I have just implemented a particle system in XNA based on this paper and I am overall impressed with the result. Using as little as 100 particles beautiful liquid formations can still emerge.

    There is a bug somewhere in my code and I could need some input from those who have implemented the paper.

    Referring to Algorithm 4 'Spring Adjustment' I do not see the difference between 'L' and 'L_ij'. They are both the same, the rest length of the spring between the two particles 'i' and 'j', right?

    Line 11 in Algorithm 4 is causing instability in my implementation when drops of ~10+ particles are forming. This is no matter which parameters are used in the simulation. Maybe it has to do with 'L' not being equal to 'L_ij'. Its a pain to debug as the drops start to jitter the more particles they consist of. Has someone had stability issues with line 11? (plasticity spring compression)

    Last question. Are people adding a drag force to the particles to increase stability?

    Best regards and thanks for the link

     

  •  04-27-2008, 9:11 PM

    Re: Textured fluid simulation

    yes, there is in fact an error in the paper with the springs.
    the actual problem was that the spring length changing part was put inside the (q<1) block so the spring only changes when the distance is less than h. that means it'll never get long enough to break. i actually e-mailed them but i guess they never got around to changing it.

    one question i have though, regarding a gpu smoke simulation i'm making, is that when the window is minimized and then brought back up again, all the smoke clears or in other words, the texture clears. is there a way to keep this from happening? it's not really that much of a problem now, but i can imagine when i make a game and the character is about to be burned alive by fire and the player just minimizes the window and clears all the fire.
  •  04-28-2008, 2:49 AM

    Re: Textured fluid simulation

    Hi Kotsoft, kudos to your software and your youtube videos, I really like them.

    About the spring removal I think there is no error in the paper? It basically states that if the distance between two particles < H then update the spring rest length. If any spring rest length is modified to be larger than H then remove them. It works in my implementation and I just did what was stated.

    Another problem I am having is the delta time. Everything works fine with deltaTime = 1 as stated in the paper. If I use deltaTime = 0.1f to get a 10x slowmo somehow the physical properties are not maintained, the particles wont contract at all. I am debugging on that now. Have you tried with different timesteps than 1?

  •  04-28-2008, 10:17 AM

    Re: Textured fluid simulation

    actually, when i implemented it i left the timesteps out to keep it simple. i guess someday i should do it.

    anyway, wraithofdark, it's not that difficult to go from one dimension into two or three.

    for example, all the boldface text actually stands for vectors (which is a helpful thing to remember when you read physics papers). and italics stand for scalar values.

    so the x = x + deltaTime*v would be implemented this way:
    deltaTime is a scalar value, so you can just use elapsedtime or whatever
    x would be a Vector2 (2 dimensional) or Vector3 (3 dimensional)
    //begin step
    Vector2 x = new Vector2();
    Vector2 v = new Vector2();
    //update step
    float deltaTime = elapsed time
    x += deltaTime*v;

    so in fact xna makes implementing these physics papers really easy.
  •  04-28-2008, 11:25 AM

    Re: Textured fluid simulation

    Ok, don't bother implementing different timestep than 1 as I think there is a bug in the paper. They use time squared in algorithm 2 line 18 and algorithm line 2. According to my understanding they should only use delta time. Not square it. At least that is what makes sense to me and it works in my simulation.
  •  04-28-2008, 4:47 PM

    Re: Textured fluid simulation

    Kotsoft: "the actual problem was that the spring length changing part was put inside the (q<1) block"

    Doh.. Now I see the error. I misread the paper and removed all springs where the particles were more than H away from each other. It works fine but it is probably not entirely accurate.

  •  05-04-2008, 8:31 PM

    Re: Textured fluid simulation

    Thanks for the tips kotosoft, I'll have another go reading over the paper and attempting to implement it.

    I find monkeying about with physics in code to be extremely entertaining and challenging, it's unlikely anything will ever come of it but I'm eager to take my rudimentary fake-particle-physics to the next level, particularly after seeing your stunning demonstrations and comparing them to my own, sluggish attempt at brute force collision which, if I do say so myself, looks sort of pretty but is remarkably crude.

    Props to all for not tempting me with source downloads!
  •  05-11-2008, 2:03 PM

    Re: Textured fluid simulation

    just wanted to show you guys something new i've been working on.

    super high res simulation

    these are some extremely high res fluids. and they're not realtime, but i really like the way they look. i'm preparing an even huger simulation with 400,000 particles. it's probably going to take a few hours. to get the images, i just exported it using the texture2d.save method.
  •  05-11-2008, 5:24 PM

    Re: Textured fluid simulation

    Your link isn't working for me...  But I wanna see it!  :-P
  •  05-11-2008, 7:50 PM

    Re: Textured fluid simulation

    kotsoft:
    just wanted to show you guys something new i've been working on.

    super high res simulation

    these are some extremely high res fluids. and they're not realtime, but i really like the way they look. i'm preparing an even huger simulation with 400,000 particles. it's probably going to take a few hours. to get the images, i just exported it using the texture2d.save method.

    I am usually not the person who uses superlatives, but this is AWESOME!

  •  05-11-2008, 7:59 PM

    Re: Textured fluid simulation

    if the vimeo one absolutely doesn't work, i also have it on youtube, but as the youtube videos are less clear, you should try to go to the vimeo video if possible.
View as RSS news feed in XML
©2007 Microsoft Corporation. All rights reserved. Privacy Statement Terms of Use Code of Conduct Feedback