Page 3 of 4 FirstFirst 1234 LastLast
Results 21 to 30 of 39

Thread: Trouble porting liquid simulation to Pascal - AARRGGHH!

  1. #21
    Fair enough Oh, sorry if my previous post seemed insulting! That was not what I intended

    cheers,
    Paul
    Games:
    Seafox


    Pages:
    Syntax Error Software itch.io page

    Online Chess
    http://gameknot.com/#paul_nicholls

  2. #22
    PGD Staff code_glitch's Avatar
    Join Date
    Oct 2009
    Location
    UK (England, the bigger bit)
    Posts
    933
    Blog Entries
    45
    Not at all, I didn't find it at all insulting actually. Rather, its encouraging to see a +1 for the 'interested in linux' or 'acknowledges linux group'. A lot of people say class linux as a hacking project by some shed geeks that isnt accessible to anyone and a rebellious non-conformist joke for the poor that can't afford 'real PCs'. And I kid you not - I have heard that opinion voiced more times than you would believe. So for me, your post was kinda refreshing since it puts Linux on par with windows as two means to the same end
    I once tried to change the world. But they wouldn't give me the source code. Damned evil cunning.

  3. #23
    I made a port, but the result makes no sense to me. This is using FPC, OpenGL and GLUT, so it should be quite portable. The text output is not supported. Here it is:

    http://www.computer-graphics.se/water_sim_fpc.zip

    It animates, but I don't find the animation very enlightening. It doesn't produce a pretty flow. I probably have some errors in the conversion (although I tried to stick as close to the original as possible).

  4. #24
    PGD Staff code_glitch's Avatar
    Join Date
    Oct 2009
    Location
    UK (England, the bigger bit)
    Posts
    933
    Blog Entries
    45
    @Ingemar: compiles and runs fine. I can see your point - esthetically it really looks pretty dire - I guess if you set each block to 1 pixel x 1 pixel you could get some decent looks going but that would kind of defeat the point of handling it in a cellular fashion as it would be more efficient to simply render it as particles then...
    I once tried to change the world. But they wouldn't give me the source code. Damned evil cunning.

  5. #25
    I got it compiled and running (buggily like mentioned) but MacOSAll had to be commented out from uses list. You could add something like {$IFDEF mac}MacOSAll,{$ENDIF} if there is such. This on Win7-32bit.
    Attached Images Attached Images

  6. #26
    Woo Hoo!!

    After some fiddling around, I have now gotten my fluid sim working just like the online demo (I think! LOL)
    http://w-shadow.com/blog/2009/09/01/...id-simulation/



    I have attached the complete project, including .exe and source code
    xeEngine - liquid sim.zip

    Escape = exit program
    R = randomize map
    C = clear map
    right mouse button = water (+ shift = air)
    left mouse button = wall (+ shift = air)

    Enjoy!

    It would be nice to know if anyone manages to use this in a project

    cheers,
    Paul
    Last edited by paul_nicholls; 30-08-2011 at 03:32 AM.
    Games:
    Seafox


    Pages:
    Syntax Error Software itch.io page

    Online Chess
    http://gameknot.com/#paul_nicholls

  7. #27
    Quote Originally Posted by User137 View Post
    I got it compiled and running (buggily like mentioned) but MacOSAll had to be commented out from uses list. You could add something like {$IFDEF mac}MacOSAll,{$ENDIF} if there is such. This on Win7-32bit.
    MacOSAll isn't even used, it just popped in because I usually use it, but it has no place in portable code. But if that was the only difference, then portability is quite good.

  8. #28
    Quote Originally Posted by paul_nicholls View Post
    After some fiddling around, I have now gotten my fluid sim working just like the online demo (I think! LOL)

    It would be nice to know if anyone manages to use this in a project
    It seems to be working somewhat, but there are 3 issues i can come up with
    - The timer is very heavy on cpu, using full capacity of 1 core.
    - Air pockets are filled with water coming from below. The pressure should in physical world limit water flow to only down and sideways, as it is implemented in many games too.
    - The simulation goes through every tile on screen per game tick. It may work with small mapsizes but when it comes to larger and pixelmap, it would hog all resources. This is why i suggested particle based approach earlier in this thread, which would be very high performance.

  9. #29
    Quote Originally Posted by paul_nicholls View Post
    Woo Hoo!!

    After some fiddling around, I have now gotten my fluid sim working just like the online demo (I think! LOL)
    I thought I should have a look at your code to see what I did wrong, but I am looking at your code and I don't get it. What code is working? I am looking in SimCompression_pde.pas, and it looks like... well, I must be looking at the wrong place because this can't be Pascal code:

    if ( blocks[x][y] := GROUND) then continue;

    That can NOT be a conversion of

    if ( blocks[x][y] == GROUND) continue;

    No, I must be looking in the wrong place. Is your archive really your working version? If it is, where is the code for the simulation?

    I also note that if I change "continue" to "cycle" in my code, my code seem to get slightly closer to correct, so is really "continue" the same in both languages?

  10. #30
    PGD Staff code_glitch's Avatar
    Join Date
    Oct 2009
    Location
    UK (England, the bigger bit)
    Posts
    933
    Blog Entries
    45
    Theres a small mistake there in the first if statement, you use := wich is to assign, a c/c++ family == is the same as = without the :

    Just my 2 pence.
    I once tried to change the world. But they wouldn't give me the source code. Damned evil cunning.

Page 3 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
  •