Data Structures |
|
struct | RtTOC |
struct | RtTOCEntry |
Functions |
|
RtTOC * | RtTOCCreate (RwStream *stream) |
void | RtTOCDestroy (RtTOC *toc) |
RwInt32 | RtTOCGetNumEntries (const RtTOC *toc) |
RtTOCEntry * | RtTOCGetEntry (RtTOC *toc, RwInt32 entry) |
RwUInt32 | RtTOCStreamGetSize (const RtTOC *toc) |
const RtTOC * | RtTOCStreamWrite (RtTOC *toc, RwStream *stream) |
RtTOC * | RtTOCStreamRead (RwStream *stream) |
rws
files (RWS Format) exported
using a RenderWare Graphics Exporter.
The TOC can also be used to skip through a stream to read specific chunks, rather than reading the stream sequentially. The offset element of the RtTOCEntry structure contains the byte offset of its entry's chunk header from the beginning of the file. Hence the sequence of events to read a TOC entry's chunk is:
The code fragment below shows one possible use of the TOC. The
TOC is obtained from an .rws
file, and all TOC entries
are queried whether they need to be loaded with an application
defined function IsTOCEntryWanted
.
RwStream *stream; stream = RwStreamOpen(rwSTREAMFILENAME, rwSTREAMREAD, "myartwork.rws"); if( stream ) { RtTOC *toc = (RtTOC *)NULL; // get the TOC if( RwStreamFindChunk(stream, rwID_TOC, NULL, NULL) ) { toc = RtTOCStreamRead(stream); } RwStreamClose(stream, NULL); if ( NULL != toc ) { RwInt32 numTOCEntries; RwInt32 i; // determine the number of entries in the TOC numTOCEntries = RtTOCGetNumEntries( toc ); for ( i = 0; i < numTOCEntries; i += 1 ) { RtTOCEntry *tocEntry; // get the next TOC entry tocEntry = RtTOCGetEntry( toc, i ); // determine if the TOC entry is wanted through an application // specific function if ( FALSE != IsTOCEntryWanted( tocEntry ) ) { // re-open the stream to reset the position stream = RwStreamOpen( rwSTREAMFILENAME, rwSTREAMREAD, "myartwork.rws" ); if ( NULL != stream ) { RwChunkHeaderInfo chunkHdrInfo; // skip to the chunk header of the TOC entry RwStreamSkip( stream, tocEntry->offset ); // read the chunk header RwStreamReadChunkHeaderInfo( stream, &chunkHdrInfo ); // stream read clunk with appropriate function // e.g. world = RpWorldStreamRead( stream ); RwStreamClose( stream, NULL ); } } } // destroy the TOC when finished RtTOCDestroy( toc ); } }
|
RtTOCCreate creates a Table Of Contents (TOC) for a stream. This function parses the input stream and generates a TOC entry for chunks listed in RwCorePluginID.
|
|
RtTOCDestroy destroys a TOC that was created by calling RtTOCCreate.
|
|
RtTOCGetEntry gets the specified TOC entry from the TOC.
|
|
RtTOCGetNumEntries gets the number of entries in the TOC.
|
|
RtTOCStreamGetSize is used to determine the size in bytes of the binary representation of the TOC. This is used in the binary chunk header to indicate the size of the texture chunk. The size does not include the size of the chunk header.
|
|
RtTOCStreamRead is used to read a TOC from the specified binary stream. Note that prior to this function call a binary TOC chunk must be found in the stream using the RwStreamFindChunk API function.
RwStream *stream; RtTOC *toc; stream = RwStreamOpen(rwSTREAMFILENAME, rwSTREAMREAD, "mybinary.xxx"); if( stream ) { if( RwStreamFindChunk(stream, rwID_TOC, NULL, NULL) ) { toc = RtTOCStreamRead(stream); } RwStreamClose(stream, NULL); }
|
|
RtTOCStreamWrite is used to write the specified TOC to the given binary stream. Note that the stream will have been opened prior to this function call.
|
Converted from CHM to HTML with chm2web Pro 2.85 (unicode) |