void *nuReadBinary( wbuff, fpos, ptype )
Sint8 *wbuff
Uint32 *fpos
Uint32 *ptype
wbuff NJ/NJM等のバイナリファイルを読み込んだバッファへのポインタ fpos ファイルの読み込み開始バイト数 ptype 読み込んだデータのタイプ
NULL 未知のデータタイプを読み込んだ NULL以外 読み込んだデータのポインタ
GD-ROMよりバッファに読み込まれた NJ、NJM等のデータからテクスチャリストやモデルデータを取り出し、 そのポインタを戻します。データの取り出し先は内部で確保されたバッファです。
バッファの解放はユーザーが syFree()関数を使用して行ってください。
/* GD-ROM上のNJファイルを開きテクスチャリスト、 モデルデータを読み込みます。 */ GDFS fid; Sint32 sn; NJS_TEXLIST *tlist; NJS_OBJECT *obj; Sint8 *w_buff; Uint32 rtype, rpos = 0; /* Open binary file */ fid = gdFsOpen("sample.nj", NULL); /* Determine the file size of the sector unit and secure the necessary buffer space required to read it */ gdFsGetFileSctSize(fid, &sn); w_buff = (Sint8 *)syMalloc(sn*2048+8); /* Read the binary file to the secured buffer and close the file */ gdFsRead(fid, sn, w_buff); gdFsClose(fid); /* Output the texture list and objects from the binary data read into the buffer */ tlist = (NJS_TEXLIST *)nuReadBinary(w_buff, &rpos, &rtype); obj = (NJS_OBJECT *)nuReadBinary(w_buff, &rpos, &rtype); : : /* Management when binary data is no longer needed */ /* (Release data in reverse order, do not remove the open region of syMalloc.) */ syFree(obj); syFree(tlist); syFree(w_buff);
引数 fposの値はデータを読み込んだ後、次の読み出し開始位置に更新されます。引数 ptypeには未知のデータを読み込んだ場合 '****' が戻ります。
現在定義されているデータタイプは次のとおりです(NjDef.hで定義されています)。
#define iff_NJINFO 'NJIN' /* data infomation */
#define iff_NJCM 'NJCM' /* ninja chunk model tree */
#define iff_NJBM 'NJBM' /* ninja basic model tree */
#define iff_NJTL 'NJTL' /* ninja texlist */
#define iff_NJLI 'NJLI' /* ninja light */
#define iff_NJCA 'NJCA' /* ninja camera */
#define iff_NMDM 'NMDM' /* ninja model motion */
#define iff_NLIM 'NLIM' /* ninja light motion */
#define iff_NCAM 'NCAM' /* ninja camera motion */
#define iff_NSSM 'NSSM' /* ninja simple shape motion */