45 # define G1_SECTION_MODEL_QUADS 18 
   46 # define G1_SECTION_MODEL_TEXTURE_NAMES 19 
   47 # define G1_SECTION_MODEL_VERT_ANIMATION 20 
   48 # define GMOD_MAX_SECTIONS 32 
   49 # define GMOD_UNUSED_VERTEX 65535 
   50 # define PI 3.141592653589793238462643 
   52 # define DEG_TO_RAD   ( PI / 180.0 ) 
   53 # define RAD_TO_DEG   ( 180.0 / PI ) 
  128 # define COLOR_MAX 1000 
  129 # define COR3_MAX 200000 
  130 # define FACE_MAX 200000 
  131 # define LINE_MAX_LEN 256 
  132 # define LEVEL_MAX 10 
  133 # define LINES_MAX 100000 
  134 # define MATERIAL_MAX 100 
  135 # define ORDER_MAX 10 
  136 # define TEXTURE_MAX 100 
  223 int main ( 
int argc, 
char *argv[] );
 
  229 bool ch_eqi ( 
char c1, 
char c2 );
 
  232 int ch_pad ( 
int *char_index, 
int *null_index, 
char *s, 
int max_string );
 
  235 int ch_write ( FILE *fileout, 
char c );
 
  259 int float_write ( FILE *fileout, 
float float_val );
 
  273 int i4_max ( 
int i1, 
int i2 );
 
  274 int i4_min ( 
int i1, 
int i2 );
 
  276 int i4_wrap ( 
int ival, 
int ilo, 
int ihi );
 
  292 float rgb_to_hue ( 
float r, 
float g, 
float b );
 
  293 bool s_eqi ( 
char* string1, 
char* string2 );
 
  295 int s_to_i4 ( 
char *s, 
int *last, 
bool *error );
 
  296 bool s_to_i4vec ( 
char *s, 
int n, 
int ivec[] );
 
  297 float s_to_r4 ( 
char *s, 
int *lchar, 
bool *error );
 
  298 bool s_to_r4vec ( 
char *s, 
int n, 
float rvec[] );
 
  312 unsigned long int tds_read_boolean ( 
unsigned char *
boolean, FILE *filein );
 
  337 void tmat_mxm ( 
float a[4][4], 
float b[4][4], 
float c[4][4] );
 
  338 void tmat_mxp ( 
float a[4][4], 
float x[4], 
float y[4] );
 
  339 void tmat_mxp2 ( 
float a[4][4], 
float x[][3], 
float y[][3], 
int n );
 
  340 void tmat_mxv ( 
float a[4][4], 
float x[4], 
float y[4] );
 
  341 void tmat_rot_axis ( 
float a[4][4], 
float b[4][4], 
float angle, 
char axis );
 
  343   float v1, 
float v2, 
float v3 );
 
  344 void tmat_scale ( 
float a[4][4], 
float b[4][4], 
float sx, 
float sy, 
float sz );
 
  345 void tmat_shear ( 
float a[4][4], 
float b[4][4], 
char *axis, 
float s );
 
  346 void tmat_trans ( 
float a[4][4], 
float b[4][4], 
float x, 
float y, 
float z );
 
  363 int main ( 
int argc, 
char *argv[] )
 
  388   cout << 
"  C++ version\n";
 
  389   cout << 
"  Read, interpret, and write out graphics information\n";
 
  390   cout << 
"  in a variety of formats.\n";
 
  392   cout << 
"  Compiled on " << __DATE__ << 
" at " << __TIME__ << 
"\n";
 
  466   strcpy ( word, 
" " );
 
  467   strcpy ( wordm1, 
" " );
 
  487       strcpy ( wordm1, word );
 
  488       strcpy ( word, 
" " );
 
  490       count = sscanf ( next, 
"%s%n", word, &width );
 
  502         strcpy ( word1, word );
 
  507       if ( strcmp ( word, 
"{" ) == 0 )
 
  509         nlbrack = nlbrack + 1;
 
  510         level = nlbrack - nrbrack;
 
  513       else if ( strcmp ( word, 
"}" ) == 0 )
 
  515         nrbrack = nrbrack + 1;
 
  517         if ( nlbrack < nrbrack )
 
  520           cout << 
"ASE_READ - Fatal error!\n";
 
  521           cout << 
"  Extraneous right bracket on line " << 
text_num << 
"\n";
 
  522           cout << 
"  Currently processing field:\n";
 
  531       if ( strcmp ( word1, 
"*3DSMAX_ASCIIEXPORT" ) == 0 )
 
  538       else if ( strcmp ( word1, 
"*COMMENT" ) == 0 )
 
  545       else if ( strcmp ( 
level_name[level], 
"*GEOMOBJECT" ) == 0 )
 
  547         if ( strcmp ( word, 
"{" ) == 0 )
 
  551         else if ( strcmp ( word, 
"}" ) == 0 )
 
  553           level = nlbrack - nrbrack;
 
  559         else if ( strcmp ( word, 
"*NODE_NAME" ) == 0 )
 
  563         else if ( strcmp ( word, 
"*NODE_TM" ) == 0 )
 
  567         else if ( strcmp ( word, 
"*MESH" ) == 0 )
 
  571         else if ( strcmp ( word, 
"*PROP_CASTSHADOW" ) == 0 )
 
  575         else if ( strcmp ( word, 
"*PROP_MOTIONBLUR" ) == 0 )
 
  579         else if ( strcmp ( word, 
"*PROP_RECVSHADOW" ) == 0 )
 
  587           cout << 
"ASE_READ - Error!\n";
 
  588           cout << 
"  Bad data in GEOMOBJECT, line " << 
text_num << 
"\n";
 
  595       else if ( strcmp ( 
level_name[level], 
"*MESH" ) == 0 )
 
  597         if ( strcmp ( word, 
"{" ) == 0 )
 
  601         else if ( strcmp ( word, 
"}" ) == 0 )
 
  603           level = nlbrack - nrbrack;
 
  606         else if ( strcmp ( word, 
"*MESH_CFACELIST" ) == 0 )
 
  610         else if ( strcmp ( word, 
"*MESH_CVERTLIST" ) == 0 )
 
  614         else if ( strcmp ( word, 
"*MESH_FACE_LIST" ) == 0 )
 
  618         else if ( strcmp ( word, 
"*MESH_NORMALS" ) == 0 )
 
  622         else if ( strcmp ( word, 
"*MESH_NUMCVERTEX" ) == 0 )
 
  626         else if ( strcmp ( word, 
"*MESH_NUMCVFACES" ) == 0 )
 
  630         else if ( strcmp ( word, 
"*MESH_NUMFACES" ) == 0 )
 
  634         else if ( strcmp ( word, 
"*MESH_NUMTVERTEX" ) == 0 )
 
  638         else if ( strcmp ( word, 
"*MESH_NUMTVFACES" ) == 0 )
 
  642         else if ( strcmp ( word, 
"*MESH_NUMVERTEX" ) == 0 )
 
  646         else if ( strcmp ( word, 
"*MESH_TFACELIST" ) == 0 )
 
  650         else if ( strcmp ( word, 
"*MESH_TVERTLIST" ) == 0 )
 
  654         else if ( strcmp ( word, 
"*MESH_VERTEX_LIST" ) == 0 )
 
  658         else if ( strcmp ( word, 
"*TIMEVALUE" ) == 0 )
 
  665           cout << 
"Bad data in MESH, line " << 
text_num << 
"\n";
 
  672       else if ( strcmp ( 
level_name[level], 
"*MESH_CFACELIST" ) == 0 )
 
  674         if ( strcmp ( word, 
"{" ) == 0 )
 
  678         else if ( strcmp ( word, 
"}" ) == 0 )
 
  680           level = nlbrack - nrbrack;
 
  683         else if ( strcmp ( word, 
"*MESH_CFACE" ) == 0 )
 
  690           cout << 
"Bad data in MESH_CFACE, line " << 
text_num << 
"\n";
 
  700       else if ( strcmp ( 
level_name[level], 
"*MESH_CVERTLIST" ) == 0 )
 
  702         if ( strcmp ( word, 
"{" ) == 0 )
 
  706         else if ( strcmp ( word, 
"}" ) == 0 )
 
  708           level = nlbrack - nrbrack;
 
  711         else if ( strcmp ( word, 
"*MESH_VERTCOL" ) == 0 )
 
  713           count = sscanf ( next, 
"%d%n", &
i, &width );
 
  716           i = 
i + cor3_num_old;
 
  718           count = sscanf ( next, 
"%f%n", &rval, &width );
 
  721           count = sscanf ( next, 
"%f%n", &gval, &width );
 
  724           count = sscanf ( next, 
"%f%n", &bval, &width );
 
  742           cout << 
"ASE_READ - Warning!\n";
 
  743           cout << 
"  Bad data in MESH_CVERTLIST, line " << 
text_num << 
"\n";
 
  752       else if ( strcmp ( 
level_name[level], 
"*MESH_FACE_LIST" ) == 0 )
 
  754         if ( strcmp ( word, 
"{" ) == 0 )
 
  758         else if ( strcmp ( word, 
"}" ) == 0 )
 
  760           level = nlbrack - nrbrack;
 
  763         else if ( strcmp ( word, 
"*MESH_FACE" ) == 0 )
 
  771             count = sscanf ( next, 
"%d%n", &
i, &width );
 
  774             count = sscanf ( next, 
"%s%n", word2, &width );
 
  776             count = sscanf ( next, 
"%s%n", word2, &width );
 
  779             count = sscanf ( next, 
"%d%n", &
i, &width );
 
  784             count = sscanf ( next, 
"%s%n", word2, &width );
 
  787             count = sscanf ( next, 
"%d%n", &
i, &width );
 
  792             count = sscanf ( next, 
"%s%n", word2, &width );
 
  795             count = sscanf ( next, 
"%d%n", &
i, &width );
 
  800             count = sscanf ( next, 
"%s%n", word2, &width );
 
  803             if ( strcmp ( word2, 
"D:" ) == 0 )
 
  805               count = sscanf ( next, 
"%d%n", &
i, &width );
 
  820           cout << 
"Bad data in MESH_FACE_LIST, line " << 
text_num << 
"\n";
 
  827       else if ( strcmp ( 
level_name[level], 
"*MESH_NORMALS" ) == 0 )
 
  829         if ( strcmp ( word, 
"{" ) == 0 )
 
  833         else if ( strcmp ( word, 
"}" ) == 0 )
 
  835           level = nlbrack - nrbrack;
 
  838         else if ( strcmp ( word, 
"*MESH_FACENORMAL" ) == 0 )
 
  840           count = sscanf ( next, 
"%d%n", &iface, &width );
 
  843           count = sscanf ( next, 
"%f%n", &x, &width );
 
  846           count = sscanf ( next, 
"%f%n", &y, &width );
 
  849           count = sscanf ( next, 
"%f%n", &z, &width );
 
  852           iface = iface + face_num_old;
 
  862         else if ( strcmp ( word, 
"*MESH_VERTEXNORMAL" ) == 0 )
 
  864           count = sscanf ( next, 
"%d%n", &
i, &width );
 
  867           count = sscanf ( next, 
"%f%n", &x, &width );
 
  870           count = sscanf ( next, 
"%f%n", &y, &width );
 
  873           count = sscanf ( next, 
"%f%n", &z, &width );
 
  886           cout << 
"Bad data in MESH_NORMALS, line " << 
text_num << 
"\n";
 
  893       else if ( strcmp ( 
level_name[level], 
"*MESH_TFACELIST" ) == 0 )
 
  895         if ( strcmp ( word, 
"{" ) == 0 )
 
  899         else if ( strcmp ( word, 
"}" ) == 0 )
 
  901           level = nlbrack - nrbrack;
 
  904         else if ( strcmp ( word1, 
"*MESH_TFACE" ) == 0 )
 
  911           cout << 
"Bad data in MESH_TFACE_LIST, line " << 
text_num << 
"\n";
 
  918       else if ( strcmp ( 
level_name[level], 
"*MESH_TVERTLIST" ) == 0 )
 
  920         if ( strcmp ( word, 
"{" ) == 0 )
 
  924         else if ( strcmp ( word, 
"}" ) == 0 )
 
  926           level = nlbrack - nrbrack;
 
  929         else if ( strcmp ( word1, 
"*MESH_TVERT" ) == 0  )
 
  936           cout << 
"Bad data in MESH_TVERTLIST, line " << 
text_num << 
"\n";
 
  943       else if ( strcmp ( 
level_name[level], 
"*MESH_VERTEX_LIST" ) == 0 )
 
  945         if ( strcmp ( word, 
"{" ) == 0 )
 
  950         else if ( strcmp ( word, 
"}" ) == 0 )
 
  952           level = nlbrack - nrbrack;
 
  955         else if ( strcmp ( word1, 
"*MESH_VERTEX" ) == 0 )
 
  958           count = sscanf ( next, 
"%d%n", &
i, &width );
 
  961           count = sscanf ( next, 
"%f%n", &x, &width );
 
  964           count = sscanf ( next, 
"%f%n", &y, &width );
 
  967           count = sscanf ( next, 
"%f%n", &z, &width );
 
  970           i = 
i + cor3_num_old;
 
 1002           cout << 
"Bad data in MESH_VERTEX_LIST, line " << 
text_num << 
"\n";
 
 1011       else if ( strcmp ( 
level_name[level], 
"*NODE_TM" ) == 0 )
 
 1013         if ( strcmp ( word, 
"{" ) == 0 )
 
 1019         else if ( strcmp ( word, 
"}" ) == 0 )
 
 1021           level = nlbrack - nrbrack;
 
 1024         else if ( strcmp ( word, 
"*INHERIT_POS" ) == 0 )
 
 1028         else if ( strcmp ( word, 
"*INHERIT_ROT" ) == 0 )
 
 1032         else if ( strcmp ( word, 
"*INHERIT_SCL" ) == 0 )
 
 1036         else if ( strcmp ( word, 
"*NODE_NAME" ) == 0 )
 
 1040         else if ( strcmp ( word, 
"*TM_POS" ) == 0 )
 
 1044         else if ( strcmp ( word, 
"*TM_ROTANGLE" ) == 0 )
 
 1048         else if ( strcmp ( word, 
"*TM_ROTAXIS" ) == 0 )
 
 1052         else if ( strcmp ( word, 
"*TM_ROW0" ) == 0 )
 
 1054           count = sscanf ( next, 
"%f%n", &temp, &width );
 
 1055           next = next + width;
 
 1058           count = sscanf ( next, 
"%f%n", &temp, &width );
 
 1059           next = next + width;
 
 1062           count = sscanf ( next, 
"%f%n", &temp, &width );
 
 1063           next = next + width;
 
 1068         else if ( strcmp ( word, 
"*TM_ROW1" ) == 0 )
 
 1070           count = sscanf ( next, 
"%f%n", &temp, &width );
 
 1071           next = next + width;
 
 1074           count = sscanf ( next, 
"%f%n", &temp, &width );
 
 1075           next = next + width;
 
 1078           count = sscanf ( next, 
"%f%n", &temp, &width );
 
 1079           next = next + width;
 
 1084         else if ( strcmp ( word, 
"*TM_ROW2" ) == 0 )
 
 1086           count = sscanf ( next, 
"%f%n", &temp, &width );
 
 1087           next = next + width;
 
 1090           count = sscanf ( next, 
"%f%n", &temp, &width );
 
 1091           next = next + width;
 
 1094           count = sscanf ( next, 
"%f%n", &temp, &width );
 
 1095           next = next + width;
 
 1100         else if ( strcmp ( word, 
"*TM_ROW3" ) == 0 )
 
 1102           count = sscanf ( next, 
"%f%n", &temp, &width );
 
 1103           next = next + width;
 
 1106           count = sscanf ( next, 
"%f%n", &temp, &width );
 
 1107           next = next + width;
 
 1110           count = sscanf ( next, 
"%f%n", &temp, &width );
 
 1111           next = next + width;
 
 1116         else if ( strcmp ( word, 
"*TM_SCALE" ) == 0 )
 
 1120         else if ( strcmp ( word, 
"*TM_SCALEAXIS" ) == 0 )
 
 1124         else if ( strcmp ( word, 
"*TM_SCALEAXISANG" ) == 0 )
 
 1131           cout << 
"Bad data in NODE_TM, line " << 
text_num << 
"\n";
 
 1138       else if ( strcmp ( 
level_name[level], 
"*SCENE" ) == 0 )
 
 1140         if ( strcmp ( word, 
"{" ) == 0 )
 
 1144         else if ( strcmp ( word, 
"}" ) == 0 )
 
 1146           level = nlbrack - nrbrack;
 
 1149         else if ( strcmp ( word, 
"*SCENE_AMBIENT_STATIC" ) == 0 )
 
 1153         else if ( strcmp ( word, 
"*SCENE_BACKGROUND_STATIC" ) == 0 )
 
 1157         else if ( strcmp ( word, 
"*SCENE_FILENAME" ) == 0 )
 
 1161         else if ( strcmp ( word, 
"*SCENE_FIRSTFRAME" ) == 0 )
 
 1165         else if ( strcmp ( word, 
"*SCENE_FRAMESPEED" ) == 0 )
 
 1169         else if ( strcmp ( word, 
"*SCENE_LASTFRAME" ) == 0 )
 
 1173         else if ( strcmp ( word, 
"*SCENE_TICKSPERFRAME" ) == 0 )
 
 1180           cout << 
"Bad data in SCENE, line " << 
text_num << 
"\n";
 
 1235   fprintf ( fileout, 
"*3DSMAX_ASCIIEXPORT 200\n" );
 
 1236   fprintf ( fileout, 
"*COMMENT \"%s, created by IVCON.\"\n", 
fileout_name );
 
 1237   fprintf ( fileout, 
"*COMMENT \"Original data in %s\"\n", 
filein_name );
 
 1243   fprintf ( fileout, 
"*SCENE {\n" );
 
 1244   fprintf ( fileout, 
"  *SCENE_FILENAME \"\"\n" );
 
 1245   fprintf ( fileout, 
"  *SCENE_FIRSTFRAME 0\n" );
 
 1246   fprintf ( fileout, 
"  *SCENE_LASTFRAME 100\n" );
 
 1247   fprintf ( fileout, 
"  *SCENE_FRAMESPEED 30\n" );
 
 1248   fprintf ( fileout, 
"  *SCENE_TICKSPERFRAME 160\n" );
 
 1249   fprintf ( fileout, 
"  *SCENE_BACKGROUND_STATIC 0.0000 0.0000 0.0000\n" );
 
 1250   fprintf ( fileout, 
"  *SCENE_AMBIENT_STATIC 0.0431 0.0431 0.0431\n" );
 
 1251   fprintf ( fileout, 
"}\n" );
 
 1257   fprintf ( fileout, 
"*GEOMOBJECT {\n" );
 
 1258   fprintf ( fileout, 
"  *NODE_NAME \"%s\"\n", 
object_name );
 
 1264   fprintf ( fileout, 
"  *NODE_TM {\n" );
 
 1265   fprintf ( fileout, 
"    *NODE_NAME \"Object01\"\n" );
 
 1266   fprintf ( fileout, 
"    *INHERIT_POS 0 0 0\n" );
 
 1267   fprintf ( fileout, 
"    *INHERIT_ROT 0 0 0\n" );
 
 1268   fprintf ( fileout, 
"    *INHERIT_SCL 0 0 0\n" );
 
 1269   fprintf ( fileout, 
"    *TM_ROW0 1.0000 0.0000 0.0000\n" );
 
 1270   fprintf ( fileout, 
"    *TM_ROW1 0.0000 1.0000 0.0000\n" );
 
 1271   fprintf ( fileout, 
"    *TM_ROW2 0.0000 0.0000 1.0000\n" );
 
 1272   fprintf ( fileout, 
"    *TM_ROW3 0.0000 0.0000 0.0000\n" );
 
 1273   fprintf ( fileout, 
"    *TM_POS 0.0000 0.0000 0.0000\n" );
 
 1274   fprintf ( fileout, 
"    *TM_ROTAXIS 0.0000 0.0000 0.0000\n" );
 
 1275   fprintf ( fileout, 
"    *TM_ROTANGLE 0.0000\n" );
 
 1276   fprintf ( fileout, 
"    *TM_SCALE 1.0000 1.0000 1.0000\n" );
 
 1277   fprintf ( fileout, 
"    *TM_SCALEAXIS 0.0000 0.0000 0.0000\n" );
 
 1278   fprintf ( fileout, 
"    *TM_SCALEAXISANG 0.0000\n" );
 
 1279   fprintf ( fileout, 
"  }\n" );
 
 1286   fprintf ( fileout, 
"  *MESH {\n" );
 
 1287   fprintf ( fileout, 
"    *TIMEVALUE 0\n" );
 
 1288   fprintf ( fileout, 
"    *MESH_NUMVERTEX %d\n", 
cor3_num );
 
 1289   fprintf ( fileout, 
"    *MESH_NUMFACES %d\n", 
face_num );
 
 1295   fprintf ( fileout, 
"    *MESH_VERTEX_LIST {\n" );
 
 1300     fprintf ( fileout, 
"      *MESH_VERTEX %d %f %f %f\n", j, 
cor3[0][j],
 
 1305   fprintf ( fileout, 
"    }\n" );
 
 1311   fprintf ( fileout, 
"    *MESH_FACE_LIST {\n" );
 
 1314   for ( iface = 0; iface < 
face_num; iface++ )
 
 1316     i1 = 
face[0][iface];
 
 1317     i2 = 
face[1][iface];
 
 1318     i3 = 
face[2][iface];
 
 1322       fprintf ( fileout, 
"      *MESH_FACE %d: A: %d B: %d C: %d", iface, i1, i2, i3 );
 
 1323       fprintf ( fileout, 
" AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING *MESH_MTLID 1\n" );
 
 1328       i4 = 
face[3][iface];
 
 1329       fprintf ( fileout, 
"      *MESH_FACE %d: A: %d B: %d C: %d D: %d", iface, i1, i2, i3, i4 );
 
 1330       fprintf ( fileout, 
" AB: 1 BC: 1 CD: 1 DA: 1 *MESH_SMOOTHING *MESH_MTLID 1\n" );
 
 1335   fprintf ( fileout, 
"    }\n" );
 
 1340   fprintf ( fileout, 
"    *MESH_NUMTVERTEX 0\n" );
 
 1345   fprintf ( fileout, 
"    *MESH_NUMCVERTEX 0\n" );
 
 1351   fprintf ( fileout, 
"    *MESH_NORMALS {\n" );
 
 1354   for ( iface = 0; iface < 
face_num; iface++ )
 
 1356     fprintf ( fileout, 
"      *MESH_FACENORMAL %d %f %f %f\n",
 
 1360     for ( ivert = 0; ivert < 
face_order[iface]; ivert++ )
 
 1362       fprintf ( fileout, 
"      *MESH_VERTEXNORMAL %d %f %f %f\n",
 
 1369   fprintf ( fileout, 
"    }\n" );
 
 1374   fprintf ( fileout, 
"  }\n" );
 
 1378   fprintf ( fileout, 
"  *PROP_MOTIONBLUR 0\n" );
 
 1379   fprintf ( fileout, 
"  *PROP_CASTSHADOW 1\n" );
 
 1380   fprintf ( fileout, 
"  *PROP_RECVSHADOW 1\n" );
 
 1384   fprintf ( fileout, 
"}\n" );
 
 1391   cout << 
"ASE_WRITE - Wrote " << 
text_num << 
" text lines;\n";
 
 1505   sscanf ( 
input, 
"%d %d %d %d", &part_num, &cor3_num_new, &face_num_new,
 
 1514   sscanf ( 
input, 
"%d %d", &poly1, &poly2 );
 
 1524     sscanf ( 
input, 
"%f %f %f", &x, &y, &z );
 
 1543       count = sscanf ( next, 
"%d%n", &ival, &width );
 
 1544       next = next + width;
 
 1573   cout << 
"BYU_READ - Read " << 
text_num << 
" text lines.\n";
 
 1666   for ( iface = 0; iface < 
face_num; iface++ )
 
 1673   fprintf ( fileout, 
"%d %d %d %d\n", part_num, 
cor3_num, 
face_num, edge_num );
 
 1676   fprintf ( fileout, 
"1 %d\n", 
face_num );
 
 1681     fprintf ( fileout, 
"%f %f %f\n", 
cor3[0][j], 
cor3[1][j], 
cor3[2][j] );
 
 1685   for ( iface = 0; iface < 
face_num; iface++ )
 
 1687     for ( ivert = 0; ivert < 
face_order[iface]; ivert++ )
 
 1689       jp = 
face[ivert][iface] + 1;
 
 1694      fprintf ( fileout, 
"%d ", jp );
 
 1696     fprintf ( fileout, 
"\n" );
 
 1703   cout << 
"BYU_WRITE - Wrote " << 
text_num << 
" text lines.\n";
 
 1740   if ( 97 <= c && c <= 122 )
 
 1777   if ( 97 <= c1 && c1 <= 122 )
 
 1781   if ( 97 <= c2 && c2 <= 122 )
 
 1786   return ( c1 == c2 );
 
 1826   nchar = strlen ( s );
 
 1828   for ( 
i = 0; 
i < nchar; 
i++ )
 
 1877   else if ( c == 
'\f' )
 
 1881   else if ( c == 
'\n' )
 
 1885   else if ( c == 
'\r' )
 
 1889   else if ( c == 
'\t' )
 
 1893   else if ( c == 
'\v' )
 
 1904 int ch_pad ( 
int *char_index, 
int *null_index, 
char *s, 
int max_string )
 
 1942   if ( *char_index < 0 ||
 
 1943       *null_index <= *char_index ||
 
 1944       max_string - 1 < *char_index )
 
 1949   if ( max_string - 1 < (*null_index) + 2 )
 
 1954   for ( 
i = *null_index + 2; *char_index + 2 < 
i; 
i-- )
 
 1958   s[*char_index+2] = 
' ';
 
 1959   s[*char_index+1] = s[*char_index];
 
 1960   s[*char_index] = 
' ';
 
 1962   *char_index = *char_index + 1;
 
 1963   *null_index = *null_index + 2;
 
 1992   c = ( char ) fgetc ( filein );
 
 2039   if ( 
'0' <= c && c <= 
'9' )
 
 2043   else if ( c == 
' ' )
 
 2077   fputc ( c, fileout );
 
 2127   bool reverse_normals;
 
 2134   reverse_faces = 
false;
 
 2135   reverse_normals = 
false;
 
 2148     reverse_normals = 
true;
 
 2150     cout << 
"COMMAND_LINE: Reverse_Normals option requested.\n";
 
 2157     reverse_faces = 
true;
 
 2159     cout << 
"COMMAND_LINE: Reverse_Faces option requested.\n";
 
 2171     cout << 
"COMMAND_LINE - Fatal error!\n";
 
 2172     cout << 
"  Failure reported from DATA_READ.\n";
 
 2178   if ( reverse_normals )
 
 2181     for ( icor3 = 0; icor3 < 
cor3_num; icor3++ )
 
 2183       for ( 
i = 0; 
i < 3; 
i++ )
 
 2189     for ( iface = 0; iface < 
face_num; iface++ )
 
 2191       for ( 
i = 0; 
i < 3; 
i++ )
 
 2197     for ( iface = 0; iface < 
face_num; iface++ )
 
 2199       for ( ivert = 0; ivert < 
face_order[iface]; ivert++ )
 
 2201         for ( 
i = 0; 
i < 3; 
i++ )
 
 2209     cout << 
"COMMAND_LINE - Note:\n";
 
 2210     cout << 
"  Reversed node, face, and vertex normals.\n";
 
 2215   if ( reverse_faces )
 
 2220     cout << 
"COMMAND_LINE - Note:\n";
 
 2221     cout << 
"  Reversed the face definitions.\n";
 
 2234     cout << 
"COMMAND_LINE - Fatal error!\n";
 
 2235     cout << 
"  Failure while writing output data.\n";
 
 2270   for ( icor3 = 0; icor3 < 
cor3_num; icor3++ )
 
 2272     for ( j = 0; j < 3; j++ )
 
 2280   for ( iface = 0; iface < 
face_num; iface++ )
 
 2282     for ( ivert = 0; ivert < 
face_order[iface]; ivert++ )
 
 2284       icor3 = 
face[ivert][iface];
 
 2285       for ( j = 0; j < 3; j++ )
 
 2295   for ( icor3 = 0; icor3 < 
cor3_num; icor3++ )
 
 2298     for ( j = 0; j < 3; j++ )
 
 2301       norm = norm + temp * temp;
 
 2307       for ( j = 0; j < 3; j++ )
 
 2313     norm = ( float ) sqrt ( norm );
 
 2315     for ( j = 0; j < 3; j++ )
 
 2371     xave = xave + 
cor3[0][
i];
 
 2372     if ( 
cor3[0][
i] < xmin )
 
 2376     if ( xmax < 
cor3[0][
i] )
 
 2381     yave = yave + 
cor3[1][
i];
 
 2382     if ( 
cor3[1][
i] < ymin )
 
 2386     if ( ymax < 
cor3[1][
i] )
 
 2391     zave = zave + 
cor3[2][
i];
 
 2392     if ( 
cor3[2][
i] < zmin )
 
 2396     if ( zmax < 
cor3[2][
i] )
 
 2407   cout << 
"COR3_RANGE - Data range:\n";
 
 2409   cout << 
"   Minimum   Average   Maximum  Range\n";
 
 2411   cout << 
"X  " << setw(10) << xmin        << 
"  " 
 2412                 << setw(10) << xave        << 
"  " 
 2413                 << setw(10) << xmax        << 
"  " 
 2414                 << setw(10) << xmax - xmin << 
"\n";
 
 2415   cout << 
"Y  " << setw(10) << ymin        << 
"  " 
 2416                 << setw(10) << yave        << 
"  " 
 2417                 << setw(10) << ymax        << 
"  " 
 2418                 << setw(10) << ymax - ymin << 
"\n";
 
 2419   cout << 
"Z  " << setw(10) << zmin        << 
"  " 
 2420                 << setw(10) << zave        << 
"  " 
 2421                 << setw(10) << zmax        << 
"  " 
 2422                 << setw(10) << zmax - zmin << 
"\n";
 
 2455     cout << 
"DATA_CHECK - Warning!\n";
 
 2456     cout << 
"  The input data requires " << 
color_num << 
" colors.\n";
 
 2457     cout << 
"  There was only room for " << 
COLOR_MAX << 
"\n";
 
 2459     cout << 
"  To correct this problem, you can change the internal\n";
 
 2460     cout << 
"  value of COLOR_MAX, recompile, and rerun the program.\n";
 
 2467     cout << 
"DATA_CHECK - Warning!\n";
 
 2468     cout << 
"  The input data requires " << 
cor3_num << 
" points.\n";
 
 2469     cout << 
"  There was only room for " << 
COR3_MAX << 
"\n";
 
 2471     cout << 
"  To correct this problem, you can change the internal\n";
 
 2472     cout << 
"  value of COR3_MAX, recompile, and rerun the program.\n";
 
 2479     cout << 
"DATA_CHECK - Warning!\n";
 
 2480     cout << 
"  The input data requires " << 
face_num << 
" faces.\n";
 
 2481     cout << 
"  There was only room for " << 
FACE_MAX << 
"\n";
 
 2483     cout << 
"  To correct this problem, you can change the internal\n";
 
 2484     cout << 
"  value of FACE_MAX, recompile, and rerun the program.\n";
 
 2491     cout << 
"DATA_CHECK - Warning!\n";
 
 2492     cout << 
"  The input data requires " << 
line_num << 
" line items.\n";
 
 2493     cout << 
"  There was only room for " << 
LINES_MAX << 
".\n";
 
 2495     cout << 
"  To correct this problem, you can change the internal\n";
 
 2496     cout << 
"  value of LINES_MAX, recompile, and rerun the program.\n";
 
 2502   for ( iface = 0; iface < 
face_num; iface++ )
 
 2514     cout << 
"DATA_CHECK - Warning!\n";
 
 2515     cout << 
"  Corrected " << nfix
 
 2516          << 
" faces using more than " << 
ORDER_MAX 
 2517          << 
" vertices per face.\n";
 
 2537   cout << 
"DATA_CHECK - Data checked.\n";
 
 2572   for ( 
i = 0; 
i < 3; 
i++ )
 
 2577   for ( 
i = 0; 
i < 3; 
i++ )
 
 2590   for ( 
i = 0; 
i < 3; 
i++ )
 
 2604   for ( iface = 0; iface < 
FACE_MAX; iface++ )
 
 2606     for ( ivert = 0; ivert < 
ORDER_MAX; ivert++ )
 
 2608       face[ivert][iface] = 0;
 
 2612   for ( iface = 0; iface < 
FACE_MAX; iface++ )
 
 2617   for ( iface = 0; iface < 
FACE_MAX; iface++ )
 
 2622   for ( iface = 0; iface < 
FACE_MAX; iface++ )
 
 2624     for ( 
i = 0; 
i < 3; 
i++ )
 
 2630   for ( iface = 0; iface < 
FACE_MAX; iface++ )
 
 2635   for ( iface = 0; iface < 
FACE_MAX; iface++ )
 
 2640   for ( iface = 0; iface < 
FACE_MAX; iface++ )
 
 2662   for ( 
i = 0; 
i < 4; 
i++ )
 
 2674     for ( 
i = 0; 
i < 3; 
i++ )
 
 2691   for ( 
i = 0; 
i < 3; 
i++ )
 
 2696   for ( 
i = 0; 
i < 3; 
i++ )
 
 2717   for ( iface = 0; iface < 
FACE_MAX; iface++ )
 
 2719     for ( ivert = 0; ivert < 
ORDER_MAX; ivert++ )
 
 2725   for ( iface = 0; iface < 
FACE_MAX; iface++ )
 
 2727     for ( ivert = 0; ivert < 
ORDER_MAX; ivert++ )
 
 2729       for ( 
i = 0; 
i < 3; 
i++ )
 
 2736   for ( j = 0; j < 3; j++ )
 
 2746   for ( iface = 0; iface < 
FACE_MAX; iface++ )
 
 2748     for ( ivert = 0; ivert < 
ORDER_MAX; ivert++ )
 
 2750       for ( 
i = 0; 
i < 2; 
i++ )
 
 2760     cout << 
"DATA_INIT: Graphics data initialized.\n";
 
 2806   if ( filein_type == NULL )
 
 2809     cout << 
"DATA_READ - Fatal error!\n";
 
 2810     cout << 
"  Could not determine the type of '" << 
filein_name << 
"'.\n";
 
 2816     cout << 
"DATA_READ: Input file has type " << filein_type << 
".\n";
 
 2830   if ( 
s_eqi ( filein_type, 
"3DS" ) ||
 
 2831        s_eqi ( filein_type, 
"STLB" ) ||
 
 2832        s_eqi ( filein_type, 
"TRIB" ) )
 
 2836     if ( filein == NULL )
 
 2839       cout << 
"DATA_READ - Fatal error!\n";
 
 2840       cout << 
"  Could not open the input file '" << 
filein_name << 
"'!\n";
 
 2844   else if ( 
s_eqi ( filein_type, 
"OFF" ) )
 
 2851       cout << 
"DATA_READ - Fatal error!\n";
 
 2852       cout << 
"  Could not open the input file '" << 
filein_name << 
"'!\n";
 
 2860     if ( filein == NULL )
 
 2863       cout << 
"DATA_READ - Fatal error!\n";
 
 2864       cout << 
"  Could not open the input file '" << 
filein_name << 
"'!\n";
 
 2871   if ( 
s_eqi ( filein_type, 
"3DS" ) )
 
 2879       for ( iface = 0; iface < 
face_num; iface++ )
 
 2881         for ( ivert = 0; ivert < 
face_order[iface]; ivert++ )
 
 2883           icor3 = 
face[ivert][iface];
 
 2892   else if ( 
s_eqi ( filein_type, 
"ASE" ) )
 
 2903   else if ( 
s_eqi ( filein_type, 
"BYU" ) )
 
 2907   else if ( 
s_eqi ( filein_type, 
"DXF" ) )
 
 2911   else if ( 
s_eqi ( filein_type, 
"GMOD" ) )
 
 2915   else if ( 
s_eqi ( filein_type, 
"HRC" ) )
 
 2919   else if ( 
s_eqi ( filein_type, 
"IV" ) )
 
 2923   else if ( 
s_eqi ( filein_type, 
"OBJ" ) )
 
 2927   else if ( 
s_eqi ( filein_type, 
"OFF" ) )
 
 2931   else if ( 
s_eqi ( filein_type, 
"SMF" ) )
 
 2936     s_eqi ( filein_type, 
"STL" ) ||
 
 2937     s_eqi ( filein_type, 
"STLA") )
 
 2941   else if ( 
s_eqi ( filein_type, 
"STLB") )
 
 2946     s_eqi ( filein_type, 
"TRI" ) ||
 
 2947     s_eqi ( filein_type, 
"TRIA") )
 
 2951   else if ( 
s_eqi ( filein_type, 
"TRIB") )
 
 2955   else if ( 
s_eqi ( filein_type, 
"VLA" ) )
 
 2962     cout << 
"DATA_READ - Fatal error!\n";
 
 2963     cout << 
"  Unacceptable input file type.\n";
 
 2967   if ( 
s_eqi ( filein_type, 
"OFF" ) )
 
 2978     cout << 
"DATA_READ: Finished reading the data file.\n";
 
 2983   if ( ierror == 
ERROR )
 
 2986     cout << 
"DATA_READ - Fatal error!\n";
 
 2987     cout << 
"  There was an error reported while reading input data.\n";
 
 3012   if ( ierror == 
ERROR )
 
 3015     cout << 
"DATA_READ - Fatal error!\n";
 
 3016     cout << 
"  An error occurred while reading the input file.\n";
 
 3043   for ( icor3 = 0; icor3 < 
cor3_num; icor3++ )
 
 3053   for ( iface = 0; iface < 
face_num; iface++ )
 
 3055     for ( ivert = 0; ivert < 
face_order[iface]; ivert++ )
 
 3067   for ( iface = 0; iface < 
face_num; iface++ )
 
 3077   for ( iline = 0; iline < 
line_num; iline++ )
 
 3144   cout << 
"DATA_REPORT - The input file contains:\n";
 
 3146   cout << 
"  Bad data items             " << 
bad_num << 
"\n";
 
 3147   cout << 
"  Text lines                 " << 
text_num << 
"\n";
 
 3148   cout << 
"  Text bytes (binary data)   " << 
bytes_num << 
"\n";
 
 3149   cout << 
"  Colors                     " << 
color_num << 
"\n";
 
 3151   cout << 
"  Duplicate points           " << 
dup_num << 
"\n";
 
 3152   cout << 
"  Faces                      " << 
face_num << 
"\n";
 
 3153   cout << 
"  Groups                     " << 
group_num << 
"\n";
 
 3154   cout << 
"  Vertices per face, maximum " << 
max_order2 << 
"\n";
 
 3155   cout << 
"  Line items                 " << 
line_num << 
"\n";
 
 3156   cout << 
"  Points                     " << 
cor3_num << 
"\n";
 
 3195   if ( fileout_type == NULL )
 
 3198     cout << 
"DATA_WRITE - Fatal error!\n";
 
 3199     cout << 
"  Could not determine the output file type.\n";
 
 3205   if ( 
s_eqi ( fileout_type, 
"3DS" ) ||
 
 3206        s_eqi ( fileout_type, 
"STLB" ) ||
 
 3207        s_eqi ( fileout_type, 
"TRIB" ) )
 
 3216   if ( fileout == NULL )
 
 3219     cout << 
"DATA_WRITE - Fatal error!\n";
 
 3220     cout << 
"  Could not open the output file!\n";
 
 3226   if ( 
s_eqi ( fileout_type, 
"3DS" ) )
 
 3231   else if ( 
s_eqi ( fileout_type, 
"ASE" ) )
 
 3235   else if ( 
s_eqi ( fileout_type, 
"BYU" ) )
 
 3239   else if ( 
s_eqi ( fileout_type, 
"DXF" ) )
 
 3243   else if ( 
s_eqi ( fileout_type, 
"GMOD" ) )
 
 3247   else if ( 
s_eqi ( fileout_type, 
"HRC" ) )
 
 3251   else if ( 
s_eqi ( fileout_type, 
"IV" ) )
 
 3255   else if ( 
s_eqi ( fileout_type, 
"OBJ" ) )
 
 3259   else if ( 
s_eqi ( fileout_type, 
"OFF" ) )
 
 3263   else if ( 
s_eqi ( fileout_type, 
"POV" ) )
 
 3267   else if ( 
s_eqi ( fileout_type, 
"SMF" ) )
 
 3272     s_eqi ( fileout_type, 
"STL" ) ||
 
 3273     s_eqi ( fileout_type, 
"STLA" ) )
 
 3277   else if ( 
s_eqi ( fileout_type, 
"STLB" ) )
 
 3281   else if ( 
s_eqi ( fileout_type, 
"TEC" ) )
 
 3286     s_eqi ( fileout_type, 
"TRI" ) ||
 
 3287     s_eqi ( fileout_type, 
"TRIA" ) )
 
 3291   else if ( 
s_eqi ( fileout_type, 
"TRIB" ) )
 
 3295   else if ( 
s_eqi ( fileout_type, 
"TXT" ) )
 
 3299   else if ( 
s_eqi ( fileout_type, 
"UCD" ) )
 
 3303   else if ( 
s_eqi ( fileout_type, 
"VLA" ) )
 
 3310       cout << 
"DATA_WRITE - Note:\n";
 
 3311       cout << 
"  Face information will temporarily be converted to\n";
 
 3312       cout << 
"  line information for output to a VLA file.\n";
 
 3319         cout << 
"DATA_WRITE - Warning:\n";
 
 3320         cout << 
"  Some face information was lost.\n";
 
 3321         cout << 
"  The maximum number of lines is " << 
LINES_MAX << 
".\n";
 
 3322         cout << 
"  The number of lines needed is " << 
line_num << 
".\n";
 
 3333   else if ( 
s_eqi ( fileout_type, 
"WRL" ) )
 
 3337   else if ( 
s_eqi ( fileout_type, 
"XGL" ) )
 
 3345     cout << 
"DATA_WRITE - Fatal error!\n";
 
 3346     cout << 
"  Unacceptable output file type '" << fileout_type << 
"'.\n";
 
 3353   if ( result == 
ERROR )
 
 3488     count = sscanf ( input1, 
"%d%n", &code, &width );
 
 3516       if ( strncmp( input2, 
"LINE", 4 ) == 0 )
 
 3520       else if ( strncmp( input2, 
"3DFACE", 6 ) == 0 )
 
 3528       for (cpos = 0; input1[cpos] == 
' '; cpos++)
 
 3531       if ( input1[cpos] == 
'1' || input1[cpos] == 
'2' || input1[cpos] == 
'3' )
 
 3533         count = sscanf ( input2, 
"%e%n", &rval, &width );
 
 3535         switch ( input1[cpos] )
 
 3719   fprintf ( fileout, 
"  0\n" );
 
 3720   fprintf ( fileout, 
"SECTION\n" );
 
 3721   fprintf ( fileout, 
"  2\n" );
 
 3722   fprintf ( fileout, 
"HEADER\n" );
 
 3723   fprintf ( fileout, 
"999\n" );
 
 3724   fprintf ( fileout, 
"%s created by IVCON.\n", 
fileout_name );
 
 3725   fprintf ( fileout, 
"999\n" );
 
 3726   fprintf ( fileout, 
"Original data in %s.\n", 
filein_name );
 
 3727   fprintf ( fileout, 
"  0\n" );
 
 3728   fprintf ( fileout, 
"ENDSEC\n" );
 
 3731   fprintf ( fileout, 
"  0\n" );
 
 3732   fprintf ( fileout, 
"SECTION\n" );
 
 3733   fprintf ( fileout, 
"  2\n" );
 
 3734   fprintf ( fileout, 
"TABLES\n" );
 
 3735   fprintf ( fileout, 
"  0\n" );
 
 3736   fprintf ( fileout, 
"ENDSEC\n" );
 
 3739   fprintf ( fileout, 
"  0\n" );
 
 3740   fprintf ( fileout, 
"SECTION\n" );
 
 3741   fprintf ( fileout, 
"  2\n" );
 
 3742   fprintf ( fileout, 
"BLOCKS\n" );
 
 3743   fprintf ( fileout, 
"  0\n" );
 
 3744   fprintf ( fileout, 
"ENDSEC\n" );
 
 3747   fprintf ( fileout, 
"  0\n" );
 
 3748   fprintf ( fileout, 
"SECTION\n" );
 
 3749   fprintf ( fileout, 
"  2\n" );
 
 3750   fprintf ( fileout, 
"ENTITIES\n" );
 
 3758   for ( iline = 0; iline < 
line_num; iline++ )
 
 3770         fprintf ( fileout, 
"  0\n" );
 
 3771         fprintf ( fileout, 
"LINE\n" );
 
 3772         fprintf ( fileout, 
"  8\n" );
 
 3773         fprintf ( fileout, 
"  0\n" );
 
 3774         fprintf ( fileout, 
" 10\n" );
 
 3775         fprintf ( fileout, 
"%f\n", 
cor3[0][jcor3] );
 
 3776         fprintf ( fileout, 
" 20\n" );
 
 3777         fprintf ( fileout, 
"%f\n", 
cor3[1][jcor3] );
 
 3778         fprintf ( fileout, 
" 30\n" );
 
 3779         fprintf ( fileout, 
"%f\n", 
cor3[2][jcor3] );
 
 3780         fprintf ( fileout, 
" 11\n" );
 
 3781         fprintf ( fileout, 
"%f\n", 
cor3[0][icor3] );
 
 3782         fprintf ( fileout, 
" 21\n" );
 
 3783         fprintf ( fileout, 
"%f\n", 
cor3[1][icor3] );
 
 3784         fprintf ( fileout, 
" 31\n" );
 
 3785         fprintf ( fileout, 
"%f\n", 
cor3[2][icor3] );
 
 3797   for ( iface = 0; iface < 
face_num; iface++ )
 
 3799     fprintf ( fileout, 
"  0\n" );
 
 3800     fprintf ( fileout, 
"3DFACE\n" );
 
 3801     fprintf ( fileout, 
"  8\n" );
 
 3802     fprintf ( fileout, 
"  Cube\n" );
 
 3805     for ( ivert = 0; ivert < 
face_order[iface]; ivert++ )
 
 3807       icor3 = 
face[ivert][iface];
 
 3809       fprintf ( fileout, 
"1%d\n", ivert );
 
 3810       fprintf ( fileout, 
"%f\n", 
cor3[0][icor3] );
 
 3811       fprintf ( fileout, 
"2%d\n", ivert );
 
 3812       fprintf ( fileout, 
"%f\n", 
cor3[1][icor3] );
 
 3813       fprintf ( fileout, 
"3%d\n", ivert );
 
 3814       fprintf ( fileout, 
"%f\n", 
cor3[2][icor3] );
 
 3820   fprintf ( fileout, 
"  0\n" );
 
 3821   fprintf ( fileout, 
"ENDSEC\n" );
 
 3822   fprintf ( fileout, 
"  0\n" );
 
 3823   fprintf ( fileout, 
"EOF\n" );
 
 3829   cout << 
"DXF_WRITE - Wrote " << 
text_num << 
" text lines.\n";
 
 3882   for ( iface = 0; iface < 
face_num; iface++ )
 
 3889   edge = 
new int[edge_num*2];
 
 3892   for ( iface = 0; iface < 
face_num; iface++ )
 
 3894     for ( vert = 0; vert < 
face_order[iface]; vert++ )
 
 3896       i = 
face[vert][iface];
 
 3898       j = 
face[vert2][iface];
 
 3899       edge[0+edge_num*2] = 
i4_min ( 
i, j );
 
 3900       edge[1+edge_num*2] = 
i4_max ( 
i, j );
 
 3901       edge_num = edge_num + 1;
 
 3923       edge[0+
i*2] = edge[0+j*2];
 
 3926       edge[1+
i*2] = edge[1+j*2];
 
 3932     else if ( indx < 0 )
 
 3934       if ( edge[0+
i*2] < edge[0+j*2] )
 
 3938       else if ( edge[0+
i*2] == edge[0+j*2] )
 
 3940         if ( edge[1+
i*2] < edge[1+j*2] )
 
 3944         else if ( edge[1+
i*2] == edge[1+j*2] )
 
 3958     else if ( indx == 0 )
 
 3967   edge_num_old = edge_num;
 
 3971   for ( 
i = 0; 
i < edge_num_old; 
i++ )
 
 3979       if ( edge[0+(
i-1)*2] != edge[0+
i*2] ||
 
 3980           edge[1+(
i-1)*2] != edge[1+
i*2] )
 
 3982         edge_num = edge_num + 1;
 
 4036   for ( iface = 0; iface < 
face_num; iface++ )
 
 4043     for ( ivert = 0; ivert < 
face_order[iface]; ivert++ )
 
 4045       edge_num = edge_num + 1;
 
 4053       inode = 
face[ivert][iface];
 
 4054       jnode = 
face[jvert][iface];
 
 4057       x = 
cor3[0][inode] - 
cor3[0][jnode];
 
 4058       y = 
cor3[1][inode] - 
cor3[1][jnode];
 
 4059       z = 
cor3[2][inode] - 
cor3[2][jnode];
 
 4061       distsq = x * x + y * y + z * z;
 
 4063       if ( distsq != 0.0 )
 
 4065         face2[face_order2] = 
face[ivert][iface];
 
 4066         vertex_normal2[0][face_order2] = 
vertex_normal[0][ivert][iface];
 
 4067         vertex_normal2[1][face_order2] = 
vertex_normal[1][ivert][iface];
 
 4068         vertex_normal2[2][face_order2] = 
vertex_normal[2][ivert][iface];
 
 4069         face_order2 = face_order2 + 1;
 
 4073         edge_num_del = edge_num_del + 1;
 
 4079     for ( ivert = 0; ivert < 
face_order[iface]; ivert++ )
 
 4081       face[ivert][iface] = face2[ivert];
 
 4082       for ( j = 0; j < 3; j++ )
 
 4091   cout << 
"EDGE_NULL_DELETE:\n";
 
 4092   cout << 
"  There are a total of " << edge_num << 
" edges.\n";
 
 4093   cout << 
"  Of these, " << edge_num_del << 
" were of zero length,\n";
 
 4094   cout << 
"  and were deleted.\n";
 
 4159   for ( iface = 0; iface < 
face_num; iface++ )
 
 4165       i1 = 
face[
i][iface];
 
 4166       i2 = 
face[
i+1][iface];
 
 4167       i3 = 
face[
i+2][iface];
 
 4184         ( x2 - x1 ) * ( x3 - x1 ) +
 
 4185         ( y2 - y1 ) * ( y3 - y1 ) +
 
 4186         ( z2 - z1 ) * ( z3 - z1 );
 
 4189           ( x2 - x1 ) * ( x2 - x1 )
 
 4190         + ( y2 - y1 ) * ( y2 - y1 )
 
 4191         + ( z2 - z1 ) * ( z2 - z1 ) );
 
 4202         alpha = dot / ( base * base );
 
 4204         x = x3 - x1 - alpha * ( x2 - x1 );
 
 4205         y = y3 - y1 - alpha * ( y2 - y1 );
 
 4206         z = z3 - z1 - alpha * ( z2 - z1 );
 
 4208         height = sqrt ( x * x + y * y + z * z );
 
 4211       area_tri = 0.5 * base * height;
 
 4221   for ( iface = 1; iface < 
face_num; iface++ )
 
 4234   cout << 
"FACE_AREA_SET:\n";
 
 4235   cout << 
"  Minimum face area is " << area_min << 
"\n";
 
 4236   cout << 
"  Maximum face area is " << area_max << 
"\n";
 
 4238   tol = area_max / 10000.0;
 
 4240   if ( area_min < tol )
 
 4244     for ( iface = 0; iface < 
face_num; iface++ )
 
 4249         face_num_del = face_num_del + 1;
 
 4253     cout << 
"  Marked " << face_num_del << 
" tiny faces for deletion.\n";
 
 4298   for ( iface = 0; iface < 
face_num; iface++ )
 
 4306     norm = ( float ) sqrt ( x * x + y * y + z * z );
 
 4312       for ( 
i = 0; 
i < 3; 
i++ )
 
 4317       for ( ivert = 0; ivert < 
face_order[iface]; ivert++ )
 
 4319         for ( 
i = 0; 
i < 3; 
i++ )
 
 4329       norm = ( float ) sqrt ( x * x + y * y + z * z );
 
 4333         for ( 
i = 0; 
i < 3; 
i++ )
 
 4335           face_normal[
i][iface] = ( float ) ( 1.0 / sqrt ( 3.0 ) );
 
 4340         for ( 
i = 0; 
i < 3; 
i++ )
 
 4351     cout << 
"FACE_NORMAL_AVE: Recomputed " << nfix << 
" face normals\n";
 
 4352     cout << 
"  by averaging face vertex normals.\n";
 
 4396   for ( iface = 0; iface < 
face_num; iface++ )
 
 4408       if ( face_num2 != iface )
 
 4413         for ( ivert = 0; ivert < 
ORDER_MAX; ivert++ )
 
 4415           face[ivert][face_num2] = 
face[ivert][iface];
 
 4417           for ( j = 0; j < 3; j++ )
 
 4428       face_num2 = face_num2 + 1;
 
 4435   cout << 
"FACE_NULL_DELETE\n";
 
 4436   cout << 
"  There are a total of " << 
face_num << 
" faces.\n";
 
 4437   cout << 
"  Of these, " << face_num2 << 
" passed the order test.\n";
 
 4470   if ( iface < 0 || 
face_num-1 < iface )
 
 4473     cout << 
"FACE_PRINT - Fatal error!\n";
 
 4474     cout << 
"  Face indices must be between 1 and " << 
face_num << 
"\n";
 
 4475     cout << 
"  But your requested value was " << iface << 
"\n";
 
 4480   cout << 
"FACE_PRINT\n";
 
 4481   cout << 
"  Information about face " << iface << 
"\n";
 
 4483   cout << 
"  Number of vertices is " << 
face_order[iface] << 
"\n";
 
 4485   cout << 
"  Vertex list:\n";
 
 4486   cout << 
"    Vertex #, Node #, Material #, X, Y, Z:\n";
 
 4488   for ( ivert = 0; ivert < 
face_order[iface]; ivert++ )
 
 4490     j = 
face[ivert][iface];
 
 4493      << setw(6)  << ivert      << 
"  " 
 4494      << setw(6)  << j          << 
"  " 
 4495      << setw(6)  << 
k          << 
"  " 
 4496      << setw(10) << 
cor3[0][j] << 
"  " 
 4497      << setw(10) << 
cor3[1][j] << 
"  " 
 4498      << setw(10) << 
cor3[2][j] << 
"\n";
 
 4502   cout << 
"  Face normal vector:\n";
 
 4510   cout << 
"  Vertex face normals:\n";;
 
 4512   for ( ivert = 0; ivert < 
face_order[iface]; ivert++ )
 
 4515       << setw(6)  << ivert                          << 
"  " 
 4561   for ( iface = 0; iface < 
face_num; iface++ )
 
 4565     for ( ivert = 0; ivert < ( m / 2 ); ivert++ )
 
 4567       itemp = 
face[ivert][iface];
 
 4568       face[ivert][iface] = 
face[m-1-ivert][iface];
 
 4569       face[m-1-ivert][iface] = itemp;
 
 4575       for ( j = 0; j < 3; j++ )
 
 4582       for ( j = 0; j < 2; j++ )
 
 4595     for ( j = 0; j < 3; j++ )
 
 4603     for ( j = 0; j < 3; j++ )
 
 4610   cout << 
"FACE_REVERSE_ORDER\n";
 
 4611   cout << 
"  Each list of nodes defining a face\n";
 
 4612   cout << 
"  has been reversed; related information,\n";
 
 4613   cout << 
"  including normal vectors, was also updated.\n";
 
 4660   cout << 
"Enter lowest face number to save between 0 and " 
 4662   scanf ( 
"%d", &iface1 );
 
 4663   if ( iface1 < 0 || 
face_num - 1 < iface1 )
 
 4665     cout << 
"Illegal choice!\n";
 
 4670   cout << 
"Enter highest face number to save between " 
 4671     << iface1 << 
" and " << 
face_num - 1 << 
":  ";
 
 4672   scanf ( 
"%d", &iface2 );
 
 4673   if ( iface2 < iface1 || 
face_num - 1 < iface2 )
 
 4675     cout << 
"Illegal choice!\n";
 
 4683   for ( iface = 0; iface < iface2 + 1 - iface1; iface++ )
 
 4686     for ( ivert = 0; ivert < 
ORDER_MAX; ivert++ )
 
 4688       face[ivert][iface] = 
face[ivert][iface+inc];
 
 4690       for ( 
i = 0; 
i < 3; 
i++ )
 
 4697     for ( 
i = 0; 
i < 3; 
i++ )
 
 4718   for ( iface = 0; iface < 
face_num; iface++ )
 
 4720     for ( ivert = 0; ivert < 
face_order[iface]; ivert++ )
 
 4722       j = 
face[ivert][iface];
 
 4723       if ( 
list[j] == -1 )
 
 4725         cor3_num2 = cor3_num2 + 1;
 
 4726         list[j] = cor3_num2;
 
 4738     if ( 
list[
i] != -1 )
 
 4740       list[
i] = cor3_num2;
 
 4741       cor3_num2 = cor3_num2 + 1;
 
 4747   for ( iface = 0; iface < 
face_num; iface++ )
 
 4749     for ( ivert = 0; ivert < 
face_order[iface]; ivert++ )
 
 4751       j = 
face[ivert][iface];
 
 4763       for ( j = 0; j < 3; j++ )
 
 4814     for ( iface = 0; iface < 
face_num; iface++ )
 
 4816       for ( ivert = 0; ivert < 
face_order[iface]; ivert++ )
 
 4818         icor3 = 
face[ivert][iface];
 
 4829       icor3 = 
face[ivert][iface];
 
 4854     for ( iface = 0; iface < 
face_num; iface++ )
 
 4856       for ( ivert = 0; ivert < 
face_order[iface]; ivert++ )
 
 4858         icor3 = 
face[ivert][iface];
 
 4869         jcor3 = 
face[jvert][iface];
 
 4871         if ( icor3 < jcor3 )
 
 4927   for ( iface = 0; iface < 
face_num; iface++ )
 
 4929     for ( ivert = 0; ivert < 
face_order[iface]; ivert++ )
 
 4970     return file_name + 
i + 1;
 
 4999   fread ( &temp, 
sizeof ( 
float ), 1, filein );
 
 5050   y.ychar[0] = y.ychar[3];
 
 5054   y.ychar[1] = y.ychar[2];
 
 5057   return ( y.yfloat );
 
 5082   int nbyte = 
sizeof ( float );
 
 5094   fwrite ( &temp, nbyte, 1, fileout );
 
 5126   static unsigned char one[4];
 
 5129   temp = 
sizeof ( float );
 
 5135   *(
float *)one = 1.0;
 
 5139   if ( one[0] == 0 && one[1] == 0 && one[2] == 128 && one[3] == 63 )
 
 5146   if ( one[0] == 63 && one[1] == 128 && one[2] == 0 && one[3] == 0 )
 
 5240   unsigned char MagicNumber[4];
 
 5241   unsigned long int NumSections;
 
 5246   unsigned short NumAnimations;
 
 5247   unsigned short NumFrames;
 
 5248   unsigned short FaceCount;
 
 5249   unsigned short TextureCount;
 
 5253   unsigned short Flags;
 
 5254   unsigned short TextureNameLen;
 
 5255   unsigned short AnimationNameLen;
 
 5264     cout << 
