Results 1 to 6 of 6

Thread: MetaCircles - simple entity demo

  1. #1
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,146
    Rep Power
    735

    Lightbulb MetaCircles - simple entity demo

    Hi,

    as the Portal 2 game I played recently modelled liquids via isosurfaces, I could not wait to try to develop similar system.
    For the start I picked 2D case of primitives I call MetaCircles. On the internet you can find them referenced as MetaBalls, but as it is simple 2D shape, the Circle suits better I think.

    Very interesting article and source of inspiration and code can be read here:
    http://www.gamedev.net/page/resource...es-in-2d-r2556

    Below I attach sample code for 2D case. The download contains 3 files:
    • MetaCircle_Demo.tBasic - the main application
    • actor_MetaCircle.tBasicU - custom entity representing single meta circle, which can be instanced in any number of copies
    • animator_MetaCircleCollection.tBasicU - custom entity serving as high level container for meta circles, taking care of calculating the whole effect

    ThinBASIC 1.8.8.0 is required.

    I hope you will like it. It is quite computionally expensive, and many further optimizations could be done (feel free to try), but I wanted to keep the code easy to navigate.
    If it runs too slow on your machine, please tune parameter at line 41 in main code:
    MetaCircleCollection_SetGridStep(%sScene, %eMetaCircleCollection, 0.15)
    
    ... to any bigger number, such as 0.2 and so on

    I hope you will like it, it is quite hypnotic to watch.


    Petr
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by Petr Schreiber; 13-07-2011 at 18:34.
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  2. #2
    thanks Petr for the valuable subject and for the code, the referenced articles contains deep philosophical discussion how data can be represented, it is seems the metaballs is an old subject. needs more time to read. also the referenced Paul's projects site is very usefull. your code as always proves that thinbasic is a capable language, and can be used for any thing imaginable.

  3. #3
    thinBasic MVPs kryton9's Avatar
    Join Date
    Nov 2006
    Location
    Naples, Florida & Duluth, Georgia
    Age
    68
    Posts
    3,865
    Rep Power
    404
    Really cool demo Petr!! It is fun to watch that is for sure.

  4. #4
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,814
    Rep Power
    10
    Great example Petr.
    I'm using it to optimize Core engine in some parts this script is able to push at the maximum.
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  5. #5
    Super Moderator Petr Schreiber's Avatar
    Join Date
    Aug 2005
    Location
    Brno - Czech Republic
    Posts
    7,146
    Rep Power
    735
    Thanks guys!,

    it is really surprising challenge from performance point of view.

    Regarding speed - before posting it here I had to do one minor optimization, which was replace function call on line 99 in animator_MetaCircleCollection.tBasicU with "expanded" function body. It brought significant speed increase, I guess the memory allocations during function invoke were the possible bottleneck, as the rest is the same.


    Petr
    Learn 3D graphics with ThinBASIC, learn TBGL!
    Windows 10 64bit - Intel Core i5-3350P @ 3.1GHz - 16 GB RAM - NVIDIA GeForce GTX 1050 Ti 4GB

  6. #6
    I was expecting it to run quite slow on my netbook but was quite surprised when I saw it running.

Members who have read this thread: 0

There are no members to list at the moment.

Tags for this Thread

Posting Permissions

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