Page 2 of 4 FirstFirst 1234 LastLast
Results 11 to 20 of 39

Thread: Trouble porting liquid simulation to Pascal - AARRGGHH!

  1. #11
    PGD Staff code_glitch's Avatar
    Join Date
    Oct 2009
    Location
    UK (England, the bigger bit)
    Posts
    933
    Blog Entries
    45
    Ingemar: I very much like that idea. Unfortunately I made an attempt to get this working but it is an utter failure in many senses... See below:

    I figured this might be easy so I wrote this up real quick: http://dl.dropbox.com/u/4853895/WaterSimF2.zip

    Its my WaterSimF2 unit I had a crack at and a TestApp using prometheus for drawing the TMX background and updating the water etc... It behaves a bit like water with one exception: IN REVERSE!!! Oo I have o idea why but it does XD

    So if anyone wants a fluid system that works in reverse until all the water is gone or just wants to mess around with it, see the link above

    Edit:
    Screenie:

    http://dl.dropbox.com/u/4853895/WaterSimF2_Screenie.png
    I once tried to change the world. But they wouldn't give me the source code. Damned evil cunning.

  2. #12
    Quote Originally Posted by Ingemar View Post
    The whole idea of making an interpreted language running with an interpreter written in Java, clinging to every design flaw of C from 1970 (even re-intruducing some flaws that were fixed in the 80's), it stinks so bad from start to end that I don't want to let more of it than the example source near my computer
    hahahaha!!!

    Quote Originally Posted by Ingemar View Post
    But fluid simulation is nice, so freshing it up it by porting it to FPC could be useful.

    One wish for the port: Portability! How about isolating all platform dependent stuff into one unit?
    Isn't my non-working port portable and platform independent? LOL

    cheers,
    Paul

  3. #13
    Quote Originally Posted by code_glitch View Post
    Ingemar: I very much like that idea. Unfortunately I made an attempt to get this working but it is an utter failure in many senses... See below:

    I figured this might be easy so I wrote this up real quick: http://dl.dropbox.com/u/4853895/WaterSimF2.zip

    Its my WaterSimF2 unit I had a crack at and a TestApp using prometheus for drawing the TMX background and updating the water etc... It behaves a bit like water with one exception: IN REVERSE!!! Oo I have o idea why but it does XD

    So if anyone wants a fluid system that works in reverse until all the water is gone or just wants to mess around with it, see the link above

    Edit:
    Screenie:

    http://dl.dropbox.com/u/4853895/WaterSimF2_Screenie.png
    Hi code_glitch, I downloaded our port to have a look and found one thing - it doesn't compile using Delphi...

    For example, in the Prometheus_Core.pas file:


    Code:
    {$Mode Delphi}
    should probably be:

    Code:
    {$ifdef fpc}
    {$Mode Delphi}
    {$endif}
    cheers,
    Paul

  4. #14
    Water simulation on pixel/block map has been in my interest for long time. I did some experiments long ago, but they weren't that great. However that tutorial you linked (http://w-shadow.com/blog/2009/09/01/...id-simulation/) was quite good, only that it was explained way too complicated.

    Lets say we do water for pixelmap. For performance and memory reasons we want to have running water in a separate array like particles, and still water (100% of pixel in water) drawn to pixelmap. The particles try to divide its water to different down, left and right, and if they can't move and go full 100% of water they solidify into pixel to that spot.

    The particle could have the water amount represented as byte (0..255), where 255 is full. Down direction is first priority. It attempts to move down if there is no particle at that spot, but if is, it adds all its water to that particle at down. How do you know what particle is down and that pixel reserved, is 1 problem. I'd propably solve it with per-pixel word map, each 0..65k telling particle index in that spot. It's much faster than going the whole particle array through checking for position, but takes more memory and limiting amount of max particles.

    Next there is left and right. They must be considered simultaneously so that the water is split evenly to all 3 positions, self, left and right. Well, here it doesn't propably even matter how you do the math, it will look cool anyway and spread the water in all cases. You can even split all water to left and right and leave current position empty, if they had room to take it all. Or you can calculate it so that water level in all 3 blocks is made as close to each other as possible, with water you have usable from the current particle.

    Could add that it might look pretty nice if water that is falling down would split it to left and right about 20% of its amount. It will make little shower effect, because it may look boring to see water flow down 1 pixel wide line.

    Oh, when doing for-loop for dynamic particles like this, you must go through it from ParticleCount-1 downto 0. It will otherwise act weird.
    Last edited by User137; 27-08-2011 at 03:54 AM.

  5. #15
    PGD Staff code_glitch's Avatar
    Join Date
    Oct 2009
    Location
    UK (England, the bigger bit)
    Posts
    933
    Blog Entries
    45
    Paul: About the {$Mode Delphi} thing, I only use FPC and falsely make the assumption everyone else does. Sorry for that one - although if my code realy does not work in delphi, you could own your own copy of FPC for $0.00 extra!

    I'm still trying to figure out what is making my sim go screwy but logically ( to me anyway ) it should work. In theory.
    I once tried to change the world. But they wouldn't give me the source code. Damned evil cunning.

  6. #16
    LOL! No worries mate, I will just try it in my insanely expensive (NOT!) copy of Lazarus

    cheers,
    Paul

  7. #17
    @code_glitch: I can't get your liquid sim to run...at first it was missing a bunch of SDL dlls (image, ttf, etc.) so I downloaded those.

    Unfortunately it crashes for me and I don't see anything apart from the crash

    ---------------------------
    Error
    ---------------------------
    An unhandled exception occurred at $0041154B :

    EAccessViolation : Access violation

    $0041154B IMAGE__LOAD, line 170 of Src/Prometheus/Video/Image.pas

    $004117B4 TILESET__LOADFROMIMAGEFILE, line 19 of Src/Prometheus/Video/TileSets.pas

    $00412D41 MAP__LOADFROMTMX, line 342 of Src/Prometheus/Video/Maps.pas

    $00401AB3 main, line 74 of TestApp.dpr




    ---------------------------
    OK
    ---------------------------
    cheers,
    Paul

  8. #18
    PGD Staff code_glitch's Avatar
    Join Date
    Oct 2009
    Location
    UK (England, the bigger bit)
    Posts
    933
    Blog Entries
    45
    Haha, of course, sorry. I'm still making retard mistakes and assumptions like 'everyone uses linux and requires no DLLs'... I repacked the whole things into one nice shiny new Win32 compatible package right here: http://dl.dropbox.com/u/4853895/Wate...Compatible.zip

    Sorry for all the faff, especially since it was just a case of dropping in the full RTL (I don't what is/isnt required here) so if you notice any of those DLLs are unused and need the extra 900kb of HD space please feel free and remove em'.
    I once tried to change the world. But they wouldn't give me the source code. Damned evil cunning.

  9. #19
    Quote Originally Posted by code_glitch View Post
    Haha, of course, sorry. I'm still making retard mistakes and assumptions like 'everyone uses linux and requires no DLLs'... I repacked the whole things into one nice shiny new Win32 compatible package right here: http://dl.dropbox.com/u/4853895/Wate...Compatible.zip

    Sorry for all the faff, especially since it was just a case of dropping in the full RTL (I don't what is/isnt required here) so if you notice any of those DLLs are unused and need the extra 900kb of HD space please feel free and remove em'.
    Thanks mate And no need to apologise at all...windows people usually don't know Linux very well, and Linux don't usually know Windows very well

    I am a real noob when it comes to Linux programming! haha

    cheers,
    Paul

  10. #20
    PGD Staff code_glitch's Avatar
    Join Date
    Oct 2009
    Location
    UK (England, the bigger bit)
    Posts
    933
    Blog Entries
    45
    HAL Voice: "I'm afraid I can't agree with you paul...."

    In reality though, if you can program on windows, press ctrl+Alt+T and type sudo apt-get install you can use linux (yes, I know some people prefer yum and rpms but hey, thats just sudo yum install...). In fact, I found programming on linux more forgiving. EG: I forgot to close that file but I can re-open it a few times (bad coding practice I know) but sometimes you don't care what the file is doing - you're trying to fix a bug in some opengl matrix
    I once tried to change the world. But they wouldn't give me the source code. Damned evil cunning.

Page 2 of 4 FirstFirst 1234 LastLast

Tags for this Thread

Bookmarks

Posting Permissions

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