Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Verlet Integration

Discussion in 'Scripting' started by alcedo, Apr 2, 2011.

  1. alcedo

    alcedo

    Joined:
    Feb 15, 2011
    Posts:
    11
    I have implemented a rudimentary Verlet Integration system in Unity, after googling around and learning from various external sources. I have also pasted a list of reference material which i have studied, but awaiting moderator's approval for now.

    Here's a video:


    Anyone interested in the source code can reply here.


    In addition, i am implementing a 2D metaball script for Unity as well. Stay tune and fingers cross that im successful =D


    Here's where i learn all the verlet integration stuff: For the bulk of it, I translated the blitzbasic code from the blitzbasic forum for my verletingration part, and the collision detection part i translated the C++ code from the gameDev.net article.

    I subsequently went around looking at various other source code and article while picking up useful stuff which i could also use in Unity C# and simply implemented it =P

    So thanks to the following people and sources!

    verlet:
    http://www.gamasutra.com/resource_guide/20030121/jacobson_02.shtml
    http://www.blitzbasic.com/Community/posts.php?topic=84714 //working on this
    http://ofbg.tripod.com/dolphin.html
    http://vimeo.com/5035839
    http://www.youtube.com/watch?v=cgrj2d-XRu8&NR=1
    http://forums.create.msdn.com/forums/p/49922/300864.aspx
    http://www.gamedev.net/page/resourc...rlet-based-approach-for-2d-game-physics-r2714
    http://www.gotoandplay.it/_articles/2005/08/advCharPhysics.php
    http://www.red3d.com/cwr/games/

    blob
    http://www.gamedev.net/topic/579014-blob-physics-tutorial/

    alternative rigging idea:
    http://forum.unity3d.com/threads/41674-Making-a-Cell-Membrane-that-Deforms-with-Physics
     
    Last edited: Apr 3, 2011
  2. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
  3. alcedo

    alcedo

    Joined:
    Feb 15, 2011
    Posts:
    11
    hmm for some reason i got this after posting a long post: Thank you for posting! Your post will not be visible until a moderator has approved it for posting.

    nonetheless, im gg to tidy up my code abit first so that beginners could access the core part of it all without all the integration with my other project lol.

    If you can't wait, I have pm-ed u the svn location
     
    Last edited: Apr 2, 2011
  4. MikeUpchat

    MikeUpchat

    Joined:
    Sep 24, 2010
    Posts:
    1,055
    That looks great, its something Ive always fancied trying, look forward to seeing and trying your code :)
     
  5. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,686
    Very nice indeed :) Always nice to see more physics stuff.
     
  6. alcedo

    alcedo

    Joined:
    Feb 15, 2011
    Posts:
    11
    I saw your Unity Videos, those ropes are verlet integration too ? =D
     
  7. alcedo

    alcedo

    Joined:
    Feb 15, 2011
    Posts:
    11

    I did some really quick tidy up, download it from: http://code.google.com/p/nus-4343/downloads/list
    And the raw basic implementation: trunk/CS4343/tags/BasicVersion

    Honestly i did not intend to release it to public, hence the code might be abit messy.

    I did however wrote plenty of comments for the source code ;-)
     
  8. SpookyCat

    SpookyCat

    Joined:
    Jan 25, 2010
    Posts:
    3,686
    They do have a verlet integrator as an option, the chain and rope in the videos uses a hybrid system of midpoint and constraints.
     
  9. MikeUpchat

    MikeUpchat

    Joined:
    Sep 24, 2010
    Posts:
    1,055
    Many thanks for taking the time to upload the project. I had a problem though, extracting the zip with winrar it says Unknown Method for every file and nothing extracts.
     
  10. Frank Oz

    Frank Oz

    Joined:
    Oct 13, 2010
    Posts:
    1,560
    This looks very cool!
     
  11. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
    I had the same problem on my Mac. Try using 7z or 7zip, that worked for me.
     
  12. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
    @alcedo - What version of Unity did you use to build this project? I tried it in 2.6, 3.1, 3.2 and 3.3 and all of them said the project needed to be upgraded and then failed.
     
  13. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
    @alcedo - I'm back again. ;) I just tried opening this on both my machines, one Mac and one Windows 7. The .zip file wouldn't extract properly on either and after "forcing" it to extract the project folders were missing bits. Could you repost a new zip? One thing you might want to keep in mind is that you probably don't need to include the entire Standard Assets folder, only those assets you need in your project. Consequently, sometimes posting a Unity Package file is a better way to go (assuming all assets are exported properly).
     
  14. 2dfxman1

    2dfxman1

    Joined:
    Oct 6, 2010
    Posts:
    1,065
    I am interested in source
     
  15. alcedo

    alcedo

    Joined:
    Feb 15, 2011
    Posts:
    11

    Yeps, I've deleted all the un-necessary stuff and gg to reupload another zip file. Sorry about that!
     
  16. alcedo

    alcedo

    Joined:
    Feb 15, 2011
    Posts:
    11
    I'm using 3.2.0 =) but i dont tk version is a problem, since its mostly .cs files =p
     
  17. alcedo

    alcedo

    Joined:
    Feb 15, 2011
    Posts:
    11
    Hi Guys,

    Sorry for the trouble ! Hope this would work now ;-)

    1. I have updated the first post to indicate where I've learnt my verlet integration.
    2. I have re-uploaded the zip file. This time round its a tiny small file after heeding advice from fellow forumers to remove the other junk =P . Its located @ the same place:= http://code.google.com/p/nus-4343/downloads/list
    3. I have basically zip up the entire project folder, to make it convenient for people to just File > open project > select the folder after extracting the package, Hit Play and click on the game screen to add some bodies.
    4. I have tried unzipping it after i zip the file, so im guessing it should not be much of a biggie now.
    5. Lastly, Go to the wiki page if anyone would like to use ONLY the raw verlet integration base code without all the other fluff which i have included. The hardest part about verlet integration is simply the collision detection IMO. The raw verlet code isn't alot .



    p.s. A pt to note is that my verlet integration code is separated from Unity's physics engine.

    Hence a majority of the other codes that you guys might see are basically codes to try to link it up to unity's physics engine and other little aesthetics.

    Ideally we would love to program our own Shaders, but we simply do not know how nor the time to read up on it, so we made used of a particle emitter system for visual representation.

    And oh yes, Turn on gizmos to be able to view it in both the game screen and the editor screen.


    cheers,
    jiahao
     
    Last edited: Apr 3, 2011
  18. alcedo

    alcedo

    Joined:
    Feb 15, 2011
    Posts:
    11
    Ohhh. Ok. i get it. Really awesome rendering as well man. Love your work ;-)
     
  19. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
    alcedo - Ok, we're getting closer. ;) This version still throws some errors when opened in 3.2:

    $Screen shot 2011-04-03 at 3.14.09 AM.png
     
  20. alcedo

    alcedo

    Joined:
    Feb 15, 2011
    Posts:
    11
    Ar that -.-|| you can delete the metaball.cs for the fix, but over on my side its just a warning, not an error :eek:
    screenshot over at my side: http://img62.imageshack.us/img62/1464/14629174.png

    I have repackaged the changes once again. :cool: Should be alright this time =D
     
  21. bigkahuna

    bigkahuna

    Joined:
    Apr 30, 2006
    Posts:
    5,434
    Fixed! Opened it with Unity 3.2 Pro under Mac. Now to do some homework and figure out how to use it! :)
     
  22. alcedo

    alcedo

    Joined:
    Feb 15, 2011
    Posts:
    11
    =) read the small wiki page on the google code site, and get the raw VI code to study it first. It's much easier that way!
     
  23. SinisterMephisto

    SinisterMephisto

    Joined:
    Feb 18, 2011
    Posts:
    178
    Dont tell me i wasted the last 3 nights on writing my own V-integrator. Arrrgh.

    Did you add IK to yours?
     
  24. paraself

    paraself

    Joined:
    Jun 30, 2012
    Posts:
    139
    Hi alcedo
    Awesome work! Though this thread is old, but verlet integration is indeed pretty blank in unity....
    Could you give a simple walkthrough on how to setup a working scene from scratch.
    I downloaded the tutorial pack, but it only contains an empty scene....
    Cheers!
    WY
     
  25. Ben1977

    Ben1977

    Joined:
    Feb 27, 2013
    Posts:
    8
    the same from my side :(

    pls post a 4.x rdy sample for your nice demo