00001
00002
00003
00004
00005
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;
00070 int n;
00071 } extravertex3DS;
00072
00073 static void mes3ds(char *s){
00074
00075
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
00084 if(id == 0){
00085 (MainVp+vi)->id=id=(long)(malloc(sizeof(extravertex3DS)));
00086 vip=(extravertex3DS *)id;
00087 vip->adj=NULL;
00088 vip->n=0;
00089
00090 }
00091 else{
00092 vip=(extravertex3DS *)id;
00093
00094 }
00095
00096 if(vip->n > 0){
00097 for(i=0;i<vip->n;i++){
00098 if(vip->adj[i] == vj){
00099
00100 return;
00101 }
00102 }
00103 }
00104 vjp=(extravertex3DS *)((MainVp+vj)->id);
00105 if(vjp != NULL && vjp->n > 0){
00106
00107 for(j=0;j<vjp->n;j++){
00108 if(vjp->adj[j] == vi){
00109
00110 return;
00111 }
00112 }
00113
00114 }
00115 if(vip->n == 0){
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;
00126 (vip->n)++;
00127
00128 CreateEdge(vi,vj);
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
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);
00156 for(i = 0; i < d->faces; i++) {
00157 v1 = d->facelist[i].v1 + FirstVertex; if (v1 >= Nvert){bError=1; continue;}
00158 v2 = d->facelist[i].v2 + FirstVertex; if (v2 >= Nvert){bError=1; continue;}
00159 v3 = d->facelist[i].v3 + FirstVertex; if (v3 >= Nvert){bError=1; continue;}
00160
00161 InsertInVertexList(outfile,v1,v2);
00162 InsertInVertexList(outfile,v2,v3);
00163 InsertInVertexList(outfile,v3,v1);
00164 }
00165 UpdateEdgeHeap(Nedge+3*d->faces);
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
00187 if(option == 0){
00188 scale_3ds=4.0*(float)DEFAULT_SCALE/maxd;
00189 }
00190 else if(option == 1){
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
00221
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,
00242 chunk3ds *chunk,
00243 ushort3ds indentlevel,
00244 skel *CurrentSp
00245 ){
00246 chunk3ds *child;
00247 ReportChunkHeader(outfile, chunk, indentlevel);
00248 switch(chunk->tag){
00249 case MAT_ENTRY :{
00250
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
00264 CurrentImageMapType=1;
00265 }
00266 break;
00267 case MAT_OPACMAP : {
00268
00269 CurrentImageMapType=4;
00270 }
00271 break;
00272 case MAT_REFLMAP :{
00273
00274 CurrentImageMapType=2;
00275 }
00276 break;
00277 case MAT_BUMPMAP :
00278 CurrentImageMapType=3;
00279
00280 break;
00281 case MAT_SPECMAP :
00282 CurrentImageMapType=5;
00283
00284 break;
00285 case MAT_NAME: {
00286 MatName *d;
00287 ReadChunkData3ds(chunk);
00288 d = chunk->data;
00289
00290 strcpy(iMat[nMats-1].name,d->name);
00291 strcpy(iMap[nImaps-1].N,d->name);
00292 break;
00293 }
00294 case MAT_MAPNAME: {
00295 char *pext;
00296 MatMapname *d;
00297 ReadChunkData3ds(chunk);
00298 d = chunk->data;
00299
00300 strcpy(CurrentImageMapFile,d->name);
00301 strlwr(CurrentImageMapFile);
00302
00303
00304 pext=strstr(CurrentImageMapFile,".dds");
00305 if(pext !=NULL)strcpy(pext,".jpg");
00306
00307 if(CurrentImageMap >=0 && CurrentImageMapType > 0){
00308 if(CurrentImageMapType == 1){
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){
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){
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){
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: {
00332 NamedObject *d;
00333 ReadChunkData3ds(chunk);
00334
00335 d = chunk->data;
00336 ObjectFirstVertex = Nvert; ObjectFirstFace = Nface;
00337 strcpy(CurrentObjectName,d->name); CurrentObjectName[16]=0;
00338
00339 break;
00340 }
00341 case POINT_ARRAY:{
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
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;
00376 Vp->xyz[0]=x; Vp->xyz[1]=y; Vp->xyz[2]=z;
00377
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: {
00388 vertex *Vp;
00389 TexVerts *d;
00390 ushort3ds i;
00391 ReadChunkData3ds(chunk);
00392 d = chunk->data;
00393
00394 if(d->numcoords == CurrentVertices){
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
00400 }
00401 }
00402 break;
00403 }
00404 case FACE_ARRAY: {
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
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;}
00417 v2 = d->facelist[i].v2 + FirstVertex; if (v2 >= Nvert){bError=1; continue;}
00418 v3 = d->facelist[i].v3 + FirstVertex; if (v3 >= Nvert){bError=1; continue;}
00419 CreateFace(v1,v2,v3);
00420
00421
00422 Fp=(MainFp+FirstFace+i);
00423 Fp->bSmooth=1;
00424 Fp->material = -1;
00425 Fp->imagemap = -1;
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){
00432 CreateEdges(outfile,d) ;
00433 UpdateEdgeHeap(Nedge);
00434
00435 }
00436 break;
00437 }
00438 case MSH_MAT_GROUP: {
00439 MshMatGroup *d;
00440 int i,fid;
00441 face *Fp;
00442 ReadChunkData3ds(chunk);
00443 d = chunk->data;
00444
00445
00446 GetActiveTextureIDs(d->matname);
00447
00448 for(i = 0; i < d->faces; i++) {
00449 fid=d->facelist[i];
00450
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
00463 break;
00464 }
00465 case M3D_VERSION : {
00466 M3dVersion *d;
00467 ReadChunkData3ds(chunk);
00468 d = chunk->data;
00469
00470 break;
00471 }
00472 case POINT_FLAG_ARRAY: {
00473 PointFlagArray *d;
00474 ushort3ds i;
00475 d = ReadChunkData3ds(chunk);
00476
00477 if (DumpLevel3ds == MaximumDump3ds) {
00478 for (i = 0; i < d->flags; i++) {
00479
00480 }
00481 }
00482 break;
00483 }
00484 case MAT_MAP_TILING: {
00485 MatMapTiling *d;
00486 ReadChunkData3ds(chunk);
00487 d = chunk->data;
00488
00489
00490
00491
00492
00493
00494
00495
00496
00497
00498
00499
00500
00501 break;
00502 }
00503 case MAT_MAP_COL1 : {
00504 MatMapCol1 *d;
00505 ReadChunkData3ds(chunk);
00506 d = chunk->data;
00507
00508
00509
00510
00511
00512 break;
00513 }
00514 case MAT_MAP_COL2 : {
00515 MatMapCol2 *d;
00516 ReadChunkData3ds(chunk);
00517 d = chunk->data;
00518
00519
00520
00521 break;
00522 }
00523 case MAT_MAP_RCOL : {
00524 MatMapRCol *d;
00525 ReadChunkData3ds(chunk);
00526 d = chunk->data;
00527
00528
00529
00530 break;
00531 }
00532 case MAT_MAP_GCOL : {
00533 MatMapGCol *d;
00534 ReadChunkData3ds(chunk);
00535 d = chunk->data;
00536
00537
00538
00539 break;
00540 }
00541 case MAT_MAP_BCOL :
00542 {
00543 MatMapBCol *d;
00544 ReadChunkData3ds(chunk);
00545 d = chunk->data;
00546
00547
00548
00549
00550
00551 break;
00552 }
00553 case MAT_MAP_TEXBLUR: {
00554 MatMapTexblur *d;
00555 ReadChunkData3ds(chunk);
00556 d = chunk->data;
00557
00558 break;
00559 }
00560 case MAT_MAP_USCALE: {
00561 MatMapUScale *d;
00562 ReadChunkData3ds(chunk);
00563 d = chunk->data;
00564
00565 break;
00566 }
00567 case MAT_MAP_VSCALE: {
00568 MatMapVScale *d;
00569 ReadChunkData3ds(chunk);
00570 d = chunk->data;
00571
00572 break;
00573 }
00574 case MAT_MAP_UOFFSET: {
00575 MatMapUOffset *d;
00576 ReadChunkData3ds(chunk);
00577 d = chunk->data;
00578
00579 break;
00580 }
00581 case MAT_MAP_VOFFSET: {
00582 MatMapVOffset *d;
00583 ReadChunkData3ds(chunk);
00584 d = chunk->data;
00585
00586 break;
00587 }
00588 case MAT_MAP_ANG: {
00589 MatMapAng *d;
00590 ReadChunkData3ds(chunk);
00591 d = chunk->data;
00592
00593 break;
00594 }
00595 case MAT_BUMP_PERCENT : {
00596 MatBumpPercent *d;
00597 ReadChunkData3ds(chunk);
00598 d = chunk->data;
00599
00600 break;
00601 }
00602 case COLOR_F : {
00603 ColorF *d;
00604 ReadChunkData3ds(chunk);
00605 d = chunk->data;
00606
00607
00608
00609 break;
00610 }
00611 case LIN_COLOR_F : {
00612 LinColorF *d;
00613 ReadChunkData3ds(chunk);
00614 d = chunk->data;
00615
00616
00617
00618 break;
00619 }
00620 case COLOR_24 : {
00621 Color24 *d;
00622 ReadChunkData3ds(chunk);
00623 d = chunk->data;
00624
00625
00626
00627 break;
00628 }
00629 case LIN_COLOR_24 :{
00630 LinColor24 *d;
00631 ReadChunkData3ds(chunk);
00632 d = chunk->data;
00633
00634
00635
00636 break;
00637 }
00638 case INT_PERCENTAGE : {
00639 IntPercentage *d;
00640 ReadChunkData3ds(chunk);
00641 d = chunk->data;
00642
00643 break;
00644 }
00645 case FLOAT_PERCENTAGE : {
00646 FloatPercentage *d;
00647 ReadChunkData3ds(chunk);
00648 d = chunk->data;
00649
00650 break;
00651 }
00652 case MASTER_SCALE : {
00653 MasterScale *d;
00654 ReadChunkData3ds(chunk);
00655 d = chunk->data;
00656
00657 break;
00658 }
00659 case BIT_MAP : {
00660 BitMap *d;
00661 ReadChunkData3ds(chunk);
00662 d = chunk->data;
00663
00664 break;
00665 }
00666 case V_GRADIENT: {
00667 VGradient *d;
00668 ReadChunkData3ds(chunk);
00669 d = chunk->data;
00670
00671 break;
00672 }
00673 case LO_SHADOW_BIAS: {
00674 LoShadowBias *d;
00675 ReadChunkData3ds(chunk);
00676 d = chunk->data;
00677
00678 break;
00679 }
00680 case HI_SHADOW_BIAS: {
00681 HiShadowBias *d;
00682 ReadChunkData3ds(chunk);
00683 d = chunk->data;
00684
00685 break;
00686 }
00687 case RAY_BIAS: {
00688 RayBias *d;
00689 ReadChunkData3ds(chunk);
00690 d = chunk->data;
00691
00692 break;
00693 }
00694 case SHADOW_MAP_SIZE: {
00695 ShadowMapSize *d;
00696 ReadChunkData3ds(chunk);
00697 d = chunk->data;
00698
00699 break;
00700 }
00701 case SHADOW_SAMPLES: {
00702 ShadowSamples *d;
00703 ReadChunkData3ds(chunk);
00704 d = chunk->data;
00705
00706 break;
00707 }
00708 case SHADOW_RANGE: {
00709 ShadowRange *d;
00710 ReadChunkData3ds(chunk);
00711 d = chunk->data;
00712
00713 break;
00714 }
00715 case SHADOW_FILTER: {
00716 ShadowFilter *d;
00717 ReadChunkData3ds(chunk);
00718 d = chunk->data;
00719
00720 break;
00721 }
00722 case O_CONSTS: {
00723 OConsts *d;
00724 ReadChunkData3ds(chunk);
00725 d = chunk->data;
00726
00727 break;
00728 }
00729 case FOG: {
00730 Fog *d;
00731 ReadChunkData3ds(chunk);
00732 d = chunk->data;
00733
00734
00735
00736
00737 break;
00738 }
00739 case LAYER_FOG: {
00740 LayerFog *d;
00741 ReadChunkData3ds(chunk);
00742 d = chunk->data;
00743
00744
00745
00746 break;
00747 }
00748 case DISTANCE_CUE: {
00749 DistanceCue *d;
00750 ReadChunkData3ds(chunk);
00751 d = chunk->data;
00752
00753
00754
00755
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
00768
00769 break;
00770 }
00771 case VIEW_USER: {
00772 ViewUser *d;
00773 ReadChunkData3ds(chunk);
00774 d = chunk->data;
00775
00776
00777
00778
00779
00780 break;
00781 }
00782 case VIEW_CAMERA: {
00783 ViewCamera *d;
00784 ReadChunkData3ds(chunk);
00785 d = chunk->data;
00786
00787 break;
00788 }
00789 case MSH_BOXMAP:{
00790 MshBoxmap *d;
00791 ushort3ds i;
00792 ReadChunkData3ds(chunk);
00793 d = chunk->data;
00794
00795 for(i = 0; i < 6; i++)
00796
00797 break;
00798 }
00799 case MESH_TEXTURE_INFO: {
00800 MeshTextureInfo *d;
00801 ushort3ds i;
00802 ReadChunkData3ds(chunk);
00803 d = chunk->data;
00804
00805
00806
00807
00808
00809
00810
00811
00812
00813
00814
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
00824 }
00825 break;
00826 }
00827 case PROC_NAME: {
00828 ProcName *d;
00829
00830 d = ReadChunkData3ds(chunk);
00831
00832
00833
00834 break;
00835 }
00836 case MESH_COLOR: {
00837 MeshColor *d;
00838 ReadChunkData3ds(chunk);
00839 d = chunk->data;
00840
00841 break;
00842 }
00843 case N_DIRECT_LIGHT: {
00844 NDirectLight *d;
00845 ReadChunkData3ds(chunk);
00846 d = chunk->data;
00847
00848 break;
00849 }
00850 case DL_EXCLUDE: {
00851 DlExclude *d;
00852 ReadChunkData3ds(chunk);
00853 d = chunk->data;
00854
00855 break;
00856 }
00857 case DL_OUTER_RANGE:
00858 case DL_INNER_RANGE: {
00859 DlOuterRange *d;
00860 ReadChunkData3ds(chunk);
00861 d = chunk->data;
00862
00863 break;
00864 }
00865 case DL_MULTIPLIER: {
00866 DlMultiplier *d;
00867 ReadChunkData3ds(chunk);
00868 d = chunk->data;
00869
00870 break;
00871 }
00872 case DL_SPOT_ROLL: {
00873 DlSpotRoll *d;
00874 d = ReadChunkData3ds(chunk);
00875
00876
00877 break;
00878 }
00879 case DL_SPOT_ASPECT: {
00880 DlSpotAspect *d;
00881 d = ReadChunkData3ds(chunk);
00882
00883 break;
00884 }
00885 case DL_SPOT_PROJECTOR: {
00886 DlSpotProjector *d;
00887 ReadChunkData3ds(chunk);
00888 d = chunk->data;
00889
00890 break;
00891 }
00892 case DL_RAY_BIAS: {
00893 DlRayBias *d;
00894 ReadChunkData3ds(chunk);
00895 d = chunk->data;
00896
00897 break;
00898 }
00899 case DL_SPOTLIGHT: {
00900 DlSpotlight *d;
00901 ReadChunkData3ds(chunk);
00902 d = chunk->data;
00903
00904
00905
00906 break;
00907 }
00908 case DL_LOCAL_SHADOW2: {
00909 DlLocalShadow2 *d;
00910 ReadChunkData3ds(chunk);
00911 d = chunk->data;
00912
00913
00914
00915
00916 break;
00917 }
00918 case N_CAMERA: {
00919 NCamera *d;
00920 ReadChunkData3ds(chunk);
00921 d = chunk->data;
00922
00923
00924
00925
00926
00927 break;
00928 }
00929 case CAM_RANGES: {
00930 CamRanges *d;
00931 ReadChunkData3ds(chunk);
00932 d = chunk->data;
00933
00934 break;
00935 }
00936 case VIEWPORT_LAYOUT: {
00937 ViewportLayout *d;
00938 ReadChunkData3ds(chunk);
00939 d = chunk->data;
00940
00941
00942
00943
00944
00945
00946
00947 break;
00948 }
00949 case VIEWPORT_SIZE: {
00950 ViewportSize *d;
00951 ReadChunkData3ds(chunk);
00952 d = chunk->data;
00953
00954 break;
00955 }
00956 case VIEWPORT_DATA_3:
00957 case VIEWPORT_DATA: {
00958 ViewportData *d;
00959 ReadChunkData3ds(chunk);
00960 d = chunk->data;
00961
00962
00963
00964
00965
00966
00967
00968
00969
00970
00971
00972
00973 break;
00974 }
00975 case XDATA_APPNAME: {
00976 XDataAppName *d;
00977 ReadChunkData3ds(chunk);
00978 d = chunk->data;
00979
00980 break;
00981 }
00982 case XDATA_STRING: {
00983 XDataString *d;
00984 ReadChunkData3ds(chunk);
00985 d = chunk->data;
00986
00987 break;
00988 }
00989 case MAT_SHADING: {
00990 MatShading *d;
00991 ReadChunkData3ds(chunk);
00992 d = chunk->data;
00993
00994 break;
00995 }
00996 case MAT_ACUBIC: {
00997 MatAcubic *d;
00998 ReadChunkData3ds(chunk);
00999 d = chunk->data;
01000
01001
01002
01003
01004
01005 break;
01006 }
01007 case MAT_WIRESIZE: {
01008 MatWireSize *d;
01009 ReadChunkData3ds(chunk);
01010 d = chunk->data;
01011
01012 break;
01013 }
01014
01015 case KFHDR: {
01016 KFHdr *d;
01017 ReadChunkData3ds(chunk);
01018 d = chunk->data;
01019
01020
01021
01022 break;
01023 }
01024 case KFSEG: {
01025 KFSeg *d;
01026 ReadChunkData3ds(chunk);
01027 d = chunk->data;
01028
01029 break;
01030 }
01031 case KFCURTIME:
01032 {
01033 KFCurtime *d;
01034 ReadChunkData3ds(chunk);
01035 d = chunk->data;
01036
01037
01038
01039 break;
01040 }
01041 case NODE_ID: {
01042 int i;
01043 KFId *d;
01044 d = ReadChunkData3ds(chunk);
01045 i = (int)d->id;
01046
01047 break;
01048 }
01049 case NODE_HDR: {
01050 NodeHdr *d;
01051 ReadChunkData3ds(chunk);
01052 d = chunk->data;
01053
01054
01055
01056
01057
01058
01059
01060
01061
01062
01063
01064 if (DumpLevel3ds == MaximumDump3ds){
01065
01066
01067
01068
01069
01070
01071
01072
01073
01074
01075
01076
01077
01078
01079
01080
01081
01082
01083
01084
01085
01086
01087
01088
01089
01090
01091
01092
01093
01094 }
01095
01096
01097
01098
01099
01100
01101 if (DumpLevel3ds == MaximumDump3ds){
01102
01103
01104
01105
01106
01107
01108
01109
01110
01111
01112
01113
01114
01115
01116
01117
01118 }
01119
01120
01121
01122
01123
01124
01125
01126 break;
01127 }
01128 case INSTANCE_NAME: {
01129 InstanceName *d;
01130 ReadChunkData3ds(chunk);
01131 d = chunk->data;
01132
01133 break;
01134 }
01135 case PARENT_NAME: {
01136 InstanceName *d;
01137 ReadChunkData3ds(chunk);
01138 d = chunk->data;
01139
01140
01141
01142
01143
01144 break;
01145 }
01146 case PIVOT:
01147 {
01148 Pivot *d;
01149 ReadChunkData3ds(chunk);
01150 d = chunk->data;
01151
01152 break;
01153 }
01154 case BOUNDBOX: {
01155 BoundBox *d;
01156 d = chunk->data;
01157 if (d != NULL){
01158
01159
01160 }
01161
01162 break;
01163 }
01164 case MORPH_SMOOTH:
01165 {
01166 MorphSmooth *d;
01167 ReadChunkData3ds(chunk);
01168 d = chunk->data;
01169
01170
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
01182
01183 for (i = 0; i < d->trackhdr.keycount; i++) {
01184
01185
01186 }
01187
01188 break;
01189 }
01190 case ROT_TRACK_TAG: {
01191 RotTrackTag *d;
01192 ulong3ds i;
01193 ReadChunkData3ds(chunk);
01194 d = chunk->data;
01195
01196 for (i = 0; i < d->trackhdr.keycount; i++) {
01197
01198
01199
01200 }
01201
01202 break;
01203 }
01204 case SCL_TRACK_TAG: {
01205 ScaleTrackTag *d;
01206 ulong3ds i;
01207 ReadChunkData3ds(chunk);
01208 d = chunk->data;
01209
01210 for (i = 0; i < d->trackhdr.keycount; i++) {
01211
01212
01213 }
01214 break;
01215 }
01216 case FOV_TRACK_TAG: {
01217 FovTrackTag *d;
01218 ulong3ds i;
01219 ReadChunkData3ds(chunk);
01220 d = chunk->data;
01221
01222 for (i = 0; i < d->trackhdr.keycount; i++) {
01223
01224
01225 }
01226
01227 break;
01228 }
01229 case ROLL_TRACK_TAG: {
01230 RollTrackTag *d;
01231 ulong3ds i;
01232 ReadChunkData3ds(chunk);
01233 d = chunk->data;
01234
01235 for (i = 0; i < d->trackhdr.keycount; i++) {
01236
01237
01238 }
01239 break;
01240 }
01241 case COL_TRACK_TAG: {
01242 ColTrackTag *d;
01243 ulong3ds i;
01244 ReadChunkData3ds(chunk);
01245 d = chunk->data;
01246
01247 for (i = 0; i < d->trackhdr.keycount; i++) {
01248
01249
01250
01251
01252 }
01253
01254 break;
01255 }
01256 case MORPH_TRACK_TAG: {
01257 MorphTrackTag *d;
01258 ulong3ds i;
01259 ReadChunkData3ds(chunk);
01260 d = chunk->data;
01261
01262 for (i = 0; i < d->trackhdr.keycount; i++) {
01263
01264
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
01276 for (i = 0; i < d->trackhdr.keycount; i++) {
01277
01278
01279 }
01280
01281 break;
01282 }
01283 case FALL_TRACK_TAG: {
01284 FallTrackTag *d;
01285 ulong3ds i;
01286 ReadChunkData3ds(chunk);
01287 d = chunk->data;
01288
01289 for (i = 0; i < d->trackhdr.keycount; i++) {
01290
01291
01292 }
01293 break;
01294 }
01295 case HIDE_TRACK_TAG: {
01296 HideTrackTag *d;
01297 ulong3ds i;
01298 ReadChunkData3ds(chunk);
01299 d = chunk->data;
01300
01301
01302
01303 for (i = 0; i < d->trackhdr.keycount; i++) {
01304
01305 }
01306 break;
01307 }
01308
01309 }
01310
01311 child = chunk->children;
01312 while (child != NULL) {
01313
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
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
01358 return FALSE;
01359 }
01360