3DSCON2.C

Go to the documentation of this file.
00001 /* --
00002 OpenFX version 2.4 - Modelling, Animation and Rendering Package
00003 -- */
00004 
00005 /* 3DSCON2.C     revised 3DCON model loader - code uses 3DSFTK library and some of its code */
00006 
00007 #define MODULE_SAPC
00008 
00009 #include <stdlib.h>
00010 #include <stdio.h>
00011 #include <math.h>
00012 #include <string.h>
00013 #include <windows.h>
00014 
00015 #define  _DSCRUCT_SUB 1
00016 
00017 #include "mstruct.h"
00018 #include "dstruct.h"
00019 
00020 #include "3dstype.h"
00021 #include "3dsprim.h"
00022 #include "3dserr.h"
00023 #include "chunkinf.h"
00024 #include "3dsftkst.h"
00025 #include "3dsutil.h"
00026 #include "dumpchnk.h"
00027 #include "chunk3ds.h"
00028 #include "3dsmatr.h"
00029 #include "kfutils.h"
00030 
00031 #include "3dscon.h"
00032 
00033 extern HWND      dlg;
00034 extern HWND      hWndParent;
00035 extern HINSTANCE hInstance;
00036 
00037 extern BOOL CALLBACK DlgProcScale(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam);
00038 extern BOOL CALLBACK DlgProc(HWND hwnd,UINT msg,WPARAM wparam,LPARAM lparam);
00039 
00040 extern void UpdateProgress(FILE *);
00041 extern int (*X__pri)(const char *,...);
00042 
00043 #define DOS386
00044 #define _X__FAR
00045 #define PI  3.1415926
00046 
00047 #define DEFAULT_SCALE (1024.0*8.0*2.0)
00048 
00049 #ifndef min
00050 #define min(a,b)  ( ((a) < (b)) ? (a) : (b) )
00051 #endif
00052 #ifndef max
00053 #define max(a,b)  ( ((a) > (b)) ? (a) : (b) )
00054 #endif
00055 
00056 double scale_3ds;
00057 int silent_3ds;
00058 double gmax[3],gmin[3],gcentre[3];
00059 
00060 static long3ds DumpLevel3ds = 2;
00061 static int FirstVertex = -1, FirstFace = -1, CurrentMaterial = -1, CurrentImageMap = -1, CurrentImageMapType = -1;
00062 static int ObjectFirstVertex = -1, ObjectFirstFace = -1;
00063 static int ActiveMaterial= -1, ActiveImageMap = -1;
00064 static int CurrentVertices=-1;
00065 static char CurrentImageMapFile[256]="";
00066 static char CurrentObjectName[256]="";
00067 
00068 typedef struct tagEXTRAVERTEX3DS {
00069  int   *adj;  // list of vertices adjaent to this one
00070  int   n;  // number of adjavent vertices
00071 } extravertex3DS;
00072 
00073 static void mes3ds(char *s){
00074 // if(silent_3ds)return;
00075 // X__pri("%s",s);
00076 }
00077 
00078 static void InsertInVertexList(FILE *outfile, long vi, long  vj){
00079  long i,j,id;
00080  int n,*adj;
00081  extravertex3DS *vip,*vjp;
00082  id=(MainVp+vi)->id;
00083  //fprintf(outfile,"Vertex %d  linked to  %d",vi,vj); 
00084  if(id == 0){ // no exta data structure yet - so create one.
00085   (MainVp+vi)->id=id=(long)(malloc(sizeof(extravertex3DS)));
00086    vip=(extravertex3DS *)id;
00087    vip->adj=NULL;
00088    vip->n=0;
00089    //fprintf(outfile," NEW (no adjacenty yet)" );
00090  }
00091  else{
00092    vip=(extravertex3DS *)id;
00093   //fprintf(outfile," Currently %d adjacent ",vip->n );
00094  } 
00095  //fprintf(outfile,"\n");
00096  if(vip->n > 0){
00097    for(i=0;i<vip->n;i++){
00098      if(vip->adj[i] == vj){
00099        //fprintf(outfile,"%d is already in the %d list\n",vj,vi); 
00100        return;  // "vj" is already adjacent to "vi"
00101      }
00102    }
00103  }
00104  vjp=(extravertex3DS *)((MainVp+vj)->id);
00105  if(vjp != NULL && vjp->n > 0){
00106    //fprintf(outfile,"VJ(%d) has a list of %d entries ",vj,vjp->n);
00107    for(j=0;j<vjp->n;j++){
00108      if(vjp->adj[j] == vi){
00109        //fprintf(outfile," and VI is in it");
00110        return; //"vi" is already adjacent to "vj" and in its connection list
00111      }
00112    }
00113    //fprintf(outfile,"\n");   
00114  }
00115  if(vip->n == 0){ // allocate space to add connection
00116    if((vip->adj = (int *)malloc((vip->n + 1)*sizeof(int))) == NULL){
00117      mes3ds("out of memory\n");  return;
00118    }
00119  }
00120  else{
00121    if((vip->adj = (int *)realloc(vip->adj,(vip->n + 1)*sizeof(int))) == NULL){
00122      mes3ds("out of memory\n");  return;
00123    }
00124  }
00125  vip->adj[vip->n] = vj;  // "vj" is added to the connection list for "vi"
00126  (vip->n)++;
00127  //fprintf(outfile,"Making edge  IV->VJ %d  -> %d adding %d(VJ) to the %d(VI)  list now with %d entries \n",vi,vj, vj,vi,vip->n);
00128  CreateEdge(vi,vj);  // make the edge
00129 }
00130 
00131 static void ClearEdgeVertexList(FILE *outfile){
00132   vertex *vp;
00133   int i,id;
00134   extravertex3DS *vip;
00135   if(Nvert > FirstVertex){
00136     for(i=FirstVertex; i < Nvert ; i++){
00137       id=(MainVp+i)->id;
00138       if(id != 0){ 
00139         vip=(extravertex3DS *)id;
00140         if(vip != NULL){
00141           if(vip->adj != NULL)free(vip->adj);
00142           //fprintf(outfile,"Clearing vertex %d with %d connections.\n",i,vip->n);
00143           free(vip);
00144           (MainVp+i)->id=0;
00145         }  
00146       }
00147     }
00148   }
00149 }
00150 
00151 static void CreateEdges(FILE *outfile, FaceArray *d){ 
00152      ushort3ds i;
00153      int bError;
00154      int v1,v2,v3;
00155      UpdateEdgeHeap(Nedge+3*d->faces); // revise later
00156      for(i = 0; i < d->faces; i++)      {
00157        v1 = d->facelist[i].v1 + FirstVertex;   if (v1 >= Nvert){bError=1; continue;}  // this is an error
00158        v2 = d->facelist[i].v2 + FirstVertex;   if (v2 >= Nvert){bError=1; continue;}  // this is an error
00159        v3 = d->facelist[i].v3 + FirstVertex;   if (v3 >= Nvert){bError=1; continue;}  
00160        //fprintf(outfile,"Face %d  (%d %d %d)\n",i,v1,v2,v3);
00161        InsertInVertexList(outfile,v1,v2); //fprintf(outfile,"\n");
00162        InsertInVertexList(outfile,v2,v3); //fprintf(outfile,"\n");
00163        InsertInVertexList(outfile,v3,v1); //fprintf(outfile,"\n");
00164      }
00165      UpdateEdgeHeap(Nedge+3*d->faces); // revise later
00166      ClearEdgeVertexList(outfile);
00167 }
00168 
00169 static short RequestItemSelect(short Nitems, char **ItemList, char *Message){
00170  return 1;
00171 }
00172 
00173 void rescale_model(short option, FILE *outfile){
00174   vertex *vp;
00175   skel   *sp;
00176   char str[128];
00177   long i;
00178   float maxd=1.e-30;
00179   double scan,x,y,z;
00180   gcentre[0] = (gmax[0]+gmin[0])/2.0;
00181   gcentre[1] = (gmax[1]+gmin[1])/2.0;
00182   gcentre[2] = (gmax[2]+gmin[2])/2.0;
00183   maxd=max(maxd,(gmax[0]-gmin[0]));
00184   maxd=max(maxd,(gmax[1]-gmin[1]));
00185   maxd=max(maxd,(gmax[2]-gmin[2]));
00186   //fprintf(outfile,"Gmax %lf %lf %lf  Gmin %lf %lf %lf  Maxd %lf\n",gmax[0],gmax[1],gmax[2],gmin[0],gmin[1],gmin[2],maxd);
00187   if(option == 0){
00188     scale_3ds=4.0*(float)DEFAULT_SCALE/maxd;
00189   }
00190   else if(option == 1){ /* scale set by param  centre from file */
00191     struct SC {double scan,xc,yc,zc,c;} Sc;
00192     Sc.xc=gcentre[0]; Sc.yc=gcentre[1]; Sc.zc=gcentre[2]; Sc.c=0;
00193     Sc.scan=4.0*(double)(DEFAULT_SCALE)/(double)maxd;
00194     scale_3ds=(float)Sc.scan;
00195     if(DialogBoxParam(hInstance,MAKEINTRESOURCE(DLG_SCALE),hWndParent,
00196                      (DLGPROC)DlgProcScale,(LPARAM)&Sc)){
00197       scale_3ds=(float)Sc.scan;
00198       if(Sc.c == 1){gcentre[0]=gcentre[1]=gcentre[2]=0.0;}
00199       else{gcentre[0]=Sc.xc; gcentre[1]=Sc.yc; gcentre[2]=Sc.zc;}
00200    }
00201   }
00202   vp=MainVp; for(i=0;i<Nvert;i++,vp++){
00203     x=((double)(vp->xyz[0]))/DEFAULT_SCALE; y=((double)(vp->xyz[1]))/DEFAULT_SCALE; z=((double)vp->xyz[2])/DEFAULT_SCALE;
00204     x = (x - gcentre[0])*scale_3ds; 
00205     y = (y - gcentre[1])*scale_3ds; 
00206     z = (z - gcentre[2])*scale_3ds;
00207     vp->xyz[0]=(long)x; vp->xyz[1]=(long)y; vp->xyz[2]=(long)z;
00208   }
00209   sp=MainSp; while(sp != NULL){
00210     x=((double)sp->xyz[0])/DEFAULT_SCALE; ((double)y=sp->xyz[1])/DEFAULT_SCALE; ((double)z=sp->xyz[2])/DEFAULT_SCALE;
00211     x = (x - gcentre[0])*scale_3ds; 
00212     y = (y - gcentre[1])*scale_3ds; 
00213     z = (z - gcentre[2])*scale_3ds; 
00214     sp->xyz[0]=(long)x; sp->xyz[1]=(long)y; sp->xyz[2]=(long)z;
00215     sp=sp->last;
00216   }
00217 }
00218 
00219 static void ReportChunkHeader(FILE *outfile, chunk3ds *chunk, ushort3ds indentlevel){
00220    //fprintf(outfile, "\n%sChunk %s (%0xH) \n%sLength is %d (%0xH) \n", indent(indentlevel),
00221    //        ChunkTagToString3ds(chunk->tag), chunk->tag, indent(indentlevel), chunk->size, chunk->size);
00222 }       
00223 
00224 void GetActiveTextureIDs(char *matname){
00225  int i;
00226  ActiveMaterial = -1;
00227  ActiveImageMap = -1;
00228  if(nMats > 0){
00229    for(i=0;i<nMats; i++){
00230      if((strcmpi(matname,iMat[i].name)) == 0)ActiveMaterial=i;
00231    }
00232  }
00233  if(nImaps > 0){
00234    for(i=0;i<nImaps; i++){
00235      if((strcmpi(matname,iMap[i].N)) == 0)ActiveImageMap=i;
00236    }
00237  }
00238 }
00239 
00240 
00241 void ProcessChunk3ds(FILE *outfile,  /* file formated text gets output to - revised from 3DSFTK library*/
00242       chunk3ds *chunk, /* chunk that is being dumped */
00243       ushort3ds indentlevel, /* level of indentation for the chunk */
00244       skel *CurrentSp
00245       ){
00246  chunk3ds *child;
00247  ReportChunkHeader(outfile, chunk, indentlevel);
00248  switch(chunk->tag){
00249    case  MAT_ENTRY :{ //RSFx
00250      //fprintf(outfile,"Material Entry\n");
00251      strcpy(CurrentImageMapFile,"");
00252      CurrentImageMapType = -1;
00253      CreateMaterial(FALSE);
00254      CreateImageMap();
00255      strcpy(iMat[nMats-1].name,"Dummy");
00256      iMat[nMats-1].bShiny=FALSE;
00257      strcpy(iMap[nImaps-1].N,"Dummy");
00258      CurrentMaterial=nMats-1;
00259      CurrentImageMap=nImaps-1;
00260    }
00261    break;
00262    case  MAT_TEXMAP : {
00263      //fprintf(outfile,"Texmap\n");
00264      CurrentImageMapType=1;
00265    }
00266    break;
00267    case  MAT_OPACMAP : {
00268      //fprintf(outfile,"Opacitymap\n");
00269      CurrentImageMapType=4;
00270    }
00271    break;
00272    case  MAT_REFLMAP :{
00273      //fprintf(outfile,"Refelction Map\n");
00274      CurrentImageMapType=2;
00275    }
00276    break;
00277    case  MAT_BUMPMAP :
00278      CurrentImageMapType=3;
00279      //fprintf(outfile,"Bumpmap\n");
00280    break;
00281    case  MAT_SPECMAP :  // not used by OpenFX
00282      CurrentImageMapType=5;
00283      //fprintf(outfile,"Specularmap\n");
00284    break;
00285    case MAT_NAME:   { //RSFx
00286     MatName *d;
00287     ReadChunkData3ds(chunk);
00288     d = chunk->data;
00289     //fprintf(outfile, "%sMaterial name(1) %s\n", indent(indentlevel), d->name);
00290     strcpy(iMat[nMats-1].name,d->name);
00291     strcpy(iMap[nImaps-1].N,d->name);
00292     break;
00293    }
00294    case MAT_MAPNAME: { // filename for the map 
00295     char *pext;
00296     MatMapname *d;
00297     ReadChunkData3ds(chunk);
00298     d = chunk->data;
00299     //fprintf(outfile, "%sMap name(1) %s\n", indent(indentlevel), d->name);
00300     strcpy(CurrentImageMapFile,d->name); 
00301     strlwr(CurrentImageMapFile);
00302 
00303     // if non supported OFX file type change type to JPG and set path to current folder //RSFx
00304     pext=strstr(CurrentImageMapFile,".dds");
00305     if(pext !=NULL)strcpy(pext,".jpg");   
00306   
00307     if(CurrentImageMap >=0 && CurrentImageMapType > 0){ //
00308       if(CurrentImageMapType == 1){ //Surface Texture
00309         iMap[CurrentImageMap].s = 1;
00310         if((iMap[CurrentImageMap].S=(char *)X__Malloc(strlen(CurrentImageMapFile)+1)) == NULL)iMap[CurrentImageMap].s=0;
00311         else strcpy(iMap[CurrentImageMap].S,CurrentImageMapFile);
00312       }      
00313       if(CurrentImageMapType == 2){ //Reflect Texture
00314         iMap[CurrentImageMap].r = 1;
00315         if((iMap[CurrentImageMap].R=(char *)X__Malloc(strlen(CurrentImageMapFile)+1)) == NULL)iMap[CurrentImageMap].r=0;
00316         else strcpy(iMap[CurrentImageMap].R,CurrentImageMapFile);
00317       }
00318       if(CurrentImageMapType == 3){ //Bump Texture
00319         iMap[CurrentImageMap].b = 1;
00320         if((iMap[CurrentImageMap].B=(char *)X__Malloc(strlen(CurrentImageMapFile)+1)) == NULL)iMap[CurrentImageMap].b=0;
00321         else strcpy(iMap[CurrentImageMap].B,CurrentImageMapFile);
00322       }
00323       if(CurrentImageMapType == 4){ //Tramsparency Texture
00324         iMap[CurrentImageMap].t = 1;
00325         if((iMap[CurrentImageMap].T=(char *)X__Malloc(strlen(CurrentImageMapFile)+1)) == NULL)iMap[CurrentImageMap].t=0;
00326         else strcpy(iMap[CurrentImageMap].T,CurrentImageMapFile);
00327       }
00328     }
00329     break;
00330    }
00331    case NAMED_OBJECT: { //RSFx
00332      NamedObject *d;
00333      ReadChunkData3ds(chunk);
00334      //fprintf(outfile,"NAMED_OBJECT ******************\n");
00335      d = chunk->data;
00336      ObjectFirstVertex = Nvert; ObjectFirstFace = Nface;
00337      strcpy(CurrentObjectName,d->name); CurrentObjectName[16]=0; 
00338      //fprintf(outfile, "%sName: %s [%s]\n", indent(indentlevel), d->name, CurrentObjectName);
00339      break;
00340    }
00341    case POINT_ARRAY:{ //   VERTICES RSFx
00342        PointArray *d;
00343        ushort3ds i;
00344        vertex *Vp;
00345        long x,y,z;
00346        double xc=0.0,yc=0.0,zc=0.0,xf,yf,zf;
00347        CreateSkeleton(CurrentSp);
00348        CurrentSp=MainSp;
00349        MainSp->xyz[0]=0;
00350        MainSp->xyz[1]=0;
00351        MainSp->xyz[2]=0;
00352        strcpy(MainSp->name,CurrentObjectName);
00353        ReadChunkData3ds(chunk);
00354        d = chunk->data;
00355        //fprintf(outfile, "%s POINT ARRARY %u Vertices  SP name [%s] \n", indent(indentlevel), d->vertices, MainSp->name);
00356        FirstVertex=Nvert; 
00357        CurrentVertices=d->vertices;
00358        UpdateVertexHeap(Nvert+d->vertices);
00359        for(i = 0; i < d->vertices; i++)  {
00360          xf = d->pointlist[i].x;
00361          yf = d->pointlist[i].y;
00362          zf = d->pointlist[i].z;
00363          xc += xf;
00364          yc += yf;
00365          zc += zf;
00366          if(xf < gmin[0])gmin[0]=xf; if(xf > gmax[0])gmax[0]=xf;
00367          if(yf < gmin[1])gmin[1]=yf; if(yf > gmax[1])gmax[1]=yf;
00368          if(zf < gmin[2])gmin[2]=zf; if(zf > gmax[2])gmax[2]=zf;
00369          x=(long)(xf*DEFAULT_SCALE);
00370          y=(long)(yf*DEFAULT_SCALE);
00371          z=(long)(zf*DEFAULT_SCALE);
00372          CreateVertex();
00373          Vp=(MainVp+Nvert-1);
00374          Vp->sp = MainSp;
00375          Vp->id=0; // used for temporary pointer to structure used to build the EdgeList.
00376          Vp->xyz[0]=x; Vp->xyz[1]=y; Vp->xyz[2]=z;
00377          //fprintf(outfile, "%sVertex %i at %f, %f, %f\n", indent(indentlevel), i, xf, yf, zf);
00378       }
00379       xc /= (double)(d->vertices);  
00380       yc /= (double)(d->vertices);  
00381       zc /= (double)(d->vertices); 
00382       MainSp->xyz[0]=(long)(xc*DEFAULT_SCALE);
00383       MainSp->xyz[1]=(long)(yc*DEFAULT_SCALE);
00384       MainSp->xyz[2]=(long)(zc*DEFAULT_SCALE);
00385       break;
00386    }
00387    case TEX_VERTS: { //RSFx
00388      vertex *Vp;
00389      TexVerts *d;
00390      ushort3ds i;
00391      ReadChunkData3ds(chunk);
00392      d = chunk->data;
00393      //fprintf(outfile, "%s%u Texture Vertices\n", indent(indentlevel), d->numcoords);
00394      if(d->numcoords == CurrentVertices){ // This corresponds to the vertices.
00395        Vp=(MainVp+FirstVertex);
00396        for(i = 0; i < d->numcoords; i++, Vp++){
00397          Vp->x=d->textvertlist[i].u;
00398          Vp->y=d->textvertlist[i].v;
00399          //fprintf(outfile, "%sVertex %i with tex vert of %f, %f\n", indent(indentlevel), i, d->textvertlist[i].u, d->textvertlist[i].v);
00400        }
00401      }
00402      break;
00403    }
00404    case FACE_ARRAY: { //RSFx
00405      FaceArray *d;
00406      face *Fp;
00407      ushort3ds i;
00408      int v1,v2,v3;
00409      int bError=0;
00410      ReadChunkData3ds(chunk);
00411      d = chunk->data;
00412      //fprintf(outfile, "%sFACE_ARRAY %u Faces\n", indent(indentlevel), d->faces);
00413      FirstFace=Nface;
00414      UpdateFaceHeap(Nface+d->faces);
00415      for(i = 0; i < d->faces; i++)      {
00416        v1 = d->facelist[i].v1 + FirstVertex;   if (v1 >= Nvert){bError=1; continue;}  // this is an error
00417        v2 = d->facelist[i].v2 + FirstVertex;   if (v2 >= Nvert){bError=1; continue;}  // this is an error
00418        v3 = d->facelist[i].v3 + FirstVertex;   if (v3 >= Nvert){bError=1; continue;}  
00419        CreateFace(v1,v2,v3);
00420        // set other properties accordingly - maps etc..
00421        //fprintf(outfile, "%sFace %i vertices %i, %i, %i and flag %x\n", indent(indentlevel), i, d->facelist[i].v1, d->facelist[i].v2, d->facelist[i].v3, d->facelist[i].flag);
00422        Fp=(MainFp+FirstFace+i);
00423        Fp->bSmooth=1;
00424        Fp->material = -1; // ActiveMaterial; //  Probably the last material - but will be corrected 
00425        Fp->imagemap = -1; // ActiveImageMap; //  if MESH_MAT_CHUNK is read.
00426        Fp->x[0]=(MainVp+v1)->x;  Fp->y[0]=(MainVp+v1)->y;
00427        Fp->x[1]=(MainVp+v2)->x;  Fp->y[1]=(MainVp+v2)->y;
00428        Fp->x[2]=(MainVp+v3)->x;  Fp->y[2]=(MainVp+v3)->y;
00429        Fp->gp=1;
00430      }
00431      if(!bError){  // create edges.
00432         CreateEdges(outfile,d) ;
00433         UpdateEdgeHeap(Nedge);
00434         //fprintf(outfile,"%d faces and %d edges\n",Nface,Nedge);
00435      }
00436      break;
00437    }
00438    case MSH_MAT_GROUP: { // assign named material to current object faces
00439      MshMatGroup *d;
00440      int i,fid;
00441      face *Fp;
00442      ReadChunkData3ds(chunk);
00443      d = chunk->data;
00444      //fprintf(outfile, "%sMESH_MAT_GROUP Material Name Of %s\n", indent(indentlevel), d->matname);
00445      //fprintf(outfile, "%sAssigned to %i faces\n", indent(indentlevel), d->faces);
00446      GetActiveTextureIDs(d->matname);
00447      //fprintf(outfile,"Active IDs  %d %d \n",ActiveMaterial,ActiveImageMap);
00448      for(i = 0; i < d->faces; i++)      {
00449        fid=d->facelist[i];
00450        //fprintf(outfile,"%sFace ID %i\n", indent(indentlevel),fid);  
00451        Fp=(MainFp+ObjectFirstFace+fid);
00452        Fp->material = ActiveMaterial;
00453        Fp->imagemap = ActiveImageMap;
00454      }
00455      break;
00456    }
00457 
00458    case MESH_VERSION :{
00459     MeshVersion *d;
00460     ReadChunkData3ds(chunk);
00461     d = chunk->data;
00462     //fprintf(outfile, "%sVersion %u\n", indent(indentlevel), d->version);
00463     break;
00464    }
00465    case M3D_VERSION :      {
00466     M3dVersion *d;
00467     ReadChunkData3ds(chunk);
00468     d = chunk->data;
00469     //fprintf(outfile, "%sVersion %u\n", indent(indentlevel), d->version);
00470     break;
00471    }
00472    case POINT_FLAG_ARRAY:      {
00473    PointFlagArray *d;
00474    ushort3ds i;
00475    d = ReadChunkData3ds(chunk);
00476    //fprintf(outfile, "%sPOINT_FLAG_ARRAY %u Flags\n", indent(indentlevel), d->flags);
00477    if (DumpLevel3ds == MaximumDump3ds)   {
00478       for (i = 0; i < d->flags; i++)      {
00479          //fprintf(outfile, "%sFlag %i is %u\n", indent(indentlevel), i, d->flaglist[i]);
00480    }
00481    }
00482    break;
00483    }
00484    case MAT_MAP_TILING:  {
00485    MatMapTiling *d;
00486    ReadChunkData3ds(chunk);
00487    d = chunk->data;
00488    //fprintf(outfile, "%sMap flags of", indent(indentlevel));
00489    //if (d->tiling & TEX_DECAL)fprintf(outfile, " TEX_DECAL");
00490    //if (d->tiling & TEX_MIRROR)fprintf(outfile, " TEX_MIRROR");
00491    //if (d->tiling & TEX_UNUSED1)fprintf(outfile, " TEX_UNUSED1");
00492    //if (d->tiling & TEX_INVERT)fprintf(outfile, " TEX_INVERT");
00493    //if (d->tiling & TEX_NOWRAP)fprintf(outfile, " TEX_NOWRAP");
00494    //if (d->tiling & TEX_SAT)fprintf(outfile, " TEX_SAT");
00495    //if (d->tiling & TEX_ALPHA_SOURCE)fprintf(outfile, " TEX_ALPHA_SOURCE");
00496    //if (d->tiling & TEX_TINT)fprintf(outfile, " TEX_TINT");
00497    //if (d->tiling & TEX_DONT_USE_ALPHA)fprintf(outfile, " TEX_DONT_USE_ALPHA");
00498    //if (d->tiling & TEX_RGB_TINT)fprintf(outfile, " TEX_RGB_TINT");
00499    //if (d->tiling == 0)printf(outfile, " NONE");
00500    //fprintf(outfile, "\n");
00501    break;
00502    }
00503    case MAT_MAP_COL1 :  {
00504    MatMapCol1 *d;
00505    ReadChunkData3ds(chunk);
00506    d = chunk->data;
00507    
00508    //fprintf(outfile, "%sColor R: %u,", indent(indentlevel), d->red);
00509    //fprintf(outfile, "G: %u,", d->green);  
00510    //fprintf(outfile, "B: %u\n", d->blue);
00511    
00512    break;
00513    }
00514    case MAT_MAP_COL2 :      {
00515    MatMapCol2 *d;
00516    ReadChunkData3ds(chunk);
00517    d = chunk->data;
00518    //fprintf(outfile, "%sColor R: %u,", indent(indentlevel), d->red);
00519    //fprintf(outfile, "G: %u,", d->green);  
00520    //fprintf(outfile, "B: %u\n", d->blue);
00521    break;
00522    }
00523    case MAT_MAP_RCOL :      {
00524    MatMapRCol *d;
00525    ReadChunkData3ds(chunk);
00526    d = chunk->data;
00527    //fprintf(outfile, "%sColor R: %u,", indent(indentlevel), d->red);
00528    //fprintf(outfile, "G: %u,", d->green);  
00529    //fprintf(outfile, "B: %u\n", d->blue);
00530    break;
00531    }
00532    case MAT_MAP_GCOL :      {
00533    MatMapGCol *d;
00534    ReadChunkData3ds(chunk);
00535    d = chunk->data;
00536    //fprintf(outfile, "%sColor R: %u,", indent(indentlevel), d->red);
00537    //fprintf(outfile, "G: %u,", d->green);  
00538    //fprintf(outfile, "B: %u\n", d->blue);
00539    break;
00540    }
00541    case MAT_MAP_BCOL :
00542       {
00543    MatMapBCol *d;
00544    ReadChunkData3ds(chunk);
00545    d = chunk->data;
00546    
00547    //fprintf(outfile, "%sColor R: %u,", indent(indentlevel), d->red);
00548    //fprintf(outfile, "G: %u,", d->green);  
00549    //fprintf(outfile, "B: %u\n", d->blue);
00550    
00551    break;
00552    }
00553    case MAT_MAP_TEXBLUR:      {
00554    MatMapTexblur *d;
00555    ReadChunkData3ds(chunk);
00556    d = chunk->data;
00557    //fprintf(outfile, "%sMap bluring of %f\n", indent(indentlevel), d->percent);
00558    break;
00559    }
00560    case MAT_MAP_USCALE:      {
00561    MatMapUScale *d;
00562    ReadChunkData3ds(chunk);
00563    d = chunk->data;
00564    //fprintf(outfile, "%sMap U scale of %f\n", indent(indentlevel), d->scale);
00565    break;
00566    }
00567    case MAT_MAP_VSCALE:      {
00568    MatMapVScale *d;
00569    ReadChunkData3ds(chunk);
00570    d = chunk->data;
00571    //fprintf(outfile, "%sMap V scale of %f\n", indent(indentlevel), d->scale);
00572    break;
00573    }
00574    case MAT_MAP_UOFFSET:      {
00575    MatMapUOffset *d;
00576    ReadChunkData3ds(chunk);
00577    d = chunk->data;
00578    //fprintf(outfile, "%sMap U offset of %f\n", indent(indentlevel), d->offset);
00579    break;
00580    }
00581    case MAT_MAP_VOFFSET:      {
00582    MatMapVOffset *d;
00583    ReadChunkData3ds(chunk);
00584    d = chunk->data;
00585    //fprintf(outfile, "%sMap V offset of %f\n", indent(indentlevel), d->offset);
00586    break;
00587    }
00588    case MAT_MAP_ANG:      {
00589    MatMapAng *d;
00590    ReadChunkData3ds(chunk);
00591    d = chunk->data;
00592    //fprintf(outfile, "%sMap rotation angle of %f\n", indent(indentlevel), d->angle);
00593    break;
00594    }
00595    case MAT_BUMP_PERCENT :      {
00596    MatBumpPercent *d;
00597    ReadChunkData3ds(chunk);
00598    d = chunk->data;
00599    //fprintf(outfile, "%sPercentage of %i%%\n", indent(indentlevel), d->intpercentage);
00600    break;
00601    }
00602    case COLOR_F :   {
00603    ColorF *d;
00604    ReadChunkData3ds(chunk);
00605    d = chunk->data;
00606    //fprintf(outfile, "%sColor R: %f,", indent(indentlevel), d->red);
00607    //fprintf(outfile, "G: %f,", d->green);
00608    //fprintf(outfile, "B: %f\n", d->blue);
00609    break;
00610    }
00611    case LIN_COLOR_F :      {
00612    LinColorF *d;
00613    ReadChunkData3ds(chunk);
00614    d = chunk->data;
00615    //fprintf(outfile, "%sColor R: %f,", indent(indentlevel), d->red);
00616    //fprintf(outfile, "G: %f,", d->green);
00617    //fprintf(outfile, "B: %f\n", d->blue);
00618    break;
00619    }
00620    case COLOR_24 :      {
00621    Color24 *d;
00622    ReadChunkData3ds(chunk);
00623    d = chunk->data;
00624    //fprintf(outfile, "%sColor R: %u,", indent(indentlevel), d->red);
00625    //fprintf(outfile, "G: %u,", d->green);  
00626    //fprintf(outfile, "B: %u\n", d->blue);
00627    break;
00628    }
00629    case LIN_COLOR_24 :{
00630    LinColor24 *d;
00631    ReadChunkData3ds(chunk);
00632    d = chunk->data;
00633    //fprintf(outfile, "%sColor R: %u,", indent(indentlevel), d->red);
00634    //fprintf(outfile, "G: %u,", d->green);  
00635    //fprintf(outfile, "B: %u\n", d->blue);
00636    break;
00637    }      
00638    case INT_PERCENTAGE :      {
00639    IntPercentage *d;
00640    ReadChunkData3ds(chunk);
00641    d = chunk->data;
00642    //fprintf(outfile, "%sPercentage of %i%%\n", indent(indentlevel), d->intpercentage);
00643    break;
00644    }
00645    case FLOAT_PERCENTAGE :      {
00646    FloatPercentage *d;
00647    ReadChunkData3ds(chunk);
00648    d = chunk->data;
00649    //fprintf(outfile, "%sPercentage of %f\n", indent(indentlevel), d->floatpercentage);
00650    break;
00651    }
00652    case MASTER_SCALE :      {
00653    MasterScale *d;
00654    ReadChunkData3ds(chunk);
00655    d = chunk->data;
00656    //fprintf(outfile, "%sMaster Scale %f\n", indent(indentlevel), d->masterscale);
00657    break;
00658    }
00659    case BIT_MAP :      {
00660    BitMap *d;
00661    ReadChunkData3ds(chunk);
00662    d = chunk->data;
00663    //fprintf(outfile, "%sBitmap name %s\n", indent(indentlevel), d->bitmap);
00664    break;
00665    }
00666    case V_GRADIENT:   {
00667    VGradient *d;
00668    ReadChunkData3ds(chunk);
00669    d = chunk->data;
00670    //fprintf(outfile, "%sMidpoint %f\n", indent(indentlevel), d->gradpercent);
00671    break;
00672    }
00673    case LO_SHADOW_BIAS:   {
00674    LoShadowBias *d;
00675    ReadChunkData3ds(chunk);
00676    d = chunk->data;
00677    //fprintf(outfile, "%sBias of %f\n", indent(indentlevel), d->bias);
00678    break;
00679    }
00680    case HI_SHADOW_BIAS:      {
00681    HiShadowBias *d;
00682    ReadChunkData3ds(chunk);
00683    d = chunk->data;
00684    //fprintf(outfile, "%sBias of %f\n", indent(indentlevel), d->bias);
00685    break;
00686    }
00687     case RAY_BIAS:      {
00688    RayBias *d;
00689    ReadChunkData3ds(chunk);
00690    d = chunk->data;
00691    //fprintf(outfile, "%sBias of %f\n", indent(indentlevel), d->bias);
00692    break;
00693    }
00694    case SHADOW_MAP_SIZE:      {
00695    ShadowMapSize *d;
00696    ReadChunkData3ds(chunk);
00697    d = chunk->data;
00698    //fprintf(outfile, "%sSize of %i\n", indent(indentlevel), d->shadowmapsize);
00699    break;
00700    }
00701    case SHADOW_SAMPLES:      {
00702    ShadowSamples *d;
00703    ReadChunkData3ds(chunk);
00704    d = chunk->data;
00705    //fprintf(outfile, "%sSize of %i\n", indent(indentlevel), d->shadowsamples);
00706    break;
00707    }
00708    case SHADOW_RANGE:      {
00709    ShadowRange *d;
00710    ReadChunkData3ds(chunk);
00711    d = chunk->data;
00712    //fprintf(outfile, "%sRange of %i\n", indent(indentlevel), d->shadowrange);
00713    break;
00714    }
00715    case SHADOW_FILTER:      {
00716    ShadowFilter *d;
00717    ReadChunkData3ds(chunk);
00718    d = chunk->data;
00719    //fprintf(outfile, "%sFilter of %f\n", indent(indentlevel), d->shadowfilter);
00720    break;
00721    }
00722    case O_CONSTS:      {
00723    OConsts *d;
00724    ReadChunkData3ds(chunk);
00725    d = chunk->data;
00726    //fprintf(outfile, "%sPlane at %f, %f, %f\n", indent(indentlevel), d->oconsts.x, d->oconsts.y, d->oconsts.z);
00727    break;
00728    }
00729    case FOG:      {
00730    Fog *d;
00731    ReadChunkData3ds(chunk);
00732    d = chunk->data;
00733    //fprintf(outfile, "%sNear plane at %f\n", indent(indentlevel), d->nearplanedist);
00734    //fprintf(outfile, "%sNear density of %f\n", indent(indentlevel), d->nearplanedensity);
00735    //fprintf(outfile, "%sFar plane at %f\n", indent(indentlevel), d->farplanedist);
00736    //fprintf(outfile, "%sFar density of %f\n", indent(indentlevel), d->farplanedensity);
00737    break;
00738    }
00739    case LAYER_FOG:      {
00740    LayerFog *d;
00741    ReadChunkData3ds(chunk);
00742    d = chunk->data;
00743    //fprintf(outfile, "%sFog Z range is %f to %f.\n", indent(indentlevel), d->zmin, d->zmax);
00744    //fprintf(outfile, "%sFog density is %f.\n", indent(indentlevel), d->density);
00745    //fprintf(outfile, "%sFog type of %x.\n", indent(indentlevel), d->type);
00746    break;
00747    }
00748    case DISTANCE_CUE:      {
00749    DistanceCue *d;
00750    ReadChunkData3ds(chunk);
00751    d = chunk->data;
00752    //fprintf(outfile, "%sNear plane at %f\n", indent(indentlevel), d->nearplanedist);
00753    //fprintf(outfile, "%sNear density of %f\n", indent(indentlevel), d->nearplanedimming);
00754    //fprintf(outfile, "%sFar plane at %f\n", indent(indentlevel), d->farplanedist);
00755    //fprintf(outfile, "%sFar density of %f\n", indent(indentlevel), d->farplanedimming);
00756    break;
00757    }
00758    case VIEW_TOP:
00759    case VIEW_BOTTOM:
00760    case VIEW_LEFT:
00761    case VIEW_RIGHT:
00762    case VIEW_FRONT:
00763    case VIEW_BACK:      {
00764    ViewStandard *d;
00765    ReadChunkData3ds(chunk);
00766    d = chunk->data;
00767    //fprintf(outfile, "%sTarget at %f, %f, %f\n", indent(indentlevel), d->viewtargetcoord.x, d->viewtargetcoord.y, d->viewtargetcoord.z);
00768    //fprintf(outfile, "%sView width of %f\n", indent(indentlevel), d->viewwidth);
00769    break;
00770    }
00771    case VIEW_USER:      {
00772    ViewUser *d;
00773    ReadChunkData3ds(chunk);
00774    d = chunk->data;
00775    //fprintf(outfile, "%sTarget at %f, %f, %f\n", indent(indentlevel), d->viewtargetcoord.x, d->viewtargetcoord.y, d->viewtargetcoord.z);
00776    //fprintf(outfile, "%sView width of %f\n", indent(indentlevel), d->viewwidth);
00777    //fprintf(outfile, "%sHorizontal view angle of %f\n", indent(indentlevel), d->xyviewangle);
00778    //fprintf(outfile, "%sVertical view angle of %f\n", indent(indentlevel), d->yzviewangle);
00779    //fprintf(outfile, "%sBank angle of %f\n", indent(indentlevel), d->bankangle);
00780    break;
00781    }
00782    case VIEW_CAMERA:       {
00783    ViewCamera *d;
00784    ReadChunkData3ds(chunk);
00785    d = chunk->data;
00786    //fprintf(outfile, "%sCamera name %s\n", indent(indentlevel), d->name);
00787    break;
00788    }
00789    case MSH_BOXMAP:{
00790    MshBoxmap *d;
00791    ushort3ds i;
00792    ReadChunkData3ds(chunk);
00793    d = chunk->data;
00794    //fprintf(outfile, "%sBoxmap consists of the following materials:\n", indent(indentlevel));
00795    for(i = 0; i < 6; i++)
00796       //fprintf(outfile, "%s%s\n", indent(indentlevel), d->matnames[i]);
00797    break;
00798    }
00799    case MESH_TEXTURE_INFO:      {
00800    MeshTextureInfo *d;
00801    ushort3ds i;
00802    ReadChunkData3ds(chunk);
00803    d = chunk->data;
00804    //fprintf(outfile, "%sMap Type of %i\n", indent(indentlevel), d->maptype);
00805    //fprintf(outfile, "%sX Tiling of %f\n", indent(indentlevel), d->xtiling);
00806    //fprintf(outfile, "%sY Tiling of %f\n", indent(indentlevel), d->ytiling);
00807    //fprintf(outfile, "%sIcon position of %f, %f, %f\n", indent(indentlevel), d->iconpos.x, d->iconpos.y, d->iconpos.z);
00808    //for (i = 0; i < 12; i+=3)   {
00809    //fprintf(outfile, "%s[%i] %f [%i] %f [%i] %f\n", indent(indentlevel), i, d->xmatrix[i], i+1, d->xmatrix[i+1], i+2, d->xmatrix[i+2]);
00810    //}
00811    //fprintf(outfile, "%sScaling Value of %f\n", indent(indentlevel), d->iconscaling);
00812    //fprintf(outfile, "%sPlanar Icon Width of %f\n", indent(indentlevel), d->iconwidth);
00813    //fprintf(outfile, "%sPlanar Icon Height of %f\n", indent(indentlevel), d->iconheight);
00814    //fprintf(outfile, "%sCylinder Icon Height of %f\n", indent(indentlevel), d->cyliconheight);
00815    break;
00816    }
00817    case MESH_MATRIX:      {
00818    MeshMatrix *d;
00819    ushort3ds i;
00820    ReadChunkData3ds(chunk);
00821    d = chunk->data;
00822    for (i = 0; i < 12; i+=3)   {
00823       //fprintf(outfile, "%s[%i] %f [%i] %f [%i] %f\n", indent(indentlevel), i, d->xmatrix[i], i+1, d->xmatrix[i+1], i+2, d->xmatrix[i+2]);
00824    }
00825    break;
00826    }
00827    case PROC_NAME:    {
00828       ProcName *d;
00829 
00830       d = ReadChunkData3ds(chunk);
00831 
00832       //fprintf(outfile, "%sProcedure Name of %s\n", indent(indentlevel), d->name);
00833 
00834       break;
00835    }
00836    case MESH_COLOR:      {
00837    MeshColor *d;
00838    ReadChunkData3ds(chunk);
00839    d = chunk->data;
00840    //fprintf(outfile, "%sColor index of %i\n", indent(indentlevel), d->color);
00841    break;
00842    }
00843    case N_DIRECT_LIGHT:   {
00844    NDirectLight *d;
00845    ReadChunkData3ds(chunk);
00846    d = chunk->data;
00847    //fprintf(outfile, "%sLight at %f, %f, %f\n", indent(indentlevel), d->lightpos.x, d->lightpos.y, d->lightpos.z);
00848    break;
00849    }
00850    case DL_EXCLUDE:      {
00851    DlExclude *d;
00852    ReadChunkData3ds(chunk);
00853    d = chunk->data;
00854    //fprintf(outfile, "%sExclude %s.\n", indent(indentlevel), d->name);
00855    break;
00856    }
00857    case DL_OUTER_RANGE:
00858    case DL_INNER_RANGE:      {
00859    DlOuterRange *d;
00860    ReadChunkData3ds(chunk);
00861    d = chunk->data;
00862    //fprintf(outfile, "%sRange of %f.\n", indent(indentlevel), d->range);
00863    break;
00864    }
00865    case DL_MULTIPLIER:      {
00866    DlMultiplier *d;
00867    ReadChunkData3ds(chunk);
00868    d = chunk->data;
00869    //fprintf(outfile, "%sMultiple of %f.\n", indent(indentlevel), d->multiple);
00870    break;
00871    }
00872    case DL_SPOT_ROLL:      {
00873    DlSpotRoll *d;
00874    d = ReadChunkData3ds(chunk);
00875 
00876    //fprintf(outfile, "%sRoll angle of %f.\n", indent(indentlevel), d->angle);
00877    break;
00878    }
00879    case DL_SPOT_ASPECT:      {
00880    DlSpotAspect *d;
00881    d = ReadChunkData3ds(chunk);
00882    //fprintf(outfile, "%sSpot aspect of %f.\n", indent(indentlevel), d->aspect);
00883    break;
00884    }
00885    case DL_SPOT_PROJECTOR:      {
00886    DlSpotProjector *d;
00887    ReadChunkData3ds(chunk);
00888    d = chunk->data;
00889    //fprintf(outfile, "%sFilename of %s.\n", indent(indentlevel), d->name);
00890    break;
00891    }
00892    case DL_RAY_BIAS:      {
00893    DlRayBias *d;
00894    ReadChunkData3ds(chunk);
00895    d = chunk->data;
00896    //fprintf(outfile, "%sBias of %f.\n", indent(indentlevel), d->bias);
00897    break;
00898    }
00899    case DL_SPOTLIGHT:      {
00900    DlSpotlight *d;
00901    ReadChunkData3ds(chunk);
00902    d = chunk->data;
00903    //fprintf(outfile, "%sTarget at %f, %f, %f\n", indent(indentlevel), d->spotlighttarg.x, d->spotlighttarg.y, d->spotlighttarg.z);
00904    //fprintf(outfile, "%sHotspot cone of %f, ", indent(indentlevel), d->hotspotangle);
00905    //fprintf(outfile, "Falloff cone of %f\n",  d->falloffangle);
00906    break;
00907    }
00908    case DL_LOCAL_SHADOW2:      {
00909    DlLocalShadow2 *d;
00910    ReadChunkData3ds(chunk);
00911    d = chunk->data;
00912    //fprintf(outfile, "%sShadow bias of %f\n", indent(indentlevel), d->localshadowbias);
00913    //fprintf(outfile, "%sShadow filter of %f\n", indent(indentlevel), d->localshadowfilter);
00914    //fprintf(outfile, "%sShadow map size of %f\n", indent(indentlevel), d->localshadowmapsize);
00915    
00916    break;
00917    }
00918    case N_CAMERA:      {
00919    NCamera *d;
00920    ReadChunkData3ds(chunk);
00921    d = chunk->data;
00922    
00923    //fprintf(outfile, "%sCamera at %f, %f, %f\n", indent(indentlevel), d->camerapos.x, d->camerapos.y, d->camerapos.z);
00924    //fprintf(outfile, "%sTarget at %f, %f, %f\n", indent(indentlevel), d->targetpos.x, d->targetpos.y, d->targetpos.z);
00925    //fprintf(outfile, "%sBank angle of %f", indent(indentlevel), d->camerabank);
00926    //fprintf(outfile, " and a foc of %f\n", d->camerafocallength);
00927    break;
00928    }
00929    case CAM_RANGES:      {
00930    CamRanges *d;
00931    ReadChunkData3ds(chunk);
00932    d = chunk->data;
00933    //fprintf(outfile, "%sCamera near range is %f and far range is %f.\n", indent(indentlevel), d->nearplane, d->farplane);
00934    break;
00935    }
00936    case VIEWPORT_LAYOUT:      {
00937    ViewportLayout *d;
00938    ReadChunkData3ds(chunk);
00939    d = chunk->data;
00940    //fprintf(outfile, "%sForm of %i\n", indent(indentlevel), d->form);
00941    //fprintf(outfile, "%sTop of %i\n", indent(indentlevel), d->top);
00942    //fprintf(outfile, "%sReady of %i\n", indent(indentlevel), d->ready);
00943    //fprintf(outfile, "%sWState of %i\n", indent(indentlevel), d->wstate);
00944    //fprintf(outfile, "%sSwap WS of %i\n", indent(indentlevel), d->swapws);
00945    //fprintf(outfile, "%sSwap Port of %i\n", indent(indentlevel), d->swapport);
00946    //fprintf(outfile, "%sSwap Cur of %i\n", indent(indentlevel), d->swapcur);
00947    break;
00948    }
00949    case VIEWPORT_SIZE:      {
00950    ViewportSize *d;
00951    ReadChunkData3ds(chunk);
00952    d = chunk->data;
00953    //fprintf(outfile, "%sWork Area X: %i Y: %i W: %i H: %i\n", indent(indentlevel), d->xpos, d->ypos, d->width, d->height);
00954    break;
00955    }
00956    case VIEWPORT_DATA_3:
00957    case VIEWPORT_DATA:      {
00958    ViewportData *d;
00959    ReadChunkData3ds(chunk);
00960    d = chunk->data;
00961    //fprintf(outfile, "%sFlags of %x\n", indent(indentlevel), d->flags);
00962    //fprintf(outfile, "%sAxis Lockouts of %x\n", indent(indentlevel), d->axislockout);
00963    //fprintf(outfile, "%sWindow Position of %i, ", indent(indentlevel), d->winxpos);
00964    //fprintf(outfile, "%i\n", d->winypos);
00965    //fprintf(outfile, "%sWindow Size of %i, ", indent(indentlevel), d->winwidth);
00966    //fprintf(outfile, "%i\n", d->winheight);
00967    //fprintf(outfile, "%sWindow View of %i\n", indent(indentlevel), d->view);
00968    //fprintf(outfile, "%sZoom Factor of %f\n", indent(indentlevel), d->zoomfactor);
00969    //fprintf(outfile, "%sWorld center of %f, %f, %f\n", indent(indentlevel), d->center.x, d->center.y, d->center.z);
00970    //fprintf(outfile, "%sHorizontal Angle of %f\n", indent(indentlevel), d->horizang);
00971    //fprintf(outfile, "%sVertical Angle of %f\n", indent(indentlevel), d->vertang);
00972    //fprintf(outfile, "%sCamera Name of %s\n", indent(indentlevel), d->camname);
00973    break;
00974    }
00975    case XDATA_APPNAME:      {
00976    XDataAppName *d;
00977    ReadChunkData3ds(chunk);
00978    d = chunk->data;
00979    //fprintf(outfile, "%sApplication name %s\n", indent(indentlevel), d->name);
00980    break;
00981    }
00982    case XDATA_STRING:      {
00983    XDataString *d;
00984    ReadChunkData3ds(chunk);
00985    d = chunk->data;
00986    //fprintf(outfile, "%sString value of %s\n", indent(indentlevel), d->string);
00987    break;
00988    }
00989    case MAT_SHADING:      {
00990    MatShading *d;
00991    ReadChunkData3ds(chunk);
00992    d = chunk->data;
00993    //fprintf(outfile, "%sShading value of %u\n", indent(indentlevel), d->matshading);
00994    break;
00995    }
00996    case MAT_ACUBIC:      {
00997    MatAcubic *d;
00998    ReadChunkData3ds(chunk);
00999    d = chunk->data;
01000    //fprintf(outfile, "%sShade level of %i\n", indent(indentlevel), d->shadelevel);
01001    //fprintf(outfile, "%sAntialias level of %i\n", indent(indentlevel), d->antialias);
01002    //fprintf(outfile, "%sFlags of %u\n", indent(indentlevel), d->flags);
01003    //fprintf(outfile, "%sMap size of %u\n", indent(indentlevel), d->mapsize);
01004    //fprintf(outfile, "%sFrame skip of %u\n", indent(indentlevel), d->frameinterval);
01005    break;
01006    }
01007    case MAT_WIRESIZE:      {
01008    MatWireSize *d;
01009    ReadChunkData3ds(chunk);
01010    d = chunk->data;
01011    //fprintf(outfile, "%sWire frame size of %f\n", indent(indentlevel), d->wiresize);
01012    break;
01013    }
01014 
01015    case KFHDR:      {
01016    KFHdr *d;
01017    ReadChunkData3ds(chunk);
01018    d = chunk->data;
01019    //fprintf(outfile, "%sRevision level of %x\n", indent(indentlevel), d->revision);
01020    //fprintf(outfile, "%sFilename %s\n", indent(indentlevel), d->filename);
01021    //fprintf(outfile, "%sAnimation length of %i\n", indent(indentlevel), d->animlength);
01022    break;
01023    }
01024    case KFSEG:      {
01025    KFSeg *d;
01026    ReadChunkData3ds(chunk);
01027    d = chunk->data;
01028    //fprintf(outfile, "%sSegment starts at %i and ends at %i\n", indent(indentlevel), d->first, d->last);
01029    break;
01030    }
01031    case KFCURTIME:
01032       {
01033    KFCurtime *d;
01034    ReadChunkData3ds(chunk);
01035    d = chunk->data;
01036    
01037    //fprintf(outfile, "%sCurrent frame is %i\n", indent(indentlevel), d->currframenum);
01038    
01039    break;
01040    }
01041    case NODE_ID:      {
01042      int i;
01043      KFId *d;
01044      d = ReadChunkData3ds(chunk);
01045      i = (int)d->id;
01046     //fprintf(outfile, "%s Node ID: %d \n", indent(indentlevel), i);
01047     break;
01048    }
01049    case NODE_HDR: {
01050    NodeHdr *d;
01051    ReadChunkData3ds(chunk);
01052    d = chunk->data;
01053    
01054    //fprintf(outfile, 
01055    //  "%sObject name: %s\n", 
01056    //  indent(indentlevel), 
01057    //  d->objname);
01058 
01059    /*--- Flags 1 */
01060    //fprintf(outfile, 
01061    //  "%sFlags 1: %x\n", 
01062    //  indent(indentlevel), 
01063    //  d->flags1);
01064    if (DumpLevel3ds == MaximumDump3ds){
01065 
01066      //if (d->flags1&NODE_RENDOB_HIDE)
01067        //fprintf(outfile, "%sNODE_RENDOB_HIDE\n", indent(indentlevel));
01068      //if (d->flags1&NODE_OFF)
01069        //fprintf(outfile, "%sNODE_OFF\n", indent(indentlevel));
01070      //if (d->flags1&ATKEY1)
01071        //fprintf(outfile, "%sATKEY1\n", indent(indentlevel));
01072      //if (d->flags1&ATKEY2)
01073        //fprintf(outfile, "%sATKEY2\n", indent(indentlevel));
01074      //if (d->flags1&ATKEY3)
01075        //fprintf(outfile, "%sATKEY3\n", indent(indentlevel));
01076      //if (d->flags1&ATKEY4)
01077        //fprintf(outfile, "%sATKEY4\n", indent(indentlevel));
01078      //if (d->flags1&ATKEY5)
01079        //fprintf(outfile, "%sATKEY5\n", indent(indentlevel));
01080      //if (d->flags1&ATKEYFLAGS)
01081        //fprintf(outfile, "%sATKEYFLAGS\n", indent(indentlevel));
01082      //if (d->flags1&MARK_NODE)
01083        //fprintf(outfile, "%sMARK_NODE\n", indent(indentlevel));
01084      //if (d->flags1&DISABLE_NODE)
01085        //fprintf(outfile, "%sDISABLE_NODE\n", indent(indentlevel));
01086      //if (d->flags1&HIDE_NODE)
01087        //fprintf(outfile, "%sHIDE_NODE\n", indent(indentlevel));
01088      //if (d->flags1&FAST_NODE)
01089        //fprintf(outfile, "%sFAST_NODE\n", indent(indentlevel));
01090      //if (d->flags1&PRIMARY_NODE)
01091        //fprintf(outfile, "%sPRIMARY_NODE\n", indent(indentlevel));
01092      //if (d->flags1&NODE_CALC_PATH)
01093        //fprintf(outfile, "%sNODE_CALC_PATH\n", indent(indentlevel));
01094    }
01095 
01096    /*--- Flags 2 */
01097    //fprintf(outfile, 
01098    //  "%sFlags 2: %x\n", 
01099    //  indent(indentlevel), 
01100    //  d->flags2);
01101    if (DumpLevel3ds == MaximumDump3ds){
01102      //if (d->flags2&NODE_HAS_PATH)
01103        //fprintf(outfile, "%sNODE_HAS_PATH\n",indent(indentlevel));
01104      //if (d->flags2&NODE_AUTO_SMOOTH)
01105        //fprintf(outfile, "%sNODE_AUTO_SMOOTH\n",indent(indentlevel));
01106      //if (d->flags2&NODE_FROZEN)
01107        //fprintf(outfile, "%sNODE_FROZEN\n",indent(indentlevel));
01108      //if (d->flags2&NODE_ANI_HIDDEN)
01109        //fprintf(outfile, "%sNODE_ANI_HIDDEN\n",indent(indentlevel));
01110      //if (d->flags2&NODE_MOTION_BLUR)
01111        //fprintf(outfile, "%sNODE_MOTION_BLUR\n",indent(indentlevel));
01112      //if (d->flags2&NODE_BLUR_BRANCH)
01113        //fprintf(outfile, "%sNODE_BLUR_BRANCH\n",indent(indentlevel));
01114      //if (d->flags2&NODE_MORPH_MTL)
01115        //fprintf(outfile, "%sNODE_MORPH_MTL\n",indent(indentlevel));
01116      //if (d->flags2&NODE_MORPH_OB)
01117        //fprintf(outfile, "%sNODE_MORPH_OB\n",indent(indentlevel));
01118    }
01119 
01120    
01121    //if (d->parentindex == -1) 
01122      //fprintf(outfile, "%sNo Parent\n", indent(indentlevel));
01123     //     else 
01124      //fprintf(outfile, 
01125       // "%sParent %i\n", indent(indentlevel), d->parentindex);
01126    break;
01127    }
01128    case INSTANCE_NAME:      { //RSFx
01129      InstanceName *d;
01130     ReadChunkData3ds(chunk);
01131     d = chunk->data;
01132     //fprintf(outfile, "%sInstance name: %s\n", indent(indentlevel), d->name);
01133     break;
01134    }
01135    case PARENT_NAME: { //RSFx
01136    InstanceName *d;
01137    ReadChunkData3ds(chunk);
01138    d = chunk->data;
01139    //if (d == NULL ||d->name[0] == 0)
01140    //fprintf(outfile, "%sNo Parent\n", indent(indentlevel));
01141    //else
01142    //fprintf(outfile, "%sParent name: %s\n",
01143    //  indent(indentlevel), d->name);
01144    break;
01145    }
01146    case PIVOT:
01147       {
01148    Pivot *d;
01149    ReadChunkData3ds(chunk);
01150    d = chunk->data;
01151    //fprintf(outfile, "%sPivot at %f, %f, %f\n", indent(indentlevel), d->offset.x, d->offset.y, d->offset.z);
01152    break;
01153    }
01154    case BOUNDBOX:      {
01155    BoundBox *d;
01156    d = chunk->data;
01157       if (d != NULL){
01158    //fprintf(outfile, "%sMinimum at %f, %f, %f\n", indent(indentlevel), d->min.x, d->min.y, d->min.z);
01159    //fprintf(outfile, "%sMaximum at %f, %f, %f\n", indent(indentlevel), d->max.x, d->max.y, d->max.z);
01160     }
01161    
01162    break;
01163    }
01164    case MORPH_SMOOTH:
01165       {
01166    MorphSmooth *d;
01167    ReadChunkData3ds(chunk);
01168    d = chunk->data;
01169    
01170    //fprintf(outfile, "%sMorph Smoothing Angle of %f\n", indent(indentlevel), d->smoothgroupangle);
01171    
01172    break;
01173    }
01174    case POS_TRACK_TAG:      {
01175    PosTrackTag *d;
01176    ulong3ds i;
01177    
01178    ReadChunkData3ds(chunk);
01179    d = chunk->data;
01180    
01181    //fprintf(outfile, "%s%u Keys, %x Flags.\n", indent(indentlevel), d->trackhdr.keycount, d->trackhdr.flags);
01182    
01183    for (i = 0; i < d->trackhdr.keycount; i++) {
01184       //PrintKeyHeader3ds(outfile,  &(d->keyhdrlist[i]), indentlevel);
01185       //fprintf(outfile, "%sObject at %f, %f, %f\n", indent(indentlevel), d->positionlist[i].x, d->positionlist[i].y, d->positionlist[i].z);
01186    }
01187    
01188    break;
01189    }
01190    case ROT_TRACK_TAG:      {
01191    RotTrackTag *d;
01192    ulong3ds i;
01193    ReadChunkData3ds(chunk);
01194    d = chunk->data;
01195    //fprintf(outfile, "%s%u Keys, %x Flags.\n", indent(indentlevel), d->trackhdr.keycount, d->trackhdr.flags);
01196    for (i = 0; i < d->trackhdr.keycount; i++)    {
01197       //PrintKeyHeader3ds(outfile, &(d->keyhdrlist[i]), indentlevel);
01198       //fprintf(outfile, "%sRotation of %f\n", indent(indentlevel), d->rotationlist[i].angle);
01199       //fprintf(outfile, "%sAxis of %f, %f, %f\n", indent(indentlevel), d->rotationlist[i].x, d->rotationlist[i].y, d->rotationlist[i].z);
01200    }
01201    
01202    break;
01203    }
01204    case SCL_TRACK_TAG:      {
01205    ScaleTrackTag *d;
01206    ulong3ds i;
01207    ReadChunkData3ds(chunk);
01208    d = chunk->data;
01209    //fprintf(outfile, "%s%u Keys, %x Flags.\n", indent(indentlevel), d->trackhdr.keycount, d->trackhdr.flags);
01210    for (i = 0; i < d->trackhdr.keycount; i++) {
01211       //PrintKeyHeader3ds(outfile, &(d->keyhdrlist[i]), indentlevel);
01212       //fprintf(outfile, "%sScale of %f, %f, %f\n", indent(indentlevel), d->scalelist[i].x, d->scalelist[i].y, d->scalelist[i].z);
01213    }
01214    break;
01215    }
01216    case FOV_TRACK_TAG:      {
01217    FovTrackTag *d;
01218    ulong3ds i;
01219    ReadChunkData3ds(chunk);
01220    d = chunk->data;
01221    //fprintf(outfile, "%s%u Keys, %x Flags.\n", indent(indentlevel), d->trackhdr.keycount, d->trackhdr.flags);
01222    for (i = 0; i < d->trackhdr.keycount; i++) {
01223       //PrintKeyHeader3ds(outfile, &(d->keyhdrlist[i]), indentlevel);
01224       //fprintf(outfile, "%sCamera Fov of %f\n", indent(indentlevel), d->fovanglelist[i]);
01225    }
01226    
01227    break;
01228    }
01229    case ROLL_TRACK_TAG:      {
01230    RollTrackTag *d;
01231    ulong3ds i;
01232    ReadChunkData3ds(chunk);
01233    d = chunk->data;
01234    //fprintf(outfile, "%s%u Keys, %x Flags.\n", indent(indentlevel), d->trackhdr.keycount, d->trackhdr.flags);
01235    for (i = 0; i < d->trackhdr.keycount; i++) {
01236       //PrintKeyHeader3ds(outfile, &(d->keyhdrlist[i]), indentlevel);
01237       //fprintf(outfile, "%sCamera Roll of %f\n", indent(indentlevel), d->rollanglelist[i]);
01238    }
01239    break;
01240    }
01241    case COL_TRACK_TAG:      {
01242    ColTrackTag *d;
01243    ulong3ds i;
01244    ReadChunkData3ds(chunk);
01245    d = chunk->data;
01246    //fprintf(outfile, "%s%u Keys, %x Flags.\n", indent(indentlevel), d->trackhdr.keycount, d->trackhdr.flags);
01247    for (i = 0; i < d->trackhdr.keycount; i++) {
01248       //PrintKeyHeader3ds(outfile, &(d->keyhdrlist[i]), indentlevel);
01249       //fprintf(outfile, "%sColor R: %f,", indent(indentlevel), d->colorlist[i].r);
01250       //fprintf(outfile, "G: %f,", d->colorlist[i].g);
01251       //fprintf(outfile, "B: %f\n", d->colorlist[i].b);
01252    }
01253    
01254    break;
01255    }
01256    case MORPH_TRACK_TAG:      {
01257    MorphTrackTag *d;
01258    ulong3ds i;
01259    ReadChunkData3ds(chunk);
01260    d = chunk->data;
01261    //fprintf(outfile, "%s%u Keys, %x Flags.\n", indent(indentlevel), d->trackhdr.keycount, d->trackhdr.flags);
01262    for (i = 0; i < d->trackhdr.keycount; i++) {
01263       //PrintKeyHeader3ds(outfile, &(d->keyhdrlist[i]), indentlevel);
01264       //fprintf(outfile, "%sMorph to %s\n", indent(indentlevel), d->morphlist[i].name);
01265    }
01266    break;
01267    }
01268    case HOT_TRACK_TAG:      {
01269    HotTrackTag *d;
01270    ulong3ds i;
01271    
01272    ReadChunkData3ds(chunk);
01273    d = chunk->data;
01274    
01275    //fprintf(outfile, "%s%u Keys, %x Flags.\n", indent(indentlevel), d->trackhdr.keycount, d->trackhdr.flags);
01276    for (i = 0; i < d->trackhdr.keycount; i++) {
01277       //PrintKeyHeader3ds(outfile, &(d->keyhdrlist[i]), indentlevel);
01278       //fprintf(outfile, "%sHotspot angle of %f\n", indent(indentlevel), d->hotspotanglelist[i]);
01279    }
01280    
01281    break;
01282    }
01283    case FALL_TRACK_TAG:      {
01284    FallTrackTag *d;
01285    ulong3ds i;
01286    ReadChunkData3ds(chunk);
01287    d = chunk->data;
01288    //fprintf(outfile, "%s%u Keys, %x Flags.\n", indent(indentlevel), d->trackhdr.keycount, d->trackhdr.flags);
01289    for (i = 0; i < d->trackhdr.keycount; i++) {
01290       //PrintKeyHeader3ds(outfile, &(d->keyhdrlist[i]), indentlevel);
01291       //fprintf(outfile, "%sFalloff Angle of %f\n", indent(indentlevel), d->falloffanglelist[i]);
01292    }
01293    break;
01294    }
01295    case HIDE_TRACK_TAG:      {
01296    HideTrackTag *d;
01297    ulong3ds i;
01298    ReadChunkData3ds(chunk);
01299    d = chunk->data;
01300    //fprintf(outfile, "%s%u Keys, %x Flags.\n", 
01301    //  indent(indentlevel), 
01302    //  d->trackhdr.keycount, d->trackhdr.flags);
01303    for (i = 0; i < d->trackhdr.keycount; i++) {
01304      //PrintKeyHeader3ds(outfile, &(d->keyhdrlist[i]), indentlevel);
01305    }
01306    break;
01307    }
01308 
01309  } /* End Switch */
01310 
01311   child = chunk->children;
01312   while (child != NULL)    {
01313     //fprintf(outfile,"child of parent [%s]\n",CurrentObjectName); //RSFxx
01314     ProcessChunk3ds(outfile, child, (ushort3ds)(indentlevel+1),CurrentSp);
01315     ON_ERROR_RETURN;
01316     child = child->sibling;
01317  }
01318 }
01319 
01320 BOOL Do3dsConvert(int argc, char **argv){
01321  HCURSOR hSave;
01322  FILE *outfile;
01323  float size=500.0;
01324  long count,fze,sc=1;
01325  unsigned short i,id;
01326  char c,argv1[512],str[512];
01327  if(argc < 2)return FALSE;
01328  strcpy(argv1,argv[1]);
01329  if(lpEVI == NULL){MessageBox(NULL,"Bad Pointer",NULL,MB_OK); return FALSE;}
01330  for(i=0;i<3;i++){
01331    gmax[i] = -1.0e30;
01332    gmin[i] =  1.0e30;
01333  } 
01334  if(Nvert > 0 || Nface > 0)return FALSE;
01335  if((i=strlen(argv1)) < 4 || argv1[i-4] != '.')strcat(argv1,".3DS");
01336  argv1[strlen(argv1)]=0;
01337  {
01338    file3ds *file= NULL;
01339    database3ds *db = NULL;
01340    chunklist3ds *meshlist=NULL, *matlist=NULL;
01341    //outfile=fopen("c:\\data\\dummy3ds.txt","w"); //RSFx
01342    outfile=stderr;
01343    SetDumpLevel3ds(MaximumDump3ds);
01344    file = OpenFile3ds(argv1, "r");
01345    hSave=SetCursor(LoadCursor(NULL,IDC_WAIT));
01346 
01347    InitDatabase3ds(&db);
01348    CreateDatabase3ds(file, db);
01349    ProcessChunk3ds(outfile, db->topchunk, 0,FirstSp);
01350    ReleaseDatabase3ds(&db);
01351    CloseFile3ds(file);
01352    SetCursor(hSave);
01353    if(dlg != NULL)DestroyWindow(dlg); dlg=NULL;
01354  }
01355  if(sc)rescale_model(1,outfile);
01356  else  rescale_model(0,outfile);
01357  //fclose(outfile); outfile=NULL; //RSFx
01358  return FALSE;
01359 }
01360 

Generated on Sun Apr 27 14:20:10 2014 for OpenFX by  doxygen 1.5.6