About
Progress
Screenshots
Downloads
Technical...

 Introduction
 Legacy Format
 New Formats
 Textures
 Objects
 Fonts
 Tracks
 Display

Contact
Links
Forums
Guest book
Stunt Mania : Technical
RENDERING INTERNALS
This section deals with how Stunt Mania builds up its display, since a full understanding of this will greatly benefit anyone coming up with alternate data files, or simply investigating the default set.

Stunt Mania considers its display to be made of various non-scenery objects interacting with chunks of scenery. Each chunk is an object, as defined in the Objects section, a bounding sphere and a z-buffer offset. The z-buffer offset is a measure of how far the polygons will be displaced in the z-buffer after transformation and is used to enable planar polygons to be drawn without error - it is not a measure of depth from the camera or anything like that.

The first job is that non-scenery objects - i.e. cars - are drawn. These should not contain translucency!

Scenery chunks are sorted by z-buffer offset, then divided into two groups - those that include translucency and those that do not. Those that do not are then drawn sorted front to back. Those that do are then drawn, sorted back to front.

Since no polygon level sorting within objects is done, it is essential that objects with translucency are careful about their composition, in order to effect correct drawing given the z-buffer.

There are two types of translucent object inherited from Sports 4d Driving. The first has all the translucent parts lying on a single plane - an example being a raised section of track. In this case the composition is easy. Simply have all the opaque polygons drawn before the translucent ones.

The second type features non-planar translucent polygons, but conveniently they happen to bound a convex section of space. Examples are the loop and left/right corkscrew pieces. It is also simple to have these objects drawn correctly. After opaque polygons, and with reverse face removal left on, simply draw the inward (with respect to the bounded volume) facing sides of all polygons first, then the outward sides.

In addition to all this, object level culling is performed based on an octree built at load time, however this is transparent to the drawing process and not something you need to concern yourself with if you are not providing new objects.

THE MAPPING OF LEGACY TRACKS TO SCENERY CHUNKS
The legacy track format is not strictly an invention of Stunt Mania, but comes from Sports 4d Driving. When Stunt Mania wants to display one of these tracks, it breaks it down from its original form to one containing scenery chunks at load time. This section explains how.

First of all the object with id 0 is loaded as the background object. This should contain the floor plane & edge fencing. This object is drawn with no z-buffer offset. You could replace this object with one that contains a non-flat floor, but calculations for the height of various track elements is not at this time based upon the object, so things could look very silly.

Stunt Mania then assembles the terrain - i.e. the hills and water that form a Sports 4d Driving track. Within the Sports 4d Driving track file format, these are described with values ranging from 1 to 18. Stunt Mania very simply maps these onto a grid of objects, where each object has its id directly dictated by the Sports 4d Driving file. i.e. the Stunt Mania object 1 is a square of water, object 16 is a diagonal corner, etc. All water objects - that is, all objects with a numeric value less than 6, are drawn with a small z-buffer offset. No object is displayed where a 0 is read from the source file.

Then all that remains are track details. There is no easy general case mapping here, because the Sports 4d Driving file format does not consistently follow any rules as such. All track objects are drawn with a small z-buffer offset. At present tracks with road crossing water (which are not strictly valid tracks it should be noted) will display incorrectly since the same small offset is used for both track objects and water.

I have explicitly assigned ids to each particular track feature. These are not set in stone, but most probably won't vary a lot. In particular I am no longer sure I need both a left corner option and a right corner option, since I can just rotate 180 degrees around the z axis, but that is another matter. At the moment, I use these allocations, straight from the C format header file used in the actual code :

#define TILE_ROAD_STRAIGHT		19
#define TILE_ROAD_SHARP_CORNER		20
#define TILE_ROAD_SLANTED		21
#define TILE_ROAD_LOOSE_CORNER		22
#define TILE_ROAD_CROSSROADS		23
#define TILE_ROAD_SHARP_OPTION_L	24
#define TILE_ROAD_SHARP_OPTION_R	25
#define TILE_ROAD_FINISH_LINE		26

#define TILE_MUD_STRAIGHT		27
#define TILE_MUD_SHARP_CORNER		28
#define TILE_MUD_SLANTED		29
#define TILE_MUD_LOOSE_CORNER		30
#define TILE_MUD_CROSSROADS		31
#define TILE_MUD_SHARP_OPTION_L		32
#define TILE_MUD_SHARP_OPTION_R		33
#define TILE_MUD_FINISH_LINE		34

#define TILE_ICE_STRAIGHT		35
#define TILE_ICE_SHARP_CORNER		36
#define TILE_ICE_SLANTED		37
#define TILE_ICE_LOOSE_CORNER		38
#define TILE_ICE_CROSSROADS		39
#define TILE_ICE_SHARP_OPTION_L		40
#define TILE_ICE_SHARP_OPTION_R		41
#define TILE_ICE_FINISH_LINE		42

#define TILE_SLALOM			43
#define TILE_BRIDGE			44
#define TILE_PIPE_END			45
#define TILE_PIPE			46
#define TILE_HALFPIPE			47
#define TILE_LR_CORKSCREW		48
#define TILE_LOOP			49
#define TILE_TUNNEL			50

#define TILE_BANKED_END			51
#define TILE_BANKED_STRAIGHT		52
#define TILE_BANKED_CORNER		53

#define TILE_ROAD_LOOSE_OPTION_L	54
#define TILE_ROAD_LOOSE_OPTION_R	55

#define TILE_CHICANE			56
#define TILE_SPLIT_END			57
#define TILE_SPLIT			58

#define TILE_RAISED_CORNER		59
#define TILE_RAISED_RAMP		60
#define TILE_SOLID_RAMP			61
#define TILE_RAISED_ROAD		62
#define TILE_RAISED_SPAN		63
#define TILE_SOLID_ROAD			64

#define TILE_UD_CORKSCREW		65

#define TILE_FURTREE			66
#define TILE_PALMTREE			67
#define TILE_TENNISCOURT		68
#define TILE_CACKTUS			69
#define TILE_BUILDING			70
#define TILE_BARN			71
#define TILE_PETROLSTATION		72
#define TILE_WINDMILL			73
#define TILE_BOAT			74
#define TILE_RESTAURANT			71
		

Naturally, rotated versions are composed by the game at runtime, and the one composite object - 'raised span across road' is formed by a simple composition of the two objects in question!





Sponsored LinksYour Ad Here