Voxel Landscape Engine
The voxel engine at its most basic level works like any other voxel heightmapping
graphics routine--it computes the screen y height of each visible voxel within
the viewing area and draws a bar with the correct color (many of them, going
from back to front), creating a visible landscape. This routine is unique
in that it does high-quality texturemapping. It also relies on a huge amount
of preprocessing to increase rendering speed. This preprocessing mostly takes
the form of building giant arrays in memory, storing adjacant heightmap and
texturemap values in single dwords in memory. Even the textures themselves
are preprocessed for greater speed. Because the rendering buffer is in 32-bit
color, everything is blended and mixed as much as possible to create a landscape
that hardly looks voxel-based. Unfortunately, all of this has a price: huge
memory requirements--nearly 20 MB for video, texture, map, and scratch storage.
The major data structures for this engine include the textures array, which
stores the expanded 256x256x32-bit textures, the heightmap, the texturemap (expanded
to 4 times its original size due to preprocessing), and the 32-bit rendering
buffer.
Player Structures
As this is a multiplayer game, data needs to be kept on each of the other players.
For simplicity, the structure stores the basic information needed to display
the player on the user's screen, come directly from that user's voxel engine
variables. This structure is also used, without modification, as the network
client packet.
| X Position (XPos) | 4 bytes (16.16 fixed point) |
| Y Position (YPos) | 4 bytes (16.16 fixed point) |
| Elevation | 2 bytes |
| Tilt | 2 bytes |
| Frame Counter (FrameNum) | 2 bytes |
| Player ID (ID) | 1 byte |
| Misc. Flags (Flags) | 1 byte |
| Total | 20 bytes |
Networking
Networking is UDP/IP, NetBIOS support may be added, and the interface to the
AI appears like a network connection. The UDP/IP networking is done through
Win9x using libsocket function calls. The basic architecture is client/server.
The server manages the game, keeps track of scores, listens for client info
packets, and regularly sends out a server packet to all of the clients. The
client (the main program) sends out a packet if it has just recieved a server
packet--this might be changed to a timer for better response times.
Event Handling
Due to the complexity of creating interrupt handlers in protected mode, all
event handling is done using polling. Less elegant, but much more stable.
Events are handled every frame in VESA, or every other frame in Mode-X (due
to page flipping). All user control is done using the keyboard, and network
packets are detected and recieved to update other players' info.