"GMOD_READ - This architecture not supported.\n";
 
 5274   fread(MagicNumber, 1, 4, filein);
 
 5275   if ( MagicNumber[0] != 0xf9 ||
 
 5276       MagicNumber[1] != 0xfa ||
 
 5277       MagicNumber[2] != 0x63 ||
 
 5278       MagicNumber[3] != 0x1e)
 
 5280     cout << 
"GMOD_READ - Bad magic number on GMOD file.\n";
 
 5288     cout << 
"GMOD_READ - Fatal error!\n";
 
 5289     cout << 
"  Too many sections (" << NumSections << 
") in GMOD file.\n";
 
 5290     cout << 
"  Please increase static limit GMOD_MAX_SECTIONS\n";
 
 5298   for ( SectionCount = 0; SectionCount < ( int ) NumSections; SectionCount++ )
 
 5306   for ( SectionCount = 0; SectionCount < ( int ) NumSections; SectionCount++ )
 
 5311     fseek ( filein, ( 
long int ) SectionOffset[SectionCount], SEEK_SET );
 
 5315     switch (SectionID[SectionCount])
 
 5329           cout << 
"GMOD_READ - Fatal error!\n";
 
 5330           cout << 
"  Too many faces (" << 
face_num << 
") in GMOD file.\n";
 
 5331           cout << 
"  Increase the size of FACE_MAX.\n";
 
 5337         for ( FaceCount = 0; FaceCount < ( 
unsigned short ) 
face_num; FaceCount++ )
 
 5340           for ( VertexCount = 0; VertexCount < 4; VertexCount++ )
 
 5349               Order = VertexCount+1;
 
 5350               if ( MaxCor < 
face[VertexCount][FaceCount] )
 
 5352                 MaxCor = 
face[VertexCount][FaceCount];
 
 5364           fread(&Scale, 
sizeof(Scale), 1, filein);
 
 5369             cout << 
"Flags = " << Flags << 
"\n";
 
 5393           cout << 
"GMOD_READ - Fatal error!\n";
 
 5394           cout << 
"  Too many texture maps (" << 
texture_num << 
").\n";
 
 5395           cout << 
