PlayfulJSTerrain port

About Monkey 2 Forums Monkey 2 Code Library PlayfulJSTerrain port

This topic contains 3 replies, has 2 voices, and was last updated by  Amon 1 month ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #15303

    DruggedBunny
    Participant

    This is a heightmap generator by PlayfulJS (see links in code). Screenshot below.

    The author doesn’t attach a license of any kind (he treats it as public domain), which won’t suit everyone, but this port is of course provided on the same basis…

     

    You can get a simple heightmap by doing this:

     

    … and here it is in runnable mojo3d demo form — paste into Ted2Go and run it! (Tested in latest GitHub develop release.)

    Attachments:
    #15304

    DruggedBunny
    Participant

    Experimental

    Multi-threaded the terrain generation (for 3D demo)!

    Binary for Windows x64

    (VirusTotal results)

    Model.CreateTerrain is the slowest part in generating the terrain, so this does the heightmap generation/mesh creation in a background thread, meaning there’s only a small jerk while the new terrain swaps in. Not sure what causes the jerk — uploading to graphics card, maybe? Still much nicer than the previous demo.

    Hit G to generate new terrain while running.

    Threading is probably only in the GitHub develop branch, and is experimental. Anyway, just quickly hacked it in out of curiosity!

    Note the ground?  checks for ease of use here, avoiding complex flags while the thread does its thing. I can simply turn the ground using ground?.Rotate (0.0, 0.125, 0.0) and if ground:Model is still loading/Null then it has no effect. Mark recommends against over-use of ?  checks!

    (I realised GenerateTerrain also hard-codes the height for now (256), easy enough to modify, of course.)

    #15310

    DruggedBunny
    Participant

    Updated to fix jagged edges — threaded demo source and binary updated too. (Non-threaded ‘should’ just run from Ted2Go in recent releases, without needing GitHub develop branch.)

    #15313

    Amon
    Participant

    This is cool. 🙂

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.