3DS文件结构(4)

2019-08-31 09:11

(v1.05)

author: Martin van Velsen

( and some great help by Gert van der Spoel ) email: vvelsen@ronix.ptf.hro.nl

If you happen to come across some variables with strange names, then that will possible be Dutch names, sorry for that :)

\\*----------------------------------------------------------------------------*/

#ifndef __3DSBIN_C__ #define __3DSBIN_C__

#include \

/*----------------------------------------------------------------------------*/

unsigned char ReadChar (void) {

return (fgetc (bin3ds));

//------ if you want to add some code to create a progress bar, then //------ I suggest you do it here. This is the only function which //------ reads from disk }

/*----------------------------------------------------------------------------*/

unsigned int ReadInt (void) {

unsigned int temp = ReadChar(); return ( temp | (ReadChar () << 8)); }

/*----------------------------------------------------------------------------*/

unsigned long ReadLong (void) {

unsigned long temp1,temp2; unsigned long temp3,temp4;

temp1=ReadInt (); temp2=ReadInt ();

return (temp3+(temp4*0x10000L)); }

/*----------------------------------------------------------------------------*/

unsigned long ReadChunkPointer (void) {

return (ReadLong ()); }

/*----------------------------------------------------------------------------*/

unsigned long GetChunkPointer (void) {

return (ftell (bin3ds)-2); // compensate for the already read Marker }

/*----------------------------------------------------------------------------*/

void ChangeChunkPointer (unsigned long temp_pointer) {

fseek (bin3ds,temp_pointer,SEEK_SET); }

/*----------------------------------------------------------------------------*/

int ReadName (void) {

unsigned int teller=0; unsigned char letter;

strcpy (temp_name,\

letter=ReadChar ();

if (letter==0) return (-1); // dummy object temp_name [teller]=letter; teller++; do {

letter=ReadChar ();

temp_name [teller]=letter; teller++; }

while ((letter!=0) && (teller<12));

temp_name [teller-1]=0;

#ifdef __DEBUG__

printf (\

#endif return (0); }

/*----------------------------------------------------------------------------*/

int ReadLongName (void) {

unsigned int teller=0; unsigned char letter;

strcpy (temp_name,\

letter=ReadChar ();

if (letter==0) return (-1); // dummy object temp_name [teller]=letter; teller++; do {

letter=ReadChar ();

temp_name [teller]=letter; teller++; }

while (letter!=0);

temp_name [teller-1]=0;

#ifdef __DEBUG__

printf (\ #endif return (0); }

/*----------------------------------------------------------------------------*/

unsigned long ReadUnknownChunk (unsigned int chunk_id) {

unsigned long current_pointer; unsigned long temp_pointer;

chunk_id=chunk_id;

current_pointer=GetChunkPointer (); temp_pointer =ReadChunkPointer ();

ChangeChunkPointer (current_pointer+temp_pointer); // move to the new chunk position return (temp_pointer); }

/*----------------------------------------------------------------------------*/

unsigned long ReadRGBColor (void) {

float rgb_val [3];

for (int i=0;i<3;i++)

fread (&(rgb_val [i]),sizeof (float),1,bin3ds);

#ifdef __DEBUG__

printf (\ rgb_val [0], rgb_val [1], rgb_val [2]); #endif

return (12L); }

/*----------------------------------------------------------------------------*/

unsigned long ReadTrueColor (void) {

unsigned char true_c_val [3];

for (int i=0;i<3;i++)

true_c_val [i]=ReadChar ();

#ifdef __DEBUG__

printf (\ true_c_val [0], true_c_val [1], true_c_val [2]); #endif

return (3L); }

/*----------------------------------------------------------------------------*/

unsigned long ReadBooleanChunk (unsigned char *boolean) {

unsigned long current_pointer; unsigned long temp_pointer;

current_pointer=GetChunkPointer (); temp_pointer =ReadChunkPointer ();

*boolean=ReadChar ();

ChangeChunkPointer (current_pointer+temp_pointer); // move to the new chunk position

return (temp_pointer); }

/*----------------------------------------------------------------------------*/

unsigned long ReadSpotChunk (void) {

unsigned long current_pointer; unsigned long temp_pointer; float target [4]; float hotspot,falloff;

current_pointer=GetChunkPointer (); temp_pointer =ReadChunkPointer ();

fread (&(target [0]),sizeof (float),1,bin3ds); fread (&(target [1]),sizeof (float),1,bin3ds); fread (&(target [2]),sizeof (float),1,bin3ds); fread (&hotspot,sizeof (float),1,bin3ds); fread (&falloff,sizeof (float),1,bin3ds);

#ifdef __DEBUG__

printf (\target of the spot is at: X:%5.2f Y:%5.2f Y:%5.2f\\n\ target [0], target [1], target [2]);

printf (\ printf (\ #endif

ChangeChunkPointer (current_pointer+temp_pointer); // move to the new chunk position return (temp_pointer); }

/*-------------------------------------------------------------------


3DS文件结构(4).doc 将本文的Word文档下载到电脑 下载失败或者文档不完整,请联系客服人员解决!

下一篇:第五章 脂类代谢(试题与答案)

相关阅读
本类排行
× 注册会员免费下载(下载后可以自由复制和排版)

马上注册会员

注:下载文档有可能“只有目录或者内容不全”等情况,请下载之前注意辨别,如果您已付费且无法下载或内容有问题,请联系我们协助你处理。
微信: QQ: