ohadpr » exper http://ohadpr.com ideas, hacks and stuff Tue, 29 May 2012 07:08:58 +0000 en hourly 1 http://wordpress.org/?v=3.3.1 OpenGL Terrain Engine http://ohadpr.com/2001/08/opengl-terrain-engine/ http://ohadpr.com/2001/08/opengl-terrain-engine/#comments Sun, 12 Aug 2001 08:14:34 +0000 ohad http://ohadpr.com/?p=65 Continue reading ]]>

Update: iPad version released

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 Gonzalez Rodriguez – terrain texture generator (CKCed) and figuring out the correct blending mode for the detail-texture.

]]>
http://ohadpr.com/2001/08/opengl-terrain-engine/feed/ 4
PQTorus http://ohadpr.com/2001/08/pqtorus/ http://ohadpr.com/2001/08/pqtorus/#comments Sun, 12 Aug 2001 08:14:23 +0000 ohad http://ohadpr.com/?p=89 Continue reading ]]> 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.

pqtorus_optionsjpg pqtorus_shot_1 pqtorus_shot_2 pqtorus_shot_3

Downloads:

Binary (win32): pqtorus.zip

]]>
http://ohadpr.com/2001/08/pqtorus/feed/ 0
Mini-Tracer & Life-Saver http://ohadpr.com/2001/08/mini-tracer-life-saver/ http://ohadpr.com/2001/08/mini-tracer-life-saver/#comments Sun, 12 Aug 2001 08:14:11 +0000 ohad http://ohadpr.com/?p=97 Continue reading ]]> Following are two screen-savers.

One implements Conway’s game of life, and the other does Recursive Sphere Ray-tracing.

The ray-tracer 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

minitracer_shot_1 minitracer_shot_2 minitracer_shot_3 life_shot

Downloads :

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

]]>
http://ohadpr.com/2001/08/mini-tracer-life-saver/feed/ 0
Earth Simulation + GIS http://ohadpr.com/2001/08/earth-simulation-gis/ http://ohadpr.com/2001/08/earth-simulation-gis/#comments Sun, 12 Aug 2001 08:14:00 +0000 ohad http://ohadpr.com/?p=80 Continue reading ]]>

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

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.


]]>
http://ohadpr.com/2001/08/earth-simulation-gis/feed/ 6
Always Picture http://ohadpr.com/2001/08/always-picture/ http://ohadpr.com/2001/08/always-picture/#comments Sun, 12 Aug 2001 08:13:45 +0000 ohad http://ohadpr.com/?p=108 Continue reading ]]>

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

]]>
http://ohadpr.com/2001/08/always-picture/feed/ 1