Results 1 to 6 of 6

Thread: [C++ and DirectX] Spring physics simulation

  1. #1
    Join Date
    Jan 2010
    Location
    Salo, Finland
    Posts
    65
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default [C++ and DirectX] Spring physics simulation

    It came to my mind that i had done this little project a few months back before starting to work with runescape so i thought maybe someone wants to play with it So it is a 2D simulation where you can build some structure with balls and attach springs to them so the springs will try to keep the distance between the balls that what it was originally.

    Left click to place a green freely moving ball and space + left click to place a red ball that is static and will not move. To delete a ball, hold numpad 1 and left click it. To set a spring between 2 balls, right click one ball and then right click the other ball and you will see a blue line appear between them, that is the spring. By holding the mouse scroll down and moving the mouse you can move everything in the world so the area doesnt limit to the area you see. When you have built enough, press numpad 7 so the simulation starts running. You can also pause the simulation with numpad 7, make some changes and unpause it if you want and you can add balls and springs at runtime too. You cannot drag the balls, all you can do atm is to edit the gravity by up and down arrow keys.

    An example structure i made to show how you can test it, just for example:


    I uploaded it here because the file is too large to upload as an attachment: http://www.filefactory.com/file/3c6a...n/DXSpring_rar
    Another download link: http://www.sendspace.com/file/elhr0k

    F-Secure (and probably other antivirus programs too) say that the .exe is a virus, that is because i have included the graphics inside it, you can see them in files.h in the source code. If you dont trust me, you are free to check the source and recompile it yourself and see that it says the same thing.

    The compiled .exe is at DXSpring/Release folder if you just want to test it. The graphics arent very fancy, just made them quick with SumoPaint. There is no save/load option so dont spend like 2 hours building a huge thing and then accidentally close the thing

    EDIT: Oh and if it says that d3dx_43.dll is missing or something like that, you need the newest directx: Download here
    And if it still doesnt run, you might not have the redistributable: x64 Download or x86 Download
    Last edited by Mato; 07-16-2012 at 04:51 PM.

  2. #2
    Join Date
    Dec 2011
    Location
    -bash
    Posts
    515
    Mentioned
    0 Post(s)
    Quoted
    27 Post(s)

    Default

    Use a different site to upload it, filefactory is being a beech

  3. #3
    Join Date
    Jan 2010
    Location
    Salo, Finland
    Posts
    65
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    There you go, try the other link.

  4. #4
    Join Date
    May 2007
    Location
    England/Liverpool
    Posts
    1,004
    Mentioned
    9 Post(s)
    Quoted
    106 Post(s)

    Default

    Nice work.
    what was your idea with this where you creating a game of some sort if so how come you discarded it

  5. #5
    Join Date
    Jan 2010
    Location
    Salo, Finland
    Posts
    65
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    I wasnt creating a game, this was just a little project to do for fun. I wanted to do another one too that would use the real mass-spring-damper equation so it would solve the equation to get the real position at the point of time, as this is just using euler integration in 50 steps so it isnt that accurate. The reason i didnt do it is that im in highschool 1st grade so my math knowledge isnt so good that i could handle the equation well enough.

  6. #6
    Join Date
    Apr 2012
    Location
    UK
    Posts
    269
    Mentioned
    2 Post(s)
    Quoted
    46 Post(s)

    Default

    Very nice good physics for a game engine though I've been working on a game engine written in java and uses opengl api so the performance can be boosted by a lot. It's going good am going to have to work on physics soon for my engine because I want to implement rag-doll and things like that got any tips?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •