Game Development Reference
In-Depth Information
find that this technique makes the surface lists much smaller than object
level surface lists. The minimum surface detail that needs to be stored in
the surface list is the surface colour as 3-byte size integer values.
Transparency level is stored as a byte-sized integer, allowing for 256
levels of transparency. Specularity is handled in the same way as
transparency, taking the floating-point value, multiplying it by 255 and
storing the result as a single byte integer. The texture ID for a surface is
stored as an index into the OpenGL texture objects; once the actual
texture IDs are generated, this value can be replaced with the OpenGL
value. A surface also contains a flag giving information about whether the
surface is luminous, smoothed or double sided.
for (i=0; i<obj->m_numsurfaces; i++){
if (srf->tex){
for(j=0; j<textotal; j++){
//Save the texture index
if (strcmp(gltex[j].name, srf->tex->name)==0) texID=j+1;
}
}else{
texID = 0;
}
//Surface details without the name
ar.Write(&srf->r, sizeof(BYTE));
ar.Write(&srf->g, sizeof(BYTE));
ar.Write(&srf->b, sizeof(BYTE));
byt = (BYTE)(srf->transparency * 255.0f);
ar.Write(&byt, sizeof(BYTE));
byt = (BYTE)(srf->specular * 255.0f);
ar.Write(&byt, sizeof(BYTE));
ar.Write(&texID, sizeof(GLuint));
ar.Write(&srf->flag, sizeof(USHORT));
srf++;
}
Compressing motion files
The key to compressing a motion file is storing the channel value as a
2-byte integer value rather than an 8- or 4-byte floating-point value. To do
this, we need to iterate through a channel temporarily storing the
minimum and maximum values. Since key values can be both positive
and negative, we will be use signed integers as the storage medium. For
Search Nedrilad ::




Custom Search