Game Development Reference
In-Depth Information
speeds up the flow of a game or demo and so is well worth taking into
consideration. A useful strategy is to adopt a statistical approach. If
resources are used across more than 60 per cent of the game, then set
them as globally available resources. These are kept across scene
loads and are loaded just once as the program does the initial load and
initialization. If resources are used across more than 60 per cent of a
scene, then set them at scene level so they are loaded and initialized
on scene load. If resources are used less than 60 per cent of the time
within a scene, then load them dynamically. These are the hardest to
achieve and the most demanding because the load and initialization
have to be done seamlessly while the user is playing the game or
demo. Since processor time is scarce at such times, you may decide
that all resources are loaded at either initial load time or scene load
time. But this approach will only suit the smaller demos; at some stage
as a production becomes more sophisticated you will need to be
dynamically switching texture resources. One approach to this problem
is to keep overall scenes smaller, but this only means that the user
experiences more delays as scenes are switched. In the end, it is a
question of play testing across a range of machines and graphics cards
to see which is the best approach to the availability of resources.
Cloning mesh data within a scene
One of the best ways to achieve economy in the use of hardware
resources is to use clones. If you have six characters in the same uniform,
then they could have exactly the same mesh data. If a mesh has 2000
vertices and 2000 triangles, then we can calculate the memory require-
ment for a single use of this mesh.
A single vertex that stores origin position, transformation position,
original vertex normal and transformed vertex normal as 12-byte vectors
will be 48 bytes. Therefore, a 2000-vertex character will use 2000
48 =
96 000 bytes, nearly 94K. This may not seem a lot, but if the same
character uses 12 128
128 bitmaps as textures, then this adds another
576K to the total. So a single character is using nearly 700K of memory
before it starts moving. If we have six of these characters then we are
using around 4 MB for the internal storage. If, however, we clone the
characters, then we reference the original mesh data and textures. If the
characters are moving in a regimented fashion in synchronization with
each other, then we can use the same motion files and just apply a small
offset to ensure that they are not all sharing the same screen space. If
they need to move independently, then the storage system can use a
Search Nedrilad ::

Custom Search