Terrain Engine

Earth Simulation + GIS

Interceptor Combat

PQ-Torus

Mini-Tracer + Life-Saver

Always-There

 



I opened this page so that all the mini-projects I put my time into won't be left in my '/myproj' directory. People are encouraged to play with these examples, learn from the source-code supplied, ask questions and point out mistakes. If you use the code in your applications/products/etc, drop me a line.


contact information is available at ohad.visual-i.com.


I started working on a terrain engine around October 2000. I was deeply moved by screenshots from black and white :)


My intention and main goal was to create something visually stunning. This meant writing a terrain texture-generator, and working hard to find good textures and blending modes.

The outcome is an engine that hold a (supposedly) 1km by 1km piece of terrain with very high accuracy. There is no triangle-cutting algorithm employed, simple brute-force. I use a large terrain texture and a tiling detail texture. There's a skybox and the terrain reflects on the water.

I used OpenGL for this one, employing the OGLC skeleton to avoid most of the opengl-win32 business.

You can move through this world using descent keys (a,z, keypad). use 'w' to switch to wire-frame and 'd' to render without the detail texture.

A few screenshots :




Downloads :

Binary (win32) + Source: terrain engine.zip (compile in debug, release gives problems :)

Thanks :

Yoni Lavi - dynamic camera and general coordinate-system fixups.
The OpenGL Challenge - OpenGL skeleton-app.
Dan González Rodríguez - terrain texture generator (CKCed) and figuring out the correct blending mode for the detail-texture

 


After the WTC attacks, CNN started using their Weather-System Simulation Program (I think) to show Afghanistan and Tomahawk missiles flying :)

This looked very nice and moved by the fact that I really didn't know too much geography and had a day or two free (Sukkot Holiday), I went on and wrote my own Earth Simulation program.

The program is based on a large sphere, with a nice texture of the earth is mapped to. You can rotate the earth, zoom-in, etc, etc.

What's GIS you ask ? Well, GIS stands for 'Geographical Information System', which actually means adding any type of information layer to a raster or vector map of the world or a portion of it.

What do I have to do with GIS ? After rotating my small earth for a few minute I started to get bored again, so I went on a hunt to find information layers that I could add.

Here are screenshots of the application in various information-display states : (click the shots to see a larger version)

The world, with Country Names

The world (zooming on Africa and the Middle-East), with coastlines, rivers, lakes, islands and state-borders

The world (looking at the USA), with all the vector information including US-State lines and country-names.

The world (looking at Europe), without the world texture, and with all the vector information.


Where did the information come from ?

The information about the location of the Countries came from something called 'The CIA FactBook 2000'. It's basically an html page with links to about 200+ countries, each one has a page with facts (including Latitude/Longitude information). I downloaded all the pages using Flashget's 'Download All' (thank god for that option), and wrote a small program that fetches all the countries names and positions and generates a '.H' file with all this information.

Vector information on Coastlines, Political Boundaries, Rivers, Lakes, Islands and US-States was much harder to get.
I searched for a long time and eventually picked up the basic binary data from the Pospeschil Micro World Data Bank II. I couldn't manage to understand the format or find any explanation of it. I then used a trial-version of a program called Idrisi to convert the pairs of the '.vec' and 'dvc' files into '.vct' and '.vdc' (these are also binary files). I then used the same program to read in the '.vct' and '.vdc' files and write out '.vxp' files. Now, the '.vxp' files are an easily understandable text-representation of the vector data. I wrote something small to convert the '.vxp' ASCII files into a binary equivilant (Binary Vector Data - '.bvd') [this isn't a public format, just something I hacked for fast loading]. And eventually our program uses the '.bvd' files directly :)

The small conversion programs are included with the source-code provided below. I didn't include all the versions of the data because they take almost 10MB alltogether.

 

Now, What can we do with the program (function-wise) ?

You can enable/disable the big Earth-Texture.
You can enable/disable Wire-Frame mode.
You can play with the line-width used by the wire-frame mode and the vector-data.
You can enable/disable the display of Country-Names.
You can seperately enable/disable the display of all the vector-layers (Coast-Lines, Islands, Lakes, Rivers, Nation Boundaries and US-States).

 

 

 

Some Notes on the application itself :

Use the mouse and it's left-button to rotate earth. Hold down Ctrl before you hit the left mouse button to scale the earth. Right-Click the window to get the options menu. Note that options are controllable by keyboard too.

Country Names are shown based on Z, the more you zoom in the more country-names appear. Countries are shown using small red sine-scaling glutSolidCubes.

 

Some notes on the 3D :

I used OpenGL for this one, it was simple and straightforward. I generate a large sphere for the earth, use glSolidCubes for the countries, and simple GL_LINE_STRIPs for the vector-data. There are no display-lists or any other optimizations, I just throw everything at the card :)

I used glut for wrapping up all of Windows's internal calls, mainly because the first app-skeleton I found used it and provided some minimal texture-loading calls. Apparently the skeleton is by Andreas Gustafsson, I can't remember where exactly I found it, sorry.

I used a font library called glTexFont by Nate Miller, it uses the Quake3 Font, cool :)

Some thanks to the people at #opengl (efnet I believe) for helping me correctly placing the country-names (especially f00Dave, thanks for all the help).

 

Downloads :

Binary (win32) + Source: earth_simul.zip
Mirror #1 : Thanks Victor McCoy

The source is provided for your enjoyment, free-use, modification, etc. Feel free to contact me if you find a bug, add a feature, or anything alike.


 

Interceptor combat is a program coded by Yonthan Lavi and myself. It was initialy intended to be hte major part of a demo we started writing but decided not to enter in an Israeli demo-compo. Since then we left it unchanged until we decided to try and enter it to flipcodes (www.flipcode.com) coding contest (subject: Vehicles).

 

 

floowing is a short description :

terrain engine by kombat, simple brute-force terrain grid, with multipass textures, water has a nice caustic animated texture on them. Skycube textures were generated by TerraVox and blended with blue haze to fit the scene's fog color.

interceptor combat by silvatar, there are two groups of 16 interceptors each. their initial places are randomly generated. they spend most of their time trying to fly around while avoiding collisions with the landscape or with each other, flying too high up or leaving the scene boundaries. otherwise they just aim at their selected target and fire while they still can ('leading' greatly helped accuracy here). shield effect uses the same caustic texture as the water. shadows are rendered using 2d projections of the interceptor hulls over a local approximation of the surface underneath them (e.g. it is assumed to be locally planar). the projectiles are just a sort of 'cylindrical' addative decals.

camera control keys
a,z - forward/backward
keypad 1,3,-,+ - slide left/right/up/down
keypad 4,6,2,8 - turn left/right/up/down
keypad 7,9 - roll ccw/cw
i,o - increase/decrease camera maximal speed (exponential)

 

Screenshots:

Downloads :

Will be added soon


The PQ-Torus, or PQ-Torus Knot, is a parameterized version of the well-known Torus (A donut-like geometrical shape).

P and Q are two parameters we use to modify the toruse's shape.

The first place I saw a PQ-Torus at was : http://www.blackpawn.com/texts/pqtorus/default.html, they have some nice screenshots and a downloadable implementation of their PQ-Torus.

There is a small toolbar through which you can control the toruses' parameters, including P, Q, Radiuses and Texturing mechanism.

I used my own approach to generate Normals for my Torus in real-time, which allows real-time wiggling, jiggling and morphing of the torus.

The nicest feature is the ability to shift P/Q values and watch the torus morph from one state to another.

 

Downloads:

Binary (win32) : download\pqtorus.zip
Sources will come soon.


Following are two screen-savers.

One implements Conway's game of life, and the other does Recursive Sphere Raytracing.

The raytracer can be run in 'application mode' as well, but it's pretty nice as a screen-saver.

The spheres are lighted using Phong illumination, including Specular-Highlights, recursion level is limited to your stack, or in other words none.

Downloads :

Life Screen-Saver (Source + Win32 Binary) : life_saver.zip
Sphere Tracer (Source + Win32 Binary) : mini_tracer.zip

 

 

 

 


Always picture is a small program that I wrote for my girlfriend to try and cheer her up during long working hours. It allows you to scatter bitmaps on your screen and continue working with these bitmaps on-top of you screen's contents.

You can give images speed, to get clouds moving on the top of your screen :-) (they come back from the other side once they disappear).

You can close all of your pictures with a menu that pops when you right-click images.

Using the mouse you can easily drag and drop the picture to anywhere you want on the desktop.

The app uses a feature introduced in Win2000 called 'Layered Window Attributes' that allows to easily use color-keying and alpha-blending on entire windows.

Download ( Source + Win32 Binary ) : AlwaysPicture.zip