"  Increase static limit TEXTURE_MAX.\n";
 
 5400         for (TextureCount = 0; TextureCount < ( 
unsigned short ) 
texture_num;
 
 5407           fread ( 
texture_name[TextureCount], 
sizeof(
char), TextureNameLen, filein);
 
 5421           cout << 
"GMOD_READ - Fatal error!\n";
 
 5422           cout << 
"  Too many vertices (" << 
cor3_num << 
").\n";
 
 5423           cout << 
"  Increase static limit COR3_MAX.\n";
 
 5431         if ( 1 < NumAnimations )
 
 5434           cout << 
"GMOD_READ - Fatal error!\n";
 
 5435           cout << 
"  GMOD files can only handle one animation.\n";
 
 5436           cout << 
"  This file contains " << NumAnimations << 
".\n";
 
 5443         fread ( 
anim_name, 
sizeof(
char), AnimationNameLen, filein);
 
 5449         if ( 1 < NumFrames )
 
 5452           cout << 
"GMOD_READ - Warning!\n";
 
 5453           cout << 
"  Too many frames of animation (" << NumFrames << 
").\n";
 
 5454           cout << 
"  Will only use 1.\n";
 
 5459         for (VertexCount = 0; VertexCount < 
cor3_num; VertexCount++)
 
 5492     cout << 
"GMOD_READ - Fatal error!\n";
 
 5493     cout << 
"  Maximum coordinate index (" << MaxCor << 
")\n";
 
 5494     cout << 
"  exceeds number of coordinates (" << 
cor3_num << 
").\n";
 
 5524   unsigned char *out_pos;
 
 5530   if (*(
char *)&endian == 1)
 
 5532     fread(&Val, 
sizeof(Val), 1, filein);
 
 5539     out_pos = (
unsigned char *)&Val;
 
 5540     for ( 
i = 
sizeof(Val)-1; 0 <= 
i ; 
i-- )
 
 5542       *(out_pos+
i) = fgetc(filein);
 
 5571   unsigned char Byte1;
 
 5572   unsigned char Byte2;
 
 5574   Byte1 = fgetc ( filein );
 
 5575   Byte2 = fgetc ( filein );
 
 5577   return Byte1 | (((
unsigned short)Byte2) << 8);
 
 5602   unsigned char Byte1, Byte2, Byte3, Byte4;
 
 5604   Byte1 = fgetc(filein);
 
 5605   Byte2 = fgetc(filein);
 
 5606   Byte3 = fgetc(filein);
 
 5607   Byte4 = fgetc(filein);
 
 5610          (((
unsigned long)Byte2) << 8) |
 
 5611          (((
unsigned long)Byte3) << 16) |
 
 5612          (((
unsigned long)Byte4) << 24);
 
 5637   static unsigned char MagicNumber[4] = { 0xf9, 0xfa, 0x63, 0x1e };
 
 5638   unsigned long NumSections;
 
 5639   unsigned long SectionHeaderPos;
 
 5640   unsigned long TextureNameSectionPos;
 
 5641   unsigned long ModelSectionPos;
 
 5642   unsigned long VertexSectionPos;
 
 5647   unsigned long SectionCount;
 
 5660     cout << 
"GMOD_WRITE - Fatal error!\n";
 
 5661     cout << 
"  This architecture not supported.\n";
 
 5671   fwrite ( MagicNumber, 
sizeof(
char), 4, fileout );
 
 5680   SectionHeaderPos = ftell ( fileout );
 
 5681   for (SectionCount = 0; SectionCount < NumSections; SectionCount++)
 
 5693   TextureNameSectionPos = ftell ( fileout );
 
 5701   for ( TextureCount = 0; TextureCount < 
face_num; TextureCount++ )
 
 5717   ModelSectionPos = ftell(fileout);
 
 5726   for ( FaceCount = 0; FaceCount < 
face_num; FaceCount++ )
 
 5729     for (VertexCount = 0; VertexCount < ((
face_order[FaceCount] < 4) ? 
face_order[FaceCount] : 4); VertexCount++)
 
 5745     for ( ; VertexCount < 4; VertexCount++ )
 
 5765     for ( DimensionCount = 0; DimensionCount < 3; DimensionCount++ )
 
 5767       CorNumber = 
face[0][FaceCount];
 
 5768       Min[DimensionCount] = 
cor3[DimensionCount][CorNumber];
 
 5769       Max[DimensionCount] = 
cor3[DimensionCount][CorNumber];
 
 5771       for (VertexCount = 1; VertexCount < ((
face_order[FaceCount] < 4) ? 
face_order[FaceCount] : 4); VertexCount++)
 
 5774         CorNumber = 
face[VertexCount][FaceCount];
 
 5776         if ( 
cor3[DimensionCount][CorNumber] < Min[DimensionCount] )
 
 5777           Min[DimensionCount] = 
cor3[DimensionCount][CorNumber];
 
 5779         if (Max[DimensionCount] < 
cor3[DimensionCount][CorNumber])
 
 5780           Max[DimensionCount] = 
cor3[DimensionCount][CorNumber];
 
 5787     MaxWidth = Max[0] - Min[0];
 
 5788     for ( DimensionCount = 1; DimensionCount < 3; DimensionCount++ )
 
 5791        if ( MaxWidth < Max[DimensionCount] - Min[DimensionCount] )
 
 5792            MaxWidth = Max[DimensionCount] - Min[DimensionCount];
 
 5795     fwrite ( &Scale, 
sizeof(Scale), 1, fileout );
 
 5814   VertexSectionPos = ftell ( fileout );
 
 5834   for ( VertexCount = 0; VertexCount < 
cor3_num; VertexCount++ )
 
 5856   fseek ( fileout, ( 
long int ) SectionHeaderPos, SEEK_SET );
 
 5899   unsigned char *out_pos;
 
 5904   if (*(
char *)&endian == 1)
 
 5907     fwrite ( &Val, 
sizeof(Val), 1, fileout );
 
 5914     out_pos = (
unsigned char *)&Val;
 
 5915     for ( 
i = 
sizeof(Val)-1; 0 <= 
i; 
i-- )
 
 5917       fputc(*(out_pos+
i), fileout);
 
 5945   unsigned char OutByte[2];
 
 5947   OutByte[0] = (
unsigned char)(Val & 0xff);
 
 5948   OutByte[1] = (
unsigned char)(Val >> 8);
 
 5950   fwrite ( OutByte, 
sizeof(
unsigned char), 2, fileout );
 
 5977   unsigned char OutByte[4];
 
 5979   OutByte[0] = (
unsigned char)(Val & 0xff);
 
 5980   OutByte[1] = (
unsigned char)((Val >> 8) & 0xff);
 
 5981   OutByte[2] = (
unsigned char)((Val >> 16) & 0xff);
 
 5982   OutByte[3] = (
unsigned char)((Val >> 24) & 0xff);
 
 5984   fwrite ( OutByte, 
sizeof(
unsigned char), 4, fileout );
 
 6012   cout << 
"Hello:  This is IVCON,\n";
 
 6013   cout << 
"  for 3D graphics file conversion.\n";
 
 6015   cout << 
"    \".3ds\"   3D Studio Max binary;\n";
 
 6016   cout << 
"    \".ase\"   3D Studio Max ASCII export;\n";
 
 6017   cout << 
"    \".byu\"   Movie.BYU surface geometry;\n";
 
 6018   cout << 
"    \".dxf\"   DXF;\n";
 
 6019   cout <<  
"    \".gmod\"  Golgotha model;\n";
 
 6020   cout << 
"    \".hrc\"   SoftImage hierarchy;\n";
 
 6021   cout << 
"    \".iv\"    SGI Open Inventor;\n";
 
 6022   cout << 
"    \".obj\"   WaveFront Advanced Visualizer;\n";
 
 6023   cout << 
"    \".off\"   GEOMVIEW Object File Format;\n";
 
 6024   cout << 
"    \".pov\"   Persistence of Vision (output only);\n";
 
 6025   cout << 
"    \".smf\"   Michael Garland's format;\n";
 
 6026   cout << 
"    \".stl\"   ASCII StereoLithography;\n";
 
 6027   cout << 
"    \".stla\"  ASCII StereoLithography;\n";
 
 6028   cout << 
"    \".stlb\"  Binary StereoLithography;\n";
 
 6029   cout << 
"    \".tec\"   TECPLOT (output only);\n";
 
 6030   cout << 
"    \".tri\"   [Greg Hood ASCII triangle format];\n";
 
 6031   cout << 
"    \".tria\"  [Greg Hood ASCII triangle format];\n";
 
 6032   cout << 
"    \".trib\"  [Greg Hood binary triangle format];\n";
 
 6033   cout << 
"    \".txt\"   Text (output only);\n";
 
 6034   cout << 
"    \".ucd\"   AVS UCD file(output only);\n";
 
 6035   cout << 
"    \".vla\"   VLA;\n";
 
 6036   cout << 
"    \".wrl\"   VRML (Virtual Reality Modeling Language) (output only).\n";
 
 6037   cout << 
"    \".xgl\"   XML/OpenGL format (output only);\n";
 
 6039   cout << 
"  Current limits include:\n";
 
 6040   cout << 
"    " << 
FACE_MAX << 
" faces.\n";
 
 6041   cout << 
"    " << 
LINES_MAX << 
" line items.\n";
 
 6042   cout << 
"    " << 
COR3_MAX << 
" points.\n";
 
 6043   cout << 
"    " << 
ORDER_MAX << 
" face order.\n";
 
 6047   cout << 
"  Last modification: 04 September 2003.\n";
 
 6075   cout << 
"Commands:\n";
 
 6077   cout << 
"< file   Read data from input file;\n";
 
 6078   cout << 
"<< file  Append data in input file to current data;\n";
 
 6079   cout << 
"> file   Write output file;\n";
 
 6080   cout << 
"B        Switch the binary file byte-swapping mode;\n";
 
 6081   cout << 
"D        Switch the debugging mode;\n";
 
 6082   cout << 
"F        Print information about one face;\n";
 
 6083   cout << 
"H        Print this help list;\n";
 
 6084   cout << 
"I        Info, print out recent changes;\n";
 
 6085   cout << 
"LINES    Convert face information to lines;\n";
 
 6086   cout << 
"N        Recompute normal vectors;\n";
 
 6087   cout << 
"P        Set LINE_PRUNE option.\n";
 
 6088   cout << 
"Q        Quit;\n";
 
 6089   cout << 
"R        Reverse the normal vectors.\n";
 
 6090   cout << 
"S        Select face subset (NOT WORKING).\n";
 
 6091   cout << 
"T        Transform the data.\n";
 
 6092   cout << 
"W        Reverse the face node ordering.\n";
 
 6290   strcpy ( word, 
" " );
 
 6291   strcpy ( wordm1, 
" " );
 
 6311       strcpy ( wordm1, word );
 
 6313       count = sscanf ( next, 
"%s%n", word2, &width );
 
 6314       next = next + width;
 
 6321       strcpy ( word, word2 );
 
 6327         strcpy ( word1, word );
 
 6334         if ( strcmp ( word1, 
"HRCH:" ) != 0 )
 
 6337           cout << 
"HRC_READ - Fatal error!\n";
 
 6338           cout << 
"  The input file has a bad header.\n";;
 
 6350       if ( strcmp ( word, 
"{" ) == 0 )
 
 6352         nlbrack = nlbrack + 1;
 
 6353         level = nlbrack - nrbrack;
 
 6357           cout << 
"New level: " << 
level_name[level] << 
"\n";;
 
 6360       else if ( strcmp ( word, 
"}" ) == 0 )
 
 6362         nrbrack = nrbrack + 1;
 
 6364         if ( nlbrack < nrbrack )
 
 6367           cout << 
"HRC_READ - Fatal error!\n";
 
 6368           cout << 
"  Extraneous right bracket on line " << 
text_num << 
".\n";
 
 6369           cout << 
"  Processing field " << 
level_name[level] << 
"\n";
 
 6376       if ( strcmp ( 
level_name[level], 
"controlpoints" ) == 0 )
 
 6379         if ( strcmp ( word, 
"{" ) == 0 )
 
 6382         else if ( strcmp ( word, 
"}" ) == 0 )
 
 6390           level = nlbrack - nrbrack;
 
 6392         else if ( word[0] == 
'[' )
 
 6395         else if ( strcmp ( word, 
"position" ) == 0 )
 
 6397           count = sscanf ( next, 
"%f%n", &x, &width );
 
 6398           next = next + width;
 
 6400           count = sscanf ( next, 
"%f%n", &y, &width );
 
 6401           next = next + width;
 
 6403           count = sscanf ( next, 
"%f%n", &z, &width );
 
 6404           next = next + width;
 
 6446           cout << 
"CONTROLPOINTS: Bad data " << word << 
"\n";
 
 6454       else if ( strcmp ( 
level_name[level], 
"edges" ) == 0 )
 
 6456         if ( strcmp( word, 
"{" ) == 0 )
 
 6459         else if ( strcmp ( word, 
"}" ) == 0 )
 
 6461           level = nlbrack - nrbrack;
 
 6463         else if ( word[0] == 
'[' )
 
 6466         else if ( strcmp ( word, 
"vertices" ) == 0 )
 
 6469           count = sscanf ( next, 
"%d%n", &jval, &width );
 
 6470           next = next + width;
 
 6479           count = sscanf ( next, 
"%d%n", &jval, &width );
 
 6480           next = next + width;
 
 6500           cout << 
"EDGES: Bad data " << word << 
"\n";
 
 6508       else if ( strcmp ( 
level_name[level], 
"material" ) == 0 )
 
 6510         if ( strcmp ( word, 
"{" ) == 0 )
 
 6514         else if ( strcmp ( word, 
"}" ) == 0 )
 
 6516           level = nlbrack - nrbrack;
 
 6518         else if ( word[0] == 
'[' )
 
 6521         else if ( strcmp ( word, 
"ambient" ) == 0 )
 
 6524         else if ( strcmp ( word, 
"coc" ) == 0 )
 
 6527         else if ( strcmp ( word, 
"diffuse" ) == 0 )
 
 6530           count = sscanf ( next, 
"%f%n", &r, &width );
 
 6531           next = next + width;
 
 6534           count = sscanf ( next, 
"%f%n", &g, &width );
 
 6535           next = next + width;
 
 6538           count = sscanf ( next, 
"%f%n", &b, &width );
 
 6539           next = next + width;
 
 6543         else if ( strcmp ( word, 
"exponent" ) == 0 )
 
 6546         else if ( strcmp ( word, 
"glow" ) == 0 )
 
 6549         else if ( strcmp ( word, 
"name" ) == 0 )
 
 6551           count = sscanf ( next, 
"%s%n", word, &width );
 
 6552           next = next + width;
 
 6555         else if ( strcmp ( word, 
"reflectivity" ) == 0 )
 
 6558         else if ( strcmp ( word, 
"refracindex" ) == 0 )
 
 6561         else if ( strcmp ( word, 
"specular" ) == 0 )
 
 6564         else if ( strcmp ( word, 
"transparency" ) == 0 )
 
 6566           count = sscanf ( next, 
"%f%n", &t, &width );
 
 6567           next = next + width;
 
 6570         else if ( strcmp ( word, 
"type" ) == 0 )
 
 6576           cout << 
"MATERIAL: Bad data " << word << 
"\n";
 
 6583       else if ( strcmp ( 
level_name[level], 
"mesh" ) == 0 )
 
 6585         if ( strcmp ( word, 
"{" ) == 0 )
 
 6588         else if ( strcmp ( word, 
"}" ) == 0 )
 
 6590           level = nlbrack - nrbrack;
 
 6592         else if ( strcmp ( word, 
"discontinuity" ) == 0 )
 
 6596         else if ( strcmp ( word, 
"edges" ) == 0 )
 
 6600         else if ( strcmp ( word, 
"flag" ) == 0 )
 
 6604         else if ( strcmp ( word, 
"polygons" ) == 0 )
 
 6608         else if ( strcmp ( word, 
"vertices" ) == 0 )
 
 6615           cout << 
"MESH: Bad data " << word << 
"\n";
 
 6623       else if ( strcmp ( 
level_name[level], 
"model" ) == 0 )
 
 6625         if ( strcmp ( word, 
"{" ) == 0 )
 
 6628         else if ( strcmp ( word, 
"}" ) == 0 )
 
 6630           level = nlbrack - nrbrack;
 
 6632         else if ( strcmp ( word, 
"material" ) == 0 )
 
 6636         else if ( strcmp ( word, 
"mesh" ) == 0 )
 
 6640         else if ( strcmp ( word, 
"name" ) == 0 )
 
 6644         else if ( strcmp ( word, 
"patch" ) == 0 )
 
 6648         else if ( strcmp ( word, 
"rotation" ) == 0 )
 
 6652         else if ( strcmp ( word, 
"scaling" ) == 0 )
 
 6656         else if ( strcmp ( word, 
"spline" ) == 0 )
 
 6660         else if ( strcmp ( word, 
"translation" ) == 0 )
 
 6667           cout << 
"MODEL: Bad data " << word << 
"\n";
 
 6675       else if ( strcmp ( 
level_name[level], 
"nodes" ) == 0 )
 
 6677         if ( strcmp ( word, 
"{" ) == 0 )
 
 6683         else if ( strcmp ( word, 
"}" ) == 0 )
 
 6685           level = nlbrack - nrbrack;
 
 6687         else if ( word[0] == 
'[' )
 
 6690         else if ( strcmp ( word, 
"normal" ) == 0 )
 
 6692           count = sscanf ( next, 
"%f%n", &x, &width );
 
 6693           next = next + width;
 
 6695           count = sscanf ( next, 
"%f%n", &y, &width );
 
 6696           next = next + width;
 
 6698           count = sscanf ( next, 
"%f%n", &z, &width );
 
 6699           next = next + width;
 
 6709         else if ( strcmp ( word, 
"uvTexture" ) == 0 )
 
 6711           count = sscanf ( next, 
"%f%n", &x, &width );
 
 6712           next = next + width;
 
 6714           count = sscanf ( next, 
"%f%n", &y, &width );
 
 6715           next = next + width;
 
 6723         else if ( strcmp ( word, 
"vertex" ) == 0 )
 
 6725           count = sscanf ( next, 
"%d%n", &jval, &width );
 
 6726           next = next + width;
 
 6739         else if ( strcmp ( word, 
"vertexColor" ) == 0 )
 
 6741           count = sscanf ( next, 
"%d%n", &jval, &width );
 
 6742           next = next + width;
 
 6744           count = sscanf ( next, 
"%d%n", &jval, &width );
 
 6745           next = next + width;
 
 6747           count = sscanf ( next, 
"%d%n", &jval, &width );
 
 6748           next = next + width;
 
 6750           count = sscanf ( next, 
"%d%n", &jval, &width );
 
 6751           next = next + width;
 
 6756           cout << 
"NODES: Bad data " << word << 
"\n";
 
 6765       else if ( strcmp ( 
level_name[level], 
"patch" ) == 0 )
 
 6767         if ( strcmp ( word, 
"{" ) == 0 )
 
 6770         else if ( strcmp ( word, 
"}" ) == 0 )
 
 6772           level = nlbrack - nrbrack;
 
 6774         else if ( strcmp ( word, 
"approx_type" ) == 0 )
 
 6777         else if ( strcmp ( word, 
"controlpoints" ) == 0 )
 
 6780         else if ( strcmp ( word, 
"curv_u" ) == 0 )
 
 6783         else if ( strcmp ( word, 
"curv_v" ) == 0 )
 
 6786         else if ( strcmp ( word, 
"recmin" ) == 0 )
 
 6789         else if ( strcmp ( word, 
"recmax" ) == 0 )
 
 6792         else if ( strcmp ( word, 
"recursion" ) == 0 )
 
 6795         else if ( strcmp ( word, 
"spacial" ) == 0 )
 
 6798         else if ( strcmp ( word, 
"taggedpoints" ) == 0 )
 
 6801         else if ( strcmp ( word, 
"ucurve" ) == 0 )
 
 6804         else if ( strcmp ( word, 
"ustep" ) == 0 )
 
 6807         else if ( strcmp ( word, 
"utension" ) == 0 )
 
 6810         else if ( strcmp ( word, 
"utype" ) == 0 )
 
 6813         else if ( strcmp ( word, 
"vclose" ) == 0 )
 
 6816         else if ( strcmp ( word, 
"vcurve" ) == 0 )
 
 6819         else if ( strcmp ( word, 
"viewdep" ) == 0 )
 
 6822         else if ( strcmp ( word, 
"vpoint" ) == 0 )
 
 6825         else if ( strcmp ( word, 
"vstep" ) == 0 )
 
 6828         else if ( strcmp ( word, 
"vtension" ) == 0 )
 
 6831         else if ( strcmp ( word, 
"vtype" ) == 0 )
 
 6837           cout << 
"PATCH: Bad data " << word << 
"\n";
 
 6844       else if ( strcmp ( 
level_name[level], 
"polygons" ) == 0 )
 
 6846         if ( strcmp ( word, 
"{" ) == 0 )
 
 6849         else if ( strcmp ( word, 
"}" ) == 0 )
 
 6851           level = nlbrack - nrbrack;
 
 6853         else if ( word[0] == 
'[' )
 
 6856         else if ( strcmp ( word, 
"material" ) == 0 )
 
 6858           count = sscanf ( next, 
"%d%n", &jval, &width );
 
 6859           next = next + width;
 
 6861           for ( ivert = 0; ivert < 
ORDER_MAX; ivert++ )
 
 6867         else if ( strcmp ( word, 
"nodes" ) == 0 )
 
 6869           count = sscanf ( next, 
"%s%n", word2, &width );
 
 6870           next = next + width;
 
 6875           cout << 
"POLYGONS: Bad data " << word << 
"\n";
 
 6883       else if ( strcmp ( 
level_name[level], 
"spline" ) == 0 )
 
 6885         if ( strcmp ( word, 
"{" ) == 0 )
 
 6888         else if ( strcmp ( word, 
"}" ) == 0 )
 
 6890           level = nlbrack - nrbrack;
 
 6892         else if ( strcmp ( word, 
"controlpoints" ) == 0 )
 
 6899         else if ( strcmp ( word, 
"name" ) == 0 )
 
 6903         else if ( strcmp ( word, 
"nbKeys" ) == 0 )
 
 6907         else if ( strcmp ( word, 
"step" ) == 0 )
 
 6911         else if ( strcmp ( word, 
"tension" ) == 0 )
 
 6915         else if ( strcmp ( word, 
"type" ) == 0 )
 
 6922           cout << 
"SPLINE: Bad data " << word << 
"\n";
 
 6930       else if ( strcmp ( 
level_name[level], 
"taggedpoints" ) == 0 )
 
 6932         if ( strcmp ( word, 
"{" ) == 0 )
 
 6935         else if ( strcmp ( word, 
"}" ) == 0 )
 
 6937           level = nlbrack - nrbrack;
 
 6939         else if ( word[0] == 
'[' )
 
 6942         else if ( strcmp ( word, 
"tagged" ) == 0 )
 
 6948           cout << 
"TAGGEDPOINTS: Bad data " << word << 
"\n";
 
 6956       else if ( strcmp ( 
level_name[level], 
"texture" ) == 0 )
 
 6958         if ( strcmp ( word, 
"{" ) == 0 )
 
 6962         else if ( strcmp ( word, 
"}" ) == 0 )
 
 6964           level = nlbrack - nrbrack;
 
 6966         else if ( word[0] == 
'[' )
 
 6969         else if ( strcmp ( word, 
"ambient" ) == 0 )
 
 6972         else if ( strcmp ( word, 
"anim" ) == 0 )
 
 6975         else if ( strcmp ( word, 
"blending" ) == 0 )
 
 6978         else if ( strcmp ( word, 
"diffuse" ) == 0 )
 
 6981         else if ( strcmp ( word, 
"effect" ) == 0 )
 
 6984         else if ( strcmp ( word, 
"glbname" ) == 0 )
 
 6987         else if ( strcmp ( word, 
"method" ) == 0 )
 
 6990         else if ( strcmp ( word, 
"name" ) == 0 )
 
 6992           count = sscanf ( next, 
"%s%n", word, &width );
 
 6993           next = next + width;
 
 6996         else if ( strcmp ( word, 
"offset" ) == 0 )
 
 6999         else if ( strcmp ( word, 
"pixelinterp" ) == 0 )
 
 7002         else if ( strcmp ( word, 
"reflect" ) == 0 )
 
 7005         else if ( strcmp ( word, 
"reflmap" ) == 0 )
 
 7008         else if ( strcmp ( word, 
"repeat" ) == 0 )
 
 7011         else if ( strcmp ( word, 
"rotation" ) == 0 )
 
 7014         else if ( strcmp ( word, 
"roughness" ) == 0 )
 
 7017         else if ( strcmp ( word, 
"scaling" ) == 0 )
 
 7020         else if ( strcmp ( word, 
"specular" ) == 0 )
 
 7023         else if ( strcmp ( word, 
"transp" ) == 0 )
 
 7026         else if ( strcmp ( word, 
"txtsup_rot" ) == 0 )
 
 7029         else if ( strcmp ( word, 
"txtsup_scal" ) == 0 )
 
 7032         else if ( strcmp ( word, 
"txtsup_trans" ) == 0 )
 
 7038           cout << 
"TEXTURE: Bad data " << word << 
"\n";
 
 7045       else if ( strcmp ( 
level_name[level], 
"vertices" ) == 0 )
 
 7047         if ( strcmp ( word, 
"{" ) == 0 )
 
 7050         else if ( strcmp ( word, 
"}" ) == 0 )
 
 7052           level = nlbrack - nrbrack;
 
 7054         else if ( word[0] == 
'[' )
 
 7057         else if ( strcmp ( word, 
"position" ) == 0 )
 
 7059           count = sscanf ( next, 
"%f%n", &x, &width );
 
 7060           next = next + width;
 
 7062           count = sscanf ( next, 
"%f%n", &y, &width );
 
 7063           next = next + width;
 
 7065           count = sscanf ( next, 
"%f%n", &z, &width );
 
 7066           next = next + width;
 
 7079           cout << 
"VERTICES: Bad data " << word << 
"\n";
 
 7293   fprintf ( fileout, 
"HRCH: Softimage 4D Creative Environment v3.00\n" );
 
 7294   fprintf ( fileout, 
"\n" );
 
 7295   fprintf ( fileout, 
"\n" );
 
 7298   fprintf ( fileout, 
"model\n" );
 
 7299   fprintf ( fileout, 
"{\n" );
 
 7300   fprintf ( fileout, 
"  name         \"%s\"\n", 
object_name );
 
 7301   fprintf ( fileout, 
"  scaling      1.000 1.000 1.000\n" );
 
 7302   fprintf ( fileout, 
"  rotation     0.000 0.000 0.000\n" );
 
 7303   fprintf ( fileout, 
"  translation  0.000 0.000 0.000\n" );
 
 7308     fprintf ( fileout, 
"\n" );
 
 7309     fprintf ( fileout, 
"  mesh\n" );
 
 7310     fprintf ( fileout, 
"  {\n" );
 
 7311     fprintf ( fileout, 
"    flag    ( PROCESS )\n" );
 
 7312     fprintf ( fileout, 
"    discontinuity  60.000\n" );
 
 7319       fprintf ( fileout, 
"\n" );
 
 7320       fprintf ( fileout, 
"    vertices %d\n", 
cor3_num );
 
 7321       fprintf ( fileout, 
"    {\n" );
 
 7326         fprintf ( fileout, 
"      [%d] position %f %f %f\n", j, 
cor3[0][j],
 
 7330       fprintf ( fileout, 
"    }\n" );
 
 7336     fprintf ( fileout, 
"\n" );
 
 7337     fprintf ( fileout, 
"    polygons %d\n", 
face_num );
 
 7338     fprintf ( fileout, 
"    {\n" );
 
 7341     for ( iface = 0; iface < 
face_num; iface++ )
 
 7343       fprintf ( fileout, 
"      [%d] nodes %d\n", iface, 
face_order[iface] );
 
 7344       fprintf ( fileout, 
"      {\n" );
 
 7347       for ( ivert = 0; ivert < 
face_order[iface]; ivert++ )
 
 7349         fprintf ( fileout, 
"        [%d] vertex %d\n", ivert, 
face[ivert][iface] );
 
 7350         fprintf ( fileout, 
"            normal %f %f %f\n",
 
 7353         fprintf ( fileout, 
"            uvTexture  %f %f\n",
 
 7355         fprintf ( fileout, 
"            vertexColor  255 178 178 178\n" );
 
 7358       fprintf ( fileout, 
"      }\n" );
 
 7359       fprintf ( fileout, 
"      material %d\n", 
face_material[iface] );
 
 7362     fprintf ( fileout, 
"    }\n" );
 
 7363     fprintf ( fileout, 
"  }\n" );
 
 7413       npts = jhi + 1 - jlo;
 
 7415       fprintf ( fileout, 
"\n" );
 
 7416       fprintf ( fileout, 
"  spline\n" );
 
 7417       fprintf ( fileout, 
"  {\n" );
 
 7418       fprintf ( fileout, 
"    name     \"spl%d\"\n", nseg );
 
 7419       fprintf ( fileout, 
"    type     LINEAR\n" );
 
 7420       fprintf ( fileout, 
"    nbKeys   %d\n", npts );
 
 7421       fprintf ( fileout, 
"    tension  0.000\n" );
 
 7422       fprintf ( fileout, 
"    step     1\n" );
 
 7423       fprintf ( fileout, 
"\n" );
 
 7426       fprintf ( fileout, 
"    controlpoints\n" );
 
 7427       fprintf ( fileout, 
"    {\n" );
 
 7430       for ( j = jlo; j <= jhi; j++ )
 
 7434         fprintf ( fileout, 
"      [%d] position %f %f %f\n", jrel,
 
 7439       fprintf ( fileout, 
"    }\n" );
 
 7440       fprintf ( fileout, 
"  }\n" );
 
 7449     fprintf ( fileout, 
"  material [%d]\n", 
i );
 
 7450     fprintf ( fileout, 
"  {\n" );
 
 7452     fprintf ( fileout, 
"    type           PHONG\n" );
 
 7459     fprintf ( fileout, 
"    exponent      50.0\n" );
 
 7460     fprintf ( fileout, 
"    reflectivity   0.0\n" );
 
 7461     fprintf ( fileout, 
"    transparency   %f\n", 1.0 - 
material_rgba[3][
i] );
 
 7462     fprintf ( fileout, 
"    refracIndex    1.0\n" );
 
 7463     fprintf ( fileout, 
"    glow           0\n" );
 
 7464     fprintf ( fileout, 
"    coc            0.0\n" );
 
 7465     fprintf ( fileout, 
"  }\n" );
 
 7475     fprintf ( fileout, 
"  texture [%d]\n", 
i );
 
 7476     fprintf ( fileout, 
"  {\n" );
 
 7478     fprintf ( fileout, 
"    glbname        \"t2d1\"\n" );
 
 7479     fprintf ( fileout, 
"    anim           STATIC\n" );
 
 7480     fprintf ( fileout, 
"    method         XY\n" );
 
 7481     fprintf ( fileout, 
"    repeat         1 1\n" );
 
 7482     fprintf ( fileout, 
"    scaling        1.000  1.000\n" );
 
 7483     fprintf ( fileout, 
"    offset         0.000  0.000\n" );
 
 7484     fprintf ( fileout, 
"    pixelInterp\n" );
 
 7485     fprintf ( fileout, 
"    effect         INTENSITY\n" );
 
 7486     fprintf ( fileout, 
"    blending       1.000\n" );
 
 7487     fprintf ( fileout, 
"    ambient        0.977\n" );
 
 7488     fprintf ( fileout, 
"    diffuse        1.000\n" );
 
 7489     fprintf ( fileout, 
"    specular       0.966\n" );
 
 7490     fprintf ( fileout, 
"    reflect        0.000\n" );
 
 7491     fprintf ( fileout, 
"    transp         0.000\n" );
 
 7492     fprintf ( fileout, 
"    roughness      0.000\n" );
 
 7493     fprintf ( fileout, 
"    reflMap        1.000\n" );
 
 7494     fprintf ( fileout, 
"    rotation       0.000\n" );
 
 7495     fprintf ( fileout, 
"    txtsup_rot     0.000  0.000  0.000\n" );
 
 7496     fprintf ( fileout, 
"    txtsup_trans   0.000  0.000  0.000\n" );
 
 7497     fprintf ( fileout, 
"    txtsup_scal    1.000  1.000  1.000\n" );
 
 7498     fprintf ( fileout, 
"  }\n" );
 
 7503   fprintf ( fileout, 
"}\n" );
 
 7509   cout << 
"HRC_WRITE - Wrote " << 
text_num << 
" text lines.\n";
 
 7654     cout << 
"I4_MODP - Fatal error!\n";
 
 7655     cout << 
"  I4_MODP ( I, J ) called with J = " << j << 
"\n";
 
 7663     value = value + abs ( j );
 
 7728   jlo = 
i4_min ( ilo, ihi );
 
 7729   jhi = 
i4_max ( ilo, ihi );
 
 7731   wide = jhi + 1 - jlo;
 
 7739     value = jlo + 
i4_modp ( ival - jlo, wide );
 
 7778     cout << 
"INIT_PROGRAM_DATA: Program data initialized.\n";
 
 7833   cout << 
"Enter command (H for help)\n";
 
 7846     if ( *next == 
'\0' )
 
 7854     if ( *next == 
'<' && *(next+1) == 
'<' )
 
 7864         cout << 
"INTERACT - Fatal error!\n";
 
 7865         cout << 
"  Failure reported from DATA_READ.\n";
 
 7871     else if ( *next == 
'<' )
 
 7883         cout << 
"INTERACT - Fatal error!\n";
 
 7884         cout << 
"  DATA_READ failed to read input data.\n";
 
 7890     else if ( *next == 
'>' )
 
 7897       if ( ierror == 
ERROR )
 
 7900         cout << 
"INTERACT - Fatal error!\n";
 
 7901         cout << 
"  OUTPUT_DATA failed to write output data.\n";
 
 7908     else if ( *next == 
'B' || *next == 
'b' )
 
 7913         cout << 
"Byte_swapping reset to FALSE.\n";
 
 7918         cout << 
"Byte_swapping reset to TRUE.\n";
 
 7925     else if ( *next == 
'D' || *next == 
'd' )
 
 7930         cout << 
"Debug reset to FALSE.\n";
 
 7935         cout << 
"Debug reset to TRUE.\n";
 
 7941     else if ( *next == 
'f' || *next == 
'F' )
 
 7944       cout << 
"  Enter a face index between 0 and " << 
face_num-1 << 
"\n";
 
 7945       scanf ( 
"%d", &iface );
 
 7951     else if ( *next == 
'h' || *next == 
'H' )
 
 7958     else if ( *next == 
'i' || *next == 
'I')
 
 7966     else if ( *next == 
'l' || *next == 
'L')
 
 7971         cout << 
"INTERACT - Note:\n";
 
 7972         cout << 
"  Face information will be converted\n";
 
 7973         cout << 
"  to line information.\n";
 
 7980             cout << 
"INTERACT - Note:\n";
 
 7981             cout << 
"  Some face information was lost.\n";
 
 7982             cout << 
"  The maximum number of lines is " << 
LINES_MAX << 
"\n";
 
 7983             cout << 
"  but we would need at least " << 
line_num << 
".\n";
 
 7994         cout << 
"INTERACT - Note:\n";
 
 7995         cout << 
"  There were no faces to convert.\n";
 
 8003     else if ( *next == 
'n' || *next == 
'N' )
 
 8005       for ( iface = 0; iface < 
face_num; iface++ )
 
 8007         for ( 
i = 0; 
i < 3; 
i++ )
 
 8013       for ( iface = 0; iface < 
face_num; iface++ )
 
 8015          for ( ivert = 0; ivert < 
face_order[iface]; ivert++ )
 
 8017           for ( 
i = 0; 
i < 3; 
i++ )
 
 8033     else if ( *next == 
'p' || *next == 
'P' )
 
 8036       cout << 
"INTERACT - SET LINE PRUNING OPTION.\n";
 
 8038       cout << 
"  LINE_PRUNE = 0 means no line pruning.\n";
 
 8039       cout << 
"               nonzero means line pruning.\n";
 
 8041       cout << 
"  Current value is LINE_PRUNE = " << 
line_prune << 
".\n";
 
 8043       cout << 
"  Enter new value for LINE_PRUNE.\n";
 
 8047         cout << 
"  ??? Error trying to read input.\n" ;
 
 8052         cout << 
"  New value is LINE_PRUNE = " << 
line_prune << 
".\n";
 
 8058     else if ( *next == 
'q' || *next == 
'Q' )
 
 8061       cout << 
"INTERACT - Normal end of execution.\n";
 
 8067     else if ( *next == 
'r' || *next == 
'R' )
 
 8069       for ( icor3 = 0; icor3 < 
cor3_num; icor3++ )
 
 8071         for ( 
i = 0; 
i < 3; 
i++ )
 
 8077       for ( iface = 0; iface < 
face_num; iface++ )
 
 8079         for ( 
i = 0; 
i < 3; 
i++ )
 
 8085       for ( iface = 0; iface < 
face_num; iface++ )
 
 8087         for ( ivert = 0; ivert < 
face_order[iface]; ivert++ )
 
 8089           for ( 
i = 0; 
i < 3; 
i++ )
 
 8097       cout << 
"INTERACT - Note:\n";
 
 8098       cout << 
"  Reversed node, face and vertex normals.\n";
 
 8103     else if ( *next == 
's' || *next == 
'S' )
 
 8110     else if ( *next == 
't' || *next == 
'T' )
 
 8113       cout << 
"For now, we only offer point scaling.\n";
 
 8114       cout << 
"Enter X, Y, Z scale factors:\n";
 
 8116       scanf ( 
"%f %f %f", &x, &y, &z );
 
 8125       for ( iface = 0; iface < 
face_num; iface++ )
 
 8127         for ( 
i = 0; 
i < 3; 
i++ )
 
 8133       for ( iface = 0; iface < 
face_num; iface++ )
 
 8135          for ( ivert = 0; ivert < 
face_order[iface]; ivert++ )
 
 8137           for ( 
i = 0; 
i < 3; 
i++ )
 
 8153     else if ( *next == 
'u' || *next == 
'U' )
 
 8159     else if ( *next == 
'v' || *next == 
'V' )
 
 8165     else if ( *next == 
'w' || *next == 
'W' )
 
 8169         for ( iface = 0; iface < 
face_num; iface++ )
 
 8173           for ( ivert = 0; ivert < m/2; ivert++ )
 
 8175             jvert = m - ivert - 1;
 
 8177             itemp = 
face[ivert][iface];
 
 8178             face[ivert][iface] = 
face[jvert][iface];
 
 8179             face[jvert][iface] = itemp;
 
 8185             for ( 
i = 0; 
i < 3; 
i++ )
 
 8195         cout << 
"INTERACT - Note:\n";
 
 8196         cout << 
"  Reversed face node ordering.\n";
 
 8205       cout << 
"INTERACT: Warning!\n";
 
 8206       cout << 
"  Your command was not recognized.\n";
 
 8210     cout << 
"Enter command (H for help)\n";
 
 8419   int   normal_num_temp;
 
 8420   int   text_numure_temp;
 
 8448   normal_num_temp = 0;
 
 8449   text_numure_temp = 0;
 
 8452   strcpy ( word, 
" " );
 
 8453   strcpy ( wordm1, 
" " );
 
 8472     while ( 
input[
i] != 
'\0' )
 
 8484     while ( 
input[
i] != 
'\0' )
 
 8497         if ( result == 
ERROR )
 
 8512       strcpy ( wordm1, word );
 
 8513       strcpy ( word, 
" " );
 
 8515       count = sscanf ( next, 
"%s%n", word, &width );
 
 8516       next = next + width;
 
 8527         strcpy ( word1, word );
 
 8534         if ( !
s_eqi ( word1, 
"#Inventor" ) )
 
 8537           cout << 
"IV_READ - Fatal error!\n";
 
 8538           cout << 
"  The input file has a bad header.\n";
 
 8551       if ( word[1] == 
'#' )
 
 8560       if ( strcmp ( word, 
"{" ) == 0 || strcmp ( word, 
"[" ) == 0 )
 
 8562         nlbrack = nlbrack + 1;
 
 8563         level = nlbrack - nrbrack;
 
 8567           cout << 
"Begin level: " << wordm1 << 
"\n";
 
 8570       else if ( strcmp ( word, 
"}" ) == 0 || strcmp ( word, 
"]" ) == 0 )
 
 8572         nrbrack = nrbrack + 1;
 
 8574         if ( nlbrack < nrbrack )
 
 8577           cout << 
"IV_READ - Fatal error!\n";
 
 8578           cout << 
"  Extraneous right bracket on line " << 
text_num << 
".\n";
 
 8579           cout << 
"  Currently processing field " << 
level_name[level] << 
"\n";
 
 8588         if ( strcmp ( word, 
"{" ) == 0 )
 
 8591         else if ( strcmp ( word, 
"}" ) == 0 )
 
 8593           level = nlbrack - nrbrack;
 
 8595         else if ( 
s_eqi ( word, 
"RGB" ) )
 
 8601           cout << 
"Bad data " << word << 
"\n";
 
 8609         if ( strcmp ( word, 
"{" ) == 0 )
 
 8612         else if ( strcmp ( word, 
"}" ) == 0 )
 
 8614           level = nlbrack - nrbrack;
 
 8616         else if ( 
s_eqi ( word, 
"POINT" ) )
 
 8622           cout << 
"COORDINATE3: Bad data " << word << 
"\n";
 
 8630         if ( strcmp ( word, 
"{" ) == 0 )
 
 8633         else if ( strcmp ( word, 
"}" ) == 0 )
 
 8635           level = nlbrack - nrbrack;
 
 8637         else if ( 
s_eqi ( word, 
"POINT" ) )
 
 8643           cout << 
"COORDINATE4: Bad data " << word << 
"\n";
 
 8651         if ( strcmp ( word, 
"[" ) == 0 )
 
 8655         else if ( strcmp ( word, 
"]" ) == 0 )
 
 8657           level = nlbrack - nrbrack;
 
 8665           count = sscanf ( word, 
"%d%n", &jval, &width );
 
 8679                   jval = jval + cor3_num_old;
 
 8698           count = sscanf ( word, 
"%d%n", &jval, &width );
 
 8743           count = sscanf ( word, 
"%d%n", &jval, &width );
 
 8755               iz = jval + cor3_num_old;
 
 8765               else if ( ivert == 1 )
 
 8772               else if ( ivert == 2 )
 
 8785                   if ( ( ivert % 2 ) == 0 )
 
 8807                 for ( 
i = 0; 
i < 3; 
i++ )
 
 8821         if ( strcmp ( word, 
"{" ) == 0 )
 
 8824         else if ( strcmp ( word, 
"}" ) == 0 )
 
 8826           level = nlbrack - nrbrack;
 
 8828         else if ( 
s_eqi ( word, 
"COORDINDEX" ) )
 
 8832         else if ( 
s_eqi ( word, 
"MATERIALINDEX" ) )
 
 8835         else if ( 
s_eqi ( word, 
"NORMALINDEX" ) )
 
 8838         else if ( 
s_eqi ( word, 
"TEXTURECOORDINDEX" ) )
 
 8849           cout << 
"Bad data " << word << 
"\n";
 
 8857         if ( strcmp ( word, 
"{" ) == 0 )
 
 8860         else if ( strcmp ( word, 
"}" ) == 0 )
 
 8862           level = nlbrack - nrbrack;
 
 8864         else if ( 
s_eqi ( word, 
"COORDINDEX" ) )
 
 8867         else if ( 
s_eqi ( word, 
"MATERIALINDEX" ) )
 
 8873           cout << 
"Bad data " << word << 
"\n";
 
 8881         if ( strcmp ( word, 
"{" ) == 0 )
 
 8884         else if ( strcmp ( word, 
"}" ) == 0 )
 
 8886           level = nlbrack - nrbrack;
 
 8888         else if ( 
s_eqi ( word, 
"NUMUCONTROLPOINTS" ) )
 
 8890           count = sscanf ( word, 
"%d%n", &jval, &width );
 
 8897               cout << 
"NU = " << nu << 
"\n";
 
 8904             cout << 
"Bad data " << word << 
"\n";
 
 8907         else if ( 
s_eqi ( word, 
"NUMVCONTROLPOINTS" ) )
 
 8909           count = sscanf ( word, 
"%d%n", &jval, &width );
 
 8916               cout << 
"NV = " << nv << 
"\n";
 
 8925         else if ( 
s_eqi ( word, 
"COORDINDEX" ) )
 
 8928         else if ( 
s_eqi ( word, 
"UKNOTVECTOR" ) )
 
 8931         else if ( 
s_eqi ( word, 
"VKNOTVECTOR" ) )
 
 8937           cout << 
"Bad data " << word << 
"\n";
 
 8945         if ( strcmp ( word, 
"{" ) == 0 )
 
 8948         else if ( strcmp ( word, 
"}" ) == 0 )
 
 8950           level = nlbrack - nrbrack;
 
 8952         else if ( 
s_eqi ( word, 
"VERTEXPROPERTY" ) )
 
 8954           count = sscanf ( next, 
"%s%n", word, &width );
 
 8955           next = next + width;
 
 8957         else if ( 
s_eqi ( word, 
"COORDINDEX" ) )
 
 8961         else if ( 
s_eqi ( word, 
"NORMALINDEX" ) )
 
 8963           count = sscanf ( next, 
"%s%n", word, &width );
 
 8964           next = next + width;
 
 8969           cout << 
"Bad data " << word << 
"\n";
 
 8977         if ( strcmp ( word, 
"{" ) == 0 )
 
 8980         else if ( strcmp ( word, 
"}" ) == 0 )
 
 8982           level = nlbrack - nrbrack;
 
 8984         else if ( 
s_eqi ( word, 
"STRING" ) )
 
 8987         else if ( strcmp ( word, 
"\"" ) == 0 )
 
 9000         if ( strcmp ( word, 
"{" ) == 0 )
 
 9003         else if ( strcmp ( word, 
"}" ) == 0 )
 
 9005           level = nlbrack - nrbrack;
 
 9007         else if ( 
s_eqi ( word, 
"model" ) )
 
 9020         if ( strcmp ( word, 
"{" ) == 0 )
 
 9023         else if ( strcmp ( word, 
"}" ) == 0 )
 
 9025           level = nlbrack - nrbrack;
 
 9027         else if ( 
s_eqi ( word, 
"AMBIENTCOLOR" ) )
 
 9030         else if ( 
s_eqi ( word, 
"EMISSIVECOLOR" ) )
 
 9033         else if ( 
s_eqi ( word, 
"DIFFUSECOLOR" ) )
 
 9036         else if ( 
s_eqi ( word, 
"SHININESS" ) )
 
 9039         else if ( 
s_eqi ( word, 
"SPECULARCOLOR" ) )
 
 9042         else if ( 
s_eqi ( word, 
"TRANSPARENCY" ) )
 
 9055         if ( strcmp ( word, 
"{" ) == 0 )
 
 9058         else if ( strcmp ( word, 
"}" ) == 0 )
 
 9060           level = nlbrack - nrbrack;
 
 9062         else if ( 
s_eqi ( word, 
"VALUE" ) )
 
 9065           next = next + width;
 
 9069           count = sscanf ( next, 
"%f%n", &rval, &width );
 
 9070           next = next + width;
 
 9078             cout << 
"Bad data " << word << 
"\n";
 
 9087         if ( strcmp ( word, 
"[" ) == 0 )
 
 9091         else if ( strcmp ( word, 
"]" ) == 0 )
 
 9093           level = nlbrack - nrbrack;
 
 9100           count = sscanf ( word, 
"%d%n", &jval, &width );
 
 9107               face_num2 = face_num2 + 1;
 
 9115                   jval = jval + cor3_num_old;
 
 9125             cout << 
"Bad data " << word << 
"\n";
 
 9133           count = sscanf ( word, 
"%d%n", &jval, &width );
 
 9141                 jval = jval + cor3_num_old;
 
 9144               line_num2 = line_num2 + 1;
 
 9150             cout << 
"Bad data " << word << 
"\n";
 
 9155           count = sscanf ( word, 
"%d%n", &jval, &width );
 
 9163             cout << 
"Bad data " << word << 
"\n";
 
 9172         if ( strcmp ( word, 
"{" ) == 0 )
 
 9175         else if ( strcmp ( word, 
"}" ) == 0 )
 
 9177           level = nlbrack - nrbrack;
 
 9179         else if ( 
s_eqi ( word, 
"MATRIX" ) )
 
 9186           count = sscanf ( word, 
"%f%n", &rval, &width );
 
 9218           if ( strcmp ( word, 
"[" ) == 0 )
 
 9222           else if ( strcmp ( word, 
"]" ) == 0 )
 
 9224             level = nlbrack - nrbrack;
 
 9229             count = sscanf ( word, 
"%f%n", &rval, &width );
 
 9243                 inormface = inormface + 1;
 
 9253           if ( strcmp ( word, 
"{" ) == 0 )
 
 9257           else if ( strcmp ( word, 
"}" ) == 0 )
 
 9259             level = nlbrack - nrbrack;
 
 9261           else if ( 
s_eqi ( word, 
"VECTOR" ) )
 
 9266             count = sscanf ( word, 
"%f%n", &rval, &width );
 
 9289               cout << 
"Bad data " << word << 
"\n";
 
 9301         if ( strcmp ( word, 
"{" ) == 0 )
 
 9304         else if ( strcmp ( word, 
"}" ) == 0 )
 
 9306           level = nlbrack - nrbrack;
 
 9308         else if ( 
s_eqi ( word, 
"VALUE" ) )
 
 9311           next = next + width;
 
 9315           count = sscanf ( word, 
"%f%n", &rval, &width );
 
 9323             cout << 
"Bad data " << word << 
"\n";
 
 9337           count = sscanf ( word, 
"%d%n", &jval, &width );
 
 9342           else if ( strcmp ( word, 
"[" ) == 0 )
 
 9345           else if ( strcmp ( word, 
"]" ) == 0 )
 
 9355           if ( strcmp ( word, 
"[" ) == 0 )
 
 9359           else if ( strcmp ( word, 
"]" ) == 0 )
 
 9361             level = nlbrack - nrbrack;
 
 9365             count = sscanf ( word, 
"%d%n", &jval, &width );
 
 9372                 iface_num = iface_num + 1;
 
 9378                   for ( 
i = 0; 
i < 3; 
i++ )
 
 9389               cout << 
"Bad data " << word << 
"\n";
 
 9401           if ( strcmp ( word, 
"[" ) == 0 )
 
 9406           else if ( strcmp ( word, 
"]" ) == 0 )
 
 9408             level = nlbrack - nrbrack;
 
 9412             count = sscanf ( word, 
"%f%n", &rval, &width );
 
 9450           if ( strcmp ( word, 
"[" ) == 0 )
 
 9453             text_numure_temp = 0;
 
 9455           else if ( strcmp ( word, 
"]" ) == 0 )
 
 9457             level = nlbrack - nrbrack;
 
 9462             count = sscanf ( word, 
"%f%n", &rval, &width );
 
 9473                 text_numure_temp = text_numure_temp + 1;
 
 9478               cout << 
"TextureCoordinate2 { Point [: Bad data\n";
 
 9495           if ( strcmp ( word, 
"[" ) == 0 )
 
 9499           else if ( strcmp ( word, 
"]" ) == 0 )
 
 9501             level = nlbrack - nrbrack;
 
 9505             count = sscanf ( word, 
"%f%n", &rval, &width );
 
 9511               icolor = icolor + 1;
 
 9522               cout << 
"Bad data " << word << 
"\n";
 
 9531           cout << 
"HALSBAND DES TODES!\n";
 
 9533           if ( strcmp ( word, 
"[" ) == 0 )
 
 9538           else if ( strcmp ( word, 
"]" ) == 0 )
 
 9540             level = nlbrack - nrbrack;
 
 9545             count = sscanf ( word, 
"%f%n", &rval, &width );
 
 9555                 icolor = icolor + 1;
 
 9564                     icface = icface + 1;
 
 9572               cout << 
"Bad data " << word << 
"\n";
 
 9583         if ( strcmp ( word, 
"{" ) == 0 )
 
 9586         else if ( strcmp ( word, 
"}" ) == 0 )
 
 9588           level = nlbrack - nrbrack;
 
 9600         if ( strcmp ( word, 
"{" ) == 0 )
 
 9603         else if ( strcmp ( word, 
"}" ) == 0 )
 
 9605           level = nlbrack - nrbrack;
 
 9607         else if ( 
s_eqi ( word, 
"CREASEANGLE" ) )
 
 9609           count = sscanf ( next, 
"%f%n", &rval, &width );
 
 9610           next = next + width;
 
 9615             cout << 
"Bad data " << word << 
"\n";
 
 9618         else if ( 
s_eqi ( word, 
"FACETYPE" ) )
 
 9620           count = sscanf ( next, 
"%s%n", word, &width );
 
 9621           next = next + width;
 
 9623         else if ( 
s_eqi ( word, 
"SHAPETYPE" ) )
 
 9625           count = sscanf ( next, 
"%s%n", word, &width );
 
 9626           next = next + width;
 
 9628         else if ( 
s_eqi ( word, 
"VERTEXORDERING" ) )
 
 9630           count = sscanf ( next, 
"%s%n", word, &width );
 
 9631           next = next + width;
 
 9636           cout << 
"Bad data " << word << 
"\n";
 
 9644         if ( strcmp ( word, 
"{" ) == 0 )
 
 9647         else if ( strcmp ( word, 
"}" ) == 0 )
 
 9649           level = nlbrack - nrbrack;
 
 9652         else if ( 
s_eqi ( word, 
"BLENDCOLOR" ) )
 
 9658         else if ( 
s_eqi ( word, 
"FILENAME" ) )
 
 9660           count = sscanf ( next, 
"%s%n", word, &width );
 
 9661           next = next + width;
 
 9676           } 
while ( c != 
'\0' );
 
 9679         else if ( 
s_eqi ( word, 
"IMAGE" ) )
 
 9682         else if ( 
s_eqi ( word, 
"MODEL" ) )
 
 9684           count = sscanf ( next, 
"%s%n", word, &width );
 
 9685           next = next + width;
 
 9687         else if ( 
s_eqi ( word, 
"WRAPS" ) )
 
 9689           count = sscanf ( next, 
"%s%n", word, &width );
 
 9690           next = next + width;
 
 9692         else if ( 
s_eqi ( word, 
"WRAPT" ) )
 
 9694           count = sscanf ( next, 
"%s%n", word, &width );
 
 9695           next = next + width;
 
 9706         if ( strcmp ( word, 
"{" ) == 0 )
 
 9709         else if ( strcmp ( word, 
"}" ) == 0 )
 
 9711           level = nlbrack - nrbrack;
 
 9713         else if ( 
s_eqi ( word, 
"POINT" ) )
 
 9719           cout << 
"TEXTURECOORDINATE2: Bad data " << word << 
"\n";
 
 9727         if ( strcmp ( word, 
"{" ) == 0 )
 
 9730         else if ( strcmp ( word, 
"}" ) == 0 )
 
 9732           level = nlbrack - nrbrack;
 
 9734         else if ( 
s_eqi ( word, 
"VALUE" ) )
 
 9737           next = next + width;
 
 9742           cout << 
"Bad data " << word << 
"\n";
 
 9750         if ( strcmp ( word, 
"[" ) == 0 )
 
 9755         else if ( strcmp ( word, 
"]" ) == 0 )
 
 9757           level = nlbrack - nrbrack;
 
 9761           count = sscanf ( word, 
"%d%n", &jval, &width );
 
 9782                 iface_num = iface_num + 1;
 
 9790             cout << 
"Bad data " << word << 
"\n";
 
 9800         if ( strcmp ( word, 
"[" ) == 0 )
 
 9804         else if ( strcmp ( word, 
"]" ) == 0 )
 
 9806           level = nlbrack - nrbrack;
 
 9811           count = sscanf ( word, 
"%d%n", &jval, &width );
 
 9819         if ( strcmp ( word, 
"[" ) == 0 )
 
 9822         else if ( strcmp ( word, 
"]" ) == 0 )
 
 9824           level = nlbrack - nrbrack;
 
 9832           count = sscanf ( word, 
"%f%n", &rval, &width );
 
 9843                 normal_num_temp = normal_num_temp + 1;
 
 9850             cout << 
"NORMAL VECTOR: bad data " << word << 
"\n";
 
 9861           if ( strcmp ( word, 
"[" ) == 0 )
 
 9866           else if ( strcmp ( word, 
"]" ) == 0 )
 
 9868             level = nlbrack - nrbrack;
 
 9872             count = sscanf ( word, 
"%f%n", &rval, &width );
 
 9891               cout << 
"Bad data " << word << 
"\n";
 
 9901         if ( strcmp ( word, 
"{" ) == 0 )
 
 9904         else if ( strcmp ( word, 
"}" ) == 0 )
 
 9906           level = nlbrack - nrbrack;
 
 9908         else if ( 
s_eqi ( word, 
"VERTEX" ) )
 
 9911         else if ( 
s_eqi ( word, 
"NORMAL" ) )
 
 9915         else if ( 
s_eqi ( word, 
"MATERIALBINDING" ) )
 
 9917           count = sscanf ( next, 
"%s%n", word, &width );
 
 9918           next = next + width;
 
 9920         else if ( 
s_eqi ( word, 
"NORMALBINDING" ) )
 
 9922           count = sscanf ( next, 
"%s%n", word, &width );
 
 9923           next = next + width;
 
 9928           cout << 
"Bad data " << word << 
"\n";
 
 9936         if ( strcmp ( word, 
"[" ) == 0 )
 
 9940         else if ( strcmp ( word, 
"]" ) == 0 )
 
 9942           level = nlbrack - nrbrack;
 
 9947           count = sscanf ( word, 
"%d%n", &jval, &width );
 
 9999   fprintf ( fileout, 
"#Inventor V2.0 ascii\n" );
 
10000   fprintf ( fileout, 
"\n" );
 
10001   fprintf ( fileout, 
"Separator {\n" );
 
10002   fprintf ( fileout, 
"  Info {\n" );
 
10003   fprintf ( fileout, 
"    string \"%s generated by IVCON.\"\n", 
fileout_name );
 
10004   fprintf ( fileout, 
"    string \"Original data in file %s.\"\n", 
filein_name );
 
10005   fprintf ( fileout, 
"  }\n" );
 
10006   fprintf ( fileout, 
"  Separator {\n" );
 
10025   fprintf ( fileout, 
"    LightModel {\n" );
 
10026   fprintf ( fileout, 
"      model PHONG\n" );
 
10027   fprintf ( fileout, 
"    }\n" );
 
10032   fprintf ( fileout, 
"    MatrixTransform { matrix\n" );
 
10041   fprintf ( fileout, 
"    }\n" );
 
10046   fprintf ( fileout, 
"    Material {\n" );
 
10047   fprintf ( fileout, 
"      ambientColor  0.2 0.2 0.2\n" );
 
10048   fprintf ( fileout, 
"      diffuseColor  0.8 0.8 0.8\n" );
 
10049   fprintf ( fileout, 
"      emissiveColor 0.0 0.0 0.0\n" );
 
10050   fprintf ( fileout, 
"      specularColor 0.0 0.0 0.0\n" );
 
10051   fprintf ( fileout, 
"      shininess     0.2\n" );
 
10052   fprintf ( fileout, 
"      transparency  0.0\n" );
 
10053   fprintf ( fileout, 
"    }\n" );
 
10058   fprintf ( fileout, 
"    MaterialBinding {\n" );
 
10059   fprintf ( fileout, 
"      value PER_VERTEX_INDEXED\n" );
 
10060   fprintf ( fileout, 
"    }\n" );
 
10073   fprintf ( fileout, 
"    NormalBinding {\n" );
 
10074   fprintf ( fileout, 
"      value PER_VERTEX_INDEXED\n" );
 
10075   fprintf ( fileout, 
"    }\n" );
 
10084     fprintf ( fileout, 
"    Texture2 {\n" );
 
10085     fprintf ( fileout, 
"      filename \"%s\"\n", 
texture_name[0] );
 
10086     fprintf ( fileout, 
"      wrapS       REPEAT\n" );
 
10087     fprintf ( fileout, 
"      wrapT       REPEAT\n" );
 
10088     fprintf ( fileout, 
"      model       MODULATE\n" );
 
10089     fprintf ( fileout, 
"      blendColor  0.0 0.0 0.0\n" );
 
10090     fprintf ( fileout, 
"    }\n" );
 
10096   fprintf ( fileout, 
"    TextureCoordinateBinding {\n" );
 
10097   fprintf ( fileout, 
"      value PER_VERTEX_INDEXED\n" );
 
10098   fprintf ( fileout, 
"    }\n" );
 
10103   fprintf ( fileout, 
"    ShapeHints {\n" );
 
10104   fprintf ( fileout, 
"      vertexOrdering COUNTERCLOCKWISE\n" );
 
10105   fprintf ( fileout, 
"      shapeType UNKNOWN_SHAPE_TYPE\n" );
 
10106   fprintf ( fileout, 
"      faceType CONVEX\n" );
 
10107   fprintf ( fileout, 
"      creaseAngle 6.28319\n" );
 
10108   fprintf ( fileout, 
"    }\n" );
 
10113   fprintf ( fileout, 
"    Coordinate3 {\n" );
 
10114   fprintf ( fileout, 
"      point [\n" );
 
10119     fprintf ( fileout, 
"        %f %f %f,\n", 
cor3[0][j], 
cor3[1][j],
 
10123   fprintf ( fileout, 
"      ]\n" );
 
10124   fprintf ( fileout, 
"    }\n" );
 
10129   fprintf ( fileout, 
"    TextureCoordinate2 {\n" );
 
10130   fprintf ( fileout, 
"      point [\n" );
 
10133   for ( iface = 0; iface < 
face_num; iface++ )
 
10135     for ( ivert = 0; ivert < 
face_order[iface]; ivert++ )
 
10137       fprintf ( fileout, 
"        %f %f,\n", 
vertex_tex_uv[0][ivert][iface],
 
10142   fprintf ( fileout, 
"      ]\n" );
 
10143   fprintf ( fileout, 
"    }\n" );
 
10150     fprintf ( fileout, 
"    BaseColor {\n" );
 
10151     fprintf ( fileout, 
"      rgb [\n" );
 
10161     fprintf ( fileout, 
"      ]\n" );
 
10162     fprintf ( fileout, 
"    }\n" );
 
10171     fprintf ( fileout, 
"    Normal { \n" );
 
10172     fprintf ( fileout, 
"      vector [\n" );
 
10175     for ( icor3 = 0; icor3 < 
cor3_num; icor3++ )
 
10177       fprintf ( fileout, 
"        %f %f %f,\n",
 
10184     fprintf ( fileout, 
"      ]\n" );
 
10185     fprintf ( fileout, 
"    }\n" );
 
10193     fprintf ( fileout, 
"    IndexedLineSet {\n" );
 
10197     fprintf ( fileout, 
"      coordIndex [\n" );
 
10206         fprintf ( fileout, 
"       " );
 
10209       fprintf ( fileout, 
" %d,", 
line_dex[j] );
 
10210       length = length + 1;
 
10214         fprintf ( fileout, 
"\n" );
 
10220     fprintf ( fileout, 
"      ]\n" );
 
10225     fprintf ( fileout, 
"      materialIndex [\n" );
 
10234         fprintf ( fileout, 
"       " );
 
10238       length = length + 1;
 
10242         fprintf ( fileout, 
"\n" );
 
10248     fprintf ( fileout, 
"      ]\n" );
 
10249     fprintf ( fileout, 
"    }\n" );
 
10257     fprintf ( fileout, 
"    IndexedFaceSet {\n" );
 
10258     fprintf ( fileout, 
"      coordIndex [\n" );
 
10261     for ( iface = 0; iface < 
face_num; iface++ )
 
10263       fprintf ( fileout, 
"       " );
 
10265       for ( ivert = 0; ivert < 
face_order[iface]; ivert++ )
 
10267         fprintf ( fileout, 
" %d,", 
face[ivert][iface] );
 
10269       fprintf ( fileout, 
" -1,\n" );
 
10273     fprintf ( fileout, 
"      ]\n" );
 
10278     fprintf ( fileout, 
"      normalIndex [\n" );
 
10281     for ( iface = 0; iface < 
face_num; iface++ )
 
10283       fprintf ( fileout, 
"       " );
 
10285       for ( ivert = 0; ivert < 
face_order[iface]; ivert++ )
 
10287         fprintf ( fileout, 
" %d,", 
face[ivert][iface] );
 
10289       fprintf ( fileout, 
" -1,\n" );
 
10292     fprintf ( fileout, 
"      ]\n" );
 
10297     fprintf ( fileout, 
"      materialIndex [\n" );
 
10300     for ( iface = 0; iface < 
face_num; iface++ )
 
10302       fprintf ( fileout, 
"       " );
 
10304       for ( ivert = 0; ivert < 
face_order[iface]; ivert++ )
 
10308       fprintf ( fileout, 
" -1,\n" );
 
10312     fprintf ( fileout, 
"      ]\n" );
 
10317     fprintf ( fileout, 
"      textureCoordIndex [\n" );
 
10322     for ( iface = 0; iface < 
face_num; iface++ )
 
10324       fprintf ( fileout, 
"       " );
 
10326       for ( ivert = 0; ivert < 
face_order[iface]; ivert++ )
 
10328         fprintf ( fileout, 
" %d,", itemp );
 
10331       fprintf ( fileout, 
" -1,\n" );
 
10335     fprintf ( fileout, 
"      ]\n" );
 
10337     fprintf ( fileout, 
"    }\n" );
 
10343   fprintf ( fileout, 
"  }\n" );
 
10344   fprintf ( fileout, 
"}\n" );
 
10350   cout << 
"IV_WRITE - Wrote " << 
text_num << 
" text lines;\n";
 
10389     for ( 
i = 1; 
i < n; 
i++ )
 
10431     y.ychar[3] = fgetc ( filein );
 
10432     y.ychar[2] = fgetc ( filein );
 
10433     y.ychar[1] = fgetc ( filein );
 
10434     y.ychar[0] = fgetc ( filein );
 
10438     y.ychar[0] = fgetc ( filein );
 
10439     y.ychar[1] = fgetc ( filein );
 
10440     y.ychar[2] = fgetc ( filein );
 
10441     y.ychar[3] = fgetc ( filein );
 
10478     fputc ( y.ychar[3], fileout );
 
10479     fputc ( y.ychar[2], fileout );
 
10480     fputc ( y.ychar[1], fileout );
 
10481     fputc ( y.ychar[0], fileout );
 
10485     fputc ( y.ychar[0], fileout );
 
10486     fputc ( y.ychar[1], fileout );
 
10487     fputc ( y.ychar[2], fileout );
 
10488     fputc ( y.ychar[3], fileout );
 
10517   cout << 
"Recent changes:\n";
 
10519   cout << 
"  05 September 2003\n";
 
10520   cout << 
"    Trying to sneak OFF_READ in.\n";
 
10521   cout << 
"    Replaced all C PRINTF calls by C++ COUT <<\n";
 
10522   cout << 
"  29 August 2003\n";
 
10523   cout << 
"    Added OFF_WRITE.\n";
 
10524   cout << 
"  04 July 2000\n";
 
10525   cout << 
"    Added preliminary XGL_WRITE.\n";
 
10526   cout << 
"  26 September 1999\n";
 
10527   cout << 
"    After ASE_READ, call NODE_TO_VERTEX_MAT\n";
 
10528   cout << 
"    and VERTEX_TO_FACE_MATERIAL.\n";
 
10529   cout << 
"  27 July 1999\n";
 
10530   cout << 
"    Corrected TMAT_ROT_VECTOR.\n";
 
10531   cout << 
"  17 July 1999\n";
 
10532   cout << 
"    Added null edge and face deletion.\n";
 
10533   cout << 
"    Corrected a string problem in SMF_READ.\n";
 
10534   cout << 
"  03 July 1999\n";
 
10535   cout << 
"    Fixed a problem with BINDING variables in SMF_READ.\n";
 
10536   cout << 
"  02 July 1999\n";
 
10537   cout << 
"    Added limited texture support in 3DS/IV.\n";
 
10538   cout << 
"  26 June 1999\n";
 
10539   cout << 
"    BYU_READ added.\n";
 
10540   cout << 
"  25 June 1999\n";
 
10541   cout << 
"    BYU_WRITE added.\n";
 
10542   cout << 
"  22 June 1999\n";
 
10543   cout << 
"    TRIB_READ added.\n";
 
10544   cout << 
"  16 June 1999\n";
 
10545   cout << 
"    TRIB_WRITE Greg Hood binary triangle output routine added.\n";
 
10546   cout << 
"  10 June 1999\n";
 
10547   cout << 
"    TRIA_WRITE Greg Hood ASCII triangle output routine added.\n";
 
10548   cout << 
"  09 June 1999\n";
 
10549   cout << 
"    TEC_WRITE TECPLOT output routine added.\n";
 
10550   cout << 
"    IV_READ and IV_WRITE use TRANSFORM_MATRIX now.\n";
 
10551   cout << 
"  26 May 1999\n";
 
10552   cout << 
"    LINE_PRUNE option added for VLA_WRITE.\n";
 
10553   cout << 
"  24 May 1999\n";
 
10554   cout << 
"    Added << command to append new graphics data to old.\n";
 
10555   cout << 
"    Stuck in first draft STLB_READ/STLB_WRITE routines.\n";
 
10556   cout << 
"    STLA_WRITE and STLB_WRITE automatically decompose \n";
 
10557   cout << 
"      non-triangular faces before writing.\n";
 
10558   cout << 
"  23 May 1999\n";
 
10559   cout << 
"    Stuck in first draft WRL_WRITE routine.\n";
 
10560   cout << 
"  22 May 1999\n";
 
10561   cout << 
"    Faces converted to lines before calling VLA_WRITE.\n";
 
10562   cout << 
"    Added UCD_WRITE.\n";
 
10563   cout << 
"    Added MATERIAL/PATCH/TAGGEDPOINTS fields in HRC_READ.\n";
 
10564   cout << 
"  17 May 1999\n";
 
10565   cout << 
"    Updated SMF_WRITE, SMF_READ to match code in IVREAD.\n";
 
10566   cout << 
"    Added transformation matrix routines.\n";
 
10567   cout << 
"  16 May 1999\n";
 
10568   cout << 
"    Zik Saleeba improved DXF support to handle polygons.\n";
 
10569   cout << 
"  15 April 1999\n";
 
10570   cout << 
"    Zik Saleeba added Golgotha GMOD file format support.\n";
 
10571   cout << 
"  03 December 1998\n";
 
10572   cout << 
"    Set up simple hooks in TDS_READ_MATERIAL_SECTION.\n";
 
10573   cout << 
"  02 December 1998\n";
 
10574   cout << 
"    Set up simple hooks for texture map names.\n";
 
10575   cout << 
"  19 November 1998\n";
 
10576   cout << 
"    IV_WRITE uses PER_VERTEX normal binding.\n";
 
10577   cout << 
"  18 November 1998\n";
 
10578   cout << 
"    Added node normals.\n";
 
10579   cout << 
"    Finally added the -RN option.\n";
 
10580   cout << 
"  17 November 1998\n";
 
10581   cout << 
"    Added face node ordering reversal option.\n";
 
10582   cout << 
"  20 October 1998\n";
 
10583   cout << 
"    Added DATA_REPORT.\n";
 
10584   cout << 
"  19 October 1998\n";
 
10585   cout << 
"    SMF_READ and SMF_WRITE added.\n";
 
10586   cout << 
"  16 October 1998\n";
 
10587   cout << 
"    Fixing a bug in IV_READ that chokes on ]} and other\n";
 
10588   cout << 
"    cases where brackets aren't properly spaced.\n";
 
10589   cout << 
"  11 October 1998\n";
 
10590   cout << 
"    Added face subset selection option S.\n";
 
10591   cout << 
"  09 October 1998\n";
 
10592   cout << 
"    Reworking normal vector treatments.\n";
 
10593   cout << 
"    Synchronizing IVREAD and IVCON.\n";
 
10594   cout << 
"    POV_WRITE added.\n";
 
10595   cout << 
"  02 October 1998\n";
 
10596   cout << 
"    IVCON reproduces BOX.3DS and CONE.3DS exactly.\n";
 
10597   cout << 
"  30 September 1998\n";
 
10598   cout << 
"    IVCON compiled on the PC.\n";
 
10599   cout << 
"    Interactive BYTE_SWAP option added for binary files.\n";
 
10600   cout << 
"  25 September 1998\n";
 
10601   cout << 
"    OBJECT_NAME made available to store object name.\n";
 
10602   cout << 
"  23 September 1998\n";
 
10603   cout << 
"    3DS binary files can be written.\n";
 
10604   cout << 
"  15 September 1998\n";
 
10605   cout << 
"    3DS binary files can be read.\n";
 
10606   cout << 
"  01 September 1998\n";
 
10607   cout << 
"    COR3_RANGE, FACE_NORMAL_AVE added.\n";
 
10608   cout << 
"    Major modifications to normal vectors.\n";
 
10609   cout << 
"  24 August 1998\n";
 
10610   cout << 
"    HRC_READ added.\n";
 
10611   cout << 
"  21 August 1998\n";
 
10612   cout << 
"    TXT_WRITE improved.\n";
 
10613   cout << 
"  20 August 1998\n";
 
10614   cout << 
"    HRC_WRITE can output lines as linear splines.\n";
 
10615   cout << 
"  19 August 1998\n";
 
10616   cout << 
"    Automatic normal computation for OBJ files.\n";
 
10617   cout << 
"    Added normal vector computation.\n";
 
10618   cout << 
"    HRC_WRITE is working.\n";
 
10619   cout << 
"  18 August 1998\n";
 
10620   cout << 
"    IV_READ/IV_WRITE handle BASECOLOR RGB properly now.\n";
 
10621   cout << 
"    Improved treatment of face materials and normals.\n";
 
10622   cout << 
"  17 August 1998\n";
 
10623   cout << 
"    ORDER_MAX increased to 35.\n";
 
10624   cout << 
"    FACE_PRINT routine added.\n";
 
10625   cout << 
"    INIT_DATA routine added.\n";
 
10626   cout << 
"  14 August 1998\n";
 
10627   cout << 
"    IV_READ is working.\n";
 
10628   cout << 
"  13 August 1998\n";
 
10629   cout << 
"    ASE_WRITE is working.\n";
 
10630   cout << 
"    IV_WRITE is working.\n";
 
10631   cout << 
"  12 August 1998\n";
 
10632   cout << 
"    ASE_READ is working.\n";
 
10633   cout << 
"  10 August 1998\n";
 
10634   cout << 
"    DXF_WRITE is working.\n";
 
10635   cout << 
"    DXF_READ is working.\n";
 
10636   cout << 
"  27 July 1998\n";
 
10637   cout << 
"    Interactive mode is working.\n";
 
10638   cout << 
"    OBJ_READ is working.\n";
 
10639   cout << 
"  25 July 1998\n";
 
10640   cout << 
"    OBJ_WRITE is working.\n";
 
10641   cout << 
"  24 July 1998\n";
 
10642   cout << 
"    DATA_CHECK checks the input data.\n";
 
10643   cout << 
"    VLA_READ is working.\n";
 
10644   cout << 
"    VLA_WRITE is working.\n";
 
10645   cout << 
"  23 July 1998\n";
 
10646   cout << 
"    STL_WRITE is working.\n";
 
10647   cout << 
"  22 July 1998\n";
 
10648   cout << 
"    STL_READ is working.\n";
 
10649   cout << 
"    TXT_WRITE is working.\n";
 
10684   for ( iface = 0; iface < 
face_num; iface++ )
 
10686     for ( ivert = 0; ivert < 
face_order[iface]; ivert++ )
 
10688       node = 
face[ivert][iface];
 
10744   int vertex_normal_num;
 
10754   vertex_normal_num = 0;
 
10770     if ( *next == 
'\0' )
 
10775     if ( *next == 
'#' || *next == 
'$' )
 
10783     sscanf ( next, 
"%s%n", token, &width );
 
10787     next = next + width;
 
10792     if ( 
s_eqi ( token, 
"BEVEL" ) )
 
10800     else if ( 
s_eqi ( token, 
"BMAT" ) )
 
10808     else if ( 
s_eqi ( token, 
"C_INTERP" ) )
 
10816     else if ( 
s_eqi ( token, 
"CON" ) )
 
10824     else if ( 
s_eqi ( token, 
"CSTYPE" ) )
 
10832     else if ( 
s_eqi ( token, 
"CTECH" ) )
 
10840     else if ( 
s_eqi ( token, 
"CURV" ) )
 
10848     else if ( 
s_eqi ( token, 
"CURV2" ) )
 
10856     else if ( 
s_eqi ( token, 
"D_INTERP" ) )
 
10864     else if ( 
s_eqi ( token, 
"DEG" ) )
 
10872     else if ( 
s_eqi ( token, 
"END" ) )
 
10891     else if ( 
s_eqi ( token, 
"F" ) )
 
10901         count = sscanf ( next, 
"%s%n", token2, &width );
 
10902         next = next + width;
 
10909         count = sscanf ( token2, 
"%d%n", &node, &width );
 
10910         next2 = token2 + width;
 
10927         if ( *next2 == 
'/' )
 
10929           for ( next3 = next2 + 1; next3 < token2 + 
LINE_MAX_LEN; next3++ )
 
10931             if ( *next3 == 
'/' )
 
10934               count = sscanf ( next3, 
"%d%n", &node, &width );
 
10937               if ( 0 <= node && node < vertex_normal_num )
 
10939                 for ( 
i = 0; 
i < 3; 
i++ )
 
10956     else if ( 
s_eqi ( token, 
"G" ) )
 
10964     else if ( 
s_eqi ( token, 
"HOLE" ) )
 
10973     else if ( 
s_eqi ( token, 
"L" ) )
 
10977         count = sscanf ( next, 
"%d%n", &node, &width );
 
10978         next = next + width;
 
11006     else if ( 
s_eqi ( token, 
"LOD" ) )
 
11014     else if ( 
s_eqi ( token, 
"MG" ) )
 
11023     else if ( 
s_eqi ( token, 
"MTLLIB" ) )
 
11031     else if ( 
s_eqi ( token, 
"O" ) )
 
11039     else if ( 
s_eqi ( token, 
"P" ) )
 
11047     else if ( 
s_eqi ( token, 
"PARM" ) )
 
11055     else if ( 
s_eqi ( token, 
"S" ) )
 
11063     else if ( 
s_eqi ( token, 
"SCRV" ) )
 
11071     else if ( 
s_eqi ( token, 
"SHADOW_OBJ" ) )
 
11079     else if ( 
s_eqi ( token, 
"SP" ) )
 
11087     else if ( 
s_eqi ( token, 
"STECH" ) )
 
11095     else if ( 
s_eqi ( token, 
"CURV" ) )
 
11103     else if ( 
s_eqi ( token, 
"SURF" ) )
 
11111     else if ( 
s_eqi ( token, 
"TRACE_OBJ" ) )
 
11119     else if ( 
s_eqi ( token, 
"TRIM" ) )
 
11127     else if ( 
s_eqi ( token, 
"USEMTL" ) )
 
11137     else if ( 
s_eqi ( token, 
"V" ) )
 
11139       sscanf ( next, 
"%e %e %e", &r1, &r2, &r3 );
 
11155     else if ( 
s_eqi ( token, 
"VN" ) )
 
11157       sscanf ( next, 
"%e %e %e", &r1, &r2, &r3 );
 
11166       vertex_normal_num = vertex_normal_num + 1;
 
11173     else if ( 
s_eqi ( token, 
"VT" ) )
 
11181     else if ( 
s_eqi ( token, 
"VP" ) )
 
11256   fprintf ( fileout, 
"# %s created by IVCON.\n", 
fileout_name );
 
11257   fprintf ( fileout, 
"# Original data in %s.\n", 
filein_name );
 
11258   fprintf ( fileout, 
"\n" );
 
11260   fprintf ( fileout, 
"\n" );
 
11268     fprintf ( fileout, 
"v %f %f %f %f\n",
 
11277     fprintf ( fileout, 
"\n" );
 
11281   for ( iface = 0; iface < 
face_num; iface++ )
 
11283     for ( ivert = 0; ivert < 
face_order[iface]; ivert++ )
 
11285       fprintf ( fileout, 
"vn %f %f %f\n", 
vertex_normal[0][ivert][iface],
 
11295     fprintf ( fileout, 
"\n" );
 
11301   for ( iface = 0; iface < 
face_num; iface++ )
 
11303     fprintf ( fileout, 
"f" );
 
11304     for ( ivert = 0; ivert < 
face_order[iface]; ivert++ )
 
11306       indexvn = indexvn + 1;
 
11307       fprintf ( fileout, 
" %d//%d", 
face[ivert][iface]+1, indexvn );
 
11309     fprintf ( fileout, 
"\n" );
 
11317     fprintf ( fileout, 
"\n" );
 
11329       fprintf ( fileout, 
"\n" );
 
11337         fprintf ( fileout, 
"l" );
 
11340       fprintf ( fileout, 
" %d", 
k+1 );
 
11345   fprintf ( fileout, 
"\n" );
 
11351   cout << 
"OBJ_WRITE - Wrote " << 
text_num << 
" text lines.\n";
 
11412   int noncomment_num;
 
11421   noncomment_num = 0;
 
11426     file_in.getline ( line, 
sizeof ( line ) );
 
11428     if ( file_in.eof ( ) )
 
11431       cout << 
"OFF_READ - Fatal error!\n";
 
11432       cout << 
"  End-of-file before anything was read.\n";
 
11433       cout << 
"  Number of text lines read = " << 
text_num << 
"\n";
 
11439     if ( line[0] == 
'#' || 
s_len_trim ( line ) == 0 )
 
11444     noncomment_num = noncomment_num + 1;
 
11446     if ( line[0] == 
'O' &&
 
11450       if ( noncomment_num == 1 )
 
11457         cout << 
"OFF_READ - Fatal error!\n";
 
11458         cout << 
"  The 'OFF' tag, if used, must be the first noncomment\n";
 
11459         cout << 
"  line in the file.\n";
 
11460         cout << 
"  Number of text lines read = " << 
text_num << 
"\n";
 
11470       cout << 
"OFF_READ - Fatal error!\n";
 
11471       cout << 
"  Error from S_TO_I4VEC while trying to extract\n";
 
11472       cout << 
"  COR3_NUM FACE_NUM EDGE_NUM record.\n";
 
11473       cout << 
"  Number of text lines read = " << 
text_num << 
"\n";
 
11474       cout << 
"  Current line = \"" << line << 
"\"\n";
 
11480     edge_num = ivec[2];
 
11493     file_in.getline ( line, 
sizeof ( line ) );
 
11495     if ( file_in.eof ( ) )
 
11498       cout << 
"OFF_READ - Fatal error!\n";
 
11499       cout << 
"  End of file while reading X Y Z coordinate data.\n";
 
11500       cout << 
"  Number of text lines read = " << 
text_num << 
"\n";
 
11506     if ( line[0] == 
'#' || 
s_len_trim ( line ) == 0 )
 
11510     noncomment_num = noncomment_num + 1;
 
11517       cout << 
"OFF_READ - Fatal error!\n";
 
11518       cout << 
"  Error from S_TO_R4VEC while trying to extract X Y Z data.\n";
 
11519       cout << 
"  Number of text lines read = " << 
text_num << 
"\n";
 
11523     for ( j = 0; j < 3; j++ )
 
11525       cor3[j][cor3_num2] = rvec[j];
 
11528     cor3_num2 = cor3_num2 + 1;
 
11539     file_in.getline ( line, 
sizeof ( line ) );
 
11541     if ( file_in.eof ( ) )
 
11544       cout << 
"OFF_READ - Fatal error!\n";
 
11545       cout << 
"  End of file while reading face data.\n";
 
11546       cout << 
"  Number of text lines read = " << 
text_num << 
"\n";
 
11552     if ( line[0] == 
'#' || 
s_len_trim ( line ) == 0 )
 
11557     noncomment_num = noncomment_num + 1;
 
11559     order = 
s_to_i4 ( line, &last, &error );
 
11564       cout << 
"OFF_READ - Fatal error!\n";
 
11565       cout << 
"  Error from S_TO_I4 while extracting face order.\n";
 
11566       cout << 
"  Number of text lines read = " << 
text_num << 
"\n";
 
11577       cout << 
"OFF_READ - Fatal error!\n";
 
11578       cout << 
"  Error from S_TO_I4VEC while extracting face indices.\n";
 
11579       cout << 
"  Number of text lines read = " << 
text_num << 
"\n";
 
11583     for ( vert = 0; vert < order; vert++ )
 
11585       face[vert][face_num2] = ivec[vert+1];
 
11588     face_num2 = face_num2 + 1;
 
11592   cout << 
"OFF_READ read " << 
text_num << 
" lines.\n";
 
11652   fprintf ( fileout, 
"OFF\n" );
 
11668     for ( 
i = 0; 
i < 3; 
i++ )
 
11670       fprintf ( fileout, 
"%f  ", 
cor3[
i][j] );
 
11672     fprintf ( fileout, 
"\n" );
 
11678   for ( iface = 0; iface < 
face_num; iface++ )
 
11680     fprintf ( fileout, 
"%d  ", 
face_order[iface] );
 
11682     for ( ivert = 0; ivert < 
face_order[iface]; ivert++ )
 
11684       fprintf ( fileout, 
"%d  ",  
face[ivert][iface] );
 
11686     fprintf ( fileout, 
"\n" );
 
11694   cout << 
"OFF_WRITE - Wrote " << 
text_num 
11776   fprintf ( fileout,  
"// %s created by IVCON.\n", 
fileout_name );
 
11777   fprintf ( fileout,  
"// Original data in %s.\n", 
filein_name );
 
11782   fprintf ( fileout, 
"\n" );
 
11783   fprintf ( fileout, 
"#version 3.0\n" );
 
11784   fprintf ( fileout, 
"#include \"colors.inc\"\n" );
 
11785   fprintf ( fileout, 
"#include \"shapes.inc\"\n" );
 
11786   fprintf ( fileout, 
"global_settings { assumed_gamma 2.2 }\n" );
 
11787   fprintf ( fileout, 
"\n" );
 
11788   fprintf ( fileout, 
"camera {\n" );
 
11789   fprintf ( fileout, 
" right < 4/3, 0, 0>\n" );
 
11790   fprintf ( fileout, 
" up < 0, 1, 0 >\n" );
 
11791   fprintf ( fileout, 
" sky < 0, 1, 0 >\n" );
 
11792   fprintf ( fileout, 
" angle 20\n" );
 
11793   fprintf ( fileout, 
" location < 0, 0, -300 >\n" );
 
11794   fprintf ( fileout, 
" look_at < 0, 0, 0>\n" );
 
11795   fprintf ( fileout, 
"}\n" );
 
11796   fprintf ( fileout, 
"\n" );
 
11797   fprintf ( fileout, 
"light_source { < 20, 50, -100 > color White }\n" );
 
11798   fprintf ( fileout, 
"\n" );
 
11799   fprintf ( fileout, 
"background { color SkyBlue }\n" );
 
11805   fprintf ( fileout, 
"\n" );
 
11806   fprintf ( fileout, 
"#declare RedText = texture {\n" );
 
11807   fprintf ( fileout, 
"  pigment { color rgb < 0.8, 0.2, 0.2> }\n" );
 
11808   fprintf ( fileout, 
"  finish { ambient 0.2 diffuse 0.5 }\n" );
 
11809   fprintf ( fileout, 
"}\n" );
 
11810   fprintf ( fileout, 
"\n" );
 
11811   fprintf ( fileout, 
"#declare GreenText = texture {\n" );
 
11812   fprintf ( fileout, 
"  pigment { color rgb < 0.2, 0.8, 0.2> }\n" );
 
11813   fprintf ( fileout, 
"  finish { ambient 0.2 diffuse 0.5 }\n" );
 
11814   fprintf ( fileout, 
"}\n" );
 
11815   fprintf ( fileout, 
"\n" );
 
11816   fprintf ( fileout, 
"#declare BlueText = texture {\n" );
 
11817   fprintf ( fileout, 
"  pigment { color rgb < 0.2, 0.2, 0.8> }\n" );
 
11818   fprintf ( fileout, 
"  finish { ambient 0.2 diffuse 0.5 }\n" );
 
11819   fprintf ( fileout, 
"}\n" );
 
11823   fprintf ( fileout,  
"mesh {\n" );
 
11835       fprintf ( fileout, 
"  smooth_triangle {\n" );
 
11838       for ( j = jlo; j < jlo + 3; j++ )
 
11851         fprintf ( fileout, 
"<%f, %f, %f>, <%f, %f, %f>",
 
11859           fprintf ( fileout, 
",\n" );
 
11863           fprintf ( fileout, 
"\n" );
 
11871         fprintf ( fileout,  
"texture { RedText } }\n" );
 
11873       else if ( 
i%2 == 0 )
 
11875         fprintf ( fileout,  
"texture { BlueText } }\n" );
 
11879         fprintf ( fileout,  
"texture { GreenText } }\n" );
 
11887   fprintf ( fileout,  
"}\n" );
 
11893   cout << 
"POV_WRITE - Wrote " << 
text_num << 
" text lines.\n";
 
11935   for ( j = 0; j < n; j++ )
 
11937     for ( 
i = 0; 
i < m; 
i++ )
 
11939       if ( a[
i][j] != r[
i] )
 
12018   else if ( 1.0 < r )
 
12027   else if ( 1.0 < g )
 
12036   else if ( 1.0 < b )
 
12065   if ( rgbmax == rgbmin )
 
12076       h = ( g - b ) / ( rgbmax - rgbmin );
 
12078     else if ( g == rgbmax )
 
12080       h = 2.0 + ( b - r ) / ( rgbmax - rgbmin );
 
12082     else if ( b == rgbmax )
 
12084       h = 4.0 + ( r - g ) / ( rgbmax - rgbmin );
 
12095     else if ( 1.0 < h )
 
12138   nchar1 = strlen ( s1 );
 
12139   nchar2 = strlen ( s2 );
 
12140   nchar = 
i4_min ( nchar1, nchar2 );
 
12145   for ( 
i = 0; 
i < nchar; 
i++ )
 
12157   if ( nchar < nchar1 )
 
12159     for ( 
i = nchar; 
i < nchar1; 
i++ )
 
12161       if ( s1[
i] != 
' ' )
 
12167   else if ( nchar < nchar2 )
 
12169     for ( 
i = nchar; 
i < nchar2; 
i++ )
 
12171       if ( s2[
i] != 
' ' )
 
12215   t = s + strlen ( s ) - 1;
 
12287       else if ( c == 
'-' )
 
12292       else if ( c == 
'+' )
 
12297       else if ( 
'0' <= c && c <= 
'9' )
 
12311     else if ( istate == 1 )
 
12316       else if ( 
'0' <= c && c <= 
'9' )
 
12330     else if ( istate == 2 )
 
12332       if ( 
'0' <= c && c <= 
'9' )
 
12334         ival = 10 * (ival) + c - 
'0';
 
12338         ival = isgn * ival;
 
12350     ival = isgn * ival;
 
12400   for ( 
i = 0; 
i < n; 
i++ )
 
12402     ivec[
i] = 
s_to_i4 ( s, &lchar, &error );
 
12407       cout << 
"S_TO_I4VEC - Fatal error!\n";
 
12408       cout << 
"  S_TO_I4 returned error while reading item " << 
i << 
"\n";
 
12532     *lchar = *lchar + 1;
 
12536     if ( c == 
' ' || c == TAB )
 
12541       else if ( ihave == 6 || ihave == 7 )
 
12545       else if ( 1 < ihave )
 
12553     else if ( c == 
',' || c == 
';' )
 
12559         *lchar = *lchar + 1;
 
12565     else if ( c == 
'-' )
 
12572       else if ( ihave == 6 )
 
12585     else if ( c == 
'+' )
 
12591       else if ( ihave == 6 )
 
12603     else if ( c == 
'.' )
 
12609       else if ( 6 <= ihave && ihave <= 8 )
 
12635     else if ( ihave < 11 && 
'0' <= c && c <= 
'9' )
 
12641       else if ( ihave == 4 )
 
12645       else if ( ihave == 6 || ihave == 7 )
 
12649       else if ( ihave == 9 )
 
12658         rtop = 10.0E+00 * rtop + ( float ) ndig;
 
12660       else if ( ihave == 5 )
 
12662         rtop = 10.0E+00 * rtop + ( float ) ndig;
 
12663         rbot = 10.0E+00 * rbot;
 
12665       else if ( ihave == 8 )
 
12667         jtop = 10 * jtop + ndig;
 
12669       else if ( ihave == 10 )
 
12671         jtop = 10 * jtop + ndig;
 
12686     if ( iterm == 1 || nchar <= *lchar + 1 )
 
12696   if ( iterm != 1 && (*lchar) + 1 == nchar )
 
12704   if ( ihave == 1 || ihave == 2 || ihave == 6 || ihave == 7 )
 
12720       rexp = pow ( ( 
double ) 10.0E+00, ( 
double ) ( jsgn * jtop ) );
 
12724       rexp = jsgn * jtop;
 
12725       rexp = rexp / jbot;
 
12726       rexp = pow ( ( 
double ) 10.0E+00, ( 
double ) rexp );
 
12731   r = isgn * rexp * rtop / rbot;
 
12774   for ( 
i = 0; 
i < n; 
i++ )
 
12776     rvec[
i] = 
s_to_r4 ( s, &lchar, &error );
 
12816   c1 = fgetc ( filein );
 
12817   c2 = fgetc ( filein );
 
12819   ival = c1 | ( c2 << 8 );
 
12851   y.yint = short_int_val;
 
12855     fputc ( y.ychar[1], fileout );
 
12856     fputc ( y.ychar[0], fileout );
 
12860     fputc ( y.ychar[0], fileout );
 
12861     fputc ( y.ychar[1], fileout );
 
12991   char *
string = 
"Dummy material";
 
13001   int vertex_correction;
 
13016   vertex_correction = 0;
 
13026       cout << 
"SMF_READ: DEBUG: Reading line #" << 
text_num << 
"\n";
 
13038     if ( *next == 
'\0' )
 
13045     if ( *next == 
'#' || *next == 
'$' )
 
13053     sscanf ( next, 
"%s%n", token, &width );
 
13057     next = next + width;
 
13065     if ( 
s_eqi ( token, 
"BEGIN" ) )
 
13077     else if ( 
s_eqi ( token, 
"BIND" ) )
 
13079       sscanf ( next, 
"%s%n", cnr, &width );
 
13080       next = next + width;
 
13084         cout << 
"CNR = " << cnr << 
"\n";
 
13087       sscanf ( next, 
"%s%n", type, &width );
 
13088       next = next + width;
 
13092         cout << 
"TYPE = " << type << 
"\n";
 
13095       if ( 
s_eqi ( cnr, 
"C" ) )
 
13097         if ( 
s_eqi ( type, 
"VERTEX" ) )
 
13101         else if ( 
s_eqi ( type, 
"FACE" ) )
 
13106       else if ( 
s_eqi ( cnr, 
"N" ) )
 
13108         if ( 
s_eqi ( type, 
"VERTEX" ) )
 
13112         else if ( 
s_eqi ( type, 
"FACE" ) )
 
13117       else if ( 
s_eqi ( cnr, 
"R" ) )
 
13119         if ( 
s_eqi ( type, 
"VERTEX" ) )
 
13123         else if ( 
s_eqi ( type, 
"FACE" ) )
 
13135     else if ( 
s_eqi ( token, 
"C" ) )
 
13137       sscanf ( next, 
"%f%n", &r, &width );
 
13138       next = next + width;
 
13140       sscanf ( next, 
"%f%n", &g, &width );
 
13141       next = next + width;
 
13143       sscanf ( next, 
"%f%n", &b, &width );
 
13144       next = next + width;
 
13158         for ( 
k = 0; 
k < 4; 
k++ )
 
13174         face_count = face_count + 1;
 
13179         node_count = node_count + 1;
 
13186         cout << 
"SMF_READ - Fatal error!\n";
 
13187         cout << 
"  Material binding undefined!\n";
 
13197     else if ( 
s_eqi ( token, 
"END" ) )
 
13204         cout << 
"SMF_READ - Fatal error!\n";
 
13205         cout << 
"  More END statements than BEGINs!\n";
 
13220     else if ( 
s_eqi ( token, 
"F" ) )
 
13230         count = sscanf ( next, 
"%s%n", token2, &width );
 
13231         next = next + width;
 
13238         count = sscanf ( token2, 
"%d%n", &node, &width );
 
13259     else if ( 
s_eqi ( token, 
"N" ) )
 
13261       sscanf ( next, 
"%f%n", &x, &width );
 
13262       next = next + width;
 
13264       sscanf ( next, 
"%f%n", &y, &width );
 
13265       next = next + width;
 
13267       sscanf ( next, 
"%f%n", &z, &width );
 
13268       next = next + width;
 
13276         iface_normal = iface_normal + 1;
 
13284         icor3_normal = icor3_normal + 1;
 
13289         cout << 
"SMF_READ - Fatal error!\n";
 
13290         cout << 
"  Normal binding undefined!\n";
 
13299     else if ( 
s_eqi ( token, 
"R" ) )
 
13301       sscanf ( next, 
"%f%n", &u, &width );
 
13302       next = next + width;
 
13304       sscanf ( next, 
"%f%n", &v, &width );
 
13305       next = next + width;
 
13312         icor3_tex_uv = icor3_tex_uv + 1;
 
13320         icor3_tex_uv = icor3_tex_uv + 1;
 
13325         cout << 
"SMF_READ - Fatal error!\n";
 
13326         cout << 
"  Texture binding undefined!\n";
 
13334     else if ( 
s_eqi ( token, 
"ROT" ) )
 
13336       sscanf ( next, 
"%c%n", &axis, &width );
 
13337       next = next + width;
 
13339       sscanf ( next, 
"%f%n", &angle, &width );
 
13340       next = next + width;
 
13347     else if ( 
s_eqi ( token, 
"SCALE" ) )
 
13349       sscanf ( next, 
"%f%n", &sx, &width );
 
13350       next = next + width;
 
13352       sscanf ( next, 
"%f%n", &sy, &width );
 
13353       next = next + width;
 
13355       sscanf ( next, 
"%f%n", &sz, &width );
 
13356       next = next + width;
 
13364     else if ( 
s_eqi ( token, 
"SET" ) )
 
13366       sscanf ( next, 
"%s%n", cnr, &width );
 
13367       next = next + width;
 
13369       sscanf ( next, 
"%d%n", &vertex_correction, &width );
 
13370       next = next + width;
 
13376     else if ( 
s_eqi ( token, 
"T_SCALE" ) )
 
13378       sscanf ( next, 
"%f%n", &dx, &width );
 
13379       next = next + width;
 
13381       sscanf ( next, 
"%f%n", &dy, &width );
 
13382       next = next + width;
 
13388     else if ( 
s_eqi ( token, 
"T_TRANS" ) )
 
13390       sscanf ( next, 
"%f%n", &dx, &width );
 
13391       next = next + width;
 
13393       sscanf ( next, 
"%f%n", &dy, &width );
 
13394       next = next + width;
 
13402     else if ( 
s_eqi ( token, 
"TEX" ) )
 
13404       sscanf ( next, 
"%s%n", 
string, &width );
 
13409         if ( 
string[
i] == 
'\0' )
 
13420     else if ( 
s_eqi ( token, 
"TRANS" ) )
 
13422       sscanf ( next, 
"%f%n", &x, &width );
 
13423       next = next + width;
 
13425       sscanf ( next, 
"%f%n", &y, &width );
 
13426       next = next + width;
 
13428       sscanf ( next, 
"%f%n", &z, &width );
 
13429       next = next + width;
 
13437     else if ( 
s_eqi ( token, 
"V" ) )
 
13439       sscanf ( next, 
"%e %e %e", &r1, &r2, &r3 );
 
13453         for ( 
i = 0; 
i < 3; 
i++ )
 
13472         cout << 
"SMF_READ: Bad data on line " << 
text_num << 
".\n";
 
13611   fprintf ( fileout, 
"#$SMF 2.0\n" );
 
13612   fprintf ( fileout, 
"#$vertices %d\n", 
cor3_num );
 
13613   fprintf ( fileout, 
"#$faces %d\n", 
face_num );
 
13614   fprintf ( fileout, 
"#\n" );
 
13615   fprintf ( fileout, 
"# %s created by IVCON.\n", 
fileout_name );
 
13616   fprintf ( fileout, 
"# Original data in %s.\n", 
filein_name );
 
13617   fprintf ( fileout, 
"#\n" );
 
13625     fprintf ( fileout, 
"v %f %f %f\n",
 
13634     fprintf ( fileout, 
"\n" );
 
13638   for ( iface = 0; iface < 
face_num; iface++ )
 
13640     fprintf ( fileout, 
"f" );
 
13641     for ( ivert = 0; ivert < 
face_order[iface]; ivert++ )
 
13643       fprintf ( fileout, 
" %d", 
face[ivert][iface]+1 );
 
13645     fprintf ( fileout, 
"\n" );
 
13651   fprintf ( fileout, 
"bind c vertex\n" );
 
13656   for ( icor3 = 0; icor3 < 
cor3_num; icor3++ )
 
13668   fprintf ( fileout, 
"bind n vertex\n" );
 
13673   for ( icor3 = 0; icor3 < 
cor3_num; icor3++ )
 
13675     fprintf ( fileout, 
"n %f %f %f\n", 
cor3_normal[0][icor3],
 
13691     fprintf ( fileout, 
"bind r vertex\n" );
 
13696     for ( icor3 = 0; icor3 < 
cor3_num; icor3++ )
 
13698       fprintf ( fileout, 
"r %f %f\n", 
cor3_tex_uv[0][icor3],
 
13708   cout << 
"SMF_WRITE - Wrote " << 
text_num << 
" text lines.\n";
 
13784   else if ( *indx < 0 )
 
13831   else if ( *indx == 1 )
 
13841     if ( *
i == n1 - 1 )
 
13848     else if ( *
i <= n1 - 1 )
 
13954     if ( *next == 
'\0' || *next == 
'#' || *next == 
'!' || *next == 
'$' )
 
13961     sscanf ( next, 
"%s%n", token, &width );
 
13965     next = next + width;
 
13969     if ( 
s_eqi ( token, 
"facet" ) )
 
13974       sscanf ( next, 
"%*s %e %e %e", &r1, &r2, &r3 );
 
13993         count = sscanf ( 
input, 
"%*s %e %e %e", &r1, &r2, &r3 );
 
14019             for ( 
i = 0; 
i < 3; 
i++ )
 
14035           for ( 
i = 0; 
i < 3; 
i++ )
 
14059     else if ( 
s_eqi ( token, 
"color" ) )
 
14061       sscanf ( next, 
"%*s %f %f %f %f", &r1, &r2, &r3, &r4 );
 
14066     else if ( 
s_eqi ( token, 
"solid" ) )
 
14073     else if ( 
s_eqi ( token, 
"endsolid" ) )
 
14082       cout << 
"STLA_READ - Fatal error!\n";
 
14083       cout << 
"  Unrecognized first word on line.\n";
 
14157   fprintf ( fileout, 
"solid MYSOLID created by IVCON, original data in %s\n",
 
14162   for ( iface = 0; iface < 
face_num; iface++ )
 
14164     for ( jvert = 2; jvert < 
face_order[iface]; jvert++ )
 
14166       face_num2 = face_num2 + 1;
 
14168       fprintf ( fileout, 
"  facet normal %f %f %f\n",
 
14171       fprintf ( fileout, 
"    outer loop\n" );
 
14173       icor3 = 
face[0][iface];
 
14174       fprintf ( fileout, 
"      vertex %f %f %f\n",
 
14177       icor3 = 
face[jvert-1][iface];
 
14178       fprintf ( fileout, 
"      vertex %f %f %f\n",
 
14181       icor3 = 
face[jvert][iface];
 
14182       fprintf ( fileout, 
"      vertex %f %f %f\n",
 
14185       fprintf ( fileout, 
"    endloop\n" );
 
14186       fprintf ( fileout, 
"  endfacet\n" );
 
14191   fprintf ( fileout, 
"endsolid MYSOLID\n" );
 
14197   cout << 
"STLA_WRITE - Wrote " << 
text_num << 
" text lines.\n";
 
14201     cout << 
"  Number of faces in original data was " << 
face_num << 
".\n";
 
14202     cout << 
"  Number of triangular faces in decomposed data is " 
14203          << face_num2 << 
".\n";
 
14251   short int attribute = 0;
 
14261   for ( 
i = 0; 
i < 80; 
i++ )
 
14281   for ( iface = 0; iface < 
face_num; iface++ )
 
14286     for ( 
i = 0; 
i < 3; 
i++ )
 
14292     for ( ivert = 0; ivert < 
face_order[iface]; ivert++ )
 
14294       for ( 
i = 0; 
i < 3; 
i++ )
 
14325       face[ivert][iface] = icor3;
 
14331       cout << 
"ATTRIBUTE = " << attribute << 
"\n";
 
14388   short int attribute = 0;
 
14398   for ( 
i = 0; 
i < 80; 
i++ )
 
14407   for ( iface = 0; iface < 
face_num; iface++ )
 
14409     face_num2 = face_num2 + 
face_order[iface] - 2;
 
14419   for ( iface = 0; iface < 
face_num; iface++ )
 
14421     for ( jvert = 2; jvert < 
face_order[iface]; jvert++ )
 
14423       for ( 
i = 0; 
i < 3; 
i++ )
 
14428       icor3 = 
face[0][iface];
 
14429       for ( 
i = 0; 
i < 3; 
i++ )
 
14434       icor3 = 
face[jvert-1][iface];
 
14435       for ( 
i = 0; 
i < 3; 
i++ )
 
14440       icor3 = 
face[jvert][iface];
 
14441       for ( 
i = 0; 
i < 3; 
i++ )
 
14455   cout << 
"STLB_WRITE - Wrote " << 
bytes_num << 
" bytes.\n";
 
14459     cout << 
"  Number of faces in original data was " << 
face_num << 
".\n";
 
14460     cout << 
"  Number of triangular faces in decomposed data is " 
14461          << face_num2 << 
".\n";
 
14527   unsigned long int chunk_begin;
 
14528   unsigned long int   chunk_end;
 
14529   unsigned long int   chunk_length;
 
14530   unsigned long int   chunk_length2;
 
14531   unsigned long int   position;
 
14532   unsigned short int  temp_int;
 
14542   if ( temp_int == 0x4d4d )
 
14546       cout << 
"TDS_READ: DEBUG: Read magic number " 
14547            << hex << temp_int << 
"\n";
 
14553     fseek ( filein, ( 
long ) position, SEEK_SET );
 
14554     version = fgetc ( filein );
 
14559       cout << 
"TDS_READ - Fatal error!\n";
 
14560       cout << 
"  This routine can only read 3DS version 3 or later.\n";
 
14561       cout << 
"  The input file is version " << version << 
".\n";
 
14567       cout << 
"TDS_READ: DEBUG: Version number is " << version << 
".\n";
 
14576     fseek ( filein, ( 
long ) position, SEEK_SET );
 
14581     chunk_end = chunk_begin + chunk_length;
 
14586       cout << 
"TDS_READ:\n";
 
14587       cout << 
"  Chunk begin  = " << chunk_begin << 
"\n";
 
14588       cout << 
"  Chunk length = " << chunk_length << 
"\n";
 
14589       cout << 
"  Chunk end    = " << chunk_end << 
"\n";
 
14592     while ( position + 2 < chunk_end )
 
14595       position = position + 2;
 
14599         cout << 
"TDS_READ: Short int = " << hex << temp_int << 
"\n";
 
14600         cout << 
"  position = " << position << 
"\n";
 
14603       if ( temp_int == 0x0002 )
 
14607           cout << 
"TDS_READ: Read_Initial_Section:\n";
 
14610         position = position + 4;
 
14611         position = position - 6 + chunk_length2;
 
14612         fseek ( filein, ( 
long ) position, SEEK_SET );
 
14614       else if ( temp_int == 0x3d3d )
 
14618           cout << 
"TDS_READ: Read_Edit_Section:\n";
 
14620         position = position - 2;
 
14623       else if ( temp_int == 0xb000 )
 
14627           cout << 
"TDS_READ: Read_Keyframe_Section:\n";
 
14630         position = position - 2;
 
14636         cout << 
"TDS_READ - Fatal error!\n";
 
14637         cout << 
"  Unexpected input, position = " << position << 
"\n";
 
14638         cout << 
"  TEMP_INT = " << hex << temp_int << 
"\n";
 
14642     position = chunk_begin + chunk_length;
 
14643     fseek ( filein, ( 
long ) position, SEEK_SET );
 
14648     cout << 
"TDS_READ - Fatal error!\n";
 
14649     cout << 
"  Could not find the main section tag.\n";
 
14670   unsigned long int current_pointer;
 
14671   bool end_found = 
false;
 
14675   unsigned short int temp_int;
 
14676   unsigned long int temp_pointer;
 
14677   unsigned long int teller;
 
14678   unsigned char true_c_val[3];
 
14680   current_pointer = ftell ( filein ) - 2;
 
14684   while ( !end_found )
 
14687     teller = teller + 2;
 
14689     switch ( temp_int )
 
14694           cout << 
"     COLOR_F color definition section tag of " 
14695             << hex << temp_int << 
"\n";
 
14697         for ( 
i = 0; 
i < 3; 
i++ )
 
14703           cout << 
"RGB_VAL = " 
14704             << setw(10) << rgb_val[0] << 
"  " 
14705             << setw(10) << rgb_val[1] << 
"  " 
14706             << setw(10) << rgb_val[2] << 
"\n";
 
14708         teller = teller + 3 * 
sizeof ( float );
 
14713           cout << 
"     COLOR_24 24 bit color definition section tag of " 
14714             << hex << temp_int << 
"\n";;
 
14717         for ( 
i = 0; 
i < 3; 
i++ )
 
14719           true_c_val[
i] = fgetc ( filein );
 
14723           cout << 
"TRUE_C_VAL = " 
14724             << setw(6) << true_c_val[0] << 
"  " 
14725             << setw(6) << true_c_val[1] << 
"  " 
14726             << setw(6) << true_c_val[2] << 
"\n";
 
14728         teller = teller + 3;
 
14734     if ( temp_pointer <= teller )
 
14741   pointer = ( long ) ( current_pointer + temp_pointer );
 
14742   fseek ( filein, pointer, SEEK_SET );
 
14744   return ( temp_pointer );
 
14761   unsigned long int   current_pointer;
 
14762   bool end_found = 
false;
 
14766   unsigned short int temp_int;
 
14767   unsigned long int temp_pointer;
 
14768   unsigned long int teller;
 
14769   unsigned char true_c_val[3];
 
14771   current_pointer = ftell ( filein ) - 2;
 
14775   while ( !end_found )
 
14778     teller = teller + 2;
 
14780     switch ( temp_int )
 
14785           cout << 
"   COLOR_F RGB color definition section tag of " 
14786             << hex << temp_int << 
"\n";
 
14788         for ( 
i = 0; 
i < 3; 
i++ )
 
14794           cout << 
"RGB_VAL = " 
14795                << setw(10) << rgb_val[0] << 
"  " 
14796                << setw(10) << rgb_val[1] << 
"  " 
14797                << setw(10) << rgb_val[2] << 
"\n";
 
14799         teller = teller + 3 * 
sizeof ( float );
 
14804           cout << 
"   COLOR_24 24 bit color definition section tag of " 
14805             << hex << temp_int << 
"\n";
 
14808         for ( 
i = 0; 
i < 3; 
i++ )
 
14810           true_c_val[
i] = fgetc ( filein );
 
14814           cout << 
"TRUE_C_VAL = " 
14815                << setw(6) << true_c_val[0] << 
"  " 
14816                << setw(6) << true_c_val[1] << 
"  " 
14817                << setw(6) << true_c_val[2] << 
"\n";
 
14819         teller = teller + 3;
 
14825     if ( temp_pointer <= teller )
 
14832   pointer = ( long ) ( current_pointer + temp_pointer );
 
14833   fseek ( filein, pointer, SEEK_SET );
 
14835   return ( temp_pointer );
 
14852   unsigned long current_pointer;
 
14854   unsigned long temp_pointer;
 
14856   current_pointer = ftell ( filein ) - 2;
 
14859   *
boolean = fgetc ( filein );
 
14861   pointer = ( long ) ( current_pointer + temp_pointer );
 
14862   fseek ( filein, pointer, SEEK_SET );
 
14864   return ( temp_pointer );
 
14881   float               camera_eye[3];
 
14882   float               camera_focus[3];
 
14883   unsigned long int   current_pointer;
 
14887   unsigned long int   temp_pointer;
 
14888   unsigned short int  u_short_int_val;
 
14890   current_pointer = ftell ( filein ) - 2;
 
14906     cout << 
" Found camera viewpoint at XYZ = " 
14907       << setw(10) << camera_eye[0] << 
"  " 
14908       << setw(10) << camera_eye[1] << 
"  " 
14909       << setw(10) << camera_eye[2] << 
"\n";
 
14910     cout << 
"     Found camera focus coordinates at XYZ = " 
14911       << setw(10) << camera_focus[0] << 
"  " 
14912       << setw(10) << camera_focus[1] << 
"  " 
14913       << setw(10) << camera_focus[2] << 
"\n";
 
14914     cout << 
"     Rotation of camera is:  " << rotation << 
"\n";
 
14915     cout << 
"     Lens in used camera is: " << lens << 
" mm.\n";
 
14918   if ( 0 < ( temp_pointer-38 ) )
 
14922       cout << 
"          Found extra camera sections.\n";
 
14927     if ( u_short_int_val == 0x4710 )
 
14931         cout << 
"          CAM_SEE_CONE.\n";
 
14938     if ( u_short_int_val == 0x4720 )
 
14942         cout << 
"          CAM_RANGES.\n";
 
14949   pointer = ( long ) ( current_pointer + temp_pointer );
 
14950   fseek ( filein, pointer, SEEK_SET );
 
14952   return ( temp_pointer );
 
14973   unsigned long int   chunk_length;
 
14974   unsigned long int   current_pointer;
 
14975   bool end_found = 
false;
 
14977   unsigned long int   teller;
 
14978   unsigned short int  temp_int;
 
14980   current_pointer = ftell ( filein ) - 2;
 
14984   while ( !end_found )
 
14987     teller = teller + 2;
 
14991       cout << 
"    TDS_READ_EDIT_SECTION processing tag " 
14992            << hex << temp_int << 
"\n";
 
14995     switch ( temp_int )
 
15000           cout << 
"    BIT_MAP section tag of " 
15001                << hex << temp_int << 
"\n";
 
15008           cout << 
"    USE_SOLID_BGND section tag of " 
15009                << hex << temp_int << 
"\n";
 
15016           cout << 
"    V_GRADIENT section tag of " 
15017                << hex << temp_int << 
"\n";
 
15054           cout << 
"    AMBIENT_LIGHT section tag of " 
15055                << hex << temp_int << 
"\n";
 
15062           cout << 
"    SOLID_BGND section tag of " 
15063                << hex << temp_int << 
"\n";
 
15070           cout << 
"    MASTER_SCALE section tag of " 
15071                << hex << temp_int << 
"\n";
 
15078           cout << 
"    MESH_VERSION section tag of " 
15079                << hex << temp_int << 
"\n";
 
15086           cout << 
"    MAT_ENTRY section tag of " 
15087                << hex << temp_int << 
"\n";
 
15094           cout << 
"    NAMED_OBJECT section tag of " 
15095                << hex << temp_int << 
"\n";
 
15102           cout << 
"    VIEWPORT_LAYOUT section tag of " 
15103                << hex << temp_int << 
"\n";
 
15110           cout << 
"    VIEWPORT_DATA_3 section tag of " 
15111                << hex << temp_int << 
"\n";
 
15118           cout << 
"    VIEWPORT_DATA section tag of " 
15119                << hex << temp_int << 
"\n";
 
15126           cout << 
"    VIEWPORT_SIZE section tag of " 
15127                << hex << temp_int << 
"\n";
 
15134           cout << 
"    Junk.\n";
 
15139     if ( chunk_length <= teller )
 
15146   pointer = ( long ) ( current_pointer + chunk_length );
 
15148   fseek ( filein, pointer, SEEK_SET );
 
15150   return ( chunk_length );
 
15167   unsigned long int   current_pointer;
 
15168   bool end_found = 
false;
 
15170   unsigned short int  temp_int;
 
15171   unsigned long int   temp_pointer;
 
15172   unsigned long int   teller;
 
15174   current_pointer = ftell ( filein ) - 2;
 
15178   while ( !end_found )
 
15181     teller = teller + 2;
 
15183     switch ( temp_int )
 
15188           cout << 
"    VIEWPORT_LAYOUT main definition section tag of " 
15189                << hex << temp_int << 
"\n";
 
15196           cout << 
"    KFSEG frames section tag of " 
15197                << hex << temp_int << 
"\n";
 
15204           cout << 
"    OBJECT_NODE_TAG object description section tag of " 
15205                << hex << temp_int << 
"\n";
 
15212           cout << 
"    KFCURTIME section tag of " 
15213                << hex << temp_int << 
"\n";
 
15220           cout << 
"    KFHDR section tag of " 
15221                << hex << temp_int << 
"\n";
 
15229     if ( temp_pointer <= teller )
 
15236   pointer = ( long ) ( current_pointer + temp_pointer );
 
15237   fseek ( filein, pointer, SEEK_SET );
 
15239   return ( temp_pointer );
 
15260   unsigned long int   chunk_size;
 
15261   unsigned long int   current_pointer;
 
15262   bool end_found = 
false;
 
15264   unsigned short int  temp_int;
 
15265   unsigned long int   temp_pointer;
 
15266   unsigned long int   teller;
 
15267   unsigned long int   u_long_int_val;
 
15268   unsigned short int  u_short_int_val;
 
15270   current_pointer = ftell ( filein ) - 2;
 
15274   while ( !end_found )
 
15277     teller = teller + 2;
 
15279     switch ( temp_int )
 
15284           cout << 
"      INSTANCE_NAME section tag of " 
15285                << hex << temp_int << 
"\n";
 
15292           cout << 
"      NODE_HDR section tag of " 
15293                << hex << temp_int << 
"\n";
 
15300           cout << 
"      POS_TRACK_TAG section tag of " 
15301                << hex << temp_int << 
"\n";
 
15306           cout << 
"      chunk_size = " << chunk_size << 
"\n";
 
15319           cout << 
"u_short_int_val = " << u_short_int_val << 
"\n";
 
15320           cout << 
"u_long_int_val = " << u_long_int_val << 
"\n";
 
15325         teller = teller + 32;
 
15330           cout << 
"      PIVOT section tag of " 
15331                << hex << temp_int << 
"\n";
 
15337         teller = teller + 12;
 
15342           cout << 
"      BOUNDBOX section tag of " 
15343                << hex << temp_int << 
"\n";
 
15350           cout << 
"      MORPH_SMOOTH section tag of " 
15351                << hex << temp_int << 
"\n";
 
15358           cout << 
"      ROT_TRACK_TAG section tag of " 
15359                << hex << temp_int << 
"\n";
 
15366           cout << 
"      SCL_TRACK_TAG section tag of " 
15367                << hex << temp_int << 
"\n";
 
15374           cout << 
"      NODE_ID section tag of " 
15375                << hex << temp_int << 
"\n";
 
15383     if ( temp_pointer <= teller )
 
15390   pointer = ( long ) ( current_pointer+temp_pointer );
 
15391   fseek ( filein, pointer, SEEK_SET );
 
15393   return ( temp_pointer );
 
15410   unsigned char boolean;
 
15411   unsigned long int current_pointer;
 
15412   bool end_found = 
false;
 
15414   float light_coors[3];
 
15417   unsigned long int teller;
 
15418   unsigned short int temp_int;
 
15419   unsigned long int temp_pointer;
 
15420   unsigned char true_c_val[3];
 
15422   current_pointer = ftell ( filein ) - 2;
 
15430   teller = teller + 3 * 4;
 
15434     cout << 
"     Found light at coordinates XYZ = " 
15435       << setw(10) << light_coors[0] << 
"  " 
15436       << setw(10) << light_coors[1] << 
"  " 
15437       << setw(10) << light_coors[2] << 
"\n";
 
15440   while ( !end_found )
 
15443     teller = teller + 2;
 
15445     switch ( temp_int )
 
15450           cout << 
"      COLOR_F RGB color definition section tag of " 
15451                << hex << temp_int << 
"\n";
 
15453         for ( 
i = 0; 
i < 3; 
i++ )
 
15459           cout << 
"      RGB_VAL value set to " 
15460             << setw(10) << rgb_val[0] << 
"  " 
15461             << setw(10) << rgb_val[1] << 
"  " 
15462             << setw(10) << rgb_val[2] << 
"\n";
 
15464         teller = teller + 3 * 
sizeof ( float );
 
15469           cout << 
"      COLOR_24 24 bit color definition section tag of " 
15470                << hex << temp_int << 
"\n";
 
15473         for ( 
i = 0; 
i < 3; 
i++ )
 
15475           true_c_val[
i] = fgetc ( filein );
 
15479           cout << 
"      TRUE_C_VAL value set to " 
15480             << setw(6) << true_c_val[0] << 
"  " 
15481             << setw(6) << true_c_val[1] << 
"  " 
15482             << setw(6) << true_c_val[2] << 
"\n";
 
15484         teller = teller + 3;
 
15489           cout << 
"      DL_OFF section: " 
15490                << hex << temp_int << 
"\n";
 
15495           if ( 
boolean == 1 )
 
15497             cout << 
"      Light is on.\n";
 
15501             cout << 
"      Light is off.\n";
 
15508           cout << 
"      DL_SPOTLIGHT section tag of " 
15509                << hex << temp_int << 
"\n";
 
15516           cout << 
"      DL_OUTER_RANGE section tag of " 
15517                << hex << temp_int << 
"\n";
 
15525     if ( temp_pointer <= teller )
 
15532   pointer = ( long ) ( current_pointer + temp_pointer );
 
15533   fseek ( filein, pointer, SEEK_SET );
 
15535   return ( temp_pointer );
 
15561     unsigned long int yint;
 
15567     y.ychar[3] = fgetc ( filein );
 
15568     y.ychar[2] = fgetc ( filein );
 
15569     y.ychar[1] = fgetc ( filein );
 
15570     y.ychar[0] = fgetc ( filein );
 
15574     y.ychar[0] = fgetc ( filein );
 
15575     y.ychar[1] = fgetc ( filein );
 
15576     y.ychar[2] = fgetc ( filein );
 
15577     y.ychar[3] = fgetc ( filein );
 
15597   unsigned char  letter;
 
15598   unsigned int   teller;
 
15601   letter = fgetc ( filein );
 
15612   teller = teller + 1;
 
15616     letter = fgetc ( filein );
 
15618     teller = teller + 1;
 
15619   } 
while ( letter != 0 );
 
15625     cout << 
"      TDS_READ_LONG_NAME found name: " << 
temp_name << 
".\n";
 
15645   unsigned long int  current_pointer;
 
15648   unsigned long int  temp_pointer;
 
15650   current_pointer = ftell ( filein ) - 2;
 
15655   if ( teller == -1 )
 
15659       cout << 
"      No material name found.\n";
 
15667       cout << 
"      Material name " << 
mat_name << 
".\n";
 
15671   pointer = ( long ) ( current_pointer + temp_pointer );
 
15672   fseek ( filein, pointer, SEEK_SET );
 
15674   return ( temp_pointer );
 
15691   unsigned long int   current_pointer;
 
15692   bool end_found = 
false;
 
15694   unsigned short int  temp_int;
 
15695   unsigned long int   temp_pointer;
 
15696   unsigned long int   teller;
 
15698   current_pointer = ftell ( filein ) - 2;
 
15703   while ( !end_found )
 
15706     teller = teller + 2;
 
15708     switch ( temp_int )
 
15713           cout << 
"     MAT_NAME definition section tag of " 
15714                << hex << temp_int << 
"\n";
 
15721           cout << 
"     MAT_AMBIENT definition section tag of " 
15722                << hex << temp_int << 
"\n";
 
15729           cout << 
"     MAT_DIFFUSE definition section tag of " 
15730                << hex << temp_int << 
"\n";
 
15737           cout << 
"     MAT_SPECULAR definition section tag of " 
15738                << hex << temp_int << 
"\n";
 
15745           cout << 
"     MAT_SHININESS definition section tag of " 
15746                << hex << temp_int << 
"\n";
 
15753           cout << 
"     MAT_SHIN2PCT definition section tag of " 
15754                << hex << temp_int << 
"\n";
 
15761           cout << 
"     MAT_SHIN3PCT definition section tag of " 
15762                << hex << temp_int << 
"\n";
 
15769           cout << 
"     MAT_TRANSPARENCY definition section tag of " 
15770                << hex << temp_int << 
"\n";
 
15777          cout << 
"     MAT_XPFALL definition section tag of " 
15778                << hex << temp_int << 
"\n";
 
15785           cout << 
"     MAT_REFBLUR definition section tag of " 
15786                << hex << temp_int << 
"\n";
 
15793           cout << 
"     MAT_SELF_ILLUM definition section tag of " 
15794                << hex << temp_int << 
"\n";
 
15801           cout << 
"     MAT_TWO_SIDE definition section tag of " 
15802                << hex << temp_int << 
"\n";
 
15809           cout << 
"     MAT_DECAL definition section tag of " 
15810                << hex << temp_int << 
"\n";
 
15817           cout << 
"     MAT_ADDITIVE definition section tag of " 
15818                << hex << temp_int << 
"\n";
 
15825           cout << 
"     MAT_SELF_ILPCT definition section tag of " 
15826                << hex << temp_int << 
"\n";
 
15833           cout << 
"     MAT_WIRE definition section tag of " 
15834                << hex << temp_int << 
"\n";
 
15841           cout << 
"     MAT_SUPERSMP definition section tag of " 
15842                << hex << temp_int << 
"\n";
 
15849           cout << 
"     MAT_WIRESIZE definition section tag of " 
15850                << hex << temp_int << 
"\n";
 
15857           cout << 
"     MAT_FACEMAP definition section tag of " 
15858                << hex << temp_int << 
"\n";
 
15865           cout << 
"     MAT_XPFALLIN definition section tag of " 
15866                << hex << temp_int << 
"\n";
 
15873           cout << 
"     MAT_PHONGSOFT definition section tag of " 
15874                << hex << temp_int << 
"\n";
 
15881           cout << 
"     MAT_WIREABS definition section tag of " 
15882                << hex << temp_int << 
"\n";
 
15889           cout << 
"     MAT_SHADING definition section tag of " 
15890                << hex << temp_int << 
"\n";
 
15897           cout << 
"     MAT_TEXMAP definition section tag of " 
15898                << hex << temp_int << 
"\n";
 
15908           cout << 
"     MAT_SPECMAP definition section tag of " 
15909                << hex << temp_int << 
"\n";
 
15916           cout << 
"     MAT_OPACMAP definition section tag of " 
15917                << hex << temp_int << 
"\n";
 
15924           cout << 
"     MAT_REFLMAP definition section tag of " 
15925                << hex << temp_int << 
"\n";
 
15932           cout << 
"     MAT_BUMPMAP definition section tag of " 
15933                << hex << temp_int << 
"\n";
 
15940           cout << 
"     MAT_MAP_TEXBLUR definition section tag of " 
15941                << hex << temp_int << 
"\n";
 
15948           cout << 
"  Junk section tag of " 
15949                << hex << temp_int << 
"\n";
 
15954     if ( temp_pointer <= teller )
 
15960   pointer = ( long ) ( current_pointer + temp_pointer );
 
15962   fseek ( filein, pointer, SEEK_SET );
 
15964   return ( temp_pointer );
 
15981   unsigned char  letter;
 
15982   unsigned int   teller;
 
15985   letter = fgetc ( filein );
 
15997   teller = teller + 1;
 
16001     letter = fgetc ( filein );
 
16003     teller = teller + 1;
 
16004   } 
while ( ( letter != 0 ) && ( teller < 12 ) );
 
16010     cout << 
"      TDS_READ_NAME found name: " << 
temp_name << 
".\n";
 
16038   unsigned short int b;
 
16039   unsigned long int chunk_size;
 
16040   unsigned short int color_index;
 
16041   unsigned long int current_pointer;
 
16042   bool end_found = 
false;
 
16043   unsigned short int  g;
 
16050   unsigned short int  r;
 
16051   unsigned short int  temp_int;
 
16052   unsigned long int   temp_pointer;
 
16053   unsigned long int   temp_pointer2;
 
16054   unsigned long int   teller;
 
16056   current_pointer = ftell ( filein ) - 2;
 
16061   while ( !end_found )
 
16064     teller = teller + 2;
 
16066     switch ( temp_int )
 
16071           cout << 
"        NAMED_OBJECT section tag of " 
16072                << hex << temp_int << 
"\n";
 
16080           cout << 
"        N_TRI_OBJECT section tag of " 
16081                << hex << temp_int << 
"\n";
 
16090           cout << 
"        POINT_ARRAY section tag of " 
16091                << hex << temp_int << 
"\n";
 
16094         current_pointer = ftell ( filein ) - 2;
 
16106         teller = teller + temp_pointer2;
 
16112           cout << 
"        POINT_FLAG_ARRAY faces (2) section tag of " 
16113                << hex << temp_int << 
"\n";
 
16122           cout << 
"        FACE_ARRAY section tag of " 
16123                << hex << temp_int << 
"\n";
 
16143           r = ( temp_int & 0x0004 ) >> 2;
 
16144           g = ( temp_int & 0x0002 ) >> 1;
 
16145           b = ( temp_int & 0x0001 );
 
16147           for ( j = 0; j < 3; j++ )
 
16157         if ( temp_int == 0x4150 )
 
16166         teller = ftell ( filein );
 
16172           cout << 
"        MSH_MAT_GROUP section tag of " 
16173                << hex << temp_int << 
"\n";
 
16181           cout << 
"        TEX_VERTS section tag of " 
16182                << hex << temp_int << 
"\n";
 
16190           cout << 
"        SMOOTH_GROUP section tag of " 
16191                << hex << temp_int << 
"\n";
 
16200           cout << 
"        MESH_MATRIX section tag of " 
16201                << hex << temp_int << 
"\n";
 
16206         for ( j = 0; j < 4; j++ )
 
16208           for ( 
i = 0; 
i < 3; 
i++ )
 
16218         teller = teller + 12 * 
sizeof ( float );
 
16225           cout << 
"        MESH_COLOR section tag of " 
16226                << hex << temp_int << 
"\n";
 
16231         if ( chunk_size == 7 )
 
16233           color_index = fgetc ( filein );
 
16234           teller = teller + 5;
 
16239           teller = teller + 6;
 
16243           cout << 
"        Color index set to " << color_index << 
"\n";
 
16250           cout << 
"        MESH_TEXTURE_INFO section tag of " 
16251                << hex << temp_int << 
"\n";
 
16259           cout << 
"        JUNK section tag of " 
16260                << hex << temp_int << 
"\n";
 
16265     if (  temp_pointer <= teller )
 
16272   pointer = ( 
long int ) ( current_pointer + temp_pointer );
 
16273   fseek ( filein, pointer, SEEK_SET );
 
16275   return ( temp_pointer );
 
16292   bool end_found = 
false;
 
16293   unsigned long int   current_pointer;
 
16296   unsigned short int  temp_int;
 
16297   unsigned long int   temp_pointer;
 
16298   unsigned long int   teller;
 
16300   current_pointer = ftell ( filein ) - 2;
 
16308   if ( int_val == -1 )
 
16312       cout << 
"      Dummy Object found\n";
 
16320   while ( !end_found )
 
16323     teller = teller + 2;
 
16325     switch ( temp_int )
 
16330           cout << 
"      N_CAMERA section tag of " 
16331                << hex << temp_int << 
"\n";
 
16338           cout << 
"      N_DIRECT_LIGHT section tag of " 
16339                << hex << temp_int << 
"\n";
 
16346           cout << 
"      OBJ_TRIMESH section tag of " 
16347                << hex << temp_int << 
"\n";
 
16354           cout << 
"      OBJ_HIDDEN section tag of " 
16355                << hex << temp_int << 
"\n";
 
16362           cout << 
"      OBJ_DOESNT_CAST section tag of " 
16363                << hex << temp_int << 
"\n";
 
16371     if ( temp_pointer <= teller )
 
16378   pointer = ( long ) ( current_pointer + temp_pointer );
 
16380   fseek ( filein, pointer, SEEK_SET );
 
16382   return ( temp_pointer );
 
16413   unsigned long int  current_pointer;
 
16416   unsigned long int  temp_pointer;
 
16417   unsigned short int n2;
 
16419   current_pointer = ftell ( filein ) - 2;
 
16422   pointer = ( 
long int ) ( current_pointer + temp_pointer );
 
16426   for ( icor3 = 0; icor3 < n2; icor3++ )
 
16432   fseek ( filein, pointer, SEEK_SET );
 
16434   return ( temp_pointer );
 
16464   unsigned long int current_pointer;
 
16467   unsigned long int  temp_pointer;
 
16471   current_pointer = ftell ( filein ) - 2;
 
16488   if ( teller == -1 )
 
16492       cout << 
"      No TEXMAP name found.\n";
 
16504   pointer = ( long ) ( current_pointer + temp_pointer );
 
16505   fseek ( filein, pointer, SEEK_SET );
 
16507   return ( temp_pointer );
 
16528   c1 = fgetc ( filein );
 
16529   c2 = fgetc ( filein );
 
16531   ival = c1 | ( c2 << 8 );
 
16550   unsigned long int current_pointer;
 
16555   unsigned long int  temp_pointer;
 
16557   current_pointer = ftell ( filein ) - 2;
 
16568     cout << 
"      The target of the spot is XYZ = " 
16569       << setw(10) << target[0] << 
"  " 
16570       << setw(10) << target[1] << 
"  " 
16571       << setw(10) << target[2] << 
"\n";
 
16572     cout << 
"      The hotspot of this light is " << hotspot << 
".\n";
 
16573     cout << 
"      The falloff of this light is " << falloff << 
".\n";
 
16576   pointer = ( long ) ( current_pointer + temp_pointer );
 
16578   fseek ( filein, pointer, SEEK_SET );
 
16580   return ( temp_pointer );
 
16597   unsigned long int current_pointer;
 
16599   unsigned long int  temp_pointer;
 
16601   current_pointer = ftell ( filein ) - 2;
 
16604   pointer = ( 
long int ) ( current_pointer + temp_pointer );
 
16606   fseek ( filein, pointer, SEEK_SET );
 
16608   return ( temp_pointer );
 
16625   unsigned long int current_pointer;
 
16626   bool end_found = 
false;
 
16628   unsigned short int  temp_int;
 
16629   unsigned long int   temp_pointer;
 
16630   unsigned long int   teller;
 
16632   current_pointer = ftell ( filein ) - 2;
 
16636   while ( !end_found )
 
16639     teller = teller + 2;
 
16641     switch ( temp_int )
 
16646           cout << 
"     VIEWPORT_DATA_3 section tag of " 
16647                << hex << temp_int << 
"\n";
 
16654           cout << 
"     VIEWPORT_DATA section tag of " 
16655                << hex << temp_int << 
"\n";
 
16662           cout << 
"     VIEWPORT_SIZE section tag of " 
16663                << hex << temp_int << 
"\n";
 
16671     if ( temp_pointer <= teller )
 
16676     if ( 3 < *views_read )
 
16682   pointer = ( 
long int ) ( current_pointer + temp_pointer );
 
16684   fseek ( filein, pointer, SEEK_SET );
 
16686   return ( temp_pointer );
 
16703   unsigned int       attribs;
 
16704   unsigned long int  current_pointer;
 
16709   unsigned long int  temp_pointer;
 
16710   char              *viewports[11] = {
 
16724   *views_read = *views_read + 1;
 
16726   current_pointer = ftell ( filein ) - 2;
 
16731   if ( attribs == 3 )
 
16735       cout << 
"<Snap> active in viewport.\n";
 
16739   if ( attribs == 5 )
 
16743       cout << 
"<Grid> active in viewport.\n";
 
16749   for ( 
i = 1; 
i < 6; 
i++ )
 
16758   if ( ( port == 0xffff ) || ( port == 0 ) )
 
16760     for ( 
i = 0; 
i < 12; 
i++ )
 
16767     if ( int_val == -1 )
 
16771         cout << 
"      No Camera name found\n";;
 
16780     cout << 
"Reading [" << viewports[port]
 
16781          << 
"] information with tag: " << port << 
"\n";
 
16784   pointer = ( 
long int ) ( current_pointer + temp_pointer );
 
16786   fseek ( filein, pointer, SEEK_SET );
 
16788   return ( temp_pointer );
 
16841   long int            long_int_val;
 
16843   short int           short_int_val;
 
16844   unsigned short int  u_short_int_val;
 
16852   l4120 = 2 + 4 + 2 + 4 * 
face_num * 2 + l4150;
 
16853   l4160 = 2 + 4 + 4 * 12;
 
16854   l4110 = 2 + 4 + 2 + 
cor3_num * 3 * 4;
 
16855   l4100 = 2 + 4 + l4110 + l4160 + l4120;
 
16856   l4000 = 2 + 4 + ( name_length + 1 ) + l4100;
 
16859   l3d3d = 2 + 4 + l3d3e + l0100 + l4000;
 
16861   lb022 = 2 + 4 + 32;
 
16862   lb021 = 2 + 4 + 9 * 4;
 
16863   lb020 = 2 + 4 + 8 * 4;
 
16864   lb013 = 2 + 4 + 6 * 2;
 
16865   lb010 = 2 + 4 + ( name_length + 1 ) + 3 * 2;
 
16867   lb002 = 2 + 4 + lb030 + lb010 + lb013 + lb020 + lb021 + lb022;
 
16869   lb008 = 2 + 4 + 2 * 4;
 
16870   lb00a = 2 + 4 + 2 + 9 + 2 * 2;
 
16871   lb000 = 2 + 4 + lb00a + lb008 + lb009 + lb002;
 
16873   l4d4d = 2 + 4 + l0002 + l3d3d + lb000;
 
16878   short_int_val = ( short ) 0x4d4d;
 
16885   short_int_val = ( short ) 0x0002;
 
16895   short_int_val = ( short ) 0x3d3d;
 
16902   short_int_val = ( short ) 0x3d3e;
 
16912   short_int_val = ( short ) 0x0100;
 
16922   short_int_val = ( short ) 0x4000;
 
16930   short_int_val = ( short ) 0x4100;
 
16938   short_int_val = ( short ) 0x4110;
 
16942   u_short_int_val = ( 
unsigned short ) 
cor3_num;
 
16945   for ( icor3 = 0; icor3 < 
cor3_num; icor3++ )
 
16947     for ( j = 0; j < 3; j++ )
 
16957   short_int_val = ( short ) 0x4160;
 
16961   for ( 
i = 0; 
i < 4; 
i++ )
 
16963     for ( j = 0; j < 3; j++ )
 
16975   short_int_val = ( short ) 0x4120;
 
16979   u_short_int_val = ( 
unsigned short ) 
face_num;
 
16982   for ( iface = 0; iface < 
face_num; iface++ )
 
16984     for ( j = 0; j < 3; j++ )
 
16986       short_int_val = 
face[j][iface];
 
16996   short_int_val = ( short ) 0x4150;
 
17000   for ( iface = 0; iface < 
face_num; iface++ )
 
17013   short_int_val = ( short ) 0xb000;
 
17020   short_int_val = ( short ) 0xb00a;
 
17026   short_int_val = 100;
 
17035   short_int_val = ( short ) 0xb008;
 
17040   long_int_val = 100;
 
17047   short_int_val = ( short ) 0xb009;
 
17057   short_int_val = ( short ) 0xb002;
 
17064   short_int_val = ( short ) 0xb030;
 
17074   short_int_val = ( short ) 0xb010;
 
17078   short_int_val = 16384;
 
17082   short_int_val = -1;
 
17089   short_int_val = ( short ) 0xb013;
 
17092   for ( 
i = 0; 
i < 3; 
i++ )
 
17102   short_int_val = ( short ) 0xb020;
 
17123   for ( 
i = 0; 
i < 3; 
i++ )
 
17133   short_int_val = ( short ) 0xb021;
 
17164   short_int_val = ( short ) 0xb022;
 
17200   cout << 
"TDS_WRITE wrote " << 
bytes_num << 
" bytes.\n";
 
17232   for ( c = 
string; nchar < 12; c++ )
 
17234     fputc ( *c, fileout );
 
17270     unsigned short int yint;
 
17274   y.yint = short_int_val;
 
17278     fputc ( y.ychar[1], fileout );
 
17279     fputc ( y.ychar[0], fileout );
 
17283     fputc ( y.ychar[0], fileout );
 
17284     fputc ( y.ychar[1], fileout );
 
17357   for ( iface = 0; iface < 
face_num; iface++ )
 
17359     for ( j = 0; j < 
face_order[iface] - 2; j++ )
 
17361       face_num2 = face_num2 + 1;
 
17367   fprintf ( fileout, 
"TITLE = \"%s created by IVCON.\"\n", 
fileout_name );
 
17368   fprintf ( fileout, 
"VARIABLES = \"X\", \"Y\", \"Z\", \"R\", \"G\", \"B\"\n" );
 
17370     "ZONE T=\"TRIANGLES\", N=%d, E=%d, F=FEPOINT, ET=TRIANGLE\n",
 
17377   for ( icor3 = 0; icor3 < 
cor3_num; icor3++ )
 
17383     fprintf ( fileout, 
"%f %f %f %f %f %f\n", 
cor3[0][icor3], 
cor3[1][icor3],
 
17384       cor3[2][icor3], r, g, b );
 
17390   for ( iface = 0; iface < 
face_num; iface++ )
 
17395     for ( j = 0; j < 
face_order[iface] - 2; j++ )
 
17397       face2[0] = 
face[  0][iface] + 1;
 
17398       face2[1] = 
face[j+1][iface] + 1;
 
17399       face2[2] = 
face[j+2][iface] + 1;
 
17401       fprintf ( fileout, 
"%d %d %d\n", face2[0], face2[1], face2[2] );
 
17411   cout << 
"TEC_WRITE - Wrote " << 
text_num << 
" text lines.\n";
 
17476   for ( 
i = 0; 
i < 4; 
i++ )
 
17478     for ( j = 0; j < 4; j++ )
 
17494 void tmat_mxm ( 
float a[4][4], 
float b[4][4], 
float c[4][4] )
 
17540   for ( 
i = 0; 
i < 4; 
i++ )
 
17542     for ( 
k = 0; 
k < 4; 
k++ )
 
17545       for ( j = 0; j < 4; j++ )
 
17547         d[
i][
k] = d[
i][
k] + a[
i][j] * b[j][
k];
 
17552   for ( 
i = 0; 
i < 4; 
i++ )
 
17554     for ( j = 0; j < 4; j++ )
 
17605   for ( 
i = 0; 
i < 3; 
i++ )
 
17608     for ( j = 0; j < 3; j++ )
 
17610       z[
i] = z[
i] + a[
i][j] * x[j];
 
17614   for ( 
i = 0; 
i < 3; 
i++ )
 
17622 void tmat_mxp2 ( 
float a[4][4], 
float x[][3], 
float y[][3], 
int n )
 
17665   for ( 
k = 0; 
k < n; 
k++ )
 
17667     for ( 
i = 0; 
i < 3; 
i++ )
 
17670       for ( j = 0; j < 3; j++ )
 
17672         z[
i] = z[
i] + a[
i][j] * x[
k][j];
 
17676     for ( 
i = 0; 
i < 3; 
i++ )
 
17728   for ( 
i = 0; 
i < 3; 
i++ )
 
17731     for ( j = 0; j < 3; j++ )
 
17733       z[
i] = z[
i] + a[
i][j] * x[j];
 
17735     z[
i] = z[
i] + a[
i][3];
 
17738   for ( 
i = 0; 
i < 3; 
i++ )
 
17796   if ( axis == 
'X' || axis == 
'x' )
 
17798     c[1][1] =   cos ( theta );
 
17799     c[1][2] = - sin ( theta );
 
17800     c[2][1] =   sin ( theta );
 
17801     c[2][2] =   cos ( theta );
 
17803   else if ( axis == 
'Y' || axis == 
'y' )
 
17805     c[0][0] =   cos ( theta );
 
17806     c[0][2] =   sin ( theta );
 
17807     c[2][0] = - sin ( theta );
 
17808     c[2][2] =   cos ( theta );
 
17810   else if ( axis == 
'Z' || axis == 
'z' )
 
17812     c[0][0] =   cos ( theta );
 
17813     c[0][1] = - sin ( theta );
 
17814     c[1][0] =   sin ( theta );
 
17815     c[1][1] =   cos ( theta );
 
17820     cout << 
"TMAT_ROT_AXIS - Fatal error!\n";
 
17821     cout << 
"  Illegal rotation axis: " << axis << 
".\n";
 
17822     cout << 
"  Legal choices are 'X', 'Y', or 'Z'.\n";
 
17828   for ( 
i = 0; 
i < 4; 
i++ )
 
17830     for ( j = 0; j < 4; j++ )
 
17840   float v1, 
float v2, 
float v3 )
 
17888   if ( v1 * v1 + v2 * v2 + v3 * v3 == 0.0 )
 
17897   ca = cos ( theta );
 
17898   sa = sin ( theta );
 
17900   c[0][0] =                v1 * v1 + ca * ( 1.0 - v1 * v1 );
 
17901   c[0][1] = ( 1.0 - ca ) * v1 * v2 - sa * v3;
 
17902   c[0][2] = ( 1.0 - ca ) * v1 * v3 + sa * v2;
 
17904   c[1][0] = ( 1.0 - ca ) * v2 * v1 + sa * v3;
 
17905   c[1][1] =                v2 * v2 + ca * ( 1.0 - v2 * v2 );
 
17906   c[1][2] = ( 1.0 - ca ) * v2 * v3 - sa * v1;
 
17908   c[2][0] = ( 1.0 - ca ) * v3 * v1 - sa * v2;
 
17909   c[2][1] = ( 1.0 - ca ) * v3 * v2 + sa * v1;
 
17910   c[2][2] =                v3 * v3 + ca * ( 1.0 - v3 * v3 );
 
17914   for ( 
i = 0; 
i < 4; 
i++ )
 
17916     for ( j = 0; j < 4; j++ )
 
17976   for ( 
i = 0; 
i < 4; 
i++ )
 
17978     for ( j = 0; j < 4; j++ )
 
17987 void tmat_shear ( 
float a[4][4], 
float b[4][4], 
char *axis, 
float s )
 
18040   if ( strcmp ( axis, 
"XY" ) == 0 || strcmp ( axis, 
"xy" ) == 0 )
 
18044   else if ( strcmp ( axis, 
"XZ" ) == 0 || strcmp ( axis, 
"xz" ) == 0 )
 
18048   else if ( strcmp ( axis, 
"YX" ) == 0 || strcmp ( axis, 
"yx" ) == 0 )
 
18052   else if ( strcmp ( axis, 
"YZ" ) == 0 || strcmp ( axis, 
"yz" ) == 0 )
 
18056   else if ( strcmp ( axis, 
"ZX" ) == 0 || strcmp ( axis, 
"zx" ) == 0 )
 
18060   else if ( strcmp ( axis, 
"ZY" ) == 0 || strcmp ( axis, 
"zy" ) == 0 )
 
18067     cout << 
"TMAT_SHEAR - Fatal error!\n";
 
18068     cout << 
"  Illegal shear axis: " << axis << 
".\n";
 
18069     cout << 
"  Legal choices are XY, XZ, YX, YZ, ZX, or ZY.\n";
 
18075   for ( 
i = 0; 
i < 4; 
i++ )
 
18077     for ( j = 0; j < 4; j++ )
 
18127   for ( 
i = 0; 
i < 4; 
i++ )
 
18129     for ( j = 0; j < 4; j++ )
 
18134   b[0][3] = b[0][3] + x;
 
18135   b[1][3] = b[1][3] + y;
 
18136   b[2][3] = b[2][3] + z;
 
18194   sscanf ( 
input, 
"%d", &face_num2 );
 
18201   for ( iface = iface_lo; iface < iface_hi; iface++ )
 
18211     for ( ivert = 0; ivert < 
face_order[iface]; ivert++ )
 
18215       sscanf ( 
input, 
"%e %e %e %e %e %e", &r1, &r2, &r3, &r4, &r5, &r6 );
 
18248         face[ivert][iface] = icor3;
 
18320   for ( iface = 0; iface < 
face_num; iface++ )
 
18322     for ( jlo = 0; jlo < 
face_order[iface] - 2; jlo++ )
 
18324       face_num2 = face_num2 + 1;
 
18328   fprintf ( fileout,  
"%d\n", face_num2 );
 
18333   for ( iface = 0; iface < 
face_num; iface++ )
 
18338     for ( jlo = 0; jlo < 
face_order[iface] - 2; jlo++ )
 
18340       face2[0] = 
face[    0][iface];
 
18341       face2[1] = 
face[jlo+1][iface];
 
18342       face2[2] = 
face[jlo+2][iface];
 
18344       for ( 
k = 0; 
k < 3; 
k++ )
 
18348         x = 
cor3[0][icor3];
 
18349         y = 
cor3[1][icor3];
 
18350         z = 
cor3[2][icor3];
 
18356         fprintf ( fileout,  
"%f %f %f %f %f %f\n", x, y, z, nx, ny, nz );
 
18369   cout << 
"TRIA_WRITE - Wrote " << 
text_num << 
" text lines.\n";
 
18429   for ( iface = iface_lo; iface < iface_hi; iface++ )
 
18437     for ( ivert = 0; ivert < 
face_order[iface]; ivert++ )
 
18439       for ( 
i = 0; 
i < 3; 
i++ )
 
18472         face[ivert][iface] = icor3;
 
18475         for ( 
i = 0; 
i < 3; 
i++ )
 
18554   for ( iface = 0; iface < 
face_num; iface++ )
 
18556     for ( jlo = 0; jlo < 
face_order[iface] - 2; jlo++ )
 
18558       face_num2 = face_num2 + 1;
 
18566   for ( iface = 0; iface < 
face_num; iface++ )
 
18571     for ( jlo = 0; jlo < 
face_order[iface] - 2; jlo ++ )
 
18573       face2[0] = 
face[    0][iface];
 
18574       face2[1] = 
face[jlo+1][iface];
 
18575       face2[2] = 
face[jlo+2][iface];
 
18577       for ( 
k = 0; 
k < 3; 
k++ )
 
18581         x = 
cor3[0][icor3];
 
18582         y = 
cor3[1][icor3];
 
18583         z = 
cor3[2][icor3];
 
18605   cout << 
"TRIB_WRITE - Wrote " << 
bytes_num << 
" bytes.\n";
 
18642   fprintf ( fileout, 
"%s created by IVCON.\n", 
fileout_name );
 
18643   fprintf ( fileout, 
"Original data in %s.\n", 
filein_name );
 
18644   fprintf ( fileout, 
"Object name is %s.\n", 
object_name );
 
18645   fprintf ( fileout, 
"Object origin at %f %f %f.\n", 
origin[0], 
origin[1],
 
18647   fprintf ( fileout, 
"Object pivot at %f %f %f.\n", 
pivot[0], 
pivot[1],
 
18653   fprintf ( fileout, 
"\n" );
 
18654   fprintf ( fileout, 
"Transformation matrix:\n" );
 
18655   fprintf ( fileout, 
"\n" );
 
18658   for ( 
i = 0; 
i < 4; 
i++ )
 
18667   fprintf ( fileout, 
"\n" );
 
18668   fprintf ( fileout, 
"  %d nodes.\n", 
cor3_num );
 
18673     fprintf ( fileout, 
"\n" );
 
18674     fprintf ( fileout, 
"  Node coordinate data:\n" );
 
18675     fprintf ( fileout, 
"\n" );
 
18680       fprintf ( fileout, 
" %d %f %f %f\n ", 
i, 
cor3[0][
i], 
cor3[1][
i],
 
18685     fprintf ( fileout, 
"\n" );
 
18686     fprintf ( fileout, 
"  Node normal vectors:\n" );
 
18687     fprintf ( fileout, 
"\n" );
 
18692       fprintf ( fileout, 
" %d %f %f %f\n ", 
i, 
cor3_normal[0][
i],
 
18697     fprintf ( fileout, 
"\n" );
 
18698     fprintf ( fileout, 
"  Node materials:\n" );
 
18699     fprintf ( fileout, 
"\n" );
 
18710       fprintf ( fileout, 
"\n" );
 
18711       fprintf ( fileout, 
"  Node texture coordinates:\n" );
 
18712       fprintf ( fileout, 
"\n" );
 
18726   fprintf ( fileout, 
"\n" );
 
18727   fprintf ( fileout, 
"  %d line data items.\n", 
line_num );
 
18732     fprintf ( fileout, 
"\n" );
 
18733     fprintf ( fileout, 
"  Line index data:\n" );
 
18734     fprintf ( fileout, 
"\n" );
 
18739     for ( iline = 0; iline < 
line_num; iline++ )
 
18741       fprintf ( fileout, 
" %d", 
line_dex[iline] );
 
18747         fprintf ( fileout, 
"\n" );
 
18753     fprintf ( fileout, 
"\n" );
 
18754     fprintf ( fileout, 
"  Line materials:\n" );
 
18755     fprintf ( fileout, 
"\n" );
 
18760     for ( iline = 0; iline < 
line_num; iline++ )
 
18770         fprintf ( fileout, 
"\n" );
 
18779   fprintf ( fileout, 
"\n" );
 
18780   fprintf ( fileout, 
"  %d colors.\n", 
color_num );
 
18785   fprintf ( fileout, 
"\n" );
 
18786   fprintf ( fileout, 
"  %d faces.\n", 
face_num );
 
18792     fprintf ( fileout, 
"\n" );
 
18793     fprintf ( fileout, 
"  Face, Material, Number of vertices, Smoothing, Flags:\n" );
 
18794     fprintf ( fileout, 
"\n" );
 
18797     for ( iface = 0; iface < 
face_num; iface++ )
 
18799       fprintf ( fileout, 
" %d %d %d %d %d\n", iface, 
face_material[iface],
 
18804     fprintf ( fileout, 
"\n" );
 
18805     fprintf ( fileout, 
"  Face, Vertices\n" );
 
18806     fprintf ( fileout, 
"\n" );
 
18809     for ( iface = 0; iface < 
face_num; iface++ )
 
18811       fprintf ( fileout, 
"%d   ", iface );
 
18812       for ( ivert = 0; ivert < 
face_order[iface]; ivert++ )
 
18814         fprintf ( fileout, 
" %d", 
face[ivert][iface] );
 
18817       fprintf ( fileout, 
"\n" );
 
18821     fprintf ( fileout, 
"\n" );
 
18822     fprintf ( fileout, 
"  Face normal vectors:\n" );
 
18823     fprintf ( fileout, 
"\n" );
 
18826     for ( iface = 0; iface < 
face_num; iface++ )
 
18828       fprintf ( fileout, 
" %d %f %f %f\n", iface, 
face_normal[0][iface],
 
18835       fprintf ( fileout, 
"\n" );
 
18836       fprintf ( fileout, 
"  Face texture coordinates:\n" );
 
18837       fprintf ( fileout, 
"\n" );
 
18840       for ( iface = 0; iface < 
face_num; iface++ )
 
18842         fprintf ( fileout, 
" %d %f %f\n", iface, 
face_tex_uv[0][iface],
 
18853     fprintf ( fileout, 
"\n" );
 
18854     fprintf ( fileout, 
"Vertex normal vectors:\n" );
 
18857     for ( iface = 0; iface < 
face_num; iface++ )
 
18859       fprintf ( fileout, 
"\n" );
 
18861       for ( ivert = 0; ivert < 
face_order[iface]; ivert++ )
 
18863         fprintf ( fileout, 
" %d %d %f %f %f\n", iface, ivert,
 
18870     fprintf ( fileout, 
"\n" );
 
18871     fprintf ( fileout, 
"Vertex materials:\n" );
 
18872     fprintf ( fileout, 
"\n" );
 
18875     for ( iface = 0; iface < 
face_num; iface++ )
 
18877       fprintf ( fileout, 
"%d", iface );
 
18878       for ( ivert = 0; ivert < 
face_order[iface]; ivert++ )
 
18882       fprintf ( fileout, 
"\n" );
 
18888       fprintf ( fileout, 
"\n" );
 
18889       fprintf ( fileout, 
"Vertex UV texture coordinates:\n" );
 
18890       fprintf ( fileout, 
"\n" );
 
18893       for ( iface = 0; iface < 
face_num; iface++ )
 
18895         for ( ivert = 0; ivert < 
face_order[iface]; ivert++ )
 
18897           fprintf ( fileout, 
"%d %d %f %f\n", iface, ivert,
 
18907   fprintf ( fileout, 
"\n" );
 
18909   fprintf ( fileout, 
"\n" );
 
18910   fprintf ( fileout, 
"Index      Name   R G B A\n" );
 
18911   fprintf ( fileout, 
"\n" );
 
18917     fprintf ( fileout, 
"%d %s %f %f %f %f\n", imat, 
material_name[imat],
 
18925   fprintf ( fileout, 
"\n" );
 
18926   fprintf ( fileout, 
"%d textures.\n", 
texture_num );
 
18931     fprintf ( fileout, 
"\n" );
 
18932     fprintf ( fileout, 
"Index  Name\n" );
 
18933     fprintf ( fileout, 
"\n" );
 
18944   cout << 
"TXT_WRITE - Wrote " << 
text_num << 
" text lines.\n";
 
19027   fprintf ( fileout, 
"#  %s created by IVREAD.\n", 
fileout_name );
 
19028   fprintf ( fileout, 
"#\n" );
 
19029   fprintf ( fileout, 
"#  Material RGB to Hue map:\n" );
 
19030   fprintf ( fileout, 
"#\n" );
 
19031   fprintf ( fileout, 
"#  material    R    G      B     Alpha  Hue\n" );
 
19032   fprintf ( fileout, 
"#\n" );
 
19043     fprintf ( fileout, 
"#  %d %f %f %f %f %f\n", j, r, g, b, a, h );
 
19047   fprintf ( fileout, 
"#\n" );
 
19048   fprintf ( fileout, 
"#  The node data is\n" );
 
19049   fprintf ( fileout, 
"#    node # / material # / RGBA / Hue\n" );
 
19050   fprintf ( fileout, 
"#\n" );
 
19058     fprintf ( fileout, 
"%d %f %f %f\n", j, 
cor3[0][j], 
cor3[1][j],
 
19073       fprintf ( fileout, 
" tri" );
 
19077       fprintf ( fileout, 
" quad" );
 
19081       fprintf ( fileout, 
" ???" );
 
19086       fprintf ( fileout, 
"%d", 
face[
i][j] );
 
19088     fprintf ( fileout, 
"\n" );
 
19093   fprintf ( fileout, 
"3  1  4  1\n" );
 
19094   fprintf ( fileout, 
"material, 0...%d\n", 
material_num - 1 );
 
19095   fprintf ( fileout, 
"RGBA, 0-1/0-1/0-1/0-1\n" );
 
19096   fprintf ( fileout, 
"Hue, 0-1\n" );
 
19108     fprintf ( fileout, 
"%d %d %f %f %f %f %f\n", j, imat, r, g, b, a, h );
 
19115   cout << 
"UCD_WRITE - Wrote " << 
text_num << 
" text lines.\n";
 
19175   for ( iface = 0; iface < 
face_num; iface++ )
 
19177     for ( ivert = 0; ivert < 
face_order[iface]; ivert++ )
 
19180       for ( 
i = 0; 
i < 3; 
i++ )
 
19183         norm = norm + temp * temp;
 
19185       norm = ( float ) sqrt ( norm );
 
19191         i0 = 
face[ivert][iface];
 
19201         i1 = 
face[jp1][iface];
 
19211         i2 = 
face[jp2][iface];
 
19216         xc = ( y1 - y0 ) * ( z2 - z0 ) - ( z1 - z0 ) * ( y2 - y0 );
 
19217         yc = ( z1 - z0 ) * ( x2 - x0 ) - ( x1 - x0 ) * ( z2 - z0 );
 
19218         zc = ( x1 - x0 ) * ( y2 - y0 ) - ( y1 - y0 ) * ( x2 - x0 );
 
19220         norm = ( float ) sqrt ( xc * xc + yc * yc + zc * zc );
 
19224           xc = ( float ) 1.0 / sqrt ( 3.0 );
 
19225           yc = ( float ) 1.0 / sqrt ( 3.0 );
 
19226           zc = ( float ) 1.0 / sqrt ( 3.0 );
 
19246     cout << 
"VERTEX_NORMAL_SET: Recomputed " << nfix
 
19247          << 
" face vertex normals.\n";
 
19285   for ( iface = 0; iface < 
face_num; iface++ )
 
19329   for ( iface = 0; iface < 
face_num; iface++ )
 
19331     for ( ivert = 0; ivert < 
face_order[iface]; ivert++ )
 
19333       node = 
face[ivert][iface];
 
19418     if ( *next == 
'\0' || *next == 
';' )
 
19425     sscanf ( next, 
"%s%n", token, &width );
 
19429     next = next + width;
 
19433     if ( 
s_eqi ( token, 
"set" ) )
 
19440     else if ( 
s_eqi ( token, 
"P" ) || 
s_eqi ( token, 
"L" ) )
 
19442       if ( 
s_eqi ( token, 
"P" ) )
 
19455       sscanf ( next, 
"%e %e %e", &r1, &r2, &r3 );
 
19476           for ( 
i = 0; 
i < 3; 
i++ )
 
19501       cout << 
"VLA_READ - Fatal error!\n";
 
19502       cout << 
"  Unrecognized first word on line.\n";
 
19576   float intense = 1.0;
 
19584   fprintf ( fileout, 
"set comment %s created by IVCON.\n", 
fileout_name );
 
19585   fprintf ( fileout, 
"set comment Original data in %s.\n", 
filein_name );
 
19586   fprintf ( fileout, 
"set comment\n" );
 
19587   fprintf ( fileout, 
"set intensity EXPLICIT\n" );
 
19588   fprintf ( fileout, 
"set parametric NON_PARAMETRIC\n" );
 
19589   fprintf ( fileout, 
"set filecontent LINES\n" );
 
19590   fprintf ( fileout, 
"set filetype NEW\n" );
 
19591   fprintf ( fileout, 
"set depthcue 0\n" );
 
19592   fprintf ( fileout, 
"set defaultdraw stellar\n" );
 
19593   fprintf ( fileout, 
"set coordsys RIGHT\n" );
 
19594   fprintf ( fileout, 
"set author IVCON\n" );
 
19595   fprintf ( fileout, 
"set site Buhl Planetarium\n" );
 
19596   fprintf ( fileout, 
"set library_id UNKNOWN\n" );
 
19602   for ( iline = 0; iline < 
line_num; iline++ )
 
19613       fprintf ( fileout, 
"%c %f %f %f %f\n",
 
19625   cout << 
"VLA_WRITE - Wrote " << 
text_num << 
" text lines.\n";
 
19719   fprintf ( fileout, 
"#VRML V2.0 utf8\n" );
 
19720   fprintf ( fileout, 
"\n" );
 
19721   fprintf ( fileout, 
"  WorldInfo {\n" );
 
19723   fprintf ( fileout, 
"    info \"WRL file generated by IVREAD.\"\n" );
 
19724   fprintf ( fileout, 
"    info \"Original data in %s\"\n", 
filein_name );
 
19725   fprintf ( fileout, 
"  }\n" );
 
19726   fprintf ( fileout, 
"\n" );
 
19727   fprintf ( fileout, 
"  Group {\n" );
 
19728   fprintf ( fileout, 
"    children [\n" );
 
19729   fprintf ( fileout, 
"      Shape {\n" );
 
19730   fprintf ( fileout, 
"        appearance Appearance {\n" );
 
19731   fprintf ( fileout, 
"          material Material {\n" );
 
19732   fprintf ( fileout, 
"            diffuseColor   0.0 0.0 0.0\n" );
 
19733   fprintf ( fileout, 
"            emissiveColor  0.0 0.0 0.0\n" );
 
19734   fprintf ( fileout, 
"            shininess      1.0\n" );
 
19735   fprintf ( fileout, 
"          }\n" );
 
19736   fprintf ( fileout, 
"        }\n" );
 
19744     fprintf ( fileout, 
"        geometry IndexedLineSet {\n" );
 
19748     fprintf ( fileout, 
"          coord Coordinate {\n" );
 
19749     fprintf ( fileout, 
"            point [\n" );
 
19753     for ( icor3 = 0; icor3 < 
cor3_num; icor3++ )
 
19755       fprintf ( fileout, 
"              %f %f %f\n", 
cor3[0][icor3],
 
19760     fprintf ( fileout, 
"            ]\n" );
 
19761     fprintf ( fileout, 
"          }\n" );
 
19766     fprintf ( fileout, 
"          coordIndex [\n" );
 
19773       fprintf ( fileout, 
"%d ", 
line_dex[j] );
 
19774       length = length + 1;
 
19777         fprintf ( fileout, 
"\n" );
 
19783     fprintf ( fileout, 
"          ]\n" );
 
19788     fprintf ( fileout, 
"          color Color {\n" );
 
19789     fprintf ( fileout, 
"            color [\n" );
 
19799     fprintf ( fileout, 
"            ]\n" );
 
19800     fprintf ( fileout, 
"          }\n" );
 
19801     fprintf ( fileout, 
"          colorPerVertex TRUE\n" );
 
19805     fprintf ( fileout, 
"          colorIndex [\n" );
 
19813       length = length + 1;
 
19816         fprintf ( fileout, 
"\n" );
 
19822     fprintf ( fileout, 
"          ]\n" );
 
19823     fprintf ( fileout, 
"        }\n" );
 
19835     fprintf ( fileout, 
"        geometry IndexedFaceSet {\n" );
 
19839     fprintf ( fileout, 
"          coord Coordinate {\n" );
 
19840     fprintf ( fileout, 
"            point [\n" );
 
19844     for ( icor3 = 0; icor3 < 
cor3_num; icor3++ )
 
19846       fprintf ( fileout, 
"              %f %f %f\n", 
cor3[0][icor3],
 
19852     fprintf ( fileout, 
"            ]\n" );
 
19853     fprintf ( fileout, 
"          }\n" );
 
19857     fprintf ( fileout, 
"          coordIndex [\n" );
 
19863     for ( iface = 0; iface < 
face_num; iface++ )
 
19865       for ( ivert = 0; ivert <= 
face_order[iface]; ivert++ )
 
19869           itemp = 
face[ivert][iface];
 
19876         fprintf ( fileout, 
"%d ", itemp );
 
19877         length = length + 1;
 
19879         if ( itemp == -1 || 10 <= length ||
 
19882           fprintf ( fileout, 
"\n" );
 
19891     fprintf ( fileout, 
"          ]\n" );
 
19896     fprintf ( fileout, 
"          colorIndex [\n" );
 
19902     for ( iface = 0; iface < 
face_num; iface++ )
 
19904       for ( ivert = 0; ivert <= 
face_order[iface]; ivert++ )
 
19917         fprintf ( fileout, 
"%d ", itemp );
 
19918         length = length + 1;
 
19920         if ( itemp == -1 || 10 <= length ||
 
19924           fprintf ( fileout, 
"\n" );
 
19934     fprintf ( fileout, 
"          ]\n" );
 
19935     fprintf ( fileout, 
"        }\n" );
 
19947   fprintf ( fileout, 
"      }\n" );
 
19948   fprintf ( fileout, 
"    ]\n" );
 
19949   fprintf ( fileout, 
"  }\n" );
 
19956   cout << 
"WRL_WRITE - Wrote " << 
text_num << 
" text lines.\n";
 
20128   float light_ambient_rgb[3];
 
20129   float light_diffuse_rgb[3];
 
20130   float light_direction[3];
 
20131   float light_specular_rgb[3];
 
20133   float material_alpha;
 
20134   float material_amb_rgb[3];
 
20135   float material_diff_rgb[3];
 
20136   float material_emiss_rgb[3];
 
20137   float material_shine;
 
20138   float material_spec_rgb[3];
 
20142   float transform_forward[3];
 
20143   float transform_position[3];
 
20144   float transform_scale[3];
 
20145   float transform_up[3];
 
20149   light_ambient_rgb[0] = 0.2;
 
20150   light_ambient_rgb[1] = 0.1;
 
20151   light_ambient_rgb[2] = 0.1;
 
20153   light_diffuse_rgb[0] = 0.1;
 
20154   light_diffuse_rgb[1] = 0.2;
 
20155   light_diffuse_rgb[2] = 0.1;
 
20157   light_direction[0] =   0.0;
 
20158   light_direction[1] =   0.0;
 
20159   light_direction[2] = 100.0;
 
20161   light_specular_rgb[0] = 0.1;
 
20162   light_specular_rgb[1] = 0.1;
 
20163   light_specular_rgb[2] = 0.2;
 
20165   material_alpha = 0.9;
 
20167   material_amb_rgb[0] = 0.1;
 
20168   material_amb_rgb[1] = 0.1;
 
20169   material_amb_rgb[2] = 0.1;
 
20171   material_diff_rgb[0] = 0.2;
 
20172   material_diff_rgb[1] = 0.1;
 
20173   material_diff_rgb[2] = 0.1;
 
20175   material_emiss_rgb[0] = 0.1;
 
20176   material_emiss_rgb[1] = 0.2;
 
20177   material_emiss_rgb[2] = 0.1;
 
20179   material_shine = 0.8;
 
20181   material_spec_rgb[0] = 0.1;
 
20182   material_spec_rgb[1] = 0.1;
 
20183   material_spec_rgb[2] = 0.2;
 
20185   transform_forward[0] = 0.0;
 
20186   transform_forward[1] = 0.0;
 
20187   transform_forward[2] = 0.0;
 
20189   transform_position[0] = 0.0;
 
20190   transform_position[1] = 0.0;
 
20191   transform_position[2] = 0.0;
 
20193   transform_scale[0] = 1.0;
 
20194   transform_scale[1] = 1.0;
 
20195   transform_scale[2] = 1.0;
 
20197   transform_up[0] = 1.0;
 
20198   transform_up[1] = 1.0;
 
20199   transform_up[2] = 1.0;
 
20205   fprintf ( fileout, 
"<WORLD>\n" );
 
20206   fprintf ( fileout, 
"\n" );
 
20210   fprintf ( fileout, 
"  <BACKGROUND>\n" );
 
20211   fprintf ( fileout, 
"    <BACKCOLOR> %f, %f, %f </BACKCOLOR>\n",
 
20213   fprintf ( fileout, 
"  </BACKGROUND>\n" );
 
20214   fprintf ( fileout, 
"\n" );
 
20215   fprintf ( fileout, 
"  <LIGHTING>\n" );
 
20216   fprintf ( fileout, 
"    <AMBIENT> %f, %f, %f </AMBIENT>\n",
 
20217     light_ambient_rgb[0], light_ambient_rgb[1], light_ambient_rgb[2] );
 
20218   fprintf ( fileout, 
"    <DIRECTIONALLIGHT>\n" );
 
20219   fprintf ( fileout, 
"      <DIFFUSE> %f, %f, %f </DIFFUSE>\n",
 
20220     light_diffuse_rgb[0], light_diffuse_rgb[1], light_diffuse_rgb[2] );
 
20221   fprintf ( fileout, 
"      <DIRECTION> %f, %f, %f </DIRECTION>\n",
 
20222     light_direction[0], light_direction[1], light_direction[2] );
 
20223   fprintf ( fileout, 
"      <SPECULAR> %f, %f, %f </SPECULAR>\n",
 
20224     light_specular_rgb[0], light_specular_rgb[1], light_specular_rgb[2] );
 
20225   fprintf ( fileout, 
"    </DIRECTIONALLIGHT>\n" );
 
20226   fprintf ( fileout, 
"  </LIGHTING>\n" );
 
20230   for ( mesh = 0; mesh < mesh_num; mesh++ )
 
20232     fprintf ( fileout, 
"\n" );
 
20233     fprintf ( fileout, 
"  <MESH ID = \"%d\">\n", mesh );
 
20234     fprintf ( fileout, 
"\n" );
 
20239       fprintf ( fileout, 
"    <P ID=\"%d\"> %f, %f, %f </P>\n", j,
 
20244     fprintf ( fileout, 
"\n" );
 
20248       fprintf ( fileout, 
"    <N ID=\"%d\"> %f, %f, %f </N>\n", j,
 
20253     for ( material = 0; material < 
material_num; material++ )
 
20255       fprintf ( fileout, 
"\n" );
 
20256       fprintf ( fileout, 
"    <MAT ID=\"%d\">\n", material );
 
20257       fprintf ( fileout, 
"      <ALPHA> %f </ALPHA>\n", material_alpha );
 
20258       fprintf ( fileout, 
"      <AMB> %f, %f, %f </AMB>\n",
 
20259         material_amb_rgb[0], material_amb_rgb[1], material_amb_rgb[2] );
 
20260       fprintf ( fileout, 
"      <DIFF> %f, %f, %f </DIFF>\n",
 
20261         material_diff_rgb[0], material_diff_rgb[1], material_diff_rgb[2] );
 
20262       fprintf ( fileout, 
"      <EMISS> %f, %f, %f </EMISS>\n",
 
20263         material_emiss_rgb[0], material_emiss_rgb[1], material_emiss_rgb[2] );
 
20264       fprintf ( fileout, 
"      <SHINE> %f </SHINE>\n", material_shine );
 
20265       fprintf ( fileout, 
"      <SPEC> %f, %f, %f </SPEC>\n",
 
20266         material_spec_rgb[0], material_spec_rgb[1], material_spec_rgb[2] );
 
20267       fprintf ( fileout, 
"    </MAT>\n" );
 
20271     fprintf ( fileout, 
"\n" );
 
20274     for ( iface = 0; iface < 
face_num; iface++ )
 
20276       fprintf ( fileout, 
"    <F>\n" );
 
20277       fprintf ( fileout, 
"      <MATREF> %d </MATREF>\n", 
face_material[iface] );
 
20279       for ( ivert = 0; ivert < 
face_order[iface]; ivert++ )
 
20282           "      <FV%d><PREF> %d </PREF><NREF> %d </NREF></FV%d>\n",
 
20283           ivert+1, 
face[ivert][iface], 
face[ivert][iface], ivert+1 );
 
20286       fprintf ( fileout, 
"    </F>\n" );
 
20290     fprintf ( fileout, 
"  </MESH>\n" );
 
20295   fprintf ( fileout, 
"\n" );
 
20298   for ( 
object = 0; 
object < 
object_num; 
object++ )
 
20300     fprintf ( fileout, 
"  <OBJECT>\n" );
 
20301     fprintf ( fileout, 
"    <TRANSFORM>\n" );
 
20302     fprintf ( fileout, 
"      <FORWARD> %f, %f, %f </FORWARD>\n",
 
20303       transform_forward[0], transform_forward[1], transform_forward[2] );
 
20304     fprintf ( fileout, 
"      <POSITION> %f, %f, %f </POSITION>\n",
 
20305       transform_position[0], transform_position[1], transform_position[2] );
 
20306     fprintf ( fileout, 
"'      <SCALE> %f, %f, %f </SCALE>\n",
 
20307       transform_scale[0], transform_scale[1], transform_scale[2] );
 
20308     fprintf ( fileout, 
"      <UP> %f, %f, %f </UP>\n",
 
20309       transform_up[0], transform_up[1], transform_up[2] );
 
20310     fprintf ( fileout, 
"    </TRANSFORM>\n" );
 
20312     fprintf ( fileout, 
"    <MESHREF> %d </MESHREF>\n", mesh );
 
20313     fprintf ( fileout, 
"  </OBJECT>\n" );
 
20317   fprintf ( fileout, 
"\n" );
 
20318   fprintf ( fileout, 
"</WORLD>\n" );
 
20325   cout << 
"XGL_WRITE - Wrote " << 
text_num << 
" text lines.\n";