# How a 3D game map is stored and handled

I'm a programmer but have not yet developed any games.

I have played various 3D games and always wondered how the Map of the field is stored and rendered.

I know some acceleration card is a necessary hardware, but how exactly the view is changed without even a single flicker on the screen.

Do you have any online material to help me understand this.

Thanks

-

Generally, the world is map up of lots of triangles, and the map is a list of these triangles and the location in the world of each vertex. The process to draw them is:

• Setup the position of the 'camera' - if you were stood in the world, this is where you'd be in world position
• Transform the triangle vertices into 'camera space'
• Transform the triangles from 'camera space' into 'screen space' - this is where the perpective effect happens (distant things are smaller). The triangles become 2D at this point.
• Draw the 2D triangle onto a hidden screen.
• When all the triangles have been drawn, show the screen to the player.

The last step is usually tied to the monitor's frame rate, so that the process of showing the hidden screen is done during the v-blank interval - a concept derived from cathode ray tube monitors which allowed the cathode beam to move from bottom right to top left, this required rapidly, but not instaneously, changing voltages on the deflection coils at the back of the ray tube.

This is a really simple method. To get high performance you need to add things like hidden surface removal, occulsion, visible set determination, and so on. There's lots of algorithms involved in deciding what to draw.

Also, I said the world is made up of triangles, but it might not be stored on disk this way. Often, the triangles that are drawn to screen are defined at run time from higher order primitives, such as height maps, splines, tessalation, geometric primitives (e.g. a sphere, box, etc) and so on.

Dedicated hardware is not necessary - many early 3D games did it all in software (even on 8-bit CPUs with no FPUs). It just makes it quicker and easier to do.

Such a simple question. No easy answer.

-

The view is changed without any flicker on the screen because of double buffering, Process all the data on the back buffer, then when it is done being processed, you swap it on the front buffer.

-