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.
     
    Buster

    April 24, 2002, 06:44 PM

    Wierd man, freakin' wierd.

     
    Hoyle

    April 24, 2002, 07:00 PM

    Ok, after doing some thinking, I really like this idea and will try to add it to geek. I'll do it by creating a MetaLandscape object (derived from a MetaFunction), that instead of being a simple function will return density values based on a height map. Well when I generate the mesh for a given area, if that is the only mesh available, I can calculate the mesh very quickly. No summation of field values or anything, just standard height map landscape for that area of the mesh. Thanks a lot for that idea!!!!! YES!!! another cool feature to add . . . .YES!

     
    abdulla

    April 24, 2002, 07:25 PM

    nice to see someone develop on linux first

     
    Hoyle

    April 24, 2002, 07:33 PM

    thx, although you don't get as much coverage as with windows app., but it's a lot easier to work in Linux. hmmmmm how many times did my app kill my OS . . . never . . . (well it did kill X a few times, ha ha ha, but no reboot)

     
    postalrat

    April 24, 2002, 07:47 PM

    Do people use the word 'engine' just to confuse me or has someone defined where that words should be used now? Is this an application, engine, visualization, simulation, library, tool, game, ????

     
    postalrat

    April 24, 2002, 07:52 PM

    Cant you jsut set to the higher priority then sleep when you are not so busy?

     
    noisecrime

    April 24, 2002, 07:55 PM

    Yes you're right I meant marching cubes algo was patented. Interesting you have developed your own method.

    Look forward to seeing what you come up with in regards to meta landscapes

     
    postalrat

    April 24, 2002, 07:57 PM

    try developing in windows 2000 for a while. i do some really strange wrong things in my code and cant remeber back the last time i couldnt get back into windows. no restarting the gui required.

     
    Sniper BoB

    April 24, 2002, 08:47 PM

    glad to be of service ;-)

     
    Diego Devesa

    April 24, 2002, 09:08 PM

    Try adding a Sleep(0) to your intensive loop.

    Hope that helps.

     
    MC BAXTON

    April 24, 2002, 09:09 PM

    LOL

     
    MC BAXTON

    April 24, 2002, 09:12 PM

    The same with XP
    just end task and that's enough ... no restart needed

     
    noxa

    April 24, 2002, 09:12 PM

    GREAT JOB :)
    I love it man, totally, and the fact that you have a linux binary is really sweet.
    As opposed to other people, mine seems to work fine. I'm running RH7.2 with latest everything.

    I did notice that when switching to fullscreen mode, it just blacks out the borders of the screen - is this a limitation of SDL (I've never used it) or just laziness on your part? *grin*

    Keep up the good work man - I think I may see if I can implement this in my current project - it would make for some beautiful asteroids :)

     
    Hoyle

    April 24, 2002, 09:34 PM

    yeah, I didn't have much of a problem when I ported to Windows XP. Previously I had developed under 95. I still thinks Linux's threads are a lot better behaved then Windows threads. In Windows I set the thread priority to 1 (normal is 0, real-time is 15), and it nearly froze the machine up. I couldn't even get the task panel to come up until about 3 minutes after I hit ctrl-alt-del. No updated display, nothing. Killed me app, and everything ok, but that was close, I almost gave up and rebooted.

     
    Hoyle

    April 24, 2002, 09:36 PM

    must be an SDL thing, I call the toggle fullscreen method. In windows this doesn't work, but it's supported in Linux. On my machine it just resets the video mode. What video card are you running? BTW - please email me your geek.log file.

     
    Hoyle

    April 24, 2002, 09:38 PM

    changing thread priority in windows nearly locks the machine. It doesn't even give any time to the OS. (going from priority 0 to 1)

     
    Hoyle

    April 24, 2002, 09:38 PM

    I will try that next time I reboot into Windows, Thanks I hope that works!

     
    stefan/dxm

    April 24, 2002, 09:41 PM

    your getting better ! :))

    nice to see you all active and shit to many "yes sayers" lately ;)

     
    Ron Frazier

    April 24, 2002, 09:47 PM

    Enough already. Just so you arent confused, webster defines an engine as "something used to effect a purpose". An engine can be anything that does something.

    You can have a graphics engine which does the rendering and controls render states.

    You can have a sound/audio/midi engine which controls audio playback or provides an interface for doing so.

    You can have a collision detection engine which takes input data and determines which data elements have collided in space.

    You can have a physics engine which is a more advanced collision detection engine and handles things like movement, accelleration, gravity, action and reaction, etc.

    You have have an animation engine which handles animating models, frame interpolation, inverse kinematics, etc.

    You can have a sprite engine which deals with drawing 2D sprites on the screen.

    You can have an input engine, which provides an interface to input hardware such as a mouse, keyboard or joystick.

    You can have a UI engine, which handles things like menus, buttons, windowing, etc. This might also include an input engine or interface with an external input engine.

    You can have a resource enigne, which handles access to resources like memory, files, etc.

    You can have a game engine which handles one or more of the above tasks, either be interfacing with several external engines or by integrating them into one big engine, for the purpose of implementing a game.

    You can have about a million other type of engines which handle other types of tasks or integrate 2 or more other types of engines together.

    In summary, an engine is just about anything that does something. This explanation should clarify for you what the word engine means. I WANT TO SEE NO MORE POSTS FROM YOU TELLING US THAT YOU ARE CONFUSED BY THE USE OF THE WORD ENGINE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

    Have a nice day :)

     
    Hoyle

    April 24, 2002, 10:05 PM

    I tried an octree, the only problem is that metaballs may have to be stored in more than one node because they aren't points, but spheres.

     
    Hoyle

    April 24, 2002, 10:06 PM

    hmm . . . that sounds strangely familiar . . . .

     
    Hoyle

    April 24, 2002, 10:10 PM

    Ok . . . I tried adding sleep(0) all thru the thread and it didn't help. I also increased thread priority . . . ouch . . . well with the sleeps at least it only took 30 seconds to get control of my computer again and not 5 minutes, but still no cigar.

    This is kinda crazy. Windows just doesn't seem to handle threads correctly. I don't know. I need some Windows Guru to try to get it to work.

     
    Hoyle

    April 24, 2002, 11:17 PM

    I added a test version of blending height fields with metaballs and it looks like it may work. It's not pretty enough for screenshots yet, but the basic idea is easy to integrate into my current code. Need to calculate the normal for a point on a heightfield. Any good ideas on that.

     
    postalrat

    April 24, 2002, 11:35 PM

    windows must have threads pretty correctly or else it wouldnt run as well as it does. there is just something we are missing. a good size sleep should do it as long as it doesnt interfere with what you are doing. if there is a yield function that would help as well. i dont know much about prgramming over mulitple threads in windows.

     
    Hoyle

    April 25, 2002, 12:39 AM

    yeah, but that's the problem it's almost like the thread sleeps for a few seconds get's woken up, does some stuff, then has to sleep for a few more seconds. In Linux they just run at the same time. They both get about 50% of the CPU and since my main thread is mostly just sending triangles to the hardware and waiting for the hardware to finish, the the LOD/Edit thread get's most of the CPU time. But the frame rate is high and the edits are quick.

    I need to talk to someone that has done Windows MT coding.

     
    Frank L

    April 25, 2002, 12:43 AM

    I applaude your effort and the fact that you have been working on this alone and created what seems to be a really nice program.

    You should however take a look at the siggraph paper to be published at the coming conference on dualcontouring, you'll see a way of doing voxel based worlds at extremely high grid resolutions (512^3 is currently being used), with CSG operations taking a total of 20 ms (ie, continuous additions or subtractions can be made at reasonable frame rates). It also features an extremely compact storage structure that makes the required storage space and RAM consumption proportional to the surface area of the solid being represented as opposed to most voxel based methods that store the whole grid explicitly, hence having problems with even small grids.

    The paper can be found here:

    http://www.cs.rice.edu/~sschaefe/research/dualcontour.pdf

     
    jdi

    April 25, 2002, 01:02 AM

    Maybe try a loose octree.

     
    Hoyle

    April 25, 2002, 01:04 AM

    Looks like a cool paper, I did a quick scan thru it, I'll print it out tomorrow and read it in more detail. That's why I love the computer graphics field, always new stuff coming out!

    Thanks!

     
    Hoyle

    April 25, 2002, 01:04 AM

    Looks like a cool paper, I did a quick scan thru it, I'll print it out tomorrow and read it in more detail. That's why I love the computer graphics field, always new stuff coming out!

    Thanks!

     
    Hoyle

    April 25, 2002, 01:05 AM

    yeah, I tried that, my first implementation (quick and dirty) sucked, and got me worse performance. I need to try it again.

     
    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.