home *** CD-ROM | disk | FTP | other *** search
- /* write.c - dump the internal database to a TTDDD FILE
- * - written by Glenn M. Lewis - 7/19/91
- * - Altered for Imagine 3.0 support - Rob Hounsell - Sept.94
- */
-
- static char rcs_id[] = "$Id: write.c,v 1.24 1995/02/01 22:21:43 glewis Exp glewis $";
-
- #include <stdio.h>
- #include <ctype.h>
- #include "t3dlib.h"
- #ifdef __STDC__
- #include <stdlib.h>
- #include <strings.h>
- #include "write_protos.h"
- #endif
-
- static void process_DESC();
- static void process_EXTR();
- static void process_INFO();
- static void process_OBJ();
- static void process_ISTG();
-
- /* Two-space tabs */
- #define TABSTOP " "
-
- static FILE *out;
- static char tab[133], strin[133];
- static int num_OBJ, num_DESC, num_TOBJ;
- static int cur_level, cur_objnum;
- static int prntline;
-
- static struct save_hier {
- int objnum;
- struct save_hier *next;
- } *root = 0;
- typedef struct save_hier HIER;
-
- /* Here are a few necessary utilities */
-
- static void indent()
- {
- strcat(tab, TABSTOP);
- }
-
- static void outdent()
- {
- register int i = strlen(tab) - strlen(TABSTOP);
- if (i<0) {
- fprintf(stderr, "Whoa, Glenn! You blew it!\n");
- tab[0] = '\0';
- return;
- }
- tab[i] = '\0';
- }
-
- #define ROUNDIT(x) ((double)((long)((x)*1000.0+0.5-((x)<0.0)))/1000.0)
-
- static void send_XYZ(f) /* Print a common string */
- XYZ_st *f;
- {
- fprintf(out, " X=%.12g", ROUNDIT(f->x));
- fprintf(out, " Y=%.12g", ROUNDIT(f->y));
- fprintf(out, " Z=%.12g\n", ROUNDIT(f->z));
- }
-
- static void stage_RGB(rgb) /* Print a common string */
- XYZ_st *rgb;
- {
- fprintf(out, " R=%.12g", ROUNDIT(rgb->x));
- fprintf(out, " G=%.12g", ROUNDIT(rgb->y));
- fprintf(out, " B=%.12g ", ROUNDIT(rgb->z));
- }
-
- static void send_RGB(rgb) /* Print a common string */
- RGB_st *rgb;
- {
- fprintf(out, " R=%u", rgb->r);
- fprintf(out, " G=%u", rgb->g);
- fprintf(out, " B=%u\n", rgb->b);
- }
-
- /********************/
- /* The MAIN section */
- /********************/
-
- int write_TTDDD(world, file)
- WORLD *world;
- FILE *file;
- {
- register OBJECT *o;
-
- if (!(out=file) || !world) return(0); /* File not open */
-
- tab[0] = '\0';
- num_OBJ = num_DESC = num_TOBJ = 0;
-
- fprintf(out, "%% T3DLIB %s - Written by Glenn M. Lewis - 940217\n\n",
- REV);
- if (world->info) process_INFO(world->info);
- if (world->istg) process_ISTG(world->istg);
- for (o=world->object; o; o=o->next)
- process_OBJ(o);
- return(1);
- }
-
- static void process_INFO(info)
- INFO *info;
- {
- register int i;
-
- fprintf(out, "%sINFO Begin\n", tab);
- indent();
- for (i=0; i<8; i++)
- if (info->brsh[i][0])
- fprintf(out, "%sBRSH[%d]=\"%s\"\n", tab, i, info->brsh[i]);
-
- for (i=0; i<8; i++)
- if (info->stnc[i][0])
- fprintf(out, "%sSTNC[%d]=\"%s\"\n", tab, i, info->stnc[i]);
-
- for (i=0; i<8; i++)
- if (info->txtr[i][0])
- fprintf(out, "%sTXTR[%d]=\"%s\"\n", tab, i, info->txtr[i]);
-
- if (info->obsv) {
- fprintf(out, "%sOBSV Camera", tab); send_XYZ(&info->obsv->came);
- fprintf(out, "%sOBSV Rotate", tab); send_XYZ(&info->obsv->rota);
- fprintf(out, "%sOBSV Focal %.12g\n", tab, info->obsv->foca);
- }
-
- if (info->otrk[0]) fprintf(out, "%sOTRK \"%s\"\n", tab, info->otrk);
-
- if (info->ostr) {
- if (info->ostr->path[0])
- fprintf(out, "%sOSTR Path \"%s\"\n", tab, info->ostr->path);
- fprintf(out, "%sOSTR Translate", tab); send_XYZ(&info->ostr->tran);
- fprintf(out, "%sOSTR Rotate ", tab); send_XYZ(&info->ostr->rota);
- fprintf(out, "%sOSTR Scale ", tab); send_XYZ(&info->ostr->scal);
- i = info->ostr->info;
- strin[0] = '\0';
- if (i&(1<<0)) strcat(strin, " ABS_TRA");
- if (i&(1<<1)) strcat(strin, " ABS_ROT");
- if (i&(1<<2)) strcat(strin, " ABS_SCL");
- if (i&(1<<4)) strcat(strin, " LOC_TRA");
- if (i&(1<<5)) strcat(strin, " LOC_ROT");
- if (i&(1<<6)) strcat(strin, " LOC_SCL");
- if (i&(1<<8)) strcat(strin, " X_ALIGN");
- if (i&(1<<9)) strcat(strin, " Y_ALIGN");
- if (i&(1<<10)) strcat(strin, " Z_ALIGN");
- if (i&(1<<12)) strcat(strin, " FOLLOW_ME");
- fprintf(out, "%sOSTR Info%s\n", tab, strin);
- }
-
- if (info->fade) {
- fprintf(out, "%sFADE FadeAt %.12g\n", tab, info->fade->at);
- fprintf(out, "%sFADE FadeBy %.12g\n", tab, info->fade->by);
- fprintf(out, "%sFADE FadeTo", tab); send_RGB(&info->fade->to);
- }
-
- if (info->skyc) {
- fprintf(out, "%sSKYC Horizon", tab); send_RGB(&info->skyc->hori);
- fprintf(out, "%sSKYC Zenith ", tab); send_RGB(&info->skyc->zeni);
- }
-
- if (info->ambi)
- { fprintf(out, "%sAMBI", tab); send_RGB(info->ambi); }
-
- if (info->glb0)
- for (i=0; i<8; i++)
- fprintf(out, "%sGLB0[%d]=%u\n", tab, i, info->glb0[i]);
-
- outdent();
- fprintf(out, "%sEnd INFO\n", tab);
- }
-
- static void process_OBJ(obj)
- register OBJECT *obj;
- {
- register HIER *p;
- num_OBJ++;
- fprintf(out, "%sOBJ Begin \"Hierarchy %d\"\n", tab, num_OBJ);
- num_DESC = num_TOBJ = 0; /* Reset counters */
- cur_level = 0;
- cur_objnum = 1;
- prntline = 1;
-
- if (obj->extr) process_EXTR(obj->extr);
- else process_DESC(obj);
-
- while (root) { /* This should happen at most once. */
- p = root->next;
- free((char *)root); /* Delete this from list */
- root = p;
- outdent();
- }
-
- fprintf(out, "%sEnd OBJ \"Hierarchy %d\"\n", tab, num_OBJ);
- }
-
- static void process_TOBJ()
- {
- register HIER *p;
- if (num_DESC-num_TOBJ < cur_level) { /* Pop old level off HIER */
- cur_level--;
- cur_objnum = root->objnum;
- p = root->next;
- free((char *)root); /* Delete from list */
- root = p;
- outdent(); /* Pretty file formatting */
- }
- fprintf(out, "%sTOBJ \"Object %d at level %d of hierarchy %d\"\n",
- tab, cur_objnum-1, num_DESC-num_TOBJ, num_OBJ);
- num_TOBJ++;
- prntline = 1;
- }
-
- static void process_EXTR(extr)
- EXTR *extr;
- {
- if (!prntline) fprintf(out, "\n"); /* Print one anyway */
- indent();
- num_DESC++;
-
- fprintf(out, "%sEXTR Begin \"Object %d at level %d of hierarchy %d\"\n",
- tab, cur_objnum, num_DESC-num_TOBJ, num_OBJ);
- indent();
- fprintf(out, "%sMTRX Translate", tab); send_XYZ(&extr->mtrx.tran);
- fprintf(out, "%sMTRX Scale ", tab); send_XYZ(&extr->mtrx.scal);
- fprintf(out, "%sMTRX Rotate", tab);
- fprintf(out, " %.12g %.12g %.12g",
- extr->mtrx.rota1.x,
- extr->mtrx.rota1.y,
- extr->mtrx.rota1.z);
- fprintf(out, " %.12g %.12g %.12g",
- extr->mtrx.rota2.x,
- extr->mtrx.rota2.y,
- extr->mtrx.rota2.z);
- fprintf(out, " %.12g %.12g %.12g",
- extr->mtrx.rota3.x,
- extr->mtrx.rota3.y,
- extr->mtrx.rota3.z);
- fprintf(out, "\n");
-
- fprintf(out, "%sLOAD \"%s\"\n", tab, extr->filename);
- outdent();
- fprintf(out, "%sEnd EXTR \"Object %d at level %d of hierarchy %d\"\n",
- tab, cur_objnum, num_DESC-num_TOBJ, num_OBJ);
-
- num_TOBJ++;
- cur_objnum++;
- outdent();
- prntline = 1;
- }
-
- static void process_DESC(object)
- OBJECT *object;
- {
- register int i, j;
- register HIER *p;
- register OBJECT *obj;
- register DESC *desc = object->desc;
- FGRP *fgrp;
-
- num_DESC++;
- if (num_DESC-num_TOBJ > cur_level) { /* Push new level in HIER */
- if (!prntline) fprintf(out, "\n"); /* Print one anyway */
- if (!(p = (HIER*)malloc(sizeof(HIER)))) {
- fprintf(stderr, "ERROR! Out of memory.\n*** ABORT ***\n");
- exit(20);
- }
- p->next = root; /* Insert into list */
- root = p;
- root->objnum = cur_objnum;
- cur_level++;
- cur_objnum = 1;
- indent(); /* Pretty file formatting */
- }
-
- fprintf(out, "%sDESC Begin \"Object %d at level %d of hierarchy %d\"\n",
- tab, cur_objnum, num_DESC-num_TOBJ, num_OBJ);
- indent();
-
- if (desc->name[0]) fprintf(out, "%sNAME \"%s\"\n", tab, desc->name);
-
- if (desc->shap) {
- fprintf(out, "%sSHAP Shape = %u\n", tab, desc->shap[0]);
- fprintf(out, "%sSHAP Lamp = %u\n", tab, desc->shap[1]);
- }
-
- if (desc->posi)
- { fprintf(out, "%sPOSI", tab); send_XYZ(desc->posi); }
-
- if (desc->axis) {
- fprintf(out, "%sAXIS XAxis", tab); send_XYZ(&desc->axis->xaxi);
- fprintf(out, "%sAXIS YAxis", tab); send_XYZ(&desc->axis->yaxi);
- fprintf(out, "%sAXIS ZAxis", tab); send_XYZ(&desc->axis->zaxi);
- }
-
- if (desc->size)
- { fprintf(out, "%sSIZE", tab); send_XYZ(desc->size); }
-
- if (desc->pcount) {
- fprintf(out, "%sPNTS PCount %u\n", tab, desc->pcount);
- for (i=0; i<desc->pcount; i++) {
- fprintf(out, "%sPNTS Point[%d]", tab, i);
- send_XYZ(&desc->pnts[i]);
- }
- }
-
- if (desc->ecount) {
- fprintf(out, "%sEDGE ECount %u\n", tab, desc->ecount);
- for (i=0; i<desc->ecount; i++) {
- fprintf(out, "%sEDGE Edge[%d] %u %u\n", tab, i,
- desc->edge[i<<1], desc->edge[(i<<1)+1]);
- }
- }
-
- if (desc->eflg) {
- fprintf(out, "%sEFLG Count %u\n", tab, desc->eflg->num);
- for (i=0; i<desc->eflg->num; i++) {
- fprintf(out, "%sEFLG Eflg[%d]=%u\n", tab, i, desc->eflg->eflg[i]);
- }
- }
-
- if (desc->fcount) {
- fprintf(out, "%sFACE TCount %u\n", tab, desc->fcount);
- for (i=0; i<desc->fcount; i++) {
- fprintf(out, "%sFACE Connect[%u] %u %u %u\n", tab, i,
- desc->face[i*3], desc->face[i*3+1], desc->face[i*3+2]);
- }
- }
-
- for (fgrp=desc->fgrp; fgrp; fgrp=fgrp->next) {
- fprintf(out, "%sFGRP Name \"%s\"\n", tab, fgrp->name);
- fprintf(out, "%sFGRP Count %u\n", tab, fgrp->num);
- for (i=0; i<fgrp->num; i++)
- fprintf(out, "%sFGRP Face[%u]=%u\n", tab, i, fgrp->face[i]);
- }
-
- for (i=0; i<4; i++) {
- if (!desc->txt2[i]) continue;
- fprintf(out, "%sTXT2[%u] Flags %u\n", tab, i, desc->txt2[i]->Flags);
- fprintf(out, "%sTXT2[%u] Translate",tab, i);
- send_XYZ(&desc->txt2[i]->TAxis.tran);
- fprintf(out, "%sTXT2[%u] XAxis",tab, i);
- send_XYZ(&desc->txt2[i]->TAxis.rota1);
- fprintf(out, "%sTXT2[%u] YAxis",tab, i);
- send_XYZ(&desc->txt2[i]->TAxis.rota2);
- fprintf(out, "%sTXT2[%u] ZAxis",tab, i);
- send_XYZ(&desc->txt2[i]->TAxis.rota3);
- fprintf(out, "%sTXT2[%u] Scale",tab, i);
- send_XYZ(&desc->txt2[i]->TAxis.scal);
- for (j = 0; j < 16; j++) {
- fprintf(out, "%sTXT2[%u] Params[%u]=%.12g\n", tab, i, j,
- desc->txt2[i]->Params[j]);
- }
- for (j = 0; j < 16; j++) {
- fprintf(out, "%sTXT2[%u] PFlags[%u]=%u\n", tab, i, j,
- desc->txt2[i]->PFlags[j]);
- }
- fprintf(out, "%sTXT2[%u] SubGroup \"%s\"\n", tab, i,
- desc->txt2[i]->SubName);
- fprintf(out, "%sTXT2[%u] Texture \"%s\"\n",tab, i,
- desc->txt2[i]->Name);
- }
-
- if (desc->colr) { fprintf(out, "%sCOLR", tab); send_RGB(desc->colr); }
-
- if (desc->refl) { fprintf(out, "%sREFL", tab); send_RGB(desc->refl); }
-
- if (desc->tran) { fprintf(out, "%sTRAN", tab); send_RGB(desc->tran); }
-
- if (desc->spc1) { fprintf(out, "%sSPC1", tab); send_RGB(desc->spc1); }
-
- if (desc->fcount) {
- fprintf(out, "%sCLST Count %u\n", tab, desc->fcount);
- for (i=0; i<desc->fcount; i++) {
- #if 0
- /* Never skip printing a CLST value - GML - 3/27/92 */
- if (desc->colr) {
- if (desc->clst[i*3 ]==desc->colr->r &&
- desc->clst[i*3+1]==desc->colr->g &&
- desc->clst[i*3+2]==desc->colr->b) continue; /* Skip */
- } else {
- if (desc->clst[i*3 ]==240 &&
- desc->clst[i*3+1]==240 &&
- desc->clst[i*3+2]==240) continue; /* Skip this one */
- }
- #endif
- fprintf(out, "%sCLST Color[%u]", tab, i);
- send_RGB((RGB_st*)&desc->clst[i*3]);
- }
- fprintf(out, "%sRLST Count %u\n", tab, desc->fcount);
- for (i=0; i<desc->fcount; i++) {
- if (desc->refl) {
- if (desc->rlst[i*3 ]==desc->refl->r &&
- desc->rlst[i*3+1]==desc->refl->g &&
- desc->rlst[i*3+2]==desc->refl->b) continue; /* Skip */
- } else {
- if (desc->rlst[i*3 ]==0 &&
- desc->rlst[i*3+1]==0 &&
- desc->rlst[i*3+2]==0) continue; /* Skip this one */
- }
- fprintf(out, "%sRLST Color[%u]", tab, i);
- send_RGB((RGB_st*)&desc->rlst[i*3]);
- }
- fprintf(out, "%sTLST Count %u\n", tab, desc->fcount);
- for (i=0; i<desc->fcount; i++) {
- if (desc->tran) {
- if (desc->tlst[i*3 ]==desc->tran->r &&
- desc->tlst[i*3+1]==desc->tran->g &&
- desc->tlst[i*3+2]==desc->tran->b) continue; /* Skip */
- } else {
- if (desc->tlst[i*3 ]==0 &&
- desc->tlst[i*3+1]==0 &&
- desc->tlst[i*3+2]==0) continue; /* Skip this one */
- }
- fprintf(out, "%sTLST Color[%u]", tab, i);
- send_RGB((RGB_st*)&desc->tlst[i*3]);
- }
- }
-
- if (desc->tpar) {
- for (i=0; i<16; i++)
- fprintf(out, "%sTPAR[%u]=%.12g\n", tab, i, desc->tpar[i]);
- }
-
- if (desc->surf) {
- for (i=0; i<5; i++)
- fprintf(out, "%sSURF[%u]=%d\n", tab, i, desc->surf[i]);
- }
-
- if (desc->mttr) {
- fprintf(out, "%sMTTR Type =%u\n", tab, desc->mttr->type);
- fprintf(out, "%sMTTR Index=%.12g\n", tab, (double)desc->mttr->indx);
- }
-
- if (desc->spec) {
- fprintf(out, "%sSPEC Spec=%u\n", tab, desc->spec[0]);
- fprintf(out, "%sSPEC Hard=%u\n", tab, desc->spec[1]);
- }
-
- if (desc->prp0) {
- for (i=0; i<6; i++)
- fprintf(out, "%sPRP0[%u]=%u\n", tab, i, desc->prp0[i]);
- }
-
- if (desc->prp1) {
- for (i=0; i<8; i++)
- fprintf(out, "%sPRP1[%u]=%u\n", tab, i, desc->prp1[i]);
- }
-
- if (desc->ints)
- fprintf(out, "%sINTS=%.12g\n", tab, desc->ints);
-
- if (desc->int1) { fprintf(out, "%sINT1", tab); send_XYZ(desc->int1); }
-
- if (desc->stry) {
- fprintf(out, "%sSTRY Path \"%s\"\n", tab, desc->stry->path);
- fprintf(out, "%sSTRY Translate", tab); send_XYZ(&desc->stry->tran);
- fprintf(out, "%sSTRY Rotate ", tab); send_XYZ(&desc->stry->rota);
- fprintf(out, "%sSTRY Scale ", tab); send_XYZ(&desc->stry->scal);
- i = desc->stry->info;
- strin[0] = '\0';
- if (i&(1<<0)) strcat(strin, " ABS_TRA");
- if (i&(1<<1)) strcat(strin, " ABS_ROT");
- if (i&(1<<2)) strcat(strin, " ABS_SCL");
- if (i&(1<<4)) strcat(strin, " LOC_TRA");
- if (i&(1<<5)) strcat(strin, " LOC_ROT");
- if (i&(1<<6)) strcat(strin, " LOC_SCL");
- if (i&(1<<8)) strcat(strin, " X_ALIGN");
- if (i&(1<<9)) strcat(strin, " Y_ALIGN");
- if (i&(1<<10)) strcat(strin, " Z_ALIGN");
- if (i&(1<<12)) strcat(strin, " FOLLOW_ME");
- fprintf(out, "%sSTRY Info%s\n", tab, strin);
- }
-
- outdent();
- fprintf(out, "%sEnd DESC \"Object %d at level %d of hierarchy %d\"\n",
- tab, cur_objnum, num_DESC-num_TOBJ, num_OBJ);
-
- for (obj=object->child; obj; obj=obj->next) {
- if (obj->extr) process_EXTR(obj->extr);
- else process_DESC(obj);
- }
-
- cur_objnum++;
- prntline = 0;
- process_TOBJ();
- }
-
- /************************************************************************/
- /* New code to write staging file - written by Glenn M. Lewis - 8/11/92 */
- /* Added Imagine3 support - Rob Hounsell - Sept 94 */
- /************************************************************************/
-
- static void process_OSZ2();
- static void process_OSIZ();
- static void process_POS2();
- static void process_POSN();
- static void process_ALN2();
- static void process_ALGN();
- static void process_ASSC();
- static void process_HING();
- static void process_LYR0();
- static void process_GLB3();
- static void process_GLB2();
- static void process_AXIS();
- static void process_LIT2();
- static void process_LITE();
- static void process_FIL3();
- static void process_FILE();
- static void process_SPFX();
-
- static void process_ISTG(istg)
- register ISTG *istg;
- {
- register SOBJ *sobj;
-
- fprintf(out, "\n%sISTG Begin\n", tab);
-
- indent();
-
- fprintf(out, "\n%sMAXF %u\t%% Max. frames\n", tab, istg->maxf);
-
- fprintf(out, "%sLOOP %u\t%% Loop flag \n", tab, istg->loop);
-
- /* Sort the SOBJ's first? */
-
- /* Here is the main loop: */
- for (sobj=istg->head; sobj; sobj=sobj->next) {
- fprintf(out, "\n%sSOBJ Begin\n", tab);
- indent();
-
- fprintf(out, "\n%sNAME \"%s\"\n", tab, sobj->name);
- fprintf(out, "%sSTGF %u\n", tab, sobj->stgf);
- if (sobj->lyr0) process_LYR0(sobj);
- if (sobj->glb3) process_GLB3(sobj);
- if (sobj->glb2) process_GLB2(sobj);
- if (sobj->fil3) process_FIL3(sobj);
- if (sobj->file) process_FILE(sobj);
- if (sobj->lit2) process_LIT2(sobj);
- if (sobj->lite) process_LITE(sobj);
- if (sobj->axis) process_AXIS(sobj);
- if (sobj->pos2) process_POS2(sobj);
- if (sobj->posn) process_POSN(sobj);
- if (sobj->aln2) process_ALN2(sobj);
- if (sobj->algn) process_ALGN(sobj);
- if (sobj->osz2) process_OSZ2(sobj);
- if (sobj->osiz) process_OSIZ(sobj);
- if (sobj->assc) process_ASSC(sobj);
- if (sobj->hing) process_HING(sobj);
- if (sobj->spfx) process_SPFX(sobj->spfx, 0);
- if (sobj->s2fx) process_SPFX(sobj->s2fx, 2);
- if (sobj->s3fx) process_SPFX(sobj->s3fx, 3);
- if (sobj->s4fx) process_SPFX(sobj->s4fx, 4);
-
- outdent();
- fprintf(out, "\n%sEND SOBJ\n", tab);
- }
-
- /* All done. */
- outdent();
- fprintf(out, "\nEND ISTG\n\n");
- }
-
- /* Chunks unique to Imagine 2.0 */
- static void process_OSIZ(sobj)
- SOBJ *sobj;
- {
- register OSIZ *osiz;
-
- fputs("\n", out);
- for (osiz=sobj->osiz; osiz; osiz=osiz->next) {
- fprintf(out, "%sOSIZ FLAGS=%u ", tab, osiz->flags);
- fprintf(out, "START=%u ", osiz->start);
- fprintf(out, "STOP=%u SIZE", osiz->stop);
- send_XYZ(&osiz->size);
- }
- }
-
- static void process_POSN(sobj)
- SOBJ *sobj;
- {
- register POSN *posn;
- register PTH2 *pth2;
-
- fputs("\n", out);
- for (posn=sobj->posn; posn; posn=posn->next) {
- if (posn->chunk_type == POSN_CHUNK) {
- fprintf(out, "%sPOSN FLAGS %u ", tab, posn->flags);
- fprintf(out, "START=%u ", posn->start);
- fprintf(out, "STOP=%u POSN", posn->stop);
- send_XYZ(&posn->posn);
- }
- else if (posn->chunk_type == PTH2_CHUNK) {
- pth2 = posn;
- fprintf(out, "%sPTH2 FLAGS=%u ", tab, pth2->flags);
- fprintf(out, "START=%u ", pth2->start);
- fprintf(out, "STOP=%u ", pth2->stop);
- fprintf(out, "ACCEL=%lu ", pth2->acceleration_frames);
- fprintf(out, "START_SPEED=%.12g ", pth2->start_speed);
- fprintf(out, "DECEL=%lu ", pth2->deacceleration_frames);
- fprintf(out, "END_SPEED=%.12g ", pth2->end_speed);
- fprintf(out, "PATH=\"%s\"\n", pth2->path);
- }
- else {
- fprintf(stderr, "Unknown chunk type %d in POSN chain.\n",
- posn->chunk_type);
- }
- }
- }
-
- static void process_ALGN(sobj)
- SOBJ *sobj;
- {
- register ALGN *algn;
- register PALN *paln;
- register TALN *taln;
-
- fputs("\n", out);
- for (algn=sobj->algn; algn; algn=algn->next) {
- if (algn->chunk_type == ALGN_CHUNK) {
- fprintf(out, "%sALGN FLAGS=%u ", tab, algn->flags);
- fprintf(out, "START=%u ", algn->start);
- fprintf(out, "STOP=%u ALGN", algn->stop);
- send_XYZ(&algn->algn);
- }
- else if (algn->chunk_type == PALN_CHUNK) {
- paln = algn;
- fprintf(out, "%sPALN FLAGS %u ", tab, paln->flags);
- fprintf(out, "START=%u ", paln->start);
- fprintf(out, "STOP=%u\n", paln->stop);
- }
- else if (algn->chunk_type == TALN_CHUNK) {
- taln = algn;
- fprintf(out, "%sTALN FLAGS=%u ", tab, taln->flags);
- fprintf(out, "START=%u ", taln->start);
- fprintf(out, "STOP=%u ", taln->stop);
- fprintf(out, "INITIAL_Y=%.12g ", taln->initial_y);
- fprintf(out, "FINAL_Y=%.12g ", taln->final_y);
- fprintf(out, "NAME=\"%s\"\n", taln->trackobj);
- }
- else {
- fprintf(stderr, "Unknown chunk type %d in ALGN chain.\n",
- algn->chunk_type);
- }
- }
- }
-
- static void process_HING(sobj)
- SOBJ *sobj;
- {
- register HING *hing;
-
- fputs("\n", out);
- for (hing=sobj->hing; hing; hing=hing->next) {
- fprintf(out, "%sHING FLAGS=%u ", tab, hing->flags);
- fprintf(out, "START=%u ", hing->start);
- fprintf(out, "STOP=%u ", hing->stop);
- fprintf(out, "NAME=\"%s\"\n", hing->hingeobj);
- }
- }
-
- static void process_GLB2(sobj)
- SOBJ *sobj;
- {
- register GLB2 *glb2;
-
- fputs("\n", out);
- for (glb2=sobj->glb2; glb2; glb2=glb2->next) {
- fprintf(out, "%sGLB2 FLAGS=%u ", tab, glb2->flags);
- fprintf(out, "START=%u ", glb2->start);
- fprintf(out, "STOP=%u ", glb2->stop);
- fprintf(out, "SKY_BLEND=%lu ", glb2->sky_blending);
- fprintf(out, "STARFIELD=%.12g ", glb2->starfield);
- fprintf(out, "TRANSITION=%lu ", glb2->transition);
- fprintf(out, "AMBIENT ");
- stage_RGB(&glb2->ambient);
- fprintf(out, "HORIZON ");
- stage_RGB(&glb2->horizon);
- fprintf(out, "ZENITH1 ");
- stage_RGB(&glb2->zenith1);
- fprintf(out, "ZENITH2 ");
- stage_RGB(&glb2->zenith2);
- fprintf(out, "FOG_COL ");
- stage_RGB(&glb2->fog_color);
- fprintf(out, "FOG_BOTTOM=%.12g ", glb2->fog_bottom);
- fprintf(out, "FOG_TOP=%.12g ", glb2->fog_top);
- fprintf(out, "FOG_LENGTH=%.12g ", glb2->fog_length);
- fprintf(out, "BRUSH_SEQ=%lu ", glb2->brush_seq);
- fprintf(out, "BACKDROP_SEQ=%lu ", glb2->backdrop_seq);
- fprintf(out, "BACKDROP=\"%s\" ", glb2->backdrop);
- fprintf(out, "GLOBALBRUSH=\"%s\"\n", glb2->globalbrush);
- }
- }
-
- static void process_LITE(sobj)
- SOBJ *sobj;
- {
- register LITE *lite;
-
- fputs("\n", out);
- for (lite=sobj->lite; lite; lite=lite->next) {
- fprintf(out, "%sLITE FLAGS %u ", tab, lite->flags);
- fprintf(out, "START=%u ", lite->start);
- fprintf(out, "STOP=%u ", lite->stop);
- fprintf(out, "COLOR ");
- stage_RGB(&lite->color);
- fprintf(out, "TRANSITION=%lu\n", lite->transition);
- }
- }
-
- static void process_FILE(sobj)
- SOBJ *sobj;
- {
- register SFILE *file;
-
- fputs("\n", out);
- for (file=sobj->file; file; file=file->next) {
- fprintf(out, "%sFILE FLAGS=%u ", tab, file->flags);
- fprintf(out, "START=%u ", file->start);
- fprintf(out, "STOP=%u ", file->stop);
- fprintf(out, "CYCLES=%.12g ", file->cycles_to_perform);
- fprintf(out, "INITIAL_PHASE=%.12g ", file->initial_cycle_phase);
- fprintf(out, "TRANSITION=%lu ", file->transition);
- fprintf(out, "NAME=\"%s\"\n", file->object_description);
- }
- }
-
- /* Chunks unique to Imagine 3.0 or common to both */
- static void process_OSZ2(sobj)
- SOBJ *sobj;
- {
- register OSZ2 *osz2;
-
- fputs("\n", out);
- for (osz2=sobj->osz2; osz2; osz2=osz2->next) {
- fprintf(out, "%sOSZ2 FLAGS=%u ", tab, osz2->flags);
- fprintf(out, "START=%u ", osz2->start);
- fprintf(out, "STOP=%u ", osz2->stop);
- fprintf(out, "VEL0=%.12g ", osz2->vel_0);
- fprintf(out, "VEL1=%.12g SIZE", osz2->vel_1);
- send_XYZ(&osz2->size);
- }
- }
-
- static void process_POS2(sobj)
- SOBJ *sobj;
- {
- register POS2 *pos2;
- register PTH2 *pth2;
-
- fputs("\n", out);
- for (pos2=sobj->pos2; pos2; pos2=pos2->next) {
- if (pos2->chunk_type == POS2_CHUNK) {
- fprintf(out, "%sPOS2 FLAGS=%u ", tab, pos2->flags);
- fprintf(out, "START=%u ", pos2->start);
- fprintf(out, "STOP=%u ", pos2->stop);
- fprintf(out, "VEL0=%.12g ", pos2->vel_0);
- fprintf(out, "VEL1=%.12g POS2", pos2->vel_1);
- send_XYZ(&pos2->pos2);
- }
- else if (pos2->chunk_type == PTH2_CHUNK) {
- pth2 = pos2;
- fprintf(out, "%sPTH2 FLAGS=%u ", tab, pth2->flags);
- fprintf(out, "START=%u ", pth2->start);
- fprintf(out, "STOP=%u ", pth2->stop);
- fprintf(out, "ACCEL=%lu ", pth2->acceleration_frames);
- fprintf(out, "START_SPEED=%.12g ", pth2->start_speed);
- fprintf(out, "DECEL=%lu ", pth2->deacceleration_frames);
- fprintf(out, "END_SPEED=%.12g ", pth2->end_speed);
- fprintf(out, "PATH=\"%s\"\n", pth2->path);
- }
- else {
- fprintf(stderr, "Unknown chunk type %d in POS2 chain.\n",
- pos2->chunk_type);
- }
- }
- }
-
- static void process_ALN2(sobj)
- SOBJ *sobj;
- {
- register ALN2 *aln2;
- register PALN *paln;
- register TALN *taln;
-
- fputs("\n", out);
- for (aln2=sobj->aln2; aln2; aln2=aln2->next) {
- if (aln2->chunk_type == ALN2_CHUNK) {
- fprintf(out, "%sALN2 FLAGS=%u ", tab, aln2->flags);
- fprintf(out, "START=%u ", aln2->start);
- fprintf(out, "STOP=%u ", aln2->stop);
- fprintf(out, "VEL0=%.12g ", aln2->vel_0);
- fprintf(out, "VEL1=%.12g ALN2", aln2->vel_1);
- send_XYZ(&aln2->aln2);
- }
- else if (aln2->chunk_type == PALN_CHUNK) {
- paln = aln2;
- fprintf(out, "%sPALN FLAGS %u ", tab, paln->flags);
- fprintf(out, "START=%u ", paln->start);
- fprintf(out, "STOP=%u\n", paln->stop);
- }
- else if (aln2->chunk_type == TALN_CHUNK) {
- taln = aln2;
- fprintf(out, "%sTALN FLAGS=%u ", tab, taln->flags);
- fprintf(out, "START=%u ", taln->start);
- fprintf(out, "STOP=%u ", taln->stop);
- fprintf(out, "INITIAL_Y=%.12g ", taln->initial_y);
- fprintf(out, "FINAL_Y=%.12g ", taln->final_y);
- fprintf(out, "NAME=\"%s\"\n", taln->trackobj);
- }
- else {
- fprintf(stderr, "Unknown chunk type %d in ALN2 chain.\n",
- aln2->chunk_type);
- }
- }
- }
-
- static void process_ASSC(sobj)
- SOBJ *sobj;
- {
- register ASSC *assc;
-
- fputs("\n", out);
- for (assc=sobj->assc; assc; assc=assc->next) {
- fprintf(out, "%sASSC FLAGS=%u ", tab, assc->flags);
- fprintf(out, "START=%u ", assc->start);
- fprintf(out, "STOP=%u ", assc->stop);
- fprintf(out, "NAME=\"%s\"\n", assc->assc_obj);
- }
- }
-
- static void process_LYR0(sobj)
- SOBJ *sobj;
- {
- register LYR0 *lyr0;
-
- for (lyr0=sobj->lyr0; lyr0; lyr0=lyr0->next) {
- fprintf(out, "%sLYR0=%u", tab, lyr0->layer);
- }
- fputs("\n", out);
- }
-
- static void process_GLB3(sobj)
- SOBJ *sobj;
- {
- register GLB3 *glb3;
-
- fputs("\n", out);
- for (glb3=sobj->glb3; glb3; glb3=glb3->next) {
- fprintf(out, "%sGLB3 FLAGS=%u ", tab, glb3->flags);
- fprintf(out, "START=%u ", glb3->start);
- fprintf(out, "STOP=%u ", glb3->stop);
- fprintf(out, "STARFIELD=%.12g ", glb3->starfield);
- fprintf(out, "TRANSITION=%lu ", glb3->transition);
- fprintf(out, "AMBIENT");
- stage_RGB(&glb3->ambient);
- fprintf(out, " HORIZON");
- stage_RGB(&glb3->horizon);
- fprintf(out, " ZENITH1");
- stage_RGB(&glb3->zenith1);
- fprintf(out, " ZENITH2");
- stage_RGB(&glb3->zenith2);
- fprintf(out, " FOG_COL");
- stage_RGB(&glb3->fog_color);
- fprintf(out, "FOG_BOTTOM=%.12g ", glb3->fog_bottom);
- fprintf(out, "FOG_TOP=%.12g ", glb3->fog_top);
- fprintf(out, "FOG_LENGTH=%.12g ", glb3->fog_length);
- fprintf(out, "BRUSH_SEQ=%lu ", glb3->brush_seq);
- fprintf(out, "BACKDROP_SEQ=%lu ", glb3->backdrop_seq);
- fprintf(out, "BACKDROP=\"%s\" ", glb3->backdrop);
- fprintf(out, "GLOBALBRUSH=\"%s\"\n", glb3->globalbrush);
- }
- }
-
- static void process_AXIS(sobj)
- SOBJ *sobj;
- {
- register SAXIS *axis;
-
- fputs("\n", out);
- for (axis=sobj->axis; axis; axis=axis->next) {
- fprintf(out, "%sAXIS FLAGS=%u ", tab, axis->flags);
- fprintf(out, "START=%u ", axis->start);
- fprintf(out, "STOP=%u\n", axis->stop);
- }
- }
-
- static void process_LIT2(sobj)
- SOBJ *sobj;
- {
- register LIT2 *lit2;
-
- fputs("\n", out);
- for (lit2=sobj->lit2; lit2; lit2=lit2->next) {
- fprintf(out, "%sLIT2 FLAGS %u ", tab, lit2->flags);
- fprintf(out, "START=%u ", lit2->start);
- fprintf(out, "STOP=%u ", lit2->stop);
- fprintf(out, "COLOR ");
- stage_RGB(&lit2->color);
- fprintf(out, "TRANSITION=%lu\n", lit2->transition);
- }
- }
-
- static void process_FIL3(sobj)
- SOBJ *sobj;
- {
- register FIL3 *fil3;
-
- fputs("\n", out);
- for (fil3=sobj->fil3; fil3; fil3=fil3->next) {
- fprintf(out, "%sFIL3 FLAGS=%u ", tab, fil3->flags);
- fprintf(out, "START=%u ", fil3->start);
- fprintf(out, "STOP=%u ", fil3->stop);
- fprintf(out, "CYCLES=%.12g ", fil3->cycles_to_perform);
- fprintf(out, "INITIAL_PHASE=%.12g ", fil3->initial_cycle_phase);
- fprintf(out, "VEL0=%.12g ", fil3->vel_0);
- fprintf(out, "VEL1=%.12g ", fil3->vel_1);
- fprintf(out, "STATE=\"%s\" ", fil3->state);
- fprintf(out, "NAME=\"%s\"\n", fil3->object_description);
- }
- }
-
- static void process_SPFX (spfx_ptr, index)
- SPFX *spfx_ptr;
- int index;
- {
- register SPFX *spfx;
-
- fputs("\n", out);
- for (spfx=spfx_ptr; spfx; spfx=spfx->next) {
- switch (index) {
- case 0:
- fprintf(out, "%sSPFX FLAGS=%u ", tab, spfx->flags);
- break;
- case 2:
- fprintf(out, "%sS2FX FLAGS=%u ", tab, spfx->flags);
- break;
- case 3:
- fprintf(out, "%sS3FX FLAGS=%u ", tab, spfx->flags);
- break;
- case 4:
- fprintf(out, "%sS4FX FLAGS=%u ", tab, spfx->flags);
- }
- fprintf(out, "START=%u ", spfx->start);
- fprintf(out, "STOP=%u ", spfx->stop);
- fprintf(out, "NAME=\"%s\" ", spfx->effect);
- fprintf(out, "DATA=\"%s\"\n", spfx->effect_data);
- }
- }
-