00001
00002
00003
00004
00005
00006
00007
00008 #define MODULE_READER
00009
00010 #include "render.h"
00011
00012 extern FILE *CF;
00013 extern short End_of_animation;
00014 extern BOOL bKeepObjectsInRAM;
00015
00016 static int CheckForExistingObject(char * objectname){
00017 int i,j;
00018 if(!bKeepObjectsInRAM)return -1;
00019 if(FirstObject > 0)for(i=0;i<FirstObject;i++){
00020 if(!Object[i].in_use && stricmp(objectname,Object[i].FileNameKey) == 0){
00021 if(Object[i].NoVbackup == 0){Object[i].NoVertices=0; Object[i].Vbase=NULL;}
00022 else if((Object[i].Vbase = (vertex *)X__Malloc(Object[i].NoVbackup*sizeof(vertex))) != NULL){
00023 if(Object[i].Vbackup != NULL){
00024 memcpy(Object[i].Vbase,Object[i].Vbackup,Object[i].NoVbackup*sizeof(vertex));
00025 Object[i].NoVertices=Object[i].NoVbackup;
00026 }
00027 else return -1;
00028 }
00029 else return -1;
00030 if(Object[i].NoFbackup == 0){Object[i].NoFaces=0; Object[i].Fbase=NULL;}
00031 else if((Object[i].Fbase = (face *)X__Malloc(Object[i].NoFbackup*sizeof(face))) != NULL){
00032 if(Object[i].Fbackup != NULL){
00033 memcpy(Object[i].Fbase,Object[i].Fbackup,Object[i].NoFbackup*sizeof(face));
00034 Object[i].NoFaces=Object[i].NoFbackup;
00035 }
00036 else return -1;
00037 }
00038 else return -1;
00039 if(Object[i].NoTbackup == 0){Object[i].NoMats=0; Object[i].Tbase=NULL;}
00040 else if((Object[i].Tbase = (matl *)X__Malloc(Object[i].NoTbackup*sizeof(matl))) != NULL){
00041 if(Object[i].Tbackup != NULL){
00042 memcpy(Object[i].Tbase,Object[i].Tbackup,Object[i].NoTbackup*sizeof(matl));
00043 Object[i].NoMats=Object[i].NoTbackup;
00044 }
00045 else return -1;
00046 }
00047 else return -1;
00048
00049 return i;
00050 }
00051 }
00052 return -1;
00053 }
00054
00055 static BOOL CopyObjectToBackup(long i){
00056 if(!bKeepObjectsInRAM)return FALSE;
00057 if(Object[i].NoVertices == 0){Object[i].NoVbackup=0; Object[i].Vbackup=NULL;}
00058 else if((Object[i].Vbackup = (vertex *)X__Malloc(Object[i].NoVertices*sizeof(vertex))) != NULL){
00059 if(Object[i].Vbackup != NULL){
00060 memcpy(Object[i].Vbackup,Object[i].Vbase,Object[i].NoVertices*sizeof(vertex));
00061 Object[i].NoVbackup=Object[i].NoVertices;
00062 }
00063 else return FALSE;
00064 }
00065 else return FALSE;
00066 if(Object[i].NoFaces == 0){Object[i].NoFbackup=0; Object[i].Fbackup=NULL;}
00067 else if((Object[i].Fbackup = (face *)X__Malloc(Object[i].NoFaces*sizeof(face))) != NULL){
00068 if(Object[i].Fbackup != NULL){
00069 memcpy(Object[i].Fbackup,Object[i].Fbase,Object[i].NoFaces*sizeof(face));
00070 Object[i].NoFbackup=Object[i].NoFaces;
00071 }
00072 else return FALSE;
00073 }
00074 else return FALSE;
00075 if(Object[i].NoMats == 0){Object[i].NoTbackup=0; Object[i].Tbackup=NULL;}
00076 else if((Object[i].Tbackup = (matl *)X__Malloc(Object[i].NoMats*sizeof(matl))) != NULL){
00077 if(Object[i].Tbackup != NULL){
00078 memcpy(Object[i].Tbackup,Object[i].Tbase,Object[i].NoMats*sizeof(matl));
00079 Object[i].NoTbackup=Object[i].NoMats;
00080 }
00081 else return FALSE;
00082 }
00083 else return FALSE;
00084
00085 return TRUE;
00086 }
00087
00088 void FreeFrameObjects(void){
00089 long i;
00090
00091 if(ObjectCount > 0){
00092 for(i=0;i<ObjectCount;i++){
00093 if(!Object[i].in_use)continue;
00094 Object[i].in_use=FALSE;
00095 if(Object[i].Vbase != NULL)X__Free(Object[i].Vbase); Object[i].Vbase=NULL; Object[i].NoVertices=0;
00096 if(Object[i].Fbase != NULL)X__Free(Object[i].Fbase); Object[i].Fbase=NULL; Object[i].NoFaces=0;
00097 if(Object[i].Tbase != NULL)X__Free(Object[i].Tbase); Object[i].Vbase=NULL; Object[i].NoMats=0;
00098 if(Object[i].Mbase != NULL)FreeMovieMapImages(i);
00099
00100 }
00101 }
00102 }
00103
00104 void FreeAllObjects(void){
00105 long i;
00106 if(Shader != NULL)FreeExternalTextures();
00107 Shader=NULL; Nshader=0;
00108 if(ObjectCount > 0){
00109 for(i=0;i<ObjectCount;i++){
00110 if(Object[i].Vbackup != NULL)X__Free(Object[i].Vbackup);
00111 if(Object[i].Fbackup != NULL)X__Free(Object[i].Fbackup);
00112 if(Object[i].Skeleton != NULL)X__Free(Object[i].Skeleton);
00113 if(Object[i].Skids != NULL)X__Free(Object[i].Skids);
00114 if(Object[i].effect_param_list != NULL)X__Free(Object[i].effect_param_list);
00115 if(Object[i].Mbase != NULL)X__Free(Object[i].Mbase);
00116 if(Object[i].Tbackup != NULL)X__Free(Object[i].Tbackup);
00117 if(Object[i].Nbase != NULL){
00118 FreeNurbs(Object[i].NoNurbs,Object[i].Nbase);
00119 Object[i].NoNurbs=0;
00120 Object[i].Nbase=NULL;
00121 }
00122
00123 }
00124 }
00125 if(Object != NULL){X__Free(Object); Object = NULL; ObjectCount=0;}
00126 }
00127
00128 static void read_vec(vector v){
00129 if(fscanf(CF,GET_VEC,&v[0],&v[1],&v[2]) != 3){
00130 Render_Message(6,0,NULL);
00131 }
00132 }
00133
00134
00135
00136 int GetCommand(long firstframe, long frame, long nAnimStart,
00137 char *outfile_root){
00138 BOOL bNew;
00139 long i,ObjectID,animator_id;
00140 long a=0,b=0,c,d,e,f;
00141 double p,t,al,du,sx,sy,sz,gbtr[4][4],tr1[4][4],tr2[4][4],
00142 qmorph_ratio,robo_ratio,i_ratio=0.0;
00143 short imo,mo,robo=NO;
00144 char Com[16],second_morph[256],robo_file1[256],robo_file2[256],
00145 morphfile[256],tempfile[256],namefile[256],*cc;
00146 object *temp_object;
00147 light *temp_light;
00148 ParticleSystem *temp_particles;
00149 XIP *temp_xip;
00150 long flag;
00151 while (fscanf(CF,"%s",Com) != EOF){
00152 imo=0;
00153 switch(Com[0]) {
00154 case 'e' :
00155 read_vec(ViewPoint);
00156 fscanf(CF,GET_VEC,&CamPhi,&CamTheta,&CamAlpha);
00157 fscanf(CF,GET_VEC,&CamSx,&CamSy,&CamSz);
00158 fscanf(CF,"%ld %ld",&a,&b); CamIm=b;
00159 fscanf(CF,GET_DOB,&CamIma);
00160 break;
00161 case 'E' :
00162 read_vec(ViewPoint);
00163 fscanf(CF,GET_VEC,&CamPhi,&CamTheta,&CamAlpha);
00164 fscanf(CF,GET_VEC,&CamSx,&CamSy,&CamSz);
00165 fscanf(CF,"%ld %ld",&a,&b); CamIm=b;
00166 fscanf(CF,GET_DOB,&CamIma);
00167 {
00168 double d1,d2,d3;
00169 fscanf(CF,GET_VEC,&CamFocalLength,&CamFnumber,&CamFocusDepth);
00170 fscanf(CF,GET_VEC,&CamFocusDepthM,&CamRuler,&d1);
00171 if((int)d1 == 0 || (int)d1 == 1)CamPolarisation=1;
00172 else CamPolarisation=2;
00173
00174 fscanf(CF,GET_VEC,&CamStereoSeparation,&CamParallaxDepth,&d1);
00175 for(i=0;i<7;i++)fscanf(CF,GET_VEC,&d1,&d2,&d3);
00176 }
00177 break;
00178 case 'i' :
00179 fscanf(CF,"%ld %ld %ld %ld",&imo,&a,&c,&b);
00180 fscanf(CF,GET_DOB,&i_ratio);
00181 if(ImageProcesses == NULL)temp_xip = (XIP *)X__Malloc(sizeof(XIP));
00182 else temp_xip = (XIP *)X__Realloc(ImageProcesses,
00183 (nImageProcesses+1)*sizeof(XIP));
00184 if(temp_xip == NULL)return -1;
00185 temp_xip[nImageProcesses].imo=(long)imo;
00186 temp_xip[nImageProcesses].first_frame=a;
00187 temp_xip[nImageProcesses].this_frame=c;
00188 temp_xip[nImageProcesses].last_frame=b;
00189 temp_xip[nImageProcesses].fmr=i_ratio;
00190 temp_xip[nImageProcesses].parameters=NULL;
00191 temp_xip[nImageProcesses].mparameters=NULL;
00192 { char itempfile[512];
00193 fscanf(CF," %[^\n]",itempfile); c=strlen(itempfile)+1;
00194 if((temp_xip[nImageProcesses].parameters=(char *)X__Malloc(c)) != NULL)
00195 strcpy(temp_xip[nImageProcesses].parameters,itempfile);
00196 if(imo == 1){
00197 fscanf(CF," %[^\n]",itempfile); c=strlen(itempfile)+1;
00198 if((temp_xip[nImageProcesses].mparameters=(char *)X__Malloc(c)) != NULL)
00199 strcpy(temp_xip[nImageProcesses].mparameters,itempfile);
00200 }
00201 }
00202 ImageProcesses=temp_xip;
00203 nImageProcesses++;
00204 break;
00205 case 'l' :
00206 if(Lights == NULL)temp_light = (light *)X__Malloc(sizeof(light));
00207 else temp_light = (light *)X__Realloc(Lights,
00208 (Nlights+1)*sizeof(light));
00209 if(temp_light == NULL){
00210 Render_Message(7,0,NULL);
00211 if(Lights != NULL)X__Free(Lights);
00212 Lights=NULL;
00213 return -1;
00214 }
00215 Lights=temp_light;
00216 Lights[Nlights].dc=FALSE;
00217 Lights[Nlights].dc_c=1.0;
00218 Lights[Nlights].dc_l=0.0;
00219 Lights[Nlights].dc_q=0.0;
00220 fscanf(CF,"%ld",&a); Lights[Nlights].type=a;
00221 fscanf(CF,"%ld %ld %ld",&a,&b,&c);
00222 fscanf(CF,GET_DOB,&Lights[Nlights].Intensity);
00223 Lights[Nlights].Intensity=1.0;
00224 Lights[Nlights].color[0] = (unsigned char)a;
00225 Lights[Nlights].color[1] = (unsigned char)b;
00226 Lights[Nlights].color[2] = (unsigned char)c;
00227 read_vec(Lights[Nlights].p);
00228 VECCOPY(Lights[Nlights].p,Lights[Nlights].pin)
00229 fscanf(CF,GET_VEC,&Lights[Nlights].dPhi
00230 ,&Lights[Nlights].dTheta
00231 ,&Lights[Nlights].dAlpha);
00232
00233
00234 fscanf(CF,"%ld %ld",&a,&b);
00235 Lights[Nlights].AnimatorID=a;
00236 Lights[Nlights].internal_type=b;
00237 fscanf(CF,GET_DOB,&Lights[Nlights].internal_size);
00238 fscanf(CF,"%ld",&a);
00239 Lights[Nlights].dc=a;
00240 fscanf(CF,GET_DOB,&Lights[Nlights].dc_c);
00241 fscanf(CF,GET_DOB,&Lights[Nlights].dc_l);
00242 fscanf(CF,GET_DOB,&Lights[Nlights].dc_q);
00243 if(Lights[Nlights].type == SPOTLIGHT){
00244 fscanf(CF,GET_DOB,&Lights[Nlights].cone1);
00245 fscanf(CF,GET_DOB,&Lights[Nlights].falloff);
00246 }
00247 Nlights++;
00248 break;
00249
00250 case 'p' :
00251 if(ParticleS == NULL)temp_particles = (ParticleSystem *)X__Malloc(sizeof(ParticleSystem));
00252 else temp_particles = (ParticleSystem *)X__Realloc(ParticleS,
00253 (Nparticles+1)*sizeof(ParticleSystem));
00254 if(temp_particles == NULL){
00255 Render_Message(7,0,NULL);
00256 if(ParticleS != NULL)X__Free(ParticleS);
00257 ParticleS=NULL; Nparticles=0;
00258 return -1;
00259 }
00260 ParticleS=temp_particles;
00261 ParticleS[Nparticles].particles=NULL;
00262 fscanf(CF,"%ld %ld %ld",&a,&b,&c);
00263 ParticleS[Nparticles].id=a;
00264 ParticleS[Nparticles].iid=b;
00265 ParticleS[Nparticles].bSingle=(BOOL)c;
00266
00267 fscanf(CF,"%s",ParticleS[Nparticles].ImageName);
00268
00269 fscanf(CF," %d %d %d %d\n",&a,&b,&c,&d);
00270 ParticleS[Nparticles].particle_size_scale=a;
00271 ParticleS[Nparticles].particle_speed_scale=b;
00272 ParticleS[Nparticles].bSteadyState=(BOOL)c;
00273 ParticleS[Nparticles].bSpinOff=(BOOL)d;
00274 fscanf(CF," %d %d %d %d\n",&a,&b,&c,&d);
00275 ParticleS[Nparticles].Rate=a; ParticleS[Nparticles].bBurst=(BOOL)b;
00276 ParticleS[Nparticles].bGround=(BOOL)c; ParticleS[Nparticles].blend_type=(BOOL)d;
00277 fscanf(CF," %d %d %d\n",&a,&b,&c);
00278 ParticleS[Nparticles].colour_start[0]=a;
00279 ParticleS[Nparticles].colour_start[1]=b;
00280 ParticleS[Nparticles].colour_start[2]=c;
00281 fscanf(CF," %d %d %d\n",&a,&b,&c);
00282 ParticleS[Nparticles].colour_end[0]=a;
00283 ParticleS[Nparticles].colour_end[1]=b;
00284 ParticleS[Nparticles].colour_end[2]=c;
00285 fscanf(CF," %d %d %d %d\n",&a,&b,&c,&d);
00286 ParticleS[Nparticles].alpha_start=a;
00287 ParticleS[Nparticles].size_start=b;
00288 ParticleS[Nparticles].alpha_end=c;
00289 ParticleS[Nparticles].size_end=d;
00290 fscanf(CF," %d %d %d\n",&a,&b,&c);
00291 ParticleS[Nparticles].life=a;
00292 ParticleS[Nparticles].speed=b;
00293 ParticleS[Nparticles].theta=c;
00294 fscanf(CF," %d %d %d %d %d\n",&a,&b,&c,&d,&e);
00295 ParticleS[Nparticles].vcolour=a; ParticleS[Nparticles].valpha=b;
00296 ParticleS[Nparticles].vsize=c; ParticleS[Nparticles].vlife=d; ParticleS[Nparticles].vspeed=e;
00297 fscanf(CF," %d %d %d \n",&a,&b,&c);
00298 ParticleS[Nparticles].ew_start=a; ParticleS[Nparticles].ud_start=b; ParticleS[Nparticles].ns_start=c;
00299 fscanf(CF," %d %d %d \n",&a,&b,&c);
00300 ParticleS[Nparticles].ew_end=a; ParticleS[Nparticles].ud_end=b; ParticleS[Nparticles].ns_end=c;
00301
00302 read_vec(ParticleS[Nparticles].pin);
00303 fscanf(CF,GET_VEC,&ParticleS[Nparticles].dPhi,&ParticleS[Nparticles].dTheta,&ParticleS[Nparticles].dAlpha);
00304 fscanf(CF,GET_VEC,&ParticleS[Nparticles].sx,&ParticleS[Nparticles].sy,&ParticleS[Nparticles].sz);
00305 fscanf(CF,"%ld",&a); ParticleS[Nparticles].im=a;
00306 fscanf(CF,GET_DOB,&ParticleS[Nparticles].ima);
00307 fscanf(CF,"%ld",&a); ParticleS[Nparticles].dframe=a;
00308 fscanf(CF,GET_DOB,&t); ParticleS[Nparticles].mratio=t;
00309 read_vec(ParticleS[Nparticles].vel);
00310 read_vec(ParticleS[Nparticles].spin);
00311 fscanf(CF,GET_VEC,&ParticleS[Nparticles].sdPhi,&ParticleS[Nparticles].sdTheta,&ParticleS[Nparticles].sdAlpha);
00312 fscanf(CF,GET_VEC,&ParticleS[Nparticles].ssx,&ParticleS[Nparticles].ssy,&ParticleS[Nparticles].ssz);
00313 fscanf(CF,"%ld",&a); ParticleS[Nparticles].sim=a;
00314 fscanf(CF,GET_DOB,&ParticleS[Nparticles].sima);
00315 Nparticles++;
00316 break;
00317 case 'G' :
00318 case 'g' :
00319 memset(&Ground,0,sizeof(ground));
00320 fscanf(CF,"%ld",&a); Ground.type=a;
00321 fscanf(CF,"%ld %ld %ld",&a,&b,&c);
00322 memset(&Ground.map,0,sizeof(imap));
00323 Ground.color[0] = (unsigned char)a;
00324 Ground.color[1] = (unsigned char)b;
00325 Ground.color[2] = (unsigned char)c;
00326 Ground.ambient_light=ambient_light*0.8;
00327 Ground.texture = -1;
00328 if(Ground.type == PLAIN)Ground.texture=0;
00329 else if(Ground.type > 127){
00330 fscanf(CF,"%ld %ld %ld",&a,&b,&c);
00331 Ground.acolor[0] = (unsigned char)a;
00332 Ground.acolor[1] = (unsigned char)b;
00333 Ground.acolor[2] = (unsigned char)c;
00334 Ground.texture = Ground.type-128;
00335 Ground.type = TEXTU;
00336 if(Ground.texture == 0)Ground.type=PLAIN;
00337 else if(Ground.texture > 15){
00338 fscanf(CF," %[^\n]",namefile);
00339 }
00340 }
00341 if(Ground.type == BRUM || Ground.type == TBRUM || Ground.type == MBRUM){
00342 fscanf(CF," %[^\n]",namefile);
00343 strcpy(Ground.map.filename,namefile);
00344 Ground.map.pp = 100;
00345 Ground.map.rp = -1;
00346 Ground.map.bp = -1;
00347 Ground.map.tp = -1;
00348 }
00349 SKIPH1:
00350 read_vec(Ground.p);
00351 fscanf(CF,GET_VEC,&p,&t,&al);
00352 fscanf(CF,GET_VEC,&sx,&sy,&sz);
00353 fscanf(CF,"%ld %ld",&a,&b);
00354 fscanf(CF,GET_DOB,&du);
00355 fscanf(CF,GET_DOB,&Ground.refl); Ground.refl *= 0.01;
00356 Ground.height=sz;
00357 Ground.x[0]=Ground.p[0]+(double)UNIT*sx*4.0;
00358 Ground.x[1]=Ground.p[1];
00359 Ground.x[2]=Ground.p[2];
00360 Ground.y[0]=Ground.p[0];
00361 Ground.y[1]=Ground.p[1]-(double)UNIT*sy*4.0;
00362 Ground.y[2]=Ground.p[2];
00363 R_Nground=1;
00364 Ground.mapped=FALSE;
00365 if(Ground.type == TEXTU){
00366 vecsub(Ground.x,Ground.p,Ground.x);
00367 vecsub(Ground.y,Ground.p,Ground.y);
00368 if(b > 0){
00369 if(b == 1)R_rotz(tr1,du*PI/180.0);
00370 if(b == 2)R_rotx(tr1,du*PI/180.0);
00371 if(b == 3)R_roty(tr1,du*PI/180.0);
00372 R_rotz(tr2,p*PI/180.0);
00373 R_m4by4(tr2,tr1,gbtr);
00374 }
00375 else R_rotz(gbtr,p*PI/180.0);
00376 R_m4by1(gbtr, Ground.x[0], Ground.x[1],
00377 Ground.x[2],&Ground.x[0],
00378 &Ground.x[1],&Ground.x[2]);
00379 R_m4by1(gbtr, Ground.y[0], Ground.y[1],
00380 Ground.y[2],&Ground.y[0],
00381 &Ground.y[1],&Ground.y[2]);
00382 vecsum(Ground.x,Ground.p,Ground.x);
00383 vecsum(Ground.y,Ground.p,Ground.y);
00384 }
00385 else if(Ground.type == BRUM || Ground.type == TBRUM || Ground.type == MBRUM){
00386 Ground.map.p[0]=0.0;
00387 Ground.map.p[1]=0.0;
00388 Ground.map.p[2]=0.0;
00389 Ground.map.x[0]=Ground.map.p[0]+UNIT*4*sx;
00390 Ground.map.x[1]=Ground.map.p[1];
00391 Ground.map.x[2]=Ground.map.p[2];
00392 Ground.map.y[0]=Ground.map.p[0];
00393 Ground.map.y[1]=Ground.map.p[1]-UNIT*4*sy;
00394 Ground.map.y[2]=Ground.map.p[2];
00395 if(b > 0){
00396 if(b == 1)R_rotz(tr1,du*PI/180.0);
00397 if(b == 2)R_rotx(tr1,du*PI/180.0);
00398 if(b == 3)R_roty(tr1,du*PI/180.0);
00399 R_rotz(tr2,p*PI/180.0);
00400 R_m4by4(tr2,tr1,gbtr);
00401 }
00402 else R_rotz(gbtr,p*PI/180.0);
00403 R_m4by1(gbtr, Ground.map.x[0], Ground.map.x[1],
00404 Ground.map.x[2],&Ground.map.x[0],
00405 &Ground.map.x[1],&Ground.map.x[2]);
00406 R_m4by1(gbtr, Ground.map.y[0], Ground.map.y[1],
00407 Ground.map.y[2],&Ground.map.y[0],
00408 &Ground.map.y[1],&Ground.map.y[2]);
00409 vecsum(Ground.map.p,Ground.p,Ground.map.p);
00410 vecsum(Ground.map.x,Ground.p,Ground.map.x);
00411 vecsum(Ground.map.y,Ground.p,Ground.map.y);
00412 VECCOPY(Ground.map.p,Ground.map.pin)
00413 VECCOPY(Ground.map.x,Ground.map.xin)
00414 VECCOPY(Ground.map.y,Ground.map.yin)
00415 if(SetupImageMap(&Ground.map,"dummy") == 1 && Ground.map.pp == 100){
00416 if(Ground.type == BRUM)Ground.maptype=SINGLE;
00417 if(Ground.type == TBRUM)Ground.maptype=TILE;
00418 if(Ground.type == MBRUM){
00419 Ground.maptype=TILE;
00420 Ground.map.moziac=YES;
00421 }
00422 Ground.mapped=TRUE;
00423 }
00424 else Ground.type=PLAIN;
00425 }
00426 if(Com[0] == 'G'){
00427 fscanf(CF,GET_DOB,&t);
00428 }
00429 VECCOPY(Ground.p,Ground.pin)
00430 VECCOPY(Ground.x,Ground.xin)
00431 VECCOPY(Ground.y,Ground.yin)
00432 break;
00433 case 'S':
00434 {int j; double dummy;
00435 for(j=0;j<32;j++)fscanf(CF,GET_DOB,&dummy);
00436 }
00437 break;
00438 case 's' :
00439 fscanf(CF,"%ld %ld %ld %ld %ld %ld ",&a,&b,&c,&d,&e,&f);
00440 Sky.Horizon[0]=a; Sky.Horizon[1]=b; Sky.Horizon[2]=c;
00441 Sky.Zenith[0]=d; Sky.Zenith[1]=e; Sky.Zenith[2]=f;
00442 fscanf(CF,GET_DOB,&Sky.blendratio);
00443 fscanf(CF,GET_DOB,&object_ambient_light);
00444 fscanf(CF,GET_DOB,&ground_ambient_light);
00445 fscanf(CF,"%ld %ld %ld %ld %ld %ld ",&a,&b,&c,&d,&e,&f);
00446 Sky.Zblend[0]=a; Sky.Zblend[1]=b; Sky.Zblend[2]=c;
00447 Sky.Hblend[0]=d; Sky.Hblend[1]=e; Sky.Hblend[2]=f;
00448 fscanf(CF,"%ld",&a);
00449 Sky.type = (short)a;
00450 Sky.mapped=FALSE;
00451 memset(&Sky.map,0,sizeof(imap));
00452 skyYscale=2.2111; skyXscale=0.888; skyBmax=199;
00453 if(Sky.type > SKYGRADED){
00454 fscanf(CF," %[^\n]",namefile);
00455 strcpy(Sky.map.filename,namefile);
00456 Sky.map.pp = 100;
00457 Sky.map.rp = -1;
00458 Sky.map.bp = -1;
00459 Sky.map.tp = -1;
00460 Sky.map.p[0]=0.0;
00461 Sky.map.p[1]=0.0;
00462 Sky.map.p[2]=UNIT*1000;
00463 Sky.map.x[0]=Sky.map.p[0]+UNIT*5000;
00464 Sky.map.x[1]=Sky.map.p[1];
00465 Sky.map.x[2]=Sky.map.p[2];
00466 Sky.map.y[0]=Sky.map.p[0];
00467 Sky.map.y[1]=Sky.map.p[1]+UNIT*5000;
00468 Sky.map.y[2]=Sky.map.p[2];
00469 VECCOPY(Sky.map.p,Sky.map.pin)
00470 VECCOPY(Sky.map.x,Sky.map.xin)
00471 VECCOPY(Sky.map.y,Sky.map.yin)
00472 if(SetupImageMap(&Sky.map,"dummy") == 1 && Sky.map.pp == 100){
00473 Sky.mapped=TRUE;
00474 Sky.map.map=PLANE;
00475 skyYscale=(double)(Sky.map.ymax-1)/90.0;
00476 skyXscale=(double)(Sky.map.xmax)/360.0;
00477 skyBmax=Sky.map.ymax-1;
00478 }
00479 else Sky.mapped=FALSE;
00480 }
00481 SKIPH2:
00482 Nsky=1;
00483 break;
00484 case 'o' :
00485 fscanf(CF," %ld",&animator_id);
00486 fscanf(CF," %[^\n]",tempfile);
00487 { char messages[255];
00488 sprintf(messages,"Loading %s",tempfile);
00489 Render_Message(91,0,messages);
00490 }
00491 strcpy(namefile,tempfile);
00492 bNew=FALSE;
00493 ObjectID=CheckForExistingObject(namefile);
00494
00495
00496
00497 if(ObjectID < 0){
00498 if(Object == NULL)temp_object = (object *)X__Malloc(sizeof(object));
00499 else temp_object = (object *)X__Realloc(Object,
00500 (ObjectCount+1)*sizeof(object));
00501 if(temp_object == NULL){
00502 Render_Message(7,0,NULL);
00503 if(Object != NULL)X__Free(Object);
00504 Object=NULL;
00505 return -1;
00506 }
00507
00508 Object=temp_object;
00509 memset(&(Object[ObjectCount]),0,sizeof(object));
00510 ObjectID=ObjectCount;
00511 ObjectCount++;
00512 bNew=TRUE;
00513 }
00514
00515 Object[ObjectID].AnimatorID=animator_id;
00516 Object[ObjectID].self_shadow=TRUE;
00517 Object[ObjectID].cast_shadow=TRUE;
00518 Object[ObjectID].show_shadow=TRUE;
00519 Object[ObjectID].wireframe=FALSE;
00520 Object[ObjectID].visibility=NO;
00521 Object[ObjectID].morphratio=1.0;
00522 fscanf(CF,"%ld",&a); mo=a;
00523 robo=NO;
00524 if(mo == 4){
00525 robo=YES;
00526 fscanf(CF," %[^\n]",tempfile);
00527 strcpy(robo_file1,tempfile);
00528 fscanf(CF," %[^\n]",tempfile);
00529 strcpy(robo_file2,tempfile);
00530 fscanf(CF,GET_DOB,&robo_ratio);
00531 mo=0;
00532 }
00533 if(mo > 0){
00534 long mvs,ovs,swp;
00535 fscanf(CF,GET_DOB,&Object[ObjectID].morphratio);
00536 fscanf(CF," %[^\n]",tempfile);
00537 strcpy(morphfile,tempfile);
00538 }
00539
00540 if(bNew){
00541 if(R_LoadObject(ObjectID,namefile,frame+nAnimStart,robo,robo_ratio,
00542 robo_file1,robo_file2) <= 0){
00543 Render_Message(34,1,namefile);
00544 return (-1);
00545 }
00546 strcpy(Object[ObjectID].FileNameKey,namefile);
00547 if(Object[ObjectID].NoFaces > 0){
00548 long i;
00549 face *f=Object[ObjectID].Fbase;
00550 vertex *v=Object[ObjectID].Vbase;
00551 for(i=0;i<Object[ObjectID].NoFaces;i++){
00552 if(f[i].ffmat >= Object[ObjectID].NoMats)Object[ObjectID].NoMats = -1;
00553 if(f[i].ffmap >= Object[ObjectID].NoMaps)Object[ObjectID].NoMaps = -1;
00554
00555
00556 f[i].ww[0]=f[i].ww[1]=f[i].ww[2]=0.5;
00557 if(!f[i].bFmc){
00558 f[i].uu[0]=(v+f[i].V[0])->u; f[i].vv[0]=(v+f[i].V[0])->v;
00559 f[i].uu[1]=(v+f[i].V[1])->u; f[i].vv[1]=(v+f[i].V[1])->v;
00560 f[i].uu[2]=(v+f[i].V[2])->u; f[i].vv[2]=(v+f[i].V[2])->v;
00561
00562
00563 }
00564 }
00565 }
00566 AssignMappingCoordinatesToVertices(&Object[ObjectID]);
00567 CopyObjectToBackup(ObjectID);
00568 }
00569 Object[ObjectID].in_use=TRUE;
00570 CompleteMovieMapLoading(ObjectID,Object[ObjectID].FileNameKey);
00571
00572 if(robo == YES && Object[ObjectID].Skids != NULL && Object[ObjectID].Skeleton != NULL){
00573 RenderTransformToRobot(ObjectID,
00574 Object[ObjectID].Skids,
00575 Object[ObjectID].Skeleton,
00576 robo_ratio,
00577 robo_file1,robo_file2);
00578 RenderRubberBones(ObjectID,Object[ObjectID].NoSkeleton,Object[ObjectID].Skids,Object[ObjectID].Skeleton);
00579 }
00580
00581 if(mo > 0){
00582 strcpy(namefile,morphfile);
00583 if(mo > 1){
00584 mo=1;
00585 fscanf(CF,GET_DOB,&qmorph_ratio);
00586 fscanf(CF," %[^\n]",tempfile);
00587 strcpy(second_morph,tempfile);
00588 }
00589
00590 if(LoadMorphObject(ObjectID, mo,namefile,Object[ObjectID].morphratio,
00591 second_morph,qmorph_ratio) == 0)Render_Message(35,1,namefile);
00592 }
00593
00594 read_vec(Object[ObjectID].Offset);
00595 fscanf(CF,GET_VEC,&Object[ObjectID].fi
00596 ,&Object[ObjectID].theta
00597 ,&Object[ObjectID].alpha);
00598 fscanf(CF,GET_VEC,&Object[ObjectID].sx
00599 ,&Object[ObjectID].sy
00600 ,&Object[ObjectID].sz);
00601 fscanf(CF,"%ld %ld",&a,&b);
00602 Object[ObjectID].im=b;
00603 fscanf(CF,GET_DOB,&Object[ObjectID].ima);
00604 fscanf(CF,"%ld",&a); Object[ObjectID].effect=a;
00605 fscanf(CF,GET_DOB,&Object[ObjectID].effectratio);
00606
00607 fscanf(CF,"%ld %ld %ld",&Object[ObjectID].self_shadow,
00608 &Object[ObjectID].cast_shadow,&Object[ObjectID].show_shadow);
00609
00610 if(a > 20){
00611 c=0L;
00612 Object[ObjectID].effect_param_list=NULL;
00613 fscanf(CF," %s",tempfile);
00614 b=strlen(tempfile)+1L;
00615 if((Object[ObjectID].effect_param_list=(char *)X__Malloc(b)) == NULL){
00616 Object[ObjectID].effect=0;
00617 goto NOFX;
00618 }
00619 else strcpy(Object[ObjectID].effect_param_list,tempfile);
00620 c += b;
00621 while(1){
00622 fscanf(CF,"%s",tempfile);
00623 if(strcmp(tempfile,"~") == 0) break;
00624 b=strlen(tempfile)+2L;
00625 c += b;
00626 if((Object[ObjectID].effect_param_list=(char *)
00627 X__Realloc(Object[ObjectID].effect_param_list,c)
00628 ) == NULL){ Object[ObjectID].effect=0; goto NOFX; }
00629 else {
00630 strcat(Object[ObjectID].effect_param_list," ");
00631 strcat(Object[ObjectID].effect_param_list,tempfile);
00632 }
00633 }
00634
00635
00636 sscanf(Object[ObjectID].effect_param_list,"%s",tempfile);
00637 Object[ObjectID].effect=50;
00638 NOFX:;
00639 }
00640 break;
00641 case 'b' : return 1; break;
00642 case 'f' : return 0; break;
00643 case 'q' :
00644 fclose(CF);
00645 CF=NULL;
00646 End_of_animation=1;
00647 WindowedRenderMessage(WRM_COMPLETE);
00648 return (-1);
00649 default: break;
00650 }
00651 }
00652 Render_Message(37,1,NULL);
00653 return (-1);
00654 }