home *** CD-ROM | disk | FTP | other *** search
/ Encyclopedia of Graphics File Formats Companion / GFF_CD.ISO / formats / ttddd / spec / t3d_src / write.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-05-30  |  18.9 KB  |  710 lines

  1. /* write.c - dump the internal database to a TTDDD file
  2.  *         - written by Glenn M. Lewis - 7/19/91
  3.  */
  4.  
  5. static char rcs_id[] = "$Id: write.c,v 1.21 1993/01/31 07:36:58 glewis Exp $";
  6.  
  7. #include <stdio.h>
  8. #include <ctype.h>
  9. #include "t3dlib.h"
  10. #ifdef __STDC__
  11. #include <stdlib.h>
  12. #include <strings.h>
  13. #include "write_protos.h"
  14. #endif
  15.  
  16. static void process_DESC();
  17. static void process_EXTR();
  18. static void process_INFO();
  19. static void process_OBJ();
  20. static void process_ISTG();
  21.  
  22. /* Two-space tabs */
  23. #define TABSTOP "  "
  24.  
  25. static FILE *out;
  26. static char tab[133], strin[133];
  27. static int num_OBJ, num_DESC, num_TOBJ;
  28. static int cur_level, cur_objnum;
  29. static int prntline;
  30.  
  31. static struct save_hier {
  32.     int objnum;
  33.     struct save_hier *next;
  34. } *root = 0;
  35. typedef struct save_hier HIER;
  36.  
  37. /* Here are a few necessary utilities */
  38.  
  39. static void indent()
  40. {
  41.     strcat(tab, TABSTOP);
  42. }
  43.  
  44. static void outdent()
  45. {
  46.     register int i = strlen(tab) - strlen(TABSTOP);
  47.     if (i<0) {
  48.         fprintf(stderr, "Whoa, Glenn!  You blew it!\n");
  49.         tab[0] = '\0';
  50.         return;
  51.     }
  52.     tab[i] = '\0';
  53. }
  54.  
  55. static void send_XYZ(f)            /* Print a common string */
  56. XYZ_st *f;
  57. {
  58.     fprintf(out, " X=%.12g",   f->x);
  59.     fprintf(out, " Y=%.12g",   f->y);
  60.     fprintf(out, " Z=%.12g\n", f->z);
  61. }
  62.  
  63. static void stage_RGB(rgb)            /* Print a common string */
  64. XYZ_st *rgb;
  65. {
  66.     fprintf(out, " R=%.12g",   rgb->x);
  67.     fprintf(out, " G=%.12g",   rgb->y);
  68.     fprintf(out, " B=%.12g ",    rgb->z);
  69. }
  70.  
  71. static void send_RGB(rgb)            /* Print a common string */
  72. RGB_st *rgb;
  73. {
  74.     fprintf(out, " R=%u",   rgb->r);
  75.     fprintf(out, " G=%u",   rgb->g);
  76.     fprintf(out, " B=%u\n", rgb->b);
  77. }
  78.  
  79. /********************/
  80. /* The MAIN section */
  81. /********************/
  82.  
  83. int write_TTDDD(world, file)
  84. WORLD *world;
  85. FILE *file;
  86. {
  87.     register OBJECT *o;
  88.  
  89.     if (!(out=file) || !world) return(0);    /* File not open */
  90.  
  91.     tab[0] = '\0';
  92.     num_OBJ = num_DESC = num_TOBJ = 0;
  93.  
  94.     fputs("% T3DLIB R38 - Written by Glenn M. Lewis - 1/30/93\n\n", out);
  95.     if (world->info) process_INFO(world->info);
  96.     if (world->istg) process_ISTG(world->istg);
  97.     for (o=world->object; o; o=o->next)
  98.         process_OBJ(o);
  99.     return(1);
  100. }
  101.  
  102. static void process_INFO(info)
  103. INFO *info;
  104. {
  105.     register int i;
  106.  
  107.     fprintf(out, "%sINFO Begin\n", tab);
  108.     indent();
  109.     for (i=0; i<8; i++)
  110.         if (info->brsh[i][0])
  111.             fprintf(out, "%sBRSH[%d]=\"%s\"\n", tab, i, info->brsh[i]);
  112.  
  113.     for (i=0; i<8; i++)
  114.         if (info->stnc[i][0])
  115.             fprintf(out, "%sSTNC[%d]=\"%s\"\n", tab, i, info->stnc[i]);
  116.  
  117.     for (i=0; i<8; i++)
  118.         if (info->txtr[i][0])
  119.             fprintf(out, "%sTXTR[%d]=\"%s\"\n", tab, i, info->txtr[i]);
  120.  
  121.     if (info->obsv) {
  122.         fprintf(out, "%sOBSV Camera", tab); send_XYZ(&info->obsv->came);
  123.         fprintf(out, "%sOBSV Rotate", tab); send_XYZ(&info->obsv->rota);
  124.         fprintf(out, "%sOBSV Focal  %.12g\n", tab, info->obsv->foca);
  125.     }
  126.  
  127.     if (info->otrk[0]) fprintf(out, "%sOTRK \"%s\"\n", tab, info->otrk);
  128.  
  129.     if (info->ostr) {
  130.         if (info->ostr->path[0])
  131.             fprintf(out, "%sOSTR Path \"%s\"\n", tab, info->ostr->path);
  132.         fprintf(out, "%sOSTR Translate", tab); send_XYZ(&info->ostr->tran);
  133.         fprintf(out, "%sOSTR Rotate   ", tab); send_XYZ(&info->ostr->rota);
  134.         fprintf(out, "%sOSTR Scale    ", tab); send_XYZ(&info->ostr->scal);
  135.         i = info->ostr->info;
  136.         strin[0] = '\0';
  137.         if (i&(1<<0))  strcat(strin, " ABS_TRA");
  138.         if (i&(1<<1))  strcat(strin, " ABS_ROT");
  139.         if (i&(1<<2))  strcat(strin, " ABS_SCL");
  140.         if (i&(1<<4))  strcat(strin, " LOC_TRA");
  141.         if (i&(1<<5))  strcat(strin, " LOC_ROT");
  142.         if (i&(1<<6))  strcat(strin, " LOC_SCL");
  143.         if (i&(1<<8))  strcat(strin, " X_ALIGN");
  144.         if (i&(1<<9))  strcat(strin, " Y_ALIGN");
  145.         if (i&(1<<10)) strcat(strin, " Z_ALIGN");
  146.         if (i&(1<<12)) strcat(strin, " FOLLOW_ME");
  147.         fprintf(out, "%sOSTR Info%s\n", tab, strin);
  148.     }
  149.  
  150.     if (info->fade) {
  151.         fprintf(out, "%sFADE FadeAt %.12g\n", tab, info->fade->at);
  152.         fprintf(out, "%sFADE FadeBy %.12g\n", tab, info->fade->by);
  153.         fprintf(out, "%sFADE FadeTo", tab); send_RGB(&info->fade->to);
  154.     }
  155.  
  156.     if (info->skyc) {
  157.         fprintf(out, "%sSKYC Horizon", tab); send_RGB(&info->skyc->hori);
  158.         fprintf(out, "%sSKYC Zenith ", tab); send_RGB(&info->skyc->zeni);
  159.     }
  160.  
  161.     if (info->ambi)
  162.         { fprintf(out, "%sAMBI", tab); send_RGB(info->ambi); }
  163.  
  164.     if (info->glb0)
  165.         for (i=0; i<8; i++)
  166.             fprintf(out, "%sGLB0[%d]=%u\n", tab, i, info->glb0[i]);
  167.  
  168.     outdent();
  169.     fprintf(out, "%sEnd INFO\n", tab);
  170. }
  171.  
  172. static void process_OBJ(obj)
  173. register OBJECT *obj;
  174. {
  175.     register HIER *p;
  176.     num_OBJ++;
  177.     fprintf(out, "%sOBJ Begin \"Hierarchy %d\"\n", tab, num_OBJ);
  178.     num_DESC = num_TOBJ = 0;        /* Reset counters */
  179.     cur_level = 0;
  180.     cur_objnum = 1;
  181.     prntline = 1;
  182.  
  183.     if (obj->extr) process_EXTR(obj->extr);
  184.     else process_DESC(obj);
  185.  
  186.     while (root) {                /* This should happen at most once. */
  187.         p = root->next;
  188.         free((char *)root);        /* Delete this from list */
  189.         root = p;
  190.         outdent();
  191.     }
  192.  
  193.     fprintf(out, "%sEnd OBJ   \"Hierarchy %d\"\n", tab, num_OBJ);
  194. }
  195.  
  196. static void process_TOBJ()
  197. {
  198.     register HIER *p;
  199.     if (num_DESC-num_TOBJ < cur_level) {    /* Pop old level off HIER */
  200.         cur_level--;
  201.         cur_objnum = root->objnum;
  202.         p = root->next;
  203.         free((char *)root);    /* Delete from list */
  204.         root = p;
  205.         outdent();    /* Pretty file formatting */
  206.     }
  207.     fprintf(out, "%sTOBJ       \"Object %d at level %d of hierarchy %d\"\n",
  208.         tab, cur_objnum-1, num_DESC-num_TOBJ, num_OBJ);
  209.     num_TOBJ++;
  210.     prntline = 1;
  211. }
  212.  
  213. static void process_EXTR(extr)
  214. EXTR *extr;
  215. {
  216.     if (!prntline) fprintf(out, "\n");    /* Print one anyway */
  217.     indent();
  218.     num_DESC++;
  219.  
  220.     fprintf(out, "%sEXTR Begin \"Object %d at level %d of hierarchy %d\"\n",
  221.         tab, cur_objnum, num_DESC-num_TOBJ, num_OBJ);
  222.     indent();
  223.     fprintf(out, "%sMTRX Translate", tab); send_XYZ(&extr->mtrx.tran);
  224.     fprintf(out, "%sMTRX Scale    ", tab); send_XYZ(&extr->mtrx.scal);
  225.     fprintf(out, "%sMTRX Rotate", tab);
  226.     fprintf(out, " %.12g %.12g %.12g",
  227.         extr->mtrx.rota1.x,
  228.         extr->mtrx.rota1.y,
  229.         extr->mtrx.rota1.z);
  230.     fprintf(out, " %.12g %.12g %.12g",
  231.         extr->mtrx.rota2.x,
  232.         extr->mtrx.rota2.y,
  233.         extr->mtrx.rota2.z);
  234.     fprintf(out, " %.12g %.12g %.12g",
  235.         extr->mtrx.rota3.x,
  236.         extr->mtrx.rota3.y,
  237.         extr->mtrx.rota3.z);
  238.     fprintf(out, "\n");
  239.  
  240.     fprintf(out, "%sLOAD \"%s\"\n", tab, extr->filename);
  241.     outdent();
  242.     fprintf(out, "%sEnd EXTR   \"Object %d at level %d of hierarchy %d\"\n",
  243.         tab, cur_objnum, num_DESC-num_TOBJ, num_OBJ);
  244.  
  245.     num_TOBJ++;
  246.     cur_objnum++;
  247.     outdent();
  248.     prntline = 1;
  249. }
  250.  
  251. static void process_DESC(object)
  252. OBJECT *object;
  253. {
  254.     register int i, j;
  255.     register HIER *p;
  256.     register OBJECT *obj;
  257.     register DESC *desc = object->desc;
  258.     FGRP *fgrp;
  259.  
  260.     num_DESC++;
  261.     if (num_DESC-num_TOBJ > cur_level) {    /* Push new level in HIER */
  262.         if (!prntline) fprintf(out, "\n");    /* Print one anyway */
  263.         if (!(p = (HIER*)malloc(sizeof(HIER)))) {
  264.             fprintf(stderr, "ERROR!  Out of memory.\n*** ABORT ***\n");
  265.             exit(20);
  266.         }
  267.         p->next = root;        /* Insert into list */
  268.         root = p;
  269.         root->objnum = cur_objnum;
  270.         cur_level++;
  271.         cur_objnum = 1;
  272.         indent();    /* Pretty file formatting */
  273.     }
  274.  
  275.     fprintf(out, "%sDESC Begin \"Object %d at level %d of hierarchy %d\"\n",
  276.         tab, cur_objnum, num_DESC-num_TOBJ, num_OBJ);
  277.     indent();
  278.  
  279.     if (desc->name[0]) fprintf(out, "%sNAME \"%s\"\n", tab, desc->name);
  280.  
  281.     if (desc->shap) {
  282.         fprintf(out, "%sSHAP Shape = %u\n", tab, desc->shap[0]);
  283.         fprintf(out, "%sSHAP Lamp  = %u\n", tab, desc->shap[1]);
  284.     }
  285.  
  286.     if (desc->posi)
  287.         { fprintf(out, "%sPOSI", tab); send_XYZ(desc->posi); }
  288.  
  289.     if (desc->axis) {
  290.         fprintf(out, "%sAXIS XAxis", tab); send_XYZ(&desc->axis->xaxi);
  291.         fprintf(out, "%sAXIS YAxis", tab); send_XYZ(&desc->axis->yaxi);
  292.         fprintf(out, "%sAXIS ZAxis", tab); send_XYZ(&desc->axis->zaxi);
  293.     }
  294.  
  295.     if (desc->size)
  296.         { fprintf(out, "%sSIZE", tab); send_XYZ(desc->size); }
  297.  
  298.     if (desc->pcount) {
  299.         fprintf(out, "%sPNTS PCount %u\n", tab, desc->pcount);
  300.         for (i=0; i<desc->pcount; i++) {
  301.             fprintf(out, "%sPNTS Point[%d]", tab, i);
  302.             send_XYZ(&desc->pnts[i]);
  303.         }
  304.     }
  305.  
  306.     if (desc->ecount) {
  307.         fprintf(out, "%sEDGE ECount %u\n", tab, desc->ecount);
  308.         for (i=0; i<desc->ecount; i++) {
  309.             fprintf(out, "%sEDGE Edge[%d] %u %u\n", tab, i,
  310.                 desc->edge[i<<1], desc->edge[(i<<1)+1]);
  311.         }
  312.     }
  313.  
  314.     if (desc->eflg) {
  315.         fprintf(out, "%sEFLG Count %u\n", tab, desc->eflg->num);
  316.         for (i=0; i<desc->eflg->num; i++) {
  317.             fprintf(out, "%sEFLG Eflg[%d]=%u\n", tab, i, desc->eflg->eflg[i]);
  318.         }
  319.     }
  320.  
  321.     if (desc->fcount) {
  322.         fprintf(out, "%sFACE TCount %u\n", tab, desc->fcount);
  323.         for (i=0; i<desc->fcount; i++) {
  324.             fprintf(out, "%sFACE Connect[%u] %u %u %u\n", tab, i,
  325.                 desc->face[i*3], desc->face[i*3+1], desc->face[i*3+2]);
  326.         }
  327.     }
  328.  
  329.     for (fgrp=desc->fgrp; fgrp; fgrp=fgrp->next) {
  330.         fprintf(out, "%sFGRP Name \"%s\"\n", tab, fgrp->name);
  331.         fprintf(out, "%sFGRP Count %u\n", tab, fgrp->num);
  332.         for (i=0; i<fgrp->num; i++)
  333.             fprintf(out, "%sFGRP Face[%u]=%u\n", tab, i, fgrp->face[i]);
  334.     }
  335.  
  336.     for (i=0; i<4; i++) {
  337.         if (!desc->txt2[i]) continue;
  338.         fprintf(out, "%sTXT2[%u] Flags %u\n", tab, i, desc->txt2[i]->Flags);
  339.         fprintf(out, "%sTXT2[%u] Translate",tab, i);
  340.         send_XYZ(&desc->txt2[i]->TAxis.tran);
  341.         fprintf(out, "%sTXT2[%u] XAxis",tab, i);
  342.         send_XYZ(&desc->txt2[i]->TAxis.rota1);
  343.         fprintf(out, "%sTXT2[%u] YAxis",tab, i);
  344.         send_XYZ(&desc->txt2[i]->TAxis.rota2);
  345.         fprintf(out, "%sTXT2[%u] ZAxis",tab, i);
  346.         send_XYZ(&desc->txt2[i]->TAxis.rota3);
  347.         fprintf(out, "%sTXT2[%u] Scale",tab, i);
  348.         send_XYZ(&desc->txt2[i]->TAxis.scal);
  349.         for (j = 0; j < 16; j++) {
  350.             fprintf(out, "%sTXT2[%u] Params[%u]=%.12g\n", tab, i, j, 
  351.             desc->txt2[i]->Params[j]);
  352.         }
  353.         for (j = 0; j < 16; j++) {
  354.             fprintf(out, "%sTXT2[%u] PFlags[%u]=%u\n", tab, i, j, 
  355.             desc->txt2[i]->PFlags[j]);
  356.         }
  357.         fprintf(out, "%sTXT2[%u] SubGroup \"%s\"\n", tab, i, 
  358.             desc->txt2[i]->SubName);
  359.         fprintf(out, "%sTXT2[%u] Texture \"%s\"\n",tab, i, 
  360.             desc->txt2[i]->Name);
  361.     }
  362.  
  363.     if (desc->colr) { fprintf(out, "%sCOLR", tab); send_RGB(desc->colr); }
  364.  
  365.     if (desc->refl) { fprintf(out, "%sREFL", tab); send_RGB(desc->refl); }
  366.  
  367.     if (desc->tran) { fprintf(out, "%sTRAN", tab); send_RGB(desc->tran); }
  368.  
  369.     if (desc->spc1) { fprintf(out, "%sSPC1", tab); send_RGB(desc->spc1); }
  370.  
  371.     if (desc->fcount) {
  372.         fprintf(out, "%sCLST Count %u\n", tab, desc->fcount);
  373.         for (i=0; i<desc->fcount; i++) {
  374. #if 0
  375. /* Never skip printing a CLST value - GML - 3/27/92 */
  376.             if (desc->colr) {
  377.                 if (desc->clst[i*3  ]==desc->colr->r &&
  378.                     desc->clst[i*3+1]==desc->colr->g &&
  379.                     desc->clst[i*3+2]==desc->colr->b) continue; /* Skip */
  380.             } else {
  381.                 if (desc->clst[i*3  ]==240 &&
  382.                     desc->clst[i*3+1]==240 &&
  383.                     desc->clst[i*3+2]==240) continue;    /* Skip this one */
  384.             }
  385. #endif
  386.             fprintf(out, "%sCLST Color[%u]", tab, i);
  387.             send_RGB((RGB_st*)&desc->clst[i*3]);
  388.         }
  389.         fprintf(out, "%sRLST Count %u\n", tab, desc->fcount);
  390.         for (i=0; i<desc->fcount; i++) {
  391.             if (desc->refl) {
  392.                 if (desc->rlst[i*3  ]==desc->refl->r &&
  393.                     desc->rlst[i*3+1]==desc->refl->g &&
  394.                     desc->rlst[i*3+2]==desc->refl->b) continue; /* Skip */
  395.             } else {
  396.                 if (desc->rlst[i*3  ]==0 &&
  397.                     desc->rlst[i*3+1]==0 &&
  398.                     desc->rlst[i*3+2]==0) continue;    /* Skip this one */
  399.             }
  400.             fprintf(out, "%sRLST Color[%u]", tab, i);
  401.             send_RGB((RGB_st*)&desc->rlst[i*3]);
  402.         }
  403.         fprintf(out, "%sTLST Count %u\n", tab, desc->fcount);
  404.         for (i=0; i<desc->fcount; i++) {
  405.             if (desc->tran) {
  406.                 if (desc->tlst[i*3  ]==desc->tran->r &&
  407.                     desc->tlst[i*3+1]==desc->tran->g &&
  408.                     desc->tlst[i*3+2]==desc->tran->b) continue; /* Skip */
  409.             } else {
  410.                 if (desc->tlst[i*3  ]==0 &&
  411.                     desc->tlst[i*3+1]==0 &&
  412.                     desc->tlst[i*3+2]==0) continue;    /* Skip this one */
  413.             }
  414.             fprintf(out, "%sTLST Color[%u]", tab, i);
  415.             send_RGB((RGB_st*)&desc->tlst[i*3]);
  416.         }
  417.     }
  418.  
  419.     if (desc->tpar) {
  420.         for (i=0; i<16; i++)
  421.             fprintf(out, "%sTPAR[%u]=%.12g\n", tab, i, desc->tpar[i]);
  422.     }
  423.  
  424.     if (desc->surf) {
  425.         for (i=0; i<5; i++)
  426.             fprintf(out, "%sSURF[%u]=%d\n", tab, i, desc->surf[i]);
  427.     }
  428.  
  429.     if (desc->mttr) {
  430.         fprintf(out, "%sMTTR Type =%u\n", tab, desc->mttr->type);
  431.         fprintf(out, "%sMTTR Index=%.12g\n", tab, (double)desc->mttr->indx);
  432.     }
  433.  
  434.     if (desc->spec) {
  435.         fprintf(out, "%sSPEC Spec=%u\n", tab, desc->spec[0]);
  436.         fprintf(out, "%sSPEC Hard=%u\n", tab, desc->spec[1]);
  437.     }
  438.  
  439.     if (desc->prp0) {
  440.         for (i=0; i<6; i++)
  441.             fprintf(out, "%sPRP0[%u]=%u\n", tab, i, desc->prp0[i]);
  442.     }
  443.  
  444.     if (desc->prp1) {
  445.         for (i=0; i<8; i++)
  446.             fprintf(out, "%sPRP1[%u]=%u\n", tab, i, desc->prp1[i]);
  447.     }
  448.  
  449.     if (desc->ints)
  450.         fprintf(out, "%sINTS=%.12g\n", tab, desc->ints);
  451.  
  452.     if (desc->int1) { fprintf(out, "%sINT1", tab); send_XYZ(desc->int1); }
  453.  
  454.     if (desc->stry) {
  455.         fprintf(out, "%sSTRY Path \"%s\"\n", tab, desc->stry->path);
  456.         fprintf(out, "%sSTRY Translate", tab); send_XYZ(&desc->stry->tran);
  457.         fprintf(out, "%sSTRY Rotate   ", tab); send_XYZ(&desc->stry->rota);
  458.         fprintf(out, "%sSTRY Scale    ", tab); send_XYZ(&desc->stry->scal);
  459.         i = desc->stry->info;
  460.         strin[0] = '\0';
  461.         if (i&(1<<0))  strcat(strin, " ABS_TRA");
  462.         if (i&(1<<1))  strcat(strin, " ABS_ROT");
  463.         if (i&(1<<2))  strcat(strin, " ABS_SCL");
  464.         if (i&(1<<4))  strcat(strin, " LOC_TRA");
  465.         if (i&(1<<5))  strcat(strin, " LOC_ROT");
  466.         if (i&(1<<6))  strcat(strin, " LOC_SCL");
  467.         if (i&(1<<8))  strcat(strin, " X_ALIGN");
  468.         if (i&(1<<9))  strcat(strin, " Y_ALIGN");
  469.         if (i&(1<<10)) strcat(strin, " Z_ALIGN");
  470.         if (i&(1<<12)) strcat(strin, " FOLLOW_ME");
  471.         fprintf(out, "%sSTRY Info%s\n", tab, strin);
  472.     }
  473.  
  474.     outdent();
  475.     fprintf(out, "%sEnd DESC   \"Object %d at level %d of hierarchy %d\"\n",
  476.         tab, cur_objnum, num_DESC-num_TOBJ, num_OBJ);
  477.  
  478.     for (obj=object->child; obj; obj=obj->next) {
  479.         if (obj->extr) process_EXTR(obj->extr);
  480.         else process_DESC(obj);
  481.     }
  482.  
  483.     cur_objnum++;
  484.     prntline = 0;
  485.     process_TOBJ();
  486. }
  487.  
  488. /************************************************************************/
  489. /* New code to write staging file - written by Glenn M. Lewis - 8/11/92 */
  490. /************************************************************************/
  491.  
  492. static void process_OSIZ();
  493. static void process_POSN();
  494. static void process_ALGN();
  495. static void process_PALN();
  496. static void process_TALN();
  497. static void process_PTH2();
  498. static void process_GLB2();
  499. static void process_AXIS();
  500. static void process_LITE();
  501. static void process_FILE();
  502.  
  503. static void process_ISTG(istg)
  504. register ISTG *istg;
  505. {
  506.     register SOBJ *sobj;
  507.  
  508.     fprintf(out, "\n%sISTG Begin\n", tab);
  509.  
  510.     indent();
  511.  
  512.     fprintf(out, "\n%sMAXF %u\t%% Max. frames\n", tab, istg->maxf);
  513.  
  514.     /* Sort the SOBJ's first? */
  515.  
  516. /* Here is the main loop: */
  517.     for (sobj=istg->head; sobj; sobj=sobj->next) {
  518.         fprintf(out, "\n%sSOBJ Begin\n", tab);
  519.         indent();
  520.  
  521.         fprintf(out, "\n%sNAME \"%s\"\n", tab, sobj->name);
  522.         fprintf(out, "%sSTGF %u\n", tab, sobj->stgf);
  523.         if (sobj->glb2) process_GLB2(sobj);
  524.         if (sobj->file) process_FILE(sobj);
  525.         if (sobj->lite) process_LITE(sobj);
  526.         if (sobj->axis) process_AXIS(sobj);
  527.         if (sobj->posn) process_POSN(sobj);
  528.         if (sobj->algn) process_ALGN(sobj);
  529.         if (sobj->osiz) process_OSIZ(sobj);
  530.         if (sobj->paln) process_PALN(sobj);
  531.         if (sobj->taln) process_TALN(sobj);
  532.         if (sobj->pth2) process_PTH2(sobj);
  533.  
  534.         outdent();
  535.         fprintf(out, "\n%sEND SOBJ\n", tab);
  536.     }
  537.  
  538. /* All done. */
  539.     outdent();
  540.     fprintf(out, "\nEND ISTG\n\n");
  541. }
  542.  
  543. static void process_OSIZ(sobj)
  544. SOBJ *sobj;
  545. {
  546.     register OSIZ *osiz;
  547.  
  548.     fputs("\n", out);
  549.     for (osiz=sobj->osiz; osiz; osiz=osiz->next) {
  550.         fprintf(out, "%sOSIZ FLAGS=%u ", tab, osiz->flags);
  551.         fprintf(out, "START=%u ", osiz->start);
  552.         fprintf(out, "STOP=%u SIZE", osiz->stop);
  553.         send_XYZ(&osiz->size);
  554.     }
  555. }
  556.  
  557. static void process_POSN(sobj)
  558. SOBJ *sobj;
  559. {
  560.     register POSN *posn;
  561.  
  562.     fputs("\n", out);
  563.     for (posn=sobj->posn; posn; posn=posn->next) {
  564.         fprintf(out, "%sPOSN FLAGS %u ", tab, posn->flags);
  565.         fprintf(out, "START=%u ", posn->start);
  566.         fprintf(out, "STOP=%u POSN", posn->stop);
  567.         send_XYZ(&posn->posn);
  568.     }
  569. }
  570.  
  571. static void process_ALGN(sobj)
  572. SOBJ *sobj;
  573. {
  574.     register ALGN *algn;
  575.  
  576.     fputs("\n", out);
  577.     for (algn=sobj->algn; algn; algn=algn->next) {
  578.         fprintf(out, "%sALGN FLAGS=%u ", tab, algn->flags);
  579.         fprintf(out, "START=%u ", algn->start);
  580.         fprintf(out, "STOP=%u ALGN", algn->stop);
  581.         send_XYZ(&algn->algn);
  582.     }
  583. }
  584.  
  585. static void process_PALN(sobj)
  586. SOBJ *sobj;
  587. {
  588.     register PALN *paln;
  589.  
  590.     fputs("\n", out);
  591.     for (paln=sobj->paln; paln; paln=paln->next) {
  592.         fprintf(out, "%sPALN FLAGS %u ", tab, paln->flags);
  593.         fprintf(out, "START=%u ", paln->start);
  594.         fprintf(out, "STOP=%u\n", paln->stop);
  595.     }
  596. }
  597.  
  598. static void process_TALN(sobj)
  599. SOBJ *sobj;
  600. {
  601.     register TALN *taln;
  602.  
  603.     fputs("\n", out);
  604.     for (taln=sobj->taln; taln; taln=taln->next) {
  605.         fprintf(out, "%sTALN FLAGS=%u ", tab, taln->flags);
  606.         fprintf(out, "START=%u ", taln->start);
  607.         fprintf(out, "STOP=%u ", taln->stop);
  608.         fprintf(out, "INITIAL_Y=%.12g ", taln->initial_y);
  609.         fprintf(out, "FINAL_Y=%.12g ", taln->final_y);
  610.         fprintf(out, "NAME=\"%s\"\n", taln->trackobj);
  611.     }
  612. }
  613.  
  614. static void process_PTH2(sobj)
  615. SOBJ *sobj;
  616. {
  617.     register PTH2 *pth2;
  618.  
  619.     fputs("\n", out);
  620.     for (pth2=sobj->pth2; pth2; pth2=pth2->next) {
  621.         fprintf(out, "%sPTH2 FLAGS=%u ", tab, pth2->flags);
  622.         fprintf(out, "START=%u ", pth2->start);
  623.         fprintf(out, "STOP=%u ", pth2->stop);
  624.         fprintf(out, "ACCEL=%lu ", pth2->acceleration_frames);
  625.         fprintf(out, "START_SPEED=%.12g ", pth2->start_speed);
  626.         fprintf(out, "DECEL=%lu ", pth2->deacceleration_frames);
  627.         fprintf(out, "END_SPEED=%.12g ", pth2->end_speed);
  628.         fprintf(out, "PATH=\"%s\"\n", pth2->path);
  629.     }
  630. }
  631.  
  632. static void process_GLB2(sobj)
  633. SOBJ *sobj;
  634. {
  635.     register GLB2 *glb2;
  636.  
  637.     fputs("\n", out);
  638.     for (glb2=sobj->glb2; glb2; glb2=glb2->next) {
  639.         fprintf(out, "%sGLB2 FLAGS=%u ", tab, glb2->flags);
  640.         fprintf(out, "START=%u ", glb2->start);
  641.         fprintf(out, "STOP=%u ", glb2->stop);
  642.         fprintf(out, "SKY_BLEND=%lu ", glb2->sky_blending);
  643.         fprintf(out, "STARFIELD=%.12g ", glb2->starfield);
  644.         fprintf(out, "TRANSITION=%lu ", glb2->transition);
  645.         fprintf(out, "AMBIENT ");
  646.         stage_RGB(&glb2->ambient);
  647.         fprintf(out, "HORIZON ");
  648.         stage_RGB(&glb2->horizon);
  649.         fprintf(out, "ZENITH1 ");
  650.         stage_RGB(&glb2->zenith1);
  651.         fprintf(out, "ZENITH2 ");
  652.         stage_RGB(&glb2->zenith2);
  653.         fprintf(out, "FOG_COL ");
  654.         stage_RGB(&glb2->fog_color);
  655.         fprintf(out, "FOG_BOTTOM=%.12g ", glb2->fog_bottom);
  656.         fprintf(out, "FOG_TOP=%.12g ", glb2->fog_top);
  657.         fprintf(out, "FOG_LENGTH=%.12g ", glb2->fog_length);
  658.         fprintf(out, "BRUSH_SEQ=%lu ", glb2->brush_seq);
  659.         fprintf(out, "BACKDROP_SEQ=%lu ", glb2->backdrop_seq);
  660.         fprintf(out, "BACKDROP=\"%s\" ", glb2->backdrop);
  661.         fprintf(out, "GLOBALBRUSH=\"%s\"\n", glb2->globalbrush);
  662.     }
  663. }
  664.  
  665. static void process_AXIS(sobj)
  666. SOBJ *sobj;
  667. {
  668.     register SAXIS *axis;
  669.  
  670.     fputs("\n", out);
  671.     for (axis=sobj->axis; axis; axis=axis->next) {
  672.         fprintf(out, "%sAXIS FLAGS=%u ", tab, axis->flags);
  673.         fprintf(out, "START=%u ", axis->start);
  674.         fprintf(out, "STOP=%u\n", axis->stop);
  675.     }
  676. }
  677.  
  678. static void process_LITE(sobj)
  679. SOBJ *sobj;
  680. {
  681.     register LITE *lite;
  682.  
  683.     fputs("\n", out);
  684.     for (lite=sobj->lite; lite; lite=lite->next) {
  685.         fprintf(out, "%sLITE FLAGS %u ", tab, lite->flags);
  686.         fprintf(out, "START=%u ", lite->start);
  687.         fprintf(out, "STOP=%u ", lite->stop);
  688.         fprintf(out, "COLOR ");
  689.         stage_RGB(&lite->color);
  690.         fprintf(out, "TRANSITION=%lu\n", lite->transition);
  691.     }
  692. }
  693.  
  694. static void process_FILE(sobj)
  695. SOBJ *sobj;
  696. {
  697.     register SFILE *file;
  698.  
  699.     fputs("\n", out);
  700.     for (file=sobj->file; file; file=file->next) {
  701.         fprintf(out, "%sFILE FLAGS=%u ", tab, file->flags);
  702.         fprintf(out, "START=%u ", file->start);
  703.         fprintf(out, "STOP=%u ", file->stop);
  704.         fprintf(out, "CYCLES=%.12g ", file->cycles_to_perform);
  705.         fprintf(out, "INITIAL_PHASE=%.12g ", file->initial_cycle_phase);
  706.         fprintf(out, "TRANSITION=%lu ", file->transition);
  707.         fprintf(out, "NAME=\"%s\"\n", file->object_description);
  708.     }
  709. }
  710.