Not logged in, Join Here! or Log In Below:  
 
News Articles Search    
 


Submitted by Jack Strohm, posted on April 24, 2002




Image Description, by Jack Strohm



NOTE - Not a terrain engine, but it can do terrain.

These are some shots from an engine I've been working on for about 2 years. I've still got a long way to go before it's finished, but since I finally got a windows version up and running I decided to post an IOTD.

I originally posted an IOTD quite awhile back, some people refered to it as green swiss cheese. I've decided to call the top left image furry swiss cheese (I'm using animal skin textures for my test now). The top right image is the left image in wireframe. The bottom left shows the top side of a smooth cube with some odd structures on it. The bottom right shows a few seconds later with some edits applied. The edits are near-realtime.

Originally the engine was supposed to be a voxel engine, inspired from some work by Stan Melax. But as I kept working on it I ended up switching it to metaballs. It seems to me that voxels are kinda like a degenerate form of metaballs anyway, at a certain area one unit squared they have a field value of infinity and everywhere else they are zero. Metaballs have some nice properties that voxels don't give you like simple normal calculation and reduced memory overhead.

Well now the engine takes a whole lot less memory than before and I've gotten edits much faster. This demo allows you to edit in one of two ways. You can fire (spacebar) a bullet that hits the terrain and destroys it (actually adds negative metaballs). You can also move to a spot and hit 'E' and deposit a positive metaball in your location. Both of these will be quickly calced and added to the new scene, on a fast system in less than a second. Please read the readme.txt before you run the program.

I've got ideas to build a game, that allows real-time deformation of the terrain (grenades, bombs, etc!). Also when I add the physics system I can use the field values from the metaballs to calculate gravity so that you can walk over the surface of the metaball structure. Think of the game "Tribes" in space, fighting on deformable metaballs.

It supports LOD using a modified binary triangle tree algorithm. The BTT seemed a bit slow, sending single triangles to the screen at a time, so instead of a triangle being a leaf node in the BTT, a large group of triangles are the leaf node of the BTT. Also LOD only occurs in the XY plane. Z LOD always stays the same. The meshes that exist in the leaf nodes of the BTT are optimized for the Geforce vertex cache.

Ok, now for my feature list:
  • Underlying data structure are metaballs.
  • Dynamically Generated Mesh and Texture coordinates.
  • Terrain doesn't have to be flat. It can have holes and caves in it easily.
  • Allows modifying of the metaballs which in turn causes all affected meshes to be recalculated (very fast!).
  • Real time editing (now it's fast, but it will get MUCH faster!) LOD implemented using a variation of binary triangle trees.
  • Saving and Loading of all data structures.
  • Console can change most system variables while the app is running.
  • Implemented in C++ and OpenGL under Linux, ported to Windows using Borland C++ (only tested under XP). Currently only tested on TNT2, Geforce2MX, Geforce2 GTS(thanks Zelcious).
  • Multithreaded (A little jerky under windows, still working on figuring that out).
  • The longest project I've ever been able to concentrate on without getting distracted (Hey that's a very cool feature!)
  • To download the source code, linux binary, or windows executable go to http://iris.homeip.net/jstrohm. Larger screenshots are also available. Prebuilt maps are available as a seperate download (they aren't very fancy!).


    [prev]
    Image of the Day Gallery
    www.flipcode.com

    [next]

     
    Message Center / Reader Comments: ( To Participate in the Discussion, Join the Community )
     
    Archive Notice: This thread is old and no longer active. It is here for reference purposes. This thread was created on an older version of the flipcode forums, before the site closed in 2005. Please keep that in mind as you view this thread, as many of the topics and opinions may be outdated.
     
    Hoyle

    April 24, 2002, 03:41 PM

    if you change thread priority in windows from something other than 0 it goes crazy. Priority 1 (a little higher than normal) nearly kills XP the thread get's all of the CPU time.

    I've thought moving my thread back into my main app, but it's so much easier to let the OS handle multitasking instead of doing it in the app. That's the whole point of the OS, and it does work correctly under Linux, it's just windows that has the problem. Well I'll solve it someday.

    Now when it just display (not editing) is it smooth?

     
    Hoyle

    April 24, 2002, 03:41 PM

    Yep!!! if anyone else has a suggestion PLEASE suggest!

     
    Hoyle

    April 24, 2002, 03:42 PM

    that is true, unless the loss in detail is small enough not to worry about (hence the 0,0 and 0,1 -> 0, .5)

     
    Hoyle

    April 24, 2002, 03:44 PM

    My fields are limited, at a specific radius they go to zero. But I don't store them effeciently. I search all available for what affects an area (say a small sphere), then I use that list of functions to build the mesh in that area. It could be much faster. That's to be fixed soon. Just have to decide on a metaball partitioning algorithm. (don't know if they exist already).

     
    Hoyle

    April 24, 2002, 03:45 PM

    crazyness makes the world interesting.

    Sanity is just a one trick pony - The Tick

     
    Hoyle

    April 24, 2002, 03:46 PM

    If anyone would like to make one (hint hint) I would love to have it autoconfiscated, but I don't know how to do it mayself . . .

     
    Hoyle

    April 24, 2002, 03:48 PM

    Amiga - very cool, always wanted one, I just had an Applie ][+. (Man the graphics were awesome :-( )

    You know of any screenshots or weblinks to something that show something similar on the Amiga?

     
    Berserk

    April 24, 2002, 03:50 PM

    I been looking at these IOTD's for a while and I'm begining to wonder how come the original posters never reply to their own thread? I find it kinda odd, they should take more interest in people who discuss their work

     
    inkyblue2

    April 24, 2002, 03:51 PM

    Storing them in an octree based on center would get you a pretty easy way to find all metaballs in a given cube. You could optimize it by "merging" metaballs that are less than a certain distance apart, preventing excessive tree depth and keeping ball count down.

     
    CGameProgrammer

    April 24, 2002, 03:53 PM

    Very cool and original! I never thought of using metaballs for terrain. I'm working on a multiple-heightmap engine with manually-specified vertex deformation to blend them together, but the metaball approach is easier to edit and you'd have full control over real-time editing of the geometry.

    The Windows program does not crash, but it does run very slowly. From previous messages, I gather this is a threading problem, but it makes it look like the metaballs are slow even for that small amount of geometry.

    MC Baxton actually has a valid complaint - the demo just has a floating rock. It's a little difficult to see how well you can make entire levels with metaballs with efficient visibility culling and memory usage. Simulating hills by making bumps is easy, but that doesn't automatically mean it can render expansive landscapes.

    You should try to make a large landscape with some natural rock bridges, caves, tunnels, cliffs, etc. and see how fast it is.

     
    Busta

    April 24, 2002, 03:57 PM

    To Berserk: Uh, Hoyle [Jack Strohm] has posted over 10 replies to questions and comments about his IOTD so far today.

     
    Hoyle

    April 24, 2002, 04:05 PM

    Thanks! I can make a large terrain but the compressed map files is about 40 to 200 megs. I'll try to make one and take some screenshots and post them on my site.

    The map in the demo is 64^3, I've run them as large as 1024^3, they take awhile to generate, but as for displaying I get about 15 or more fps. I have a lot of optmizations to put in place that will increase frame rate.

    Also, as I've mentioned before I need a metaball partitioning structure which will greatly speed up the generation of meshes (both at startup and during edits).

    All these things are on my todo list.

    Thanks for the suggestions!

     
    red-eye

    April 24, 2002, 04:15 PM

    Unfortunately I don't have time....but if you are interested in learning, I used this book to learn the basics:

    http://sources.redhat.com/autobook/download.html

    It's available free online as well as in print.



     
    Hoyle

    April 24, 2002, 04:16 PM

    thanks, I may do that . . . . but I don't have much time. . . got too many features I want to add to my engine . . .

    Thanks!

     
    Punchey

    April 24, 2002, 04:24 PM

    I agree that it seems that most of the time, there is scant reply from the original poster. And I appreciate Hoyle's heavy participation in the discussion of his own posting today. This is the way all IOTD posters should do! Thanks, Hoyle!

     
    Hoyle

    April 24, 2002, 04:29 PM

    woot!!!! - way to go me!!!, no seriously thanks, It just seems logical if you post an IOTD, you want feedback. So when people comment or ask questions it's not hard to reply quickly. Flipcode's message system makes it very easy to monitor the threads and to see what stuff is new, so when I see a new message I just respond quickly to it.

     
    Sniper BoB

    April 24, 2002, 04:32 PM

    Couldn't you have the [meta|meat]balls operate on a hight map? that would make the level sizes much smaller. If terrain engines of the present teach you anthing it should be that 90% of a map can be defined with a single hight map. You could then use the metaballs to define the rest of it operate on that hight map.


    -SniperBoB-

     
    Hoyle

    April 24, 2002, 04:36 PM

    I just remembered, try typing make depend, then make clean, then make, and see if that works under debian.

     
    Hoyle

    April 24, 2002, 04:38 PM

    could you expand and explain this a bit more, sounds interesting . . .

     
    ramses0

    April 24, 2002, 04:40 PM

    I got the same error message, don't have time to try building it from source right now, but I was able to get the windows version working under the latest WineX. First of all, it looks pretty cool, although the "popup" effects from zooming way out, and then way back in are disconcerting.

    ...wasn't able to try the editing stuff (for some reason the keyboard bindings didn't work :^) ... I'd love to know if running the windows version under linux would have the same performance problems while editing (the normal demo didn't appear to have any problems).

    obPraise: Looks cool! :^)

    --Robert

     
    shrike

    April 24, 2002, 04:44 PM

    You mention ways to add metaballs, but unless there is a way to delete them too, the map will get cluttered with extra metaballs that dont add anything but calculation time.

     
    Hoyle

    April 24, 2002, 04:55 PM

    My friend ran it under Wine and had the same problem with the Key Bindings, not sure why.

    Thanks!

     
    Hoyle

    April 24, 2002, 04:55 PM

    absulutely correct - this is something I'm looking into on how to resolve.

     
    Berserk

    April 24, 2002, 05:08 PM

    Ah, I didn't know Hoyle is Jack Strohm. The original post should mention the author's forum nick name

     
    Hoyle

    April 24, 2002, 05:11 PM

    ha ha, yeah that feature has been requested before. Hopefully it will be added soon.

     
    noisecrime

    April 24, 2002, 05:14 PM

    Sniper has an interesting idea there.

    I often thought metaballs would make a good method for carving out cave systems, either in preprocessing, or realtime.

    My view on what Sniper said is that you could add clumps of metaballs to a standard hieghtmap terrain, to achieve caves, holes, overhangs etc. Actually thats pretty much what you've got working already, it just needs to be put into a larger terrain engine.

    As terrain doesn't change much (if at all) all thats needed is a preprocessor step to combine the terrian with the metaballs when the level is loaded. This would reduce the memory requirements against say storing the data to a polygon soup terrain of the same type, as you have a simple 8 bit heightmap, with a list of metaball positions and strengths.

    However with a decent space partitioning system, the terrain could be updated in realtime via the metaballs (i.e when you blow up some part of the terrain, or a volcano with lava pouring out), which could be cool.

    Another advantage might be to produce two meshes from the terrain and metaballs, one at screen mesh resolution, and another lower resolution for the metaballs for collision detection.

    BTW you know metaballs method is patented? So unlikely you could actually use it in a commercial project ;(

     
    Hoyle

    April 24, 2002, 05:21 PM

    okay, that makes a lot of sense, I'll think about that.

    as for the patent, I wasn't aware that metaballs were patented . . . I know marching cubes is patented (which is almost always to display metaballs), but I'm not using marching cubes.

     
    Wernaeh

    April 24, 2002, 05:42 PM

    Like the left upper image best ;) - Wernaeh

     
    Sniper BoB

    April 24, 2002, 06:17 PM

    every time I come back to check responces or comments, I get a new idea! This is so exciting, glad you shared it with us.

    How about allowing for the manipulation of existing metaballs? Maybe with a transform gizmo like that of 3D Studio Max and some kind of slider for the size of the ball.

    It would make it real nice to edit the terrain for the level editors (as oppossed to the players and their explosives)

    -SniperBoB-

     
    Hoyle

    April 24, 2002, 06:20 PM

    that's also a possibility. I haven't started working on modeling tools. I did play a bit with using other functions besides spheres, like hard edged cubes, smooth spheres. Someone even posted awhile back in there signature an equation for a heart that I plugged in and got a weird metaball heart shape. I've even thought of adding a metaball whose functions retrieved there values from a height map.

    You could probably add transforms to bend and squish the balls (sounds painful!). That would be cool.

    I'm glad you enjoyed it!

     
    This thread contains 120 messages.
    First Previous ( To view more messages, select a page: 0 1 2 3 ... out of 3) Next Last
     
     
    Hosting by Solid Eight Studios, maker of PhotoTangler Collage Maker.