40 #define G1_SECTION_MODEL_QUADS 18
41 #define G1_SECTION_MODEL_TEXTURE_NAMES 19
42 #define G1_SECTION_MODEL_VERT_ANIMATION 20
43 #define GMOD_MAX_SECTIONS 32
44 #define GMOD_UNUSED_VERTEX 65535
45 #define PI 3.141592653589793238462643
48 #define DEG_TO_RAD ( PI / 180.0 )
49 #define RAD_TO_DEG ( 180.0 / PI )
125 #define COLOR_MAX 1000
126 #define COR3_MAX 200000
127 #define FACE_MAX 200000
128 #define LINE_MAX_LEN 256
130 #define LINES_MAX 100000
131 #define MATERIAL_MAX 100
133 #define TEXTURE_MAX 100
220 int main (
int argc,
char **argv );
226 int char_pad (
int *char_index,
int *null_index,
char *
string,
252 int float_write ( FILE *fileout,
float float_val );
271 int leqi (
char* string1,
char* string2 );
280 float rgb_to_hue (
float r,
float g,
float b );
293 unsigned long int tds_read_boolean (
unsigned char *
boolean, FILE *filein );
316 unsigned short int int_val );
319 void tmat_mxm (
float a[4][4],
float b[4][4],
float c[4][4] );
320 void tmat_mxp (
float a[4][4],
float x[4],
float y[4] );
321 void tmat_mxp2 (
float a[4][4],
float x[][3],
float y[][3],
int n );
322 void tmat_mxv (
float a[4][4],
float x[4],
float y[4] );
323 void tmat_rot_axis (
float a[4][4],
float b[4][4],
float angle,
326 float v1,
float v2,
float v3 );
327 void tmat_scale (
float a[4][4],
float b[4][4],
float sx,
float sy,
329 void tmat_shear (
float a[4][4],
float b[4][4],
char *axis,
331 void tmat_trans (
float a[4][4],
float b[4][4],
float x,
float y,
349 int main (
int argc,
char **argv )
436 strcpy ( word,
" " );
437 strcpy ( wordm1,
" " );
456 strcpy ( wordm1, word );
457 strcpy ( word,
" " );
459 count = sscanf ( next,
"%s%n", word, &width );
469 strcpy ( word1, word );
474 if ( strcmp ( word,
"{" ) == 0 ) {
476 nlbrack = nlbrack + 1;
477 level = nlbrack - nrbrack;
480 else if ( strcmp ( word,
"}" ) == 0 ) {
482 nrbrack = nrbrack + 1;
484 if ( nlbrack < nrbrack ) {
487 printf (
"ASE_READ - Fatal error!\n" );
488 printf (
" Extraneous right bracket on line %d\n",
text_num );
489 printf (
" Currently processing field:\n" );
498 if ( strcmp ( word1,
"*3DSMAX_ASCIIEXPORT" ) == 0 ) {
504 else if ( strcmp ( word1,
"*COMMENT" ) == 0 ) {
510 else if ( strcmp (
level_name[level],
"*GEOMOBJECT" ) == 0 ) {
512 if ( strcmp ( word,
"{" ) == 0 ) {
515 else if ( strcmp ( word,
"}" ) == 0 ) {
516 level = nlbrack - nrbrack;
522 else if ( strcmp ( word,
"*NODE_NAME" ) == 0 ) {
525 else if ( strcmp ( word,
"*NODE_TM" ) == 0 ) {
528 else if ( strcmp ( word,
"*MESH" ) == 0 ) {
531 else if ( strcmp ( word,
"*PROP_CASTSHADOW" ) == 0 ) {
534 else if ( strcmp ( word,
"*PROP_MOTIONBLUR" ) == 0 ) {
537 else if ( strcmp ( word,
"*PROP_RECVSHADOW" ) == 0 ) {
542 printf (
"Bad data in GEOMOBJECT, line %d\n",
text_num );
549 else if ( strcmp (
level_name[level],
"*MESH" ) == 0 ) {
551 if ( strcmp ( word,
"{" ) == 0 ) {
554 else if ( strcmp ( word,
"}" ) == 0 ) {
555 level = nlbrack - nrbrack;
558 else if ( strcmp ( word,
"*MESH_CFACELIST" ) == 0 ) {
561 else if ( strcmp ( word,
"*MESH_CVERTLIST" ) == 0 ) {
564 else if ( strcmp ( word,
"*MESH_FACE_LIST" ) == 0 ) {
567 else if ( strcmp ( word,
"*MESH_NORMALS" ) == 0 ) {
570 else if ( strcmp ( word,
"*MESH_NUMCVERTEX" ) == 0 ) {
573 else if ( strcmp ( word,
"*MESH_NUMCVFACES" ) == 0 ) {
576 else if ( strcmp ( word,
"*MESH_NUMFACES" ) == 0 ) {
579 else if ( strcmp ( word,
"*MESH_NUMTVERTEX" ) == 0 ) {
582 else if ( strcmp ( word,
"*MESH_NUMTVFACES" ) == 0 ) {
585 else if ( strcmp ( word,
"*MESH_NUMVERTEX" ) == 0 ) {
588 else if ( strcmp ( word,
"*MESH_TFACELIST" ) == 0 ) {
591 else if ( strcmp ( word,
"*MESH_TVERTLIST" ) == 0 ) {
594 else if ( strcmp ( word,
"*MESH_VERTEX_LIST" ) == 0 ) {
597 else if ( strcmp ( word,
"*TIMEVALUE" ) == 0 ) {
602 printf (
"Bad data in MESH, line %d\n",
text_num );
609 else if ( strcmp (
level_name[level],
"*MESH_CFACELIST" ) == 0 ) {
611 if ( strcmp ( word,
"{" ) == 0 ) {
614 else if ( strcmp ( word,
"}" ) == 0 ) {
615 level = nlbrack - nrbrack;
618 else if ( strcmp ( word,
"*MESH_CFACE" ) == 0 ) {
623 printf (
"Bad data in MESH_CFACE, line %d\n",
text_num );
633 else if ( strcmp (
level_name[level],
"*MESH_CVERTLIST" ) == 0 ) {
635 if ( strcmp ( word,
"{" ) == 0 ) {
638 else if ( strcmp ( word,
"}" ) == 0 ) {
639 level = nlbrack - nrbrack;
642 else if ( strcmp ( word,
"*MESH_VERTCOL" ) == 0 ) {
644 count = sscanf ( next,
"%d%n", &
i, &width );
647 i =
i + cor3_num_old;
649 count = sscanf ( next,
"%f%n", &rval, &width );
652 count = sscanf ( next,
"%f%n", &gval, &width );
655 count = sscanf ( next,
"%f%n", &bval, &width );
671 printf (
"ASE_READ - Warning!\n" );
672 printf (
" Bad data in MESH_CVERTLIST, line %d\n",
text_num );
681 else if ( strcmp (
level_name[level],
"*MESH_FACE_LIST" ) == 0 ) {
683 if ( strcmp ( word,
"{" ) == 0 ) {
686 else if ( strcmp ( word,
"}" ) == 0 ) {
687 level = nlbrack - nrbrack;
690 else if ( strcmp ( word,
"*MESH_FACE" ) == 0 ) {
697 count = sscanf ( next,
"%d%n", &
i, &width );
700 count = sscanf ( next,
"%s%n", word2, &width );
702 count = sscanf ( next,
"%s%n", word2, &width );
705 count = sscanf ( next,
"%d%n", &
i, &width );
710 count = sscanf ( next,
"%s%n", word2, &width );
713 count = sscanf ( next,
"%d%n", &
i, &width );
718 count = sscanf ( next,
"%s%n", word2, &width );
721 count = sscanf ( next,
"%d%n", &
i, &width );
726 count = sscanf ( next,
"%s%n", word2, &width );
729 if ( strcmp ( word2,
"D:" ) == 0 ) {
730 count = sscanf ( next,
"%d%n", &
i, &width );
744 printf (
"Bad data in MESH_FACE_LIST, line %d\n",
text_num );
751 else if ( strcmp (
level_name[level],
"*MESH_NORMALS" ) == 0 ) {
753 if ( strcmp ( word,
"{" ) == 0 ) {
756 else if ( strcmp ( word,
"}" ) == 0 ) {
757 level = nlbrack - nrbrack;
760 else if ( strcmp ( word,
"*MESH_FACENORMAL" ) == 0 ) {
762 count = sscanf ( next,
"%d%n", &iface, &width );
765 count = sscanf ( next,
"%f%n", &x, &width );
768 count = sscanf ( next,
"%f%n", &y, &width );
771 count = sscanf ( next,
"%f%n", &z, &width );
774 iface = iface + face_num_old;
784 else if ( strcmp ( word,
"*MESH_VERTEXNORMAL" ) == 0 ) {
786 count = sscanf ( next,
"%d%n", &
i, &width );
789 count = sscanf ( next,
"%f%n", &x, &width );
792 count = sscanf ( next,
"%f%n", &y, &width );
795 count = sscanf ( next,
"%f%n", &z, &width );
807 printf (
"Bad data in MESH_NORMALS, line %d\n",
text_num );
814 else if ( strcmp (
level_name[level],
"*MESH_TFACELIST" ) == 0 ) {
816 if ( strcmp ( word,
"{" ) == 0 ) {
819 else if ( strcmp ( word,
"}" ) == 0 ) {
820 level = nlbrack - nrbrack;
823 else if ( strcmp ( word1,
"*MESH_TFACE" ) == 0 ) {
828 printf (
"Bad data in MESH_TFACE_LIST, line %d\n",
text_num );
835 else if ( strcmp (
level_name[level],
"*MESH_TVERTLIST" ) == 0 ) {
837 if ( strcmp ( word,
"{" ) == 0 ) {
840 else if ( strcmp ( word,
"}" ) == 0 ) {
841 level = nlbrack - nrbrack;
844 else if ( strcmp ( word1,
"*MESH_TVERT" ) == 0 ) {
849 printf (
"Bad data in MESH_TVERTLIST, line %d\n",
text_num );
856 else if ( strcmp (
level_name[level],
"*MESH_VERTEX_LIST" ) == 0 ) {
858 if ( strcmp ( word,
"{" ) == 0 ) {
862 else if ( strcmp ( word,
"}" ) == 0 ) {
863 level = nlbrack - nrbrack;
866 else if ( strcmp ( word1,
"*MESH_VERTEX" ) == 0 ) {
868 count = sscanf ( next,
"%d%n", &
i, &width );
871 count = sscanf ( next,
"%f%n", &x, &width );
874 count = sscanf ( next,
"%f%n", &y, &width );
877 count = sscanf ( next,
"%f%n", &z, &width );
880 i =
i + cor3_num_old;
910 printf (
"Bad data in MESH_VERTEX_LIST, line %d\n",
text_num );
919 else if ( strcmp (
level_name[level],
"*NODE_TM" ) == 0 ) {
921 if ( strcmp ( word,
"{" ) == 0 ) {
927 else if ( strcmp ( word,
"}" ) == 0 ) {
928 level = nlbrack - nrbrack;
931 else if ( strcmp ( word,
"*INHERIT_POS" ) == 0 ) {
934 else if ( strcmp ( word,
"*INHERIT_ROT" ) == 0 ) {
937 else if ( strcmp ( word,
"*INHERIT_SCL" ) == 0 ) {
940 else if ( strcmp ( word,
"*NODE_NAME" ) == 0 ) {
943 else if ( strcmp ( word,
"*TM_POS" ) == 0 ) {
946 else if ( strcmp ( word,
"*TM_ROTANGLE" ) == 0 ) {
949 else if ( strcmp ( word,
"*TM_ROTAXIS" ) == 0 ) {
952 else if ( strcmp ( word,
"*TM_ROW0" ) == 0 ) {
954 count = sscanf ( next,
"%f%n", &temp, &width );
958 count = sscanf ( next,
"%f%n", &temp, &width );
962 count = sscanf ( next,
"%f%n", &temp, &width );
968 else if ( strcmp ( word,
"*TM_ROW1" ) == 0 ) {
970 count = sscanf ( next,
"%f%n", &temp, &width );
974 count = sscanf ( next,
"%f%n", &temp, &width );
978 count = sscanf ( next,
"%f%n", &temp, &width );
984 else if ( strcmp ( word,
"*TM_ROW2" ) == 0 ) {
986 count = sscanf ( next,
"%f%n", &temp, &width );
990 count = sscanf ( next,
"%f%n", &temp, &width );
994 count = sscanf ( next,
"%f%n", &temp, &width );
1000 else if ( strcmp ( word,
"*TM_ROW3" ) == 0 ) {
1002 count = sscanf ( next,
"%f%n", &temp, &width );
1003 next = next + width;
1006 count = sscanf ( next,
"%f%n", &temp, &width );
1007 next = next + width;
1010 count = sscanf ( next,
"%f%n", &temp, &width );
1011 next = next + width;
1016 else if ( strcmp ( word,
"*TM_SCALE" ) == 0 ) {
1019 else if ( strcmp ( word,
"*TM_SCALEAXIS" ) == 0 ) {
1022 else if ( strcmp ( word,
"*TM_SCALEAXISANG" ) == 0 ) {
1027 printf (
"Bad data in NODE_TM, line %d\n",
text_num );
1034 else if ( strcmp (
level_name[level],
"*SCENE" ) == 0 ) {
1036 if ( strcmp ( word,
"{" ) == 0 ) {
1039 else if ( strcmp ( word,
"}" ) == 0 ) {
1040 level = nlbrack - nrbrack;
1043 else if ( strcmp ( word,
"*SCENE_AMBIENT_STATIC" ) == 0 ) {
1046 else if ( strcmp ( word,
"*SCENE_BACKGROUND_STATIC" ) == 0 ) {
1049 else if ( strcmp ( word,
"*SCENE_FILENAME" ) == 0 ) {
1052 else if ( strcmp ( word,
"*SCENE_FIRSTFRAME" ) == 0 ) {
1055 else if ( strcmp ( word,
"*SCENE_FRAMESPEED" ) == 0 ) {
1058 else if ( strcmp ( word,
"*SCENE_LASTFRAME" ) == 0 ) {
1061 else if ( strcmp ( word,
"*SCENE_TICKSPERFRAME" ) == 0 ) {
1066 printf (
"Bad data in SCENE, line %d\n",
text_num );
1117 fprintf ( fileout,
"*3DSMAX_ASCIIEXPORT 200\n" );
1118 fprintf ( fileout,
"*COMMENT \"%s, created by IVCON.\"\n",
fileout_name );
1119 fprintf ( fileout,
"*COMMENT \"Original data in %s\"\n",
filein_name );
1125 fprintf ( fileout,
"*SCENE {\n" );
1126 fprintf ( fileout,
" *SCENE_FILENAME \"\"\n" );
1127 fprintf ( fileout,
" *SCENE_FIRSTFRAME 0\n" );
1128 fprintf ( fileout,
" *SCENE_LASTFRAME 100\n" );
1129 fprintf ( fileout,
" *SCENE_FRAMESPEED 30\n" );
1130 fprintf ( fileout,
" *SCENE_TICKSPERFRAME 160\n" );
1131 fprintf ( fileout,
" *SCENE_BACKGROUND_STATIC 0.0000 0.0000 0.0000\n" );
1132 fprintf ( fileout,
" *SCENE_AMBIENT_STATIC 0.0431 0.0431 0.0431\n" );
1133 fprintf ( fileout,
"}\n" );
1139 fprintf ( fileout,
"*GEOMOBJECT {\n" );
1140 fprintf ( fileout,
" *NODE_NAME \"%s\"\n",
object_name );
1146 fprintf ( fileout,
" *NODE_TM {\n" );
1147 fprintf ( fileout,
" *NODE_NAME \"Object01\"\n" );
1148 fprintf ( fileout,
" *INHERIT_POS 0 0 0\n" );
1149 fprintf ( fileout,
" *INHERIT_ROT 0 0 0\n" );
1150 fprintf ( fileout,
" *INHERIT_SCL 0 0 0\n" );
1151 fprintf ( fileout,
" *TM_ROW0 1.0000 0.0000 0.0000\n" );
1152 fprintf ( fileout,
" *TM_ROW1 0.0000 1.0000 0.0000\n" );
1153 fprintf ( fileout,
" *TM_ROW2 0.0000 0.0000 1.0000\n" );
1154 fprintf ( fileout,
" *TM_ROW3 0.0000 0.0000 0.0000\n" );
1155 fprintf ( fileout,
" *TM_POS 0.0000 0.0000 0.0000\n" );
1156 fprintf ( fileout,
" *TM_ROTAXIS 0.0000 0.0000 0.0000\n" );
1157 fprintf ( fileout,
" *TM_ROTANGLE 0.0000\n" );
1158 fprintf ( fileout,
" *TM_SCALE 1.0000 1.0000 1.0000\n" );
1159 fprintf ( fileout,
" *TM_SCALEAXIS 0.0000 0.0000 0.0000\n" );
1160 fprintf ( fileout,
" *TM_SCALEAXISANG 0.0000\n" );
1161 fprintf ( fileout,
" }\n" );
1168 fprintf ( fileout,
" *MESH {\n" );
1169 fprintf ( fileout,
" *TIMEVALUE 0\n" );
1170 fprintf ( fileout,
" *MESH_NUMVERTEX %d\n",
cor3_num );
1171 fprintf ( fileout,
" *MESH_NUMFACES %d\n",
face_num );
1177 fprintf ( fileout,
" *MESH_VERTEX_LIST {\n" );
1181 fprintf ( fileout,
" *MESH_VERTEX %d %f %f %f\n", j,
cor3[0][j],
1186 fprintf ( fileout,
" }\n" );
1192 fprintf ( fileout,
" *MESH_FACE_LIST {\n" );
1195 for ( iface = 0; iface <
face_num; iface++ ) {
1197 i1 =
face[0][iface];
1198 i2 =
face[1][iface];
1199 i3 =
face[2][iface];
1202 fprintf ( fileout,
" *MESH_FACE %d: A: %d B: %d C: %d", iface, i1, i2, i3 );
1203 fprintf ( fileout,
" AB: 1 BC: 1 CA: 1 *MESH_SMOOTHING *MESH_MTLID 1\n" );
1207 i4 =
face[3][iface];
1208 fprintf ( fileout,
" *MESH_FACE %d: A: %d B: %d C: %d D: %d", iface, i1, i2, i3, i4 );
1209 fprintf ( fileout,
" AB: 1 BC: 1 CD: 1 DA: 1 *MESH_SMOOTHING *MESH_MTLID 1\n" );
1214 fprintf ( fileout,
" }\n" );
1219 fprintf ( fileout,
" *MESH_NUMTVERTEX 0\n" );
1224 fprintf ( fileout,
" *MESH_NUMCVERTEX 0\n" );
1230 fprintf ( fileout,
" *MESH_NORMALS {\n" );
1233 for ( iface = 0; iface <
face_num; iface++ ) {
1235 fprintf ( fileout,
" *MESH_FACENORMAL %d %f %f %f\n",
1239 for ( ivert = 0; ivert <
face_order[iface]; ivert++ ) {
1240 fprintf ( fileout,
" *MESH_VERTEXNORMAL %d %f %f %f\n",
1247 fprintf ( fileout,
" }\n" );
1252 fprintf ( fileout,
" }\n" );
1256 fprintf ( fileout,
" *PROP_MOTIONBLUR 0\n" );
1257 fprintf ( fileout,
" *PROP_CASTSHADOW 1\n" );
1258 fprintf ( fileout,
" *PROP_RECVSHADOW 1\n" );
1262 fprintf ( fileout,
"}\n" );
1269 printf (
"ASE_WRITE - Wrote %d text lines;\n",
text_num );
1379 sscanf (
input,
"%d %d %d %d", &part_num, &cor3_num_new, &face_num_new,
1387 sscanf (
input,
"%d %d", &poly1, &poly2 );
1396 sscanf (
input,
"%f %f %f", &x, &y, &z );
1414 count = sscanf ( next,
"%d%n", &ival, &width );
1415 next = next + width;
1441 printf (
"BYU_READ - Read %d text lines.\n",
text_num );
1531 for ( iface = 0; iface <
face_num; iface++ ) {
1537 fprintf ( fileout,
"%d %d %d %d\n", part_num,
cor3_num,
face_num, edge_num );
1540 fprintf ( fileout,
"1 %d\n",
face_num );
1544 fprintf ( fileout,
"%f %f %f\n",
cor3[0][j],
cor3[1][j],
cor3[2][j] );
1548 for ( iface = 0; iface <
face_num; iface++ ) {
1550 for ( ivert = 0; ivert <
face_order[iface]; ivert++ ) {
1552 jp =
face[ivert][iface] + 1;
1556 fprintf ( fileout,
"%d ", jp );
1558 fprintf ( fileout,
"\n" );
1565 printf (
"BYU_WRITE - Wrote %d text lines.\n",
text_num );
1591 nchar = strlen (
string );
1593 for (
i = 0;
i < nchar;
i++ ) {
1594 if (
string[
i] == c ) {
1604 int char_pad (
int *char_index,
int *null_index,
char *
string,
1640 if ( *char_index < 0 ||
1641 *char_index >= *null_index ||
1642 *char_index > STRING_MAX-1 ) {
1646 if ( (*null_index) + 2 > STRING_MAX-1 ) {
1650 for (
i = *null_index + 2;
i > *char_index + 2;
i-- ) {
1651 string[
i] =
string[
i-2];
1653 string[*char_index+2] =
' ';
1654 string[*char_index+1] =
string[*char_index];
1655 string[*char_index] =
' ';
1657 *char_index = *char_index + 1;
1658 *null_index = *null_index + 2;
1684 c = ( char ) fgetc ( filein );
1708 fputc ( c, fileout );
1756 int reverse_normals;
1762 reverse_faces =
FALSE;
1763 reverse_normals =
FALSE;
1775 reverse_normals =
TRUE;
1777 printf (
"COMMAND_LINE: Reverse_Normals option requested.\n" );
1783 reverse_faces =
TRUE;
1785 printf (
"COMMAND_LINE: Reverse_Faces option requested.\n" );
1794 if ( ierror ==
ERROR ) {
1796 printf (
"COMMAND_LINE - Fatal error!\n" );
1797 printf (
" Failure while reading input data.\n" );
1803 if ( reverse_normals ==
TRUE ) {
1805 for ( icor3 = 0; icor3 <
cor3_num; icor3++ ) {
1806 for (
i = 0;
i < 3;
i++ ) {
1811 for ( iface = 0; iface <
face_num; iface++ ) {
1812 for (
i = 0;
i < 3;
i++ ) {
1817 for ( iface = 0; iface <
face_num; iface++ ) {
1818 for ( ivert = 0; ivert <
face_order[iface]; ivert++ ) {
1819 for (
i = 0;
i < 3;
i++ ) {
1826 printf (
"COMMAND_LINE - Note:\n" );
1827 printf (
" Reversed node, face, and vertex normals.\n" );
1832 if ( reverse_faces ==
TRUE ) {
1837 printf (
"COMMAND_LINE - Note:\n" );
1838 printf (
" Reversed the face definitions.\n" );
1848 if ( ierror ==
ERROR ) {
1850 printf (
"COMMAND_LINE - Fatal error!\n" );
1851 printf (
" Failure while writing output data.\n" );
1883 for ( icor3 = 0; icor3 <
cor3_num; icor3++ ) {
1884 for ( j = 0; j < 3; j++ ) {
1891 for ( iface = 0; iface <
face_num; iface++ ) {
1893 for ( ivert = 0; ivert <
face_order[iface]; ivert++ ) {
1895 icor3 =
face[ivert][iface];
1897 for ( j = 0; j < 3; j++ ) {
1906 for ( icor3 = 0; icor3 <
cor3_num; icor3++ ) {
1909 for ( j = 0; j < 3; j++ ) {
1911 norm = norm + temp * temp;
1914 if ( norm == 0.0 ) {
1916 for ( j = 0; j < 3; j++ ) {
1921 norm = ( float ) sqrt ( norm );
1923 for ( j = 0; j < 3; j++ ) {
1975 xave = xave +
cor3[0][
i];
1976 if (
cor3[0][
i] < xmin ) {
1979 if (
cor3[0][
i] > xmax ) {
1983 yave = yave +
cor3[1][
i];
1984 if (
cor3[1][
i] < ymin ) {
1987 if (
cor3[1][
i] > ymax ) {
1991 zave = zave +
cor3[2][
i];
1992 if (
cor3[2][
i] < zmin ) {
1995 if (
cor3[2][
i] > zmax ) {
2005 printf (
"COR3_RANGE - Data range:\n" );
2007 printf (
" Minimum Average Maximum Range\n" );
2009 printf (
"X %f %f %f %f\n", xmin, xave, xmax, xmax-xmin );
2010 printf (
"Y %f %f %f %f\n", ymin, yave, ymax, ymax-ymin );
2011 printf (
"Z %f %f %f %f\n", zmin, zave, zmax, zmax-zmin );
2039 printf (
"DATA_CHECK - Warning!\n" );
2040 printf (
" The input data requires %d colors.\n",
color_num );
2041 printf (
" There was only room for %d\n",
COLOR_MAX );
2047 printf (
"DATA_CHECK - Warning!\n" );
2048 printf (
" The input data requires %d points.\n",
cor3_num );
2049 printf (
" There was only room for %d\n",
COR3_MAX );
2055 printf (
"DATA_CHECK - Warning!\n" );
2056 printf (
" The input data requires %d faces.\n",
face_num );
2057 printf (
" There was only room for %d\n",
FACE_MAX );
2063 printf (
"DATA_CHECK - Warning!\n" );
2064 printf (
" The input data requires %d line items.\n",
line_num );
2065 printf (
" There was only room for %d.\n",
LINES_MAX );
2071 for ( iface = 0; iface <
face_num; iface++ ) {
2082 printf (
"DATA_CHECK - Warning!\n" );
2083 printf (
" Corrected %d faces using more than %d vertices per face.\n",
2100 printf (
"DATA_CHECK - Data checked.\n" );
2132 for (
i = 0;
i < 3;
i++ ) {
2136 for (
i = 0;
i < 3;
i++ ) {
2146 for (
i = 0;
i < 3;
i++ ) {
2157 for ( iface = 0; iface <
FACE_MAX; iface++ ) {
2158 for ( ivert = 0; ivert <
ORDER_MAX; ivert++ ) {
2159 face[ivert][iface] = 0;
2163 for ( iface = 0; iface <
FACE_MAX; iface++ ) {
2167 for ( iface = 0; iface <
FACE_MAX; iface++ ) {
2171 for ( iface = 0; iface <
FACE_MAX; iface++ ) {
2172 for (
i = 0;
i < 3;
i++ ) {
2177 for ( iface = 0; iface <
FACE_MAX; iface++ ) {
2181 for ( iface = 0; iface <
FACE_MAX; iface++ ) {
2185 for ( iface = 0; iface <
FACE_MAX; iface++ ) {
2203 for (
i = 0;
i < 4;
i++ ) {
2212 for (
i = 0;
i < 3;
i++ ) {
2228 for (
i = 0;
i < 3;
i++ ) {
2232 for (
i = 0;
i < 3;
i++ ) {
2250 for ( iface = 0; iface <
FACE_MAX; iface++ ) {
2251 for ( ivert = 0; ivert <
ORDER_MAX; ivert++ ) {
2256 for ( iface = 0; iface <
FACE_MAX; iface++ ) {
2257 for ( ivert = 0; ivert <
ORDER_MAX; ivert++ ) {
2258 for (
i = 0;
i < 3;
i++ ) {
2264 for ( j = 0; j < 3; j++ ) {
2272 for ( iface = 0; iface <
FACE_MAX; iface++ ) {
2273 for ( ivert = 0; ivert <
ORDER_MAX; ivert++ ) {
2274 for (
i = 0;
i < 2;
i++ ) {
2282 printf (
"DATA_INIT: Graphics data initialized.\n" );
2320 if ( filein_type == NULL ) {
2322 printf (
"DATA_READ - Fatal error!\n" );
2323 printf (
" Could not determine the type of '%s'.\n",
filein_name );
2328 printf (
"DATA_READ: Input file has type %s.\n", filein_type );
2342 if (
leqi ( filein_type,
"3DS" ) ==
TRUE ||
2343 leqi ( filein_type,
"STLB" ) ==
TRUE ||
2344 leqi ( filein_type,
"TRIB" ) ==
TRUE ) {
2351 if ( filein == NULL ) {
2353 printf (
"DATA_READ - Fatal error!\n" );
2354 printf (
" Could not open the input file '%s'!\n",
filein_name );
2360 if (
leqi ( filein_type,
"3DS" ) ==
TRUE ) {
2368 for ( iface = 0; iface <
face_num; iface++ ) {
2369 for ( ivert = 0; ivert <
face_order[iface]; ivert++ ) {
2370 icor3 =
face[ivert][iface];
2379 else if (
leqi ( filein_type,
"ASE" ) ==
TRUE ) {
2392 else if (
leqi ( filein_type,
"BYU" ) ==
TRUE ) {
2397 else if (
leqi ( filein_type,
"DXF" ) ==
TRUE ) {
2402 else if (
leqi ( filein_type,
"GMOD" ) ==
TRUE ) {
2407 else if (
leqi ( filein_type,
"HRC" ) ==
TRUE ) {
2412 else if (
leqi ( filein_type,
"IV" ) ==
TRUE ) {
2417 else if (
leqi ( filein_type,
"OBJ" ) ==
TRUE ) {
2422 else if (
leqi ( filein_type,
"SMF" ) ==
TRUE ) {
2428 leqi ( filein_type,
"STL" ) ==
TRUE ||
2429 leqi ( filein_type,
"STLA") ==
TRUE ) {
2440 else if (
leqi ( filein_type,
"STLB") ==
TRUE ) {
2446 leqi ( filein_type,
"TRI" ) ==
TRUE ||
2447 leqi ( filein_type,
"TRIA") ==
TRUE ) {
2452 else if (
leqi ( filein_type,
"TRIB") ==
TRUE ) {
2457 else if (
leqi ( filein_type,
"VLA" ) ==
TRUE ) {
2464 printf (
"DATA_READ - Fatal error!\n" );
2465 printf (
" Unacceptable input file type.\n" );
2472 printf (
"DATA_READ: Finished reading the data file.\n" );
2477 if ( ierror ==
ERROR ) {
2500 if ( ierror ==
ERROR ) {
2502 printf (
"DATA_READ - Fatal error!\n" );
2503 printf (
" An error occurred while reading the input file.\n" );
2529 for ( icor3 = 0; icor3 <
cor3_num; icor3++ ) {
2537 for ( iface = 0; iface <
face_num; iface++ ) {
2538 for ( ivert = 0; ivert <
face_order[iface]; ivert++ ) {
2547 for ( iface = 0; iface <
face_num; iface++ ) {
2555 for ( iline = 0; iline <
line_num; iline++ ) {
2615 printf (
"DATA_REPORT - The input file contains:\n" );
2617 printf (
" Bad data items %d\n",
bad_num );
2618 printf (
" Text lines %d\n",
text_num );
2619 printf (
" Text bytes (binary data) %d\n",
bytes_num );
2622 printf (
" Duplicate points %d\n",
dup_num );
2623 printf (
" Faces %d\n",
face_num );
2625 printf (
" Vertices per face, maximum %d\n",
max_order2 );
2626 printf (
" Line items %d\n",
line_num );
2627 printf (
" Points %d\n",
cor3_num );
2663 if ( fileout_type == NULL ) {
2665 printf (
"DATA_WRITE - Fatal error!\n" );
2666 printf (
" Could not determine the output file type.\n" );
2672 if (
leqi ( fileout_type,
"3DS" ) ==
TRUE ||
2673 leqi ( fileout_type,
"STLB" ) ==
TRUE ||
2674 leqi ( fileout_type,
"TRIB" ) ) {
2681 if ( fileout == NULL ) {
2683 printf (
"DATA_WRITE - Fatal error!\n" );
2684 printf (
" Could not open the output file!\n" );
2690 if (
leqi ( fileout_type,
"3DS" ) ==
TRUE ) {
2696 else if (
leqi ( fileout_type,
"ASE" ) ==
TRUE ) {
2701 else if (
leqi ( fileout_type,
"BYU" ) ==
TRUE ) {
2706 else if (
leqi ( fileout_type,
"DXF" ) ==
TRUE ) {
2711 else if (
leqi ( fileout_type,
"GMOD" ) ==
TRUE ) {
2716 else if (
leqi ( fileout_type,
"HRC" ) ==
TRUE ) {
2721 else if (
leqi ( fileout_type,
"IV" ) ==
TRUE ) {
2726 else if (
leqi ( fileout_type,
"OBJ" ) ==
TRUE ) {
2731 else if (
leqi ( fileout_type,
"POV" ) ==
TRUE ) {
2736 else if (
leqi ( fileout_type,
"SMF" ) ==
TRUE ) {
2742 leqi ( fileout_type,
"STL" ) ==
TRUE ||
2743 leqi ( fileout_type,
"STLA" ) ==
TRUE ) {
2748 else if (
leqi ( fileout_type,
"STLB" ) ==
TRUE ) {
2753 else if (
leqi ( fileout_type,
"TEC" ) ==
TRUE ) {
2759 leqi ( fileout_type,
"TRI" ) ==
TRUE ||
2760 leqi ( fileout_type,
"TRIA" ) ==
TRUE ) {
2765 else if (
leqi ( fileout_type,
"TRIB" ) ==
TRUE ) {
2770 else if (
leqi ( fileout_type,
"TXT" ) ==
TRUE ) {
2775 else if (
leqi ( fileout_type,
"UCD" ) ==
TRUE ) {
2780 else if (
leqi ( fileout_type,
"VLA" ) ==
TRUE ) {
2787 printf (
"DATA_WRITE - Note:\n" );
2788 printf (
" Face information will temporarily be converted to\n" );
2789 printf (
" line information for output to a VLA file.\n" );
2795 printf (
"DATA_WRITE - Warning:\n" );
2796 printf (
" Some face information was lost.\n" );
2797 printf (
" The maximum number of lines is %d.\n",
LINES_MAX );
2798 printf (
" The number of lines needed is %d.\n",
line_num );
2809 else if (
leqi ( fileout_type,
"WRL" ) ==
TRUE ) {
2814 else if (
leqi ( fileout_type,
"XGL" ) ==
TRUE ) {
2823 printf (
"DATA_WRITE - Fatal error!\n" );
2824 printf (
" Unacceptable output file type \"%s\".\n", fileout_type );
2832 if ( result ==
ERROR ) {
2954 if ( fgets ( input1,
LINE_MAX_LEN, filein ) == NULL ) {
2960 count = sscanf ( input1,
"%d%n", &code, &width );
2967 if ( fgets ( input2,
LINE_MAX_LEN, filein ) == NULL ) {
2982 if ( strncmp( input2,
"LINE", 4 ) == 0 ) {
2985 else if ( strncmp( input2,
"3DFACE", 6 ) == 0 ) {
2992 for (cpos = 0; input1[cpos] ==
' '; cpos++)
2995 if ( input1[cpos] ==
'1' || input1[cpos] ==
'2' || input1[cpos] ==
'3' ) {
2997 count = sscanf ( input2,
"%e%n", &rval, &width );
2999 switch ( input1[cpos] )
3026 if ( icor3 == -1 ) {
3170 fprintf ( fileout,
" 0\n" );
3171 fprintf ( fileout,
"SECTION\n" );
3172 fprintf ( fileout,
" 2\n" );
3173 fprintf ( fileout,
"HEADER\n" );
3174 fprintf ( fileout,
"999\n" );
3175 fprintf ( fileout,
"%s created by IVCON.\n",
fileout_name );
3176 fprintf ( fileout,
"999\n" );
3177 fprintf ( fileout,
"Original data in %s.\n",
filein_name );
3178 fprintf ( fileout,
" 0\n" );
3179 fprintf ( fileout,
"ENDSEC\n" );
3182 fprintf ( fileout,
" 0\n" );
3183 fprintf ( fileout,
"SECTION\n" );
3184 fprintf ( fileout,
" 2\n" );
3185 fprintf ( fileout,
"TABLES\n" );
3186 fprintf ( fileout,
" 0\n" );
3187 fprintf ( fileout,
"ENDSEC\n" );
3190 fprintf ( fileout,
" 0\n" );
3191 fprintf ( fileout,
"SECTION\n" );
3192 fprintf ( fileout,
" 2\n" );
3193 fprintf ( fileout,
"BLOCKS\n" );
3194 fprintf ( fileout,
" 0\n" );
3195 fprintf ( fileout,
"ENDSEC\n" );
3198 fprintf ( fileout,
" 0\n" );
3199 fprintf ( fileout,
"SECTION\n" );
3200 fprintf ( fileout,
" 2\n" );
3201 fprintf ( fileout,
"ENTITIES\n" );
3209 for ( iline = 0; iline <
line_num; iline++ ) {
3213 if ( icor3 == -1 ) {
3219 if ( newline ==
FALSE ) {
3221 fprintf ( fileout,
" 0\n" );
3222 fprintf ( fileout,
"LINE\n" );
3223 fprintf ( fileout,
" 8\n" );
3224 fprintf ( fileout,
" 0\n" );
3225 fprintf ( fileout,
" 10\n" );
3226 fprintf ( fileout,
"%f\n",
cor3[0][jcor3] );
3227 fprintf ( fileout,
" 20\n" );
3228 fprintf ( fileout,
"%f\n",
cor3[1][jcor3] );
3229 fprintf ( fileout,
" 30\n" );
3230 fprintf ( fileout,
"%f\n",
cor3[2][jcor3] );
3231 fprintf ( fileout,
" 11\n" );
3232 fprintf ( fileout,
"%f\n",
cor3[0][icor3] );
3233 fprintf ( fileout,
" 21\n" );
3234 fprintf ( fileout,
"%f\n",
cor3[1][icor3] );
3235 fprintf ( fileout,
" 31\n" );
3236 fprintf ( fileout,
"%f\n",
cor3[2][icor3] );
3251 for ( iface = 0; iface <
face_num; iface++ ) {
3253 fprintf ( fileout,
" 0\n" );
3254 fprintf ( fileout,
"3DFACE\n" );
3255 fprintf ( fileout,
" 8\n" );
3256 fprintf ( fileout,
" Cube\n" );
3259 for ( ivert = 0; ivert <
face_order[iface]; ivert++ ) {
3261 icor3 =
face[ivert][iface];
3263 fprintf ( fileout,
"1%d\n", ivert );
3264 fprintf ( fileout,
"%f\n",
cor3[0][icor3] );
3265 fprintf ( fileout,
"2%d\n", ivert );
3266 fprintf ( fileout,
"%f\n",
cor3[1][icor3] );
3267 fprintf ( fileout,
"3%d\n", ivert );
3268 fprintf ( fileout,
"%f\n",
cor3[2][icor3] );
3274 fprintf ( fileout,
" 0\n" );
3275 fprintf ( fileout,
"ENDSEC\n" );
3276 fprintf ( fileout,
" 0\n" );
3277 fprintf ( fileout,
"EOF\n" );
3283 printf (
"DXF_WRITE - Wrote %d text lines.\n",
text_num );
3328 for ( iface = 0; iface <
face_num; iface++ ) {
3334 for ( ivert = 0; ivert <
face_order[iface]; ivert++ ) {
3336 edge_num = edge_num + 1;
3343 inode =
face[ivert][iface];
3344 jnode =
face[jvert][iface];
3347 x =
cor3[0][inode] -
cor3[0][jnode];
3348 y =
cor3[1][inode] -
cor3[1][jnode];
3349 z =
cor3[2][inode] -
cor3[2][jnode];
3351 distsq = x * x + y * y + z * z;
3353 if ( distsq != 0.0 ) {
3354 face2[face_order2] =
face[ivert][iface];
3355 vertex_normal2[0][face_order2] =
vertex_normal[0][ivert][iface];
3356 vertex_normal2[1][face_order2] =
vertex_normal[1][ivert][iface];
3357 vertex_normal2[2][face_order2] =
vertex_normal[2][ivert][iface];
3358 face_order2 = face_order2 + 1;
3361 edge_num_del = edge_num_del + 1;
3367 for ( ivert = 0; ivert <
face_order[iface]; ivert++ ) {
3368 face[ivert][iface] = face2[ivert];
3369 for ( j = 0; j < 3; j++ ) {
3377 printf (
"EDGE_NULL_DELETE:\n" );
3378 printf (
" There are a total of %d edges.\n", edge_num );
3379 printf (
" Of these, %d were of zero length, and deleted.\n", edge_num_del );
3441 for ( iface = 0; iface <
face_num; iface++ ) {
3447 i1 =
face[
i][iface];
3448 i2 =
face[
i+1][iface];
3449 i3 =
face[
i+2][iface];
3466 ( x2 - x1 ) * ( x3 - x1 ) +
3467 ( y2 - y1 ) * ( y3 - y1 ) +
3468 ( z2 - z1 ) * ( z3 - z1 );
3471 ( x2 - x1 ) * ( x2 - x1 )
3472 + ( y2 - y1 ) * ( y2 - y1 )
3473 + ( z2 - z1 ) * ( z2 - z1 ) );
3478 if ( base == 0.0 ) {
3483 alpha = dot / ( base * base );
3485 x = x3 - x1 - alpha * ( x2 - x1 );
3486 y = y3 - y1 - alpha * ( y2 - y1 );
3487 z = z3 - z1 - alpha * ( z2 - z1 );
3489 height = sqrt ( x * x + y * y + z * z );
3493 area_tri = 0.5 * base * height;
3504 for ( iface = 1; iface <
face_num; iface++ ) {
3514 printf (
"FACE_AREA_SET:\n" );
3515 printf (
" Minimum face area is %f\n", area_min );
3516 printf (
" Maximum face area is %f\n", area_max );
3518 tol = area_max / 10000.0;
3520 if ( area_min < tol ) {
3524 for ( iface = 0; iface <
face_num; iface++ ) {
3527 face_num_del = face_num_del + 1;
3531 printf (
" Marked %d tiny faces for deletion.\n", face_num_del );
3572 for ( iface = 0; iface <
face_num; iface++ ) {
3580 norm = ( float ) sqrt ( x * x + y * y + z * z );
3582 if ( norm == 0.0 ) {
3586 for (
i = 0;
i < 3;
i++ ) {
3590 for ( ivert = 0; ivert <
face_order[iface]; ivert++ ) {
3591 for (
i = 0;
i < 3;
i++ ) {
3600 norm = ( float ) sqrt ( x * x + y * y + z * z );
3602 if ( norm == 0.0 ) {
3603 for (
i = 0;
i < 3;
i++ ) {
3604 face_normal[
i][iface] = ( float ) ( 1.0 / sqrt ( 3.0 ) );
3608 for (
i = 0;
i < 3;
i++ ) {
3617 printf (
"FACE_NORMAL_AVE: Recomputed %d face normals\n", nfix );
3618 printf (
" by averaging face vertex normals.\n" );
3659 for ( iface = 0; iface <
face_num; iface++ ) {
3669 if ( face_num2 != iface ) {
3674 for ( ivert = 0; ivert <
ORDER_MAX; ivert++ ) {
3675 face[ivert][face_num2] =
face[ivert][iface];
3677 for ( j = 0; j < 3; j++ ) {
3687 face_num2 = face_num2 + 1;
3694 printf (
"FACE_NULL_DELETE\n" );
3695 printf (
" There are a total of %d faces.\n",
face_num );
3696 printf (
" Of these, %d passed the order test.\n", face_num2 );
3726 if ( iface < 0 || iface >
face_num-1 ) {
3728 printf (
"FACE_PRINT - Fatal error!\n" );
3729 printf (
" Face indices must be between 1 and %d\n",
face_num );
3730 printf (
" But your requested value was %d\n", iface );
3735 printf (
"FACE_PRINT\n" );
3736 printf (
" Information about face %d\n", iface );
3738 printf (
" Number of vertices is %d\n",
face_order[iface] );
3740 printf (
" Vertex list:\n" );
3741 printf (
" Vertex #, Node #, Material #, X, Y, Z:\n" );
3743 for ( ivert = 0; ivert <
face_order[iface]; ivert++ ) {
3744 j =
face[ivert][iface];
3746 printf (
" %d %d %d %f %f %f\n", ivert, j,
k,
cor3[0][j],
cor3[1][j],
3751 printf (
" Face normal vector:\n" );
3757 printf (
" Vertex face normals:\n" );
3759 for ( ivert = 0; ivert <
face_order[iface]; ivert++ ) {
3760 printf (
" %d %f %f %f\n", ivert,
vertex_normal[0][ivert][iface],
3801 for ( iface = 0; iface <
face_num; iface++ ) {
3805 for ( ivert = 0; ivert < ( m / 2 ); ivert++ ) {
3807 itemp =
face[ivert][iface];
3808 face[ivert][iface] =
face[m-1-ivert][iface];
3809 face[m-1-ivert][iface] = itemp;
3815 for ( j = 0; j < 3; j++ ) {
3821 for ( j = 0; j < 2; j++ ) {
3832 for ( j = 0; j < 3; j++ ) {
3838 for ( j = 0; j < 3; j++ ) {
3844 printf (
"FACE_REVERSE_ORDER\n" );
3845 printf (
" Each list of nodes defining a face\n" );
3846 printf (
" has been reversed; related information,\n" );
3847 printf (
" including normal vectors, was also updated.\n" );
3892 printf (
"Enter lowest face number to save between 0 and %d:\n",
face_num-1 );
3893 scanf (
"%d", &iface1 );
3894 if ( iface1 < 0 || iface1 >
face_num - 1 ) {
3895 printf (
"Illegal choice!\n" );
3900 printf (
"Enter highest face number to save between %d and %d:\n",
3902 scanf (
"%d", &iface2 );
3903 if ( iface2 < iface1 || iface2 >
face_num - 1 ) {
3904 printf (
"Illegal choice!\n" );
3912 for ( iface = 0; iface < iface2 + 1 - iface1; iface++ ) {
3914 for ( ivert = 0; ivert <
ORDER_MAX; ivert++ ) {
3915 face[ivert][iface] =
face[ivert][iface+inc];
3917 for (
i = 0;
i < 3;
i++ ) {
3923 for (
i = 0;
i < 3;
i++ ) {
3942 for ( iface = 0; iface <
face_num; iface++ ){
3943 for ( ivert = 0; ivert <
face_order[iface]; ivert++ ){
3944 j =
face[ivert][iface];
3945 if (
list[j] == -1 ) {
3946 cor3_num2 = cor3_num2 + 1;
3947 list[j] = cor3_num2;
3958 if (
list[
i] != -1 ) {
3959 list[
i] = cor3_num2;
3960 cor3_num2 = cor3_num2 + 1;
3966 for ( iface = 0; iface <
face_num; iface++ ){
3967 for ( ivert = 0; ivert <
face_order[iface]; ivert++ ){
3968 j =
face[ivert][iface];
3978 for ( j = 0; j < 3; j++ ) {
4025 for ( iface = 0; iface <
face_num; iface++ ) {
4027 for ( ivert = 0; ivert <
face_order[iface]; ivert++ ) {
4029 icor3 =
face[ivert][iface];
4039 icor3 =
face[ivert][iface];
4062 for ( iface = 0; iface <
face_num; iface++ ) {
4064 for ( ivert = 0; ivert <
face_order[iface]; ivert++ ) {
4066 icor3 =
face[ivert][iface];
4075 jcor3 =
face[jvert][iface];
4077 if ( icor3 < jcor3 ) {
4130 for ( iface = 0; iface <
face_num; iface++ ) {
4131 for ( ivert = 0; ivert <
face_order[iface]; ivert++ ) {
4166 return file_name +
i + 1;
4188 fread ( &temp,
sizeof (
float ), 1, filein );
4234 y.ychar[0] = y.ychar[3];
4238 y.ychar[1] = y.ychar[2];
4241 return ( y.yfloat );
4259 int nbyte =
sizeof ( float );
4269 fwrite ( &temp, nbyte, 1, fileout );
4293 static unsigned char one[4];
4296 temp =
sizeof ( float );
4301 *(
float *)one = 1.0;
4303 if (one[0] == 0 && one[1] == 0 && one[2] == 128 && one[3] == 63) {
4308 if (one[0] == 63 && one[1] == 128 && one[2] == 0 && one[3] == 0) {
4399 unsigned char MagicNumber[4];
4400 unsigned long int NumSections;
4405 unsigned short NumAnimations;
4406 unsigned short NumFrames;
4407 unsigned short FaceCount;
4408 unsigned short TextureCount;
4412 unsigned short Flags;
4413 unsigned short TextureNameLen;
4414 unsigned short AnimationNameLen;
4423 printf(
"GMOD_READ - This architecture not supported.\n");
4432 fread(MagicNumber, 1, 4, filein);
4433 if (MagicNumber[0] != 0xf9 ||
4434 MagicNumber[1] != 0xfa ||
4435 MagicNumber[2] != 0x63 ||
4436 MagicNumber[3] != 0x1e) {
4437 printf(
"GMOD_READ - Bad magic number on GMOD file.\n");
4443 printf(
"GMOD_READ - Too many sections (%ld) in GMOD file - please increase static limit GMOD_MAX_SECTIONS\n", NumSections);
4451 for ( SectionCount = 0; SectionCount < ( int ) NumSections; SectionCount++ ) {
4458 for ( SectionCount = 0; SectionCount < ( int ) NumSections; SectionCount++ ) {
4462 fseek ( filein, (
long int ) SectionOffset[SectionCount], SEEK_SET );
4466 switch (SectionID[SectionCount]) {
4478 printf(
"GMOD_READ - Too many faces (%d) in GMOD file - please increase static limit FACE_MAX.\n",
face_num);
4484 for ( FaceCount = 0; FaceCount < (
unsigned short )
face_num; FaceCount++ ) {
4487 for ( VertexCount = 0; VertexCount < 4; VertexCount++ ) {
4494 Order = VertexCount+1;
4495 if (MaxCor <
face[VertexCount][FaceCount])
4496 MaxCor =
face[VertexCount][FaceCount];
4507 fread(&Scale,
sizeof(Scale), 1, filein);
4511 printf (
"Flags = %d\n", Flags );
4537 printf (
"GMOD_READ - Too many texture maps (%d) in GMOD file.\n",
texture_num );
4538 printf (
" Increase static limit TEXTURE_MAX.\n" );
4543 for (TextureCount = 0; TextureCount < (
unsigned short )
texture_num;
4549 fread (
texture_name[TextureCount],
sizeof(
char), TextureNameLen, filein);
4565 printf(
"GMOD_READ - Too many vertices (%d) in GMOD file - please increase static limit COR3_MAX.\n",
cor3_num);
4575 if (NumAnimations > 1) {
4576 printf (
"GMOD_READ - Fatal error!\n" );
4577 printf (
" GMOD files can only handle one animation.\n" );
4578 printf (
" This file contains %d.\n", NumAnimations );
4584 fread (
anim_name,
sizeof(
char), AnimationNameLen, filein);
4590 printf(
"GMOD_READ - Too many frames of animation (%d) in GMOD file - will only use 1.\n", NumFrames);
4593 for (VertexCount = 0; VertexCount <
cor3_num; VertexCount++) {
4621 printf (
"GMOD_READ - Maximum coordinate index (%d)\n", MaxCor );
4622 printf (
" exceeded number of coordinates (%d) in GMOD file.\n",
cor3_num );
4649 unsigned char *out_pos;
4653 if (*(
char *)&endian == 1) {
4655 fread(&Val,
sizeof(Val), 1, filein);
4659 out_pos = (
unsigned char *)&Val;
4660 for (
i =
sizeof(Val)-1;
i >= 0;
i-- ) {
4661 *(out_pos+
i) = fgetc(filein);
4687 unsigned char Byte1;
4688 unsigned char Byte2;
4690 Byte1 = fgetc ( filein );
4691 Byte2 = fgetc ( filein );
4693 return Byte1 | (((
unsigned short)Byte2) << 8);
4715 unsigned char Byte1, Byte2, Byte3, Byte4;
4717 Byte1 = fgetc(filein);
4718 Byte2 = fgetc(filein);
4719 Byte3 = fgetc(filein);
4720 Byte4 = fgetc(filein);
4723 (((
unsigned long)Byte2) << 8) |
4724 (((
unsigned long)Byte3) << 16) |
4725 (((
unsigned long)Byte4) << 24);
4747 static unsigned char MagicNumber[4] = { 0xf9, 0xfa, 0x63, 0x1e };
4748 unsigned long NumSections;
4749 unsigned long SectionHeaderPos;
4750 unsigned long TextureNameSectionPos;
4751 unsigned long ModelSectionPos;
4752 unsigned long VertexSectionPos;
4757 unsigned long SectionCount;
4769 printf(
"GMOD_WRITE - This architecture not supported.\n");
4780 fwrite ( MagicNumber,
sizeof(
char), 4, fileout );
4791 SectionHeaderPos = ftell ( fileout );
4792 for (SectionCount = 0; SectionCount < NumSections; SectionCount++) {
4803 TextureNameSectionPos = ftell ( fileout );
4813 for ( TextureCount = 0; TextureCount <
face_num; TextureCount++ ) {
4830 ModelSectionPos = ftell(fileout);
4842 for ( FaceCount = 0; FaceCount <
face_num; FaceCount++ ) {
4844 for (VertexCount = 0; VertexCount < ((
face_order[FaceCount] < 4) ?
face_order[FaceCount] : 4); VertexCount++) {
4863 for ( ; VertexCount < 4; VertexCount++ ) {
4885 for ( DimensionCount = 0; DimensionCount < 3; DimensionCount++ ) {
4887 CorNumber =
face[0][FaceCount];
4888 Min[DimensionCount] =
cor3[DimensionCount][CorNumber];
4889 Max[DimensionCount] =
cor3[DimensionCount][CorNumber];
4891 for (VertexCount = 1; VertexCount < ((
face_order[FaceCount] < 4) ?
face_order[FaceCount] : 4); VertexCount++) {
4893 CorNumber =
face[VertexCount][FaceCount];
4895 if (Min[DimensionCount] >
cor3[DimensionCount][CorNumber])
4896 Min[DimensionCount] =
cor3[DimensionCount][CorNumber];
4898 if (Max[DimensionCount] <
cor3[DimensionCount][CorNumber])
4899 Max[DimensionCount] =
cor3[DimensionCount][CorNumber];
4907 MaxWidth = Max[0] - Min[0];
4908 for ( DimensionCount = 1; DimensionCount < 3; DimensionCount++ ) {
4910 if ( MaxWidth < Max[DimensionCount] - Min[DimensionCount] )
4911 MaxWidth = Max[DimensionCount] - Min[DimensionCount];
4915 fwrite ( &Scale,
sizeof(Scale), 1, fileout );
4937 VertexSectionPos = ftell ( fileout );
4967 for ( VertexCount = 0; VertexCount <
cor3_num; VertexCount++ ) {
4990 fseek ( fileout, (
long int ) SectionHeaderPos, SEEK_SET );
5034 unsigned char *out_pos;
5037 if (*(
char *)&endian == 1) {
5039 fwrite ( &Val,
sizeof(Val), 1, fileout );
5043 out_pos = (
unsigned char *)&Val;
5044 for (
i =
sizeof(Val)-1;
i >= 0;
i-- ) {
5045 fputc(*(out_pos+
i), fileout);
5069 unsigned char OutByte[2];
5071 OutByte[0] = (
unsigned char)(Val & 0xff);
5072 OutByte[1] = (
unsigned char)(Val >> 8);
5074 fwrite ( OutByte,
sizeof(
unsigned char), 2, fileout );
5096 unsigned char OutByte[4];
5098 OutByte[0] = (
unsigned char)(Val & 0xff);
5099 OutByte[1] = (
unsigned char)((Val >> 8) & 0xff);
5100 OutByte[2] = (
unsigned char)((Val >> 16) & 0xff);
5101 OutByte[3] = (
unsigned char)((Val >> 24) & 0xff);
5103 fwrite ( OutByte,
sizeof(
unsigned char), 4, fileout );
5126 printf (
"Hello: This is IVCON,\n" );
5127 printf (
" for 3D graphics file conversion.\n" );
5129 printf (
" \".3ds\" 3D Studio Max binary;\n" );
5130 printf (
" \".ase\" 3D Studio Max ASCII export;\n" );
5131 printf (
" \".byu\" Movie.BYU surface geometry;\n" );
5132 printf (
" \".dxf\" DXF;\n" );
5133 printf (
" \".gmod\" Golgotha model;\n" );
5134 printf (
" \".hrc\" SoftImage hierarchy;\n" );
5135 printf (
" \".iv\" SGI Open Inventor;\n" );
5136 printf (
" \".obj\" WaveFront Advanced Visualizer;\n" );
5137 printf (
" \".pov\" Persistence of Vision (output only);\n" );
5138 printf (
" \".smf\" Michael Garland's format;\n" );
5139 printf (
" \".stl\" ASCII StereoLithography;\n" );
5140 printf (
" \".stla\" ASCII StereoLithography;\n" );
5141 printf (
" \".stlb\" Binary StereoLithography;\n" );
5142 printf (
" \".tec\" TECPLOT (output only);\n" );
5143 printf (
" \".tri\" [Greg Hood ASCII triangle format];\n" );
5144 printf (
" \".tria\" [Greg Hood ASCII triangle format];\n" );
5145 printf (
" \".trib\" [Greg Hood binary triangle format];\n" );
5146 printf (
" \".txt\" Text (output only);\n" );
5147 printf (
" \".ucd\" AVS UCD file(output only);\n" );
5148 printf (
" \".vla\" VLA;\n" );
5149 printf (
" \".wrl\" VRML (Virtual Reality Modeling Language) (output only).\n" );
5150 printf (
" \".xgl\" XML/OpenGL format (output only);\n" );
5152 printf (
" Current limits include:\n" );
5153 printf (
" %d faces;\n",
FACE_MAX );
5154 printf (
" %d line items;\n",
LINES_MAX );
5155 printf (
" %d points;\n",
COR3_MAX );
5156 printf (
" %d face order;\n",
ORDER_MAX );
5160 printf (
" Last modification: 04 July 2000.\n" );
5162 printf (
" Send problem reports to burkardt@psc.edu.\n" );
5187 printf (
"Commands:\n" );
5189 printf (
"< file Read data from input file;\n" );
5190 printf (
"<< file Append data in input file to current data;\n" );
5191 printf (
"> file Write output file;\n" );
5192 printf (
"B Switch the binary file byte-swapping mode;\n" );
5193 printf (
"D Switch the debugging mode;\n" );
5194 printf (
"F Print information about one face;\n" );
5195 printf (
"H Print this help list;\n" );
5196 printf (
"I Info, print out recent changes;\n" );
5197 printf (
"LINES Convert face information to lines;\n" );
5198 printf (
"N Recompute normal vectors;\n" );
5199 printf (
"P Set LINE_PRUNE option.\n" );
5200 printf (
"Q Quit;\n" );
5201 printf (
"R Reverse the normal vectors.\n" );
5202 printf (
"S Select face subset (NOT WORKING).\n" );
5203 printf (
"T Transform the data.\n" );
5204 printf (
"W Reverse the face node ordering.\n" );
5399 strcpy ( word,
" " );
5400 strcpy ( wordm1,
" " );
5418 strcpy ( wordm1, word );
5420 count = sscanf ( next,
"%s%n", word2, &width );
5421 next = next + width;
5427 strcpy ( word, word2 );
5432 strcpy ( word1, word );
5439 if ( strcmp ( word1,
"HRCH:" ) != 0 ) {
5441 printf (
"HRC_READ - Fatal error!\n" );
5442 printf (
" The input file has a bad header.\n" );
5453 if ( strcmp ( word,
"{" ) == 0 ) {
5454 nlbrack = nlbrack + 1;
5455 level = nlbrack - nrbrack;
5458 printf (
"New level: %s\n",
level_name[level] );
5461 else if ( strcmp ( word,
"}" ) == 0 ) {
5462 nrbrack = nrbrack + 1;
5464 if ( nlbrack < nrbrack ) {
5466 printf (
"HRC_READ - Fatal error!\n" );
5467 printf (
" Extraneous right bracket on line %d.\n",
text_num );
5468 printf (
" Currently processing field %s\n.",
level_name[level] );
5475 if ( strcmp (
level_name[level],
"controlpoints" ) == 0 ) {
5477 if ( strcmp ( word,
"{" ) == 0 ) {
5479 else if ( strcmp ( word,
"}" ) == 0 ) {
5486 level = nlbrack - nrbrack;
5488 else if ( word[0] ==
'[' ) {
5490 else if ( strcmp ( word,
"position" ) == 0 ) {
5492 count = sscanf ( next,
"%f%n", &x, &width );
5493 next = next + width;
5495 count = sscanf ( next,
"%f%n", &y, &width );
5496 next = next + width;
5498 count = sscanf ( next,
"%f%n", &z, &width );
5499 next = next + width;
5512 if ( icor3 == -1 ) {
5535 printf (
"CONTROLPOINTS: Bad data %s\n", word );
5543 else if ( strcmp (
level_name[level],
"edges" ) == 0 ) {
5545 if ( strcmp( word,
"{" ) == 0 ) {
5547 else if ( strcmp ( word,
"}" ) == 0 ) {
5548 level = nlbrack - nrbrack;
5550 else if ( word[0] ==
'[' ) {
5552 else if ( strcmp ( word,
"vertices" ) == 0 ) {
5554 count = sscanf ( next,
"%d%n", &jval, &width );
5555 next = next + width;
5563 count = sscanf ( next,
"%d%n", &jval, &width );
5564 next = next + width;
5581 printf (
"EDGES: Bad data %s\n", word );
5589 else if ( strcmp (
level_name[level],
"material" ) == 0 ) {
5591 if ( strcmp ( word,
"{" ) == 0 ) {
5594 else if ( strcmp ( word,
"}" ) == 0 ) {
5595 level = nlbrack - nrbrack;
5597 else if ( word[0] ==
'[' ) {
5599 else if ( strcmp ( word,
"ambient" ) == 0 ) {
5601 else if ( strcmp ( word,
"coc" ) == 0 ) {
5603 else if ( strcmp ( word,
"diffuse" ) == 0 ) {
5605 count = sscanf ( next,
"%f%n", &r, &width );
5606 next = next + width;
5609 count = sscanf ( next,
"%f%n", &g, &width );
5610 next = next + width;
5613 count = sscanf ( next,
"%f%n", &b, &width );
5614 next = next + width;
5618 else if ( strcmp ( word,
"exponent" ) == 0 ) {
5620 else if ( strcmp ( word,
"glow" ) == 0 ) {
5622 else if ( strcmp ( word,
"name" ) == 0 ) {
5623 count = sscanf ( next,
"%s%n", word, &width );
5624 next = next + width;
5627 else if ( strcmp ( word,
"reflectivity" ) == 0 ) {
5629 else if ( strcmp ( word,
"refracindex" ) == 0 ) {
5631 else if ( strcmp ( word,
"specular" ) == 0 ) {
5633 else if ( strcmp ( word,
"transparency" ) == 0 ) {
5634 count = sscanf ( next,
"%f%n", &t, &width );
5635 next = next + width;
5638 else if ( strcmp ( word,
"type" ) == 0 ) {
5642 printf (
"MATERIAL: Bad data %s\n", word );
5649 else if ( strcmp (
level_name[level],
"mesh" ) == 0 ) {
5651 if ( strcmp ( word,
"{" ) == 0 ) {
5653 else if ( strcmp ( word,
"}" ) == 0 ) {
5654 level = nlbrack - nrbrack;
5656 else if ( strcmp ( word,
"discontinuity" ) == 0 ) {
5659 else if ( strcmp ( word,
"edges" ) == 0 ) {
5662 else if ( strcmp ( word,
"flag" ) == 0 ) {
5665 else if ( strcmp ( word,
"polygons" ) == 0 ) {
5668 else if ( strcmp ( word,
"vertices" ) == 0 ) {
5673 printf (
"MESH: Bad data %s\n", word );
5681 else if ( strcmp (
level_name[level],
"model" ) == 0 ) {
5683 if ( strcmp ( word,
"{" ) == 0 ) {
5685 else if ( strcmp ( word,
"}" ) == 0 ) {
5686 level = nlbrack - nrbrack;
5688 else if ( strcmp ( word,
"material" ) == 0 ) {
5691 else if ( strcmp ( word,
"mesh" ) == 0 ) {
5694 else if ( strcmp ( word,
"name" ) == 0 ) {
5697 else if ( strcmp ( word,
"patch" ) == 0 ) {
5700 else if ( strcmp ( word,
"rotation" ) == 0 ) {
5703 else if ( strcmp ( word,
"scaling" ) == 0 ) {
5706 else if ( strcmp ( word,
"spline" ) == 0 ) {
5709 else if ( strcmp ( word,
"translation" ) == 0 ) {
5714 printf (
"MODEL: Bad data %s\n", word );
5722 else if ( strcmp (
level_name[level],
"nodes" ) == 0 ) {
5724 if ( strcmp ( word,
"{" ) == 0 ) {
5729 else if ( strcmp ( word,
"}" ) == 0 ) {
5730 level = nlbrack - nrbrack;
5732 else if ( word[0] ==
'[' ) {
5734 else if ( strcmp ( word,
"normal" ) == 0 ) {
5736 count = sscanf ( next,
"%f%n", &x, &width );
5737 next = next + width;
5739 count = sscanf ( next,
"%f%n", &y, &width );
5740 next = next + width;
5742 count = sscanf ( next,
"%f%n", &z, &width );
5743 next = next + width;
5752 else if ( strcmp ( word,
"uvTexture" ) == 0 ) {
5754 count = sscanf ( next,
"%f%n", &x, &width );
5755 next = next + width;
5757 count = sscanf ( next,
"%f%n", &y, &width );
5758 next = next + width;
5765 else if ( strcmp ( word,
"vertex" ) == 0 ) {
5767 count = sscanf ( next,
"%d%n", &jval, &width );
5768 next = next + width;
5780 else if ( strcmp ( word,
"vertexColor" ) == 0 ) {
5782 count = sscanf ( next,
"%d%n", &jval, &width );
5783 next = next + width;
5785 count = sscanf ( next,
"%d%n", &jval, &width );
5786 next = next + width;
5788 count = sscanf ( next,
"%d%n", &jval, &width );
5789 next = next + width;
5791 count = sscanf ( next,
"%d%n", &jval, &width );
5792 next = next + width;
5796 printf (
"NODES: Bad data %s\n", word );
5805 else if ( strcmp (
level_name[level],
"patch" ) == 0 ) {
5807 if ( strcmp ( word,
"{" ) == 0 ) {
5809 else if ( strcmp ( word,
"}" ) == 0 ) {
5810 level = nlbrack - nrbrack;
5812 else if ( strcmp ( word,
"approx_type" ) == 0 ) {
5814 else if ( strcmp ( word,
"controlpoints" ) == 0 ) {
5816 else if ( strcmp ( word,
"curv_u" ) == 0 ) {
5818 else if ( strcmp ( word,
"curv_v" ) == 0 ) {
5820 else if ( strcmp ( word,
"recmin" ) == 0 ) {
5822 else if ( strcmp ( word,
"recmax" ) == 0 ) {
5824 else if ( strcmp ( word,
"recursion" ) == 0 ) {
5826 else if ( strcmp ( word,
"spacial" ) == 0 ) {
5828 else if ( strcmp ( word,
"taggedpoints" ) == 0 ) {
5830 else if ( strcmp ( word,
"ucurve" ) == 0 ) {
5832 else if ( strcmp ( word,
"ustep" ) == 0 ) {
5834 else if ( strcmp ( word,
"utension" ) == 0 ) {
5836 else if ( strcmp ( word,
"utype" ) == 0 ) {
5838 else if ( strcmp ( word,
"vclose" ) == 0 ) {
5840 else if ( strcmp ( word,
"vcurve" ) == 0 ) {
5842 else if ( strcmp ( word,
"viewdep" ) == 0 ) {
5844 else if ( strcmp ( word,
"vpoint" ) == 0 ) {
5846 else if ( strcmp ( word,
"vstep" ) == 0 ) {
5848 else if ( strcmp ( word,
"vtension" ) == 0 ) {
5850 else if ( strcmp ( word,
"vtype" ) == 0 ) {
5854 printf (
"PATCH: Bad data %s\n", word );
5861 else if ( strcmp (
level_name[level],
"polygons" ) == 0 ) {
5863 if ( strcmp ( word,
"{" ) == 0 ) {
5865 else if ( strcmp ( word,
"}" ) == 0 ) {
5866 level = nlbrack - nrbrack;
5868 else if ( word[0] ==
'[' ) {
5870 else if ( strcmp ( word,
"material" ) == 0 ) {
5872 count = sscanf ( next,
"%d%n", &jval, &width );
5873 next = next + width;
5875 for ( ivert = 0; ivert <
ORDER_MAX; ivert++ ) {
5880 else if ( strcmp ( word,
"nodes" ) == 0 ) {
5881 count = sscanf ( next,
"%s%n", word2, &width );
5882 next = next + width;
5886 printf (
"POLYGONS: Bad data %s\n", word );
5894 else if ( strcmp (
level_name[level],
"spline" ) == 0 ) {
5896 if ( strcmp ( word,
"{" ) == 0 ) {
5898 else if ( strcmp ( word,
"}" ) == 0 ) {
5899 level = nlbrack - nrbrack;
5901 else if ( strcmp ( word,
"controlpoints" ) == 0 ) {
5907 else if ( strcmp ( word,
"name" ) == 0 ) {
5910 else if ( strcmp ( word,
"nbKeys" ) == 0 ) {
5913 else if ( strcmp ( word,
"step" ) == 0 ) {
5916 else if ( strcmp ( word,
"tension" ) == 0 ) {
5919 else if ( strcmp ( word,
"type" ) == 0 ) {
5924 printf (
"SPLINE: Bad data %s\n", word );
5932 else if ( strcmp (
level_name[level],
"taggedpoints" ) == 0 ) {
5934 if ( strcmp ( word,
"{" ) == 0 ) {
5936 else if ( strcmp ( word,
"}" ) == 0 ) {
5937 level = nlbrack - nrbrack;
5939 else if ( word[0] ==
'[' ) {
5941 else if ( strcmp ( word,
"tagged" ) == 0 ) {
5945 printf (
"TAGGEDPOINTS: Bad data %s\n", word );
5953 else if ( strcmp (
level_name[level],
"texture" ) == 0 ) {
5955 if ( strcmp ( word,
"{" ) == 0 ) {
5958 else if ( strcmp ( word,
"}" ) == 0 ) {
5959 level = nlbrack - nrbrack;
5961 else if ( word[0] ==
'[' ) {
5963 else if ( strcmp ( word,
"ambient" ) == 0 ) {
5965 else if ( strcmp ( word,
"anim" ) == 0 ) {
5967 else if ( strcmp ( word,
"blending" ) == 0 ) {
5969 else if ( strcmp ( word,
"diffuse" ) == 0 ) {
5971 else if ( strcmp ( word,
"effect" ) == 0 ) {
5973 else if ( strcmp ( word,
"glbname" ) == 0 ) {
5975 else if ( strcmp ( word,
"method" ) == 0 ) {
5977 else if ( strcmp ( word,
"name" ) == 0 ) {
5978 count = sscanf ( next,
"%s%n", word, &width );
5979 next = next + width;
5982 else if ( strcmp ( word,
"offset" ) == 0 ) {
5984 else if ( strcmp ( word,
"pixelinterp" ) == 0 ) {
5986 else if ( strcmp ( word,
"reflect" ) == 0 ) {
5988 else if ( strcmp ( word,
"reflmap" ) == 0 ) {
5990 else if ( strcmp ( word,
"repeat" ) == 0 ) {
5992 else if ( strcmp ( word,
"rotation" ) == 0 ) {
5994 else if ( strcmp ( word,
"roughness" ) == 0 ) {
5996 else if ( strcmp ( word,
"scaling" ) == 0 ) {
5998 else if ( strcmp ( word,
"specular" ) == 0 ) {
6000 else if ( strcmp ( word,
"transp" ) == 0 ) {
6002 else if ( strcmp ( word,
"txtsup_rot" ) == 0 ) {
6004 else if ( strcmp ( word,
"txtsup_scal" ) == 0 ) {
6006 else if ( strcmp ( word,
"txtsup_trans" ) == 0 ) {
6010 printf (
"TEXTURE: Bad data %s\n", word );
6017 else if ( strcmp (
level_name[level],
"vertices" ) == 0 ) {
6019 if ( strcmp ( word,
"{" ) == 0 ) {
6021 else if ( strcmp ( word,
"}" ) == 0 ) {
6022 level = nlbrack - nrbrack;
6024 else if ( word[0] ==
'[' ) {
6026 else if ( strcmp ( word,
"position" ) == 0 ) {
6028 count = sscanf ( next,
"%f%n", &x, &width );
6029 next = next + width;
6031 count = sscanf ( next,
"%f%n", &y, &width );
6032 next = next + width;
6034 count = sscanf ( next,
"%f%n", &z, &width );
6035 next = next + width;
6046 printf (
"VERTICES: Bad data %s\n", word );
6255 fprintf ( fileout,
"HRCH: Softimage 4D Creative Environment v3.00\n" );
6256 fprintf ( fileout,
"\n" );
6257 fprintf ( fileout,
"\n" );
6260 fprintf ( fileout,
"model\n" );
6261 fprintf ( fileout,
"{\n" );
6262 fprintf ( fileout,
" name \"%s\"\n",
object_name );
6263 fprintf ( fileout,
" scaling 1.000 1.000 1.000\n" );
6264 fprintf ( fileout,
" rotation 0.000 0.000 0.000\n" );
6265 fprintf ( fileout,
" translation 0.000 0.000 0.000\n" );
6270 fprintf ( fileout,
"\n" );
6271 fprintf ( fileout,
" mesh\n" );
6272 fprintf ( fileout,
" {\n" );
6273 fprintf ( fileout,
" flag ( PROCESS )\n" );
6274 fprintf ( fileout,
" discontinuity 60.000\n" );
6281 fprintf ( fileout,
"\n" );
6282 fprintf ( fileout,
" vertices %d\n",
cor3_num );
6283 fprintf ( fileout,
" {\n" );
6288 fprintf ( fileout,
" [%d] position %f %f %f\n", j,
cor3[0][j],
6292 fprintf ( fileout,
" }\n" );
6298 fprintf ( fileout,
"\n" );
6299 fprintf ( fileout,
" polygons %d\n",
face_num );
6300 fprintf ( fileout,
" {\n" );
6303 for ( iface = 0; iface <
face_num; iface++ ) {
6305 fprintf ( fileout,
" [%d] nodes %d\n", iface,
face_order[iface] );
6306 fprintf ( fileout,
" {\n" );
6309 for ( ivert = 0; ivert <
face_order[iface]; ivert++ ) {
6311 fprintf ( fileout,
" [%d] vertex %d\n", ivert,
face[ivert][iface] );
6312 fprintf ( fileout,
" normal %f %f %f\n",
6315 fprintf ( fileout,
" uvTexture %f %f\n",
6317 fprintf ( fileout,
" vertexColor 255 178 178 178\n" );
6320 fprintf ( fileout,
" }\n" );
6321 fprintf ( fileout,
" material %d\n",
face_material[iface] );
6324 fprintf ( fileout,
" }\n" );
6325 fprintf ( fileout,
" }\n" );
6370 npts = jhi + 1 - jlo;
6372 fprintf ( fileout,
"\n" );
6373 fprintf ( fileout,
" spline\n" );
6374 fprintf ( fileout,
" {\n" );
6375 fprintf ( fileout,
" name \"spl%d\"\n", nseg );
6376 fprintf ( fileout,
" type LINEAR\n" );
6377 fprintf ( fileout,
" nbKeys %d\n", npts );
6378 fprintf ( fileout,
" tension 0.000\n" );
6379 fprintf ( fileout,
" step 1\n" );
6380 fprintf ( fileout,
"\n" );
6383 fprintf ( fileout,
" controlpoints\n" );
6384 fprintf ( fileout,
" {\n" );
6387 for ( j = jlo; j <= jhi; j++ ) {
6390 fprintf ( fileout,
" [%d] position %f %f %f\n", jrel,
6395 fprintf ( fileout,
" }\n" );
6396 fprintf ( fileout,
" }\n" );
6405 fprintf ( fileout,
" material [%d]\n",
i );
6406 fprintf ( fileout,
" {\n" );
6408 fprintf ( fileout,
" type PHONG\n" );
6415 fprintf ( fileout,
" exponent 50.0\n" );
6416 fprintf ( fileout,
" reflectivity 0.0\n" );
6417 fprintf ( fileout,
" transparency %f\n", 1.0 -
material_rgba[3][
i] );
6418 fprintf ( fileout,
" refracIndex 1.0\n" );
6419 fprintf ( fileout,
" glow 0\n" );
6420 fprintf ( fileout,
" coc 0.0\n" );
6421 fprintf ( fileout,
" }\n" );
6431 fprintf ( fileout,
" texture [%d]\n",
i );
6432 fprintf ( fileout,
" {\n" );
6434 fprintf ( fileout,
" glbname \"t2d1\"\n" );
6435 fprintf ( fileout,
" anim STATIC\n" );
6436 fprintf ( fileout,
" method XY\n" );
6437 fprintf ( fileout,
" repeat 1 1\n" );
6438 fprintf ( fileout,
" scaling 1.000 1.000\n" );
6439 fprintf ( fileout,
" offset 0.000 0.000\n" );
6440 fprintf ( fileout,
" pixelInterp\n" );
6441 fprintf ( fileout,
" effect INTENSITY\n" );
6442 fprintf ( fileout,
" blending 1.000\n" );
6443 fprintf ( fileout,
" ambient 0.977\n" );
6444 fprintf ( fileout,
" diffuse 1.000\n" );
6445 fprintf ( fileout,
" specular 0.966\n" );
6446 fprintf ( fileout,
" reflect 0.000\n" );
6447 fprintf ( fileout,
" transp 0.000\n" );
6448 fprintf ( fileout,
" roughness 0.000\n" );
6449 fprintf ( fileout,
" reflMap 1.000\n" );
6450 fprintf ( fileout,
" rotation 0.000\n" );
6451 fprintf ( fileout,
" txtsup_rot 0.000 0.000 0.000\n" );
6452 fprintf ( fileout,
" txtsup_trans 0.000 0.000 0.000\n" );
6453 fprintf ( fileout,
" txtsup_scal 1.000 1.000 1.000\n" );
6454 fprintf ( fileout,
" }\n" );
6459 fprintf ( fileout,
"}\n" );
6465 printf (
"HRC_WRITE - Wrote %d text lines.\n",
text_num );
6499 printf (
"INIT_PROGRAM_DATA: Program data initialized.\n" );
6551 printf (
"Enter command (H for help)\n" );
6557 for ( next =
input; *next !=
'\0' && isspace(*next); next++ ) {
6562 if ( *next ==
'\0' ) {
6569 if ( *next ==
'<' && *(next+1) ==
'<' ) {
6576 if ( ierror ==
ERROR ) {
6578 printf (
"INTERACT - Fatal error!\n" );
6579 printf (
" DATA_READ failed to read input data.\n" );
6585 else if ( *next ==
'<' ) {
6594 if ( ierror ==
ERROR ) {
6596 printf (
"INTERACT - Fatal error!\n" );
6597 printf (
" DATA_READ failed to read input data.\n" );
6603 else if ( *next ==
'>' ) {
6610 if ( ierror ==
ERROR ) {
6612 printf (
"INTERACT - Fatal error!\n" );
6613 printf (
" OUTPUT_DATA failed to write output data.\n" );
6620 else if ( *next ==
'B' || *next ==
'b' ) {
6624 printf (
"Byte_swapping reset to FALSE.\n" );
6628 printf (
"Byte_swapping reset to TRUE.\n" );
6635 else if ( *next ==
'D' || *next ==
'd' ) {
6638 printf (
"Debug reset to FALSE.\n" );
6642 printf (
"Debug reset to TRUE.\n" );
6648 else if ( *next ==
'f' || *next ==
'F' ) {
6650 printf (
" Enter a face index between 0 and %d:",
face_num-1 );
6651 scanf (
"%d", &iface );
6657 else if ( *next ==
'h' || *next ==
'H' ) {
6663 else if ( *next ==
'i' || *next ==
'I') {
6670 else if ( *next ==
'l' || *next ==
'L') {
6675 printf (
"INTERACT - Note:\n" );
6676 printf (
" Face information will be converted\n" );
6677 printf (
" to line information.\n" );
6684 printf (
"INTERACT - Note:\n" );
6685 printf (
" Some face information was lost.\n" );
6686 printf (
" The maximum number of lines is %d,\n",
LINES_MAX );
6687 printf (
" but we would need at least %d.\n",
line_num );
6698 printf (
"INTERACT - Note:\n" );
6699 printf (
" There were no faces to convert.\n" );
6707 else if ( *next ==
'n' || *next ==
'N') {
6709 for ( iface = 0; iface <
face_num; iface++ ) {
6710 for (
i = 0;
i < 3;
i++ ) {
6715 for ( iface = 0; iface <
face_num; iface++ ) {
6716 for ( ivert = 0; ivert <
face_order[iface]; ivert++ ) {
6717 for (
i = 0;
i < 3;
i++ ) {
6732 else if ( *next ==
'p' || *next ==
'P' ) {
6735 printf (
"INTERACT - SET LINE PRUNING OPTION.\n" );
6737 printf (
" LINE_PRUNE = 0 means no line pruning.\n" );
6738 printf (
" nonzero means line pruning.\n" );
6740 printf (
" Current value is LINE_PRUNE = %d.\n",
line_prune );
6742 printf (
" Enter new value for LINE_PRUNE.\n" );
6745 printf (
" ??? Error trying to read input.\n" );
6749 printf (
" New value is LINE_PRUNE = %d.\n",
line_prune );
6755 else if ( *next ==
'q' || *next ==
'Q' ) {
6757 printf (
"INTERACT - Normal end of execution.\n" );
6763 else if ( *next ==
'r' || *next ==
'R' ) {
6765 for ( icor3 = 0; icor3 <
cor3_num; icor3++ ) {
6766 for (
i = 0;
i < 3;
i++ ) {
6771 for ( iface = 0; iface <
face_num; iface++ ) {
6772 for (
i = 0;
i < 3;
i++ ) {
6777 for ( iface = 0; iface <
face_num; iface++ ) {
6778 for ( ivert = 0; ivert <
face_order[iface]; ivert++ ) {
6779 for (
i = 0;
i < 3;
i++ ) {
6786 printf (
"INTERACT - Note:\n" );
6787 printf (
" Reversed node, face and vertex normals.\n" );
6792 else if ( *next ==
's' || *next ==
'S' ) {
6798 else if ( *next ==
't' || *next ==
'T' ) {
6801 printf (
"For now, we only offer point scaling.\n" );
6802 printf (
"Enter X, Y, Z scale factors:\n" );
6804 scanf (
"%f %f %f", &x, &y, &z );
6812 for ( iface = 0; iface <
face_num; iface++ ) {
6813 for (
i = 0;
i < 3;
i++ ) {
6818 for ( iface = 0; iface <
face_num; iface++ ) {
6819 for ( ivert = 0; ivert <
face_order[iface]; ivert++ ) {
6820 for (
i = 0;
i < 3;
i++ ) {
6835 else if ( *next ==
'u' || *next ==
'U' ) {
6840 else if ( *next ==
'v' || *next ==
'V' ) {
6845 else if ( *next ==
'w' || *next ==
'W' ) {
6849 for ( iface = 0; iface <
face_num; iface++ ) {
6853 for ( ivert = 0; ivert < m/2; ivert++ ) {
6855 jvert = m - ivert - 1;
6857 itemp =
face[ivert][iface];
6858 face[ivert][iface] =
face[jvert][iface];
6859 face[jvert][iface] = itemp;
6865 for (
i = 0;
i < 3;
i++ ) {
6874 printf (
"INTERACT - Note:\n" );
6875 printf (
" Reversed face node ordering.\n" );
6883 printf (
"INTERACT: Warning!\n" );
6884 printf (
" Your command was not recognized.\n" );
6888 printf (
"Enter command (H for help)\n" );
7094 int normal_num_temp;
7095 int text_numure_temp;
7123 normal_num_temp = 0;
7124 text_numure_temp = 0;
7127 strcpy ( word,
" " );
7128 strcpy ( wordm1,
" " );
7146 while (
input[
i] !=
'\0' ) {
7156 while (
input[
i] !=
'\0' ) {
7168 if ( result ==
ERROR ) {
7181 strcpy ( wordm1, word );
7182 strcpy ( word,
" " );
7184 count = sscanf ( next,
"%s%n", word, &width );
7185 next = next + width;
7194 strcpy ( word1, word );
7201 if (
leqi ( word1,
"#Inventor" ) !=
TRUE ) {
7203 printf (
"IV_READ - Fatal error!\n" );
7204 printf (
" The input file has a bad header.\n" );
7216 if ( word[1] ==
'#' ) {
7224 if ( strcmp ( word,
"{" ) == 0 || strcmp ( word,
"[" ) == 0 ) {
7225 nlbrack = nlbrack + 1;
7226 level = nlbrack - nrbrack;
7229 printf (
"Begin level: %s\n", wordm1 );
7232 else if ( strcmp ( word,
"}" ) == 0 || strcmp ( word,
"]" ) == 0 ) {
7233 nrbrack = nrbrack + 1;
7235 if ( nlbrack < nrbrack ) {
7237 printf (
"IV_READ - Fatal error!\n" );
7238 printf (
" Extraneous right bracket on line %d.\n",
text_num );
7239 printf (
" Currently processing field %s\n.",
level_name[level] );
7248 if ( strcmp ( word,
"{" ) == 0 ) {
7250 else if ( strcmp ( word,
"}" ) == 0 ) {
7251 level = nlbrack - nrbrack;
7253 else if (
leqi ( word,
"RGB" ) ==
TRUE ) {
7257 printf (
"Bad data %s\n", word );
7265 if ( strcmp ( word,
"{" ) == 0 ) {
7267 else if ( strcmp ( word,
"}" ) == 0 ) {
7268 level = nlbrack - nrbrack;
7270 else if (
leqi ( word,
"POINT" ) ==
TRUE ) {
7274 printf (
"COORDINATE3: Bad data %s\n", word );
7282 if ( strcmp ( word,
"{" ) == 0 ) {
7284 else if ( strcmp ( word,
"}" ) == 0 ) {
7285 level = nlbrack - nrbrack;
7287 else if (
leqi ( word,
"POINT" ) ==
TRUE ) {
7291 printf (
"COORDINATE4: Bad data %s\n", word );
7299 if ( strcmp ( word,
"[" ) == 0 ) {
7302 else if ( strcmp ( word,
"]" ) == 0 ) {
7303 level = nlbrack - nrbrack;
7310 count = sscanf ( word,
"%d%n", &jval, &width );
7320 jval = jval + cor3_num_old;
7338 count = sscanf ( word,
"%d%n", &jval, &width );
7376 count = sscanf ( word,
"%d%n", &jval, &width );
7387 iz = jval + cor3_num_old;
7395 else if ( ivert == 1 ) {
7400 else if ( ivert == 2 ) {
7410 if ( ( ivert % 2 ) == 0 ) {
7428 if ( face_num < FACE_MAX && ivert > 2 ) {
7429 for (
i = 0;
i < 3;
i++ ) {
7442 if ( strcmp ( word,
"{" ) == 0 ) {
7444 else if ( strcmp ( word,
"}" ) == 0 ) {
7445 level = nlbrack - nrbrack;
7447 else if (
leqi ( word,
"COORDINDEX" ) ==
TRUE ) {
7450 else if (
leqi ( word,
"MATERIALINDEX" ) ==
TRUE ) {
7452 else if (
leqi ( word,
"NORMALINDEX" ) ==
TRUE ) {
7454 else if (
leqi ( word,
"TEXTURECOORDINDEX" ) ==
TRUE ) {
7462 printf (
"Bad data %s\n", word );
7470 if ( strcmp ( word,
"{" ) == 0 ) {
7472 else if ( strcmp ( word,
"}" ) == 0 ) {
7473 level = nlbrack - nrbrack;
7475 else if (
leqi ( word,
"COORDINDEX" ) ==
TRUE ) {
7477 else if (
leqi ( word,
"MATERIALINDEX" ) ==
TRUE ) {
7481 printf (
"Bad data %s\n", word );
7489 if ( strcmp ( word,
"{" ) == 0 ) {
7491 else if ( strcmp ( word,
"}" ) == 0 ) {
7492 level = nlbrack - nrbrack;
7494 else if (
leqi ( word,
"NUMUCONTROLPOINTS") ==
TRUE ) {
7496 count = sscanf ( word,
"%d%n", &jval, &width );
7501 printf (
"NU = %d\n", nu );
7507 printf (
"Bad data %s\n", word );
7510 else if (
leqi ( word,
"NUMVCONTROLPOINTS" ) ==
TRUE ) {
7512 count = sscanf ( word,
"%d%n", &jval, &width );
7517 printf (
"NV = %d\n", nv );
7525 else if (
leqi ( word,
"COORDINDEX" ) ==
TRUE ) {
7527 else if (
leqi ( word,
"UKNOTVECTOR" ) ==
TRUE ) {
7529 else if (
leqi ( word,
"VKNOTVECTOR" ) ==
TRUE ) {
7533 printf (
"Bad data %s\n", word );
7541 if ( strcmp ( word,
"{" ) == 0 ) {
7543 else if ( strcmp ( word,
"}" ) == 0 ) {
7544 level = nlbrack - nrbrack;
7546 else if (
leqi ( word,
"VERTEXPROPERTY" ) ==
TRUE ) {
7547 count = sscanf ( next,
"%s%n", word, &width );
7548 next = next + width;
7550 else if (
leqi ( word,
"COORDINDEX" ) ==
TRUE ) {
7553 else if (
leqi ( word,
"NORMALINDEX" ) ==
TRUE ) {
7554 count = sscanf ( next,
"%s%n", word, &width );
7555 next = next + width;
7559 printf (
"Bad data %s\n", word );
7567 if ( strcmp ( word,
"{" ) == 0 ) {
7569 else if ( strcmp ( word,
"}" ) == 0 ) {
7570 level = nlbrack - nrbrack;
7572 else if (
leqi ( word,
"STRING" ) ==
TRUE ) {
7574 else if ( strcmp ( word,
"\"" ) == 0 ) {
7585 if ( strcmp ( word,
"{" ) == 0 ) {
7587 else if ( strcmp ( word,
"}" ) == 0 ) {
7588 level = nlbrack - nrbrack;
7590 else if (
leqi ( word,
"model" ) ==
TRUE ) {
7601 if ( strcmp ( word,
"{" ) == 0 ) {
7603 else if ( strcmp ( word,
"}" ) == 0 ) {
7604 level = nlbrack - nrbrack;
7606 else if (
leqi ( word,
"AMBIENTCOLOR" ) ==
TRUE ) {
7608 else if (
leqi ( word,
"EMISSIVECOLOR" ) ==
TRUE ) {
7610 else if (
leqi ( word,
"DIFFUSECOLOR" ) ==
TRUE ) {
7612 else if (
leqi ( word,
"SHININESS" ) ==
TRUE ) {
7614 else if (
leqi ( word,
"SPECULARCOLOR" ) ==
TRUE ) {
7616 else if (
leqi ( word,
"TRANSPARENCY" ) ==
TRUE ) {
7627 if ( strcmp ( word,
"{" ) == 0 ) {
7629 else if ( strcmp ( word,
"}" ) == 0 ) {
7630 level = nlbrack - nrbrack;
7632 else if (
leqi ( word,
"VALUE" ) ==
TRUE ) {
7634 next = next + width;
7637 count = sscanf ( next,
"%f%n", &rval, &width );
7638 next = next + width;
7644 printf (
"Bad data %s\n", word );
7653 if ( strcmp ( word,
"[" ) == 0 ) {
7656 else if ( strcmp ( word,
"]" ) == 0 ) {
7657 level = nlbrack - nrbrack;
7664 count = sscanf ( word,
"%d%n", &jval, &width );
7670 face_num2 = face_num2 + 1;
7676 jval = jval + cor3_num_old;
7685 printf (
"Bad data %s\n", word );
7693 count = sscanf ( word,
"%d%n", &jval, &width );
7699 jval = jval + cor3_num_old;
7702 line_num2 = line_num2 + 1;
7707 printf (
"Bad data %s\n", word );
7711 count = sscanf ( word,
"%d%n", &jval, &width );
7717 printf (
"Bad data %s\n", word );
7726 if ( strcmp ( word,
"{" ) == 0 ) {
7728 else if ( strcmp ( word,
"}" ) == 0 ) {
7729 level = nlbrack - nrbrack;
7731 else if (
leqi ( word,
"MATRIX" ) ==
TRUE ) {
7737 count = sscanf ( word,
"%f%n", &rval, &width );
7766 if ( strcmp ( word,
"[" ) == 0 ) {
7769 else if ( strcmp ( word,
"]" ) == 0 ) {
7770 level = nlbrack - nrbrack;
7774 count = sscanf ( word,
"%f%n", &rval, &width );
7785 inormface = inormface + 1;
7795 if ( strcmp ( word,
"{" ) == 0 ) {
7798 else if ( strcmp ( word,
"}" ) == 0 ) {
7799 level = nlbrack - nrbrack;
7801 else if (
leqi ( word,
"VECTOR" ) ==
TRUE ) {
7805 count = sscanf ( word,
"%f%n", &rval, &width );
7823 printf (
"Bad data %s\n", word );
7834 if ( strcmp ( word,
"{" ) == 0 ) {
7836 else if ( strcmp ( word,
"}" ) == 0 ) {
7837 level = nlbrack - nrbrack;
7839 else if (
leqi ( word,
"VALUE" ) ==
TRUE ) {
7841 next = next + width;
7844 count = sscanf ( word,
"%f%n", &rval, &width );
7850 printf (
"Bad data %s\n", word );
7862 count = sscanf ( word,
"%d%n", &jval, &width );
7866 else if ( strcmp ( word,
"[" ) == 0 ) {
7868 else if ( strcmp ( word,
"]" ) == 0 ) {
7876 if ( strcmp ( word,
"[" ) == 0 ) {
7879 else if ( strcmp ( word,
"]" ) == 0 ) {
7880 level = nlbrack - nrbrack;
7884 count = sscanf ( word,
"%d%n", &jval, &width );
7889 iface_num = iface_num + 1;
7893 for (
i = 0;
i < 3;
i++ ){
7902 printf (
"Bad data %s\n", word );
7914 if ( strcmp ( word,
"[" ) == 0 ) {
7918 else if ( strcmp ( word,
"]" ) == 0 ) {
7919 level = nlbrack - nrbrack;
7923 count = sscanf ( word,
"%f%n", &rval, &width );
7959 if ( strcmp ( word,
"[" ) == 0 ) {
7961 text_numure_temp = 0;
7963 else if ( strcmp ( word,
"]" ) == 0 ) {
7964 level = nlbrack - nrbrack;
7968 count = sscanf ( word,
"%f%n", &rval, &width );
7977 text_numure_temp = text_numure_temp + 1;
7981 printf (
"TextureCoordinate2 { Point [: Bad data\n" );
7997 if ( strcmp ( word,
"[" ) == 0 ) {
8000 else if ( strcmp ( word,
"]" ) == 0 ) {
8001 level = nlbrack - nrbrack;
8005 count = sscanf ( word,
"%f%n", &rval, &width );
8010 icolor = icolor + 1;
8012 if ( icolor == 3 ) {
8019 printf (
"Bad data %s\n", word );
8028 printf (
"HALSBAND DES TODES!\n" );
8030 if ( strcmp ( word,
"[" ) == 0 ) {
8034 else if ( strcmp ( word,
"]" ) == 0 ) {
8035 level = nlbrack - nrbrack;
8039 count = sscanf ( word,
"%f%n", &rval, &width );
8047 icolor = icolor + 1;
8048 if ( icolor == 3 ) {
8054 icface = icface + 1;
8061 printf (
"Bad data %s\n", word );
8072 if ( strcmp ( word,
"{" ) == 0 ) {
8074 else if ( strcmp ( word,
"}" ) == 0 ) {
8075 level = nlbrack - nrbrack;
8086 if ( strcmp ( word,
"{" ) == 0 ) {
8088 else if ( strcmp ( word,
"}" ) == 0 ) {
8089 level = nlbrack - nrbrack;
8091 else if (
leqi ( word,
"CREASEANGLE" ) ==
TRUE ) {
8093 count = sscanf ( next,
"%f%n", &rval, &width );
8094 next = next + width;
8098 printf (
"Bad data %s\n", word );
8101 else if (
leqi ( word,
"FACETYPE" ) ==
TRUE ) {
8102 count = sscanf ( next,
"%s%n", word, &width );
8103 next = next + width;
8105 else if (
leqi ( word,
"SHAPETYPE" ) ==
TRUE ) {
8106 count = sscanf ( next,
"%s%n", word, &width );
8107 next = next + width;
8109 else if (
leqi ( word,
"VERTEXORDERING" ) ==
TRUE ) {
8110 count = sscanf ( next,
"%s%n", word, &width );
8111 next = next + width;
8115 printf (
"Bad data %s\n", word );
8123 if ( strcmp ( word,
"{" ) == 0 ) {
8125 else if ( strcmp ( word,
"}" ) == 0 ) {
8126 level = nlbrack - nrbrack;
8129 else if (
leqi ( word,
"BLENDCOLOR" ) ==
TRUE ) {
8134 else if (
leqi ( word,
"FILENAME" ) ==
TRUE ) {
8136 count = sscanf ( next,
"%s%n", word, &width );
8137 next = next + width;
8150 }
while ( c !=
'\0' );
8153 else if (
leqi ( word,
"IMAGE" ) ==
TRUE ) {
8155 else if (
leqi ( word,
"MODEL" ) ==
TRUE ) {
8156 count = sscanf ( next,
"%s%n", word, &width );
8157 next = next + width;
8159 else if (
leqi ( word,
"WRAPS" ) ==
TRUE ) {
8160 count = sscanf ( next,
"%s%n", word, &width );
8161 next = next + width;
8163 else if (
leqi ( word,
"WRAPT" ) ==
TRUE ) {
8164 count = sscanf ( next,
"%s%n", word, &width );
8165 next = next + width;
8175 if ( strcmp ( word,
"{" ) == 0 ) {
8177 else if ( strcmp ( word,
"}" ) == 0 ) {
8178 level = nlbrack - nrbrack;
8180 else if (
leqi ( word,
"POINT" ) ==
TRUE ) {
8184 printf (
"TEXTURECOORDINATE2: Bad data %s\n", word );
8192 if ( strcmp ( word,
"{" ) == 0 ) {
8194 else if ( strcmp ( word,
"}" ) == 0 ) {
8195 level = nlbrack - nrbrack;
8197 else if (
leqi ( word,
"VALUE" ) ==
TRUE ) {
8199 next = next + width;
8203 printf (
"Bad data %s\n", word );
8211 if ( strcmp ( word,
"[" ) == 0 ) {
8215 else if ( strcmp ( word,
"]" ) == 0 ) {
8216 level = nlbrack - nrbrack;
8220 count = sscanf ( word,
"%d%n", &jval, &width );
8224 if ( jval == - 1 ) {
8238 iface_num = iface_num + 1;
8245 printf (
"Bad data %s\n", word );
8255 if ( strcmp ( word,
"[" ) == 0 ) {
8258 else if ( strcmp ( word,
"]" ) == 0 ) {
8259 level = nlbrack - nrbrack;
8263 count = sscanf ( word,
"%d%n", &jval, &width );
8270 if ( strcmp ( word,
"[" ) == 0 ) {
8272 else if ( strcmp ( word,
"]" ) == 0 ) {
8273 level = nlbrack - nrbrack;
8280 count = sscanf ( word,
"%f%n", &rval, &width );
8289 normal_num_temp = normal_num_temp + 1;
8295 printf (
"NORMAL VECTOR: bad data %s\n", word );
8306 if ( strcmp ( word,
"[" ) == 0 ) {
8310 else if ( strcmp ( word,
"]" ) == 0 ) {
8311 level = nlbrack - nrbrack;
8314 count = sscanf ( word,
"%f%n", &rval, &width );
8330 printf (
"Bad data %s\n", word );
8340 if ( strcmp ( word,
"{" ) == 0 ) {
8342 else if ( strcmp ( word,
"}" ) == 0 ) {
8343 level = nlbrack - nrbrack;
8345 else if (
leqi ( word,
"VERTEX" ) ==
TRUE ) {
8347 else if (
leqi ( word,
"NORMAL" ) ==
TRUE ) {
8350 else if (
leqi ( word,
"MATERIALBINDING" ) ==
TRUE ) {
8351 count = sscanf ( next,
"%s%n", word, &width );
8352 next = next + width;
8354 else if (
leqi ( word,
"NORMALBINDING" ) ==
TRUE ) {
8355 count = sscanf ( next,
"%s%n", word, &width );
8356 next = next + width;
8360 printf (
"Bad data %s\n", word );
8368 if ( strcmp ( word,
"[" ) == 0 ) {
8371 else if ( strcmp ( word,
"]" ) == 0 ) {
8372 level = nlbrack - nrbrack;
8376 count = sscanf ( word,
"%d%n", &jval, &width );
8424 fprintf ( fileout,
"#Inventor V2.0 ascii\n" );
8425 fprintf ( fileout,
"\n" );
8426 fprintf ( fileout,
"Separator {\n" );
8427 fprintf ( fileout,
" Info {\n" );
8428 fprintf ( fileout,
" string \"%s generated by IVCON.\"\n",
fileout_name );
8429 fprintf ( fileout,
" string \"Original data in file %s.\"\n",
filein_name );
8430 fprintf ( fileout,
" }\n" );
8431 fprintf ( fileout,
" Separator {\n" );
8450 fprintf ( fileout,
" LightModel {\n" );
8451 fprintf ( fileout,
" model PHONG\n" );
8452 fprintf ( fileout,
" }\n" );
8457 fprintf ( fileout,
" MatrixTransform { matrix\n" );
8466 fprintf ( fileout,
" }\n" );
8471 fprintf ( fileout,
" Material {\n" );
8472 fprintf ( fileout,
" ambientColor 0.2 0.2 0.2\n" );
8473 fprintf ( fileout,
" diffuseColor 0.8 0.8 0.8\n" );
8474 fprintf ( fileout,
" emissiveColor 0.0 0.0 0.0\n" );
8475 fprintf ( fileout,
" specularColor 0.0 0.0 0.0\n" );
8476 fprintf ( fileout,
" shininess 0.2\n" );
8477 fprintf ( fileout,
" transparency 0.0\n" );
8478 fprintf ( fileout,
" }\n" );
8483 fprintf ( fileout,
" MaterialBinding {\n" );
8484 fprintf ( fileout,
" value PER_VERTEX_INDEXED\n" );
8485 fprintf ( fileout,
" }\n" );
8498 fprintf ( fileout,
" NormalBinding {\n" );
8499 fprintf ( fileout,
" value PER_VERTEX_INDEXED\n" );
8500 fprintf ( fileout,
" }\n" );
8508 fprintf ( fileout,
" Texture2 {\n" );
8509 fprintf ( fileout,
" filename \"%s\"\n",
texture_name[0] );
8510 fprintf ( fileout,
" wrapS REPEAT\n" );
8511 fprintf ( fileout,
" wrapT REPEAT\n" );
8512 fprintf ( fileout,
" model MODULATE\n" );
8513 fprintf ( fileout,
" blendColor 0.0 0.0 0.0\n" );
8514 fprintf ( fileout,
" }\n" );
8520 fprintf ( fileout,
" TextureCoordinateBinding {\n" );
8521 fprintf ( fileout,
" value PER_VERTEX_INDEXED\n" );
8522 fprintf ( fileout,
" }\n" );
8527 fprintf ( fileout,
" ShapeHints {\n" );
8528 fprintf ( fileout,
" vertexOrdering COUNTERCLOCKWISE\n" );
8529 fprintf ( fileout,
" shapeType UNKNOWN_SHAPE_TYPE\n" );
8530 fprintf ( fileout,
" faceType CONVEX\n" );
8531 fprintf ( fileout,
" creaseAngle 6.28319\n" );
8532 fprintf ( fileout,
" }\n" );
8537 fprintf ( fileout,
" Coordinate3 {\n" );
8538 fprintf ( fileout,
" point [\n" );
8542 fprintf ( fileout,
" %f %f %f,\n",
cor3[0][j],
cor3[1][j],
cor3[2][j] );
8545 fprintf ( fileout,
" ]\n" );
8546 fprintf ( fileout,
" }\n" );
8551 fprintf ( fileout,
" TextureCoordinate2 {\n" );
8552 fprintf ( fileout,
" point [\n" );
8555 for ( iface = 0; iface <
face_num; iface++ ) {
8556 for ( ivert = 0; ivert <
face_order[iface]; ivert++ ) {
8557 fprintf ( fileout,
" %f %f,\n",
vertex_tex_uv[0][ivert][iface],
8562 fprintf ( fileout,
" ]\n" );
8563 fprintf ( fileout,
" }\n" );
8570 fprintf ( fileout,
" BaseColor {\n" );
8571 fprintf ( fileout,
" rgb [\n" );
8580 fprintf ( fileout,
" ]\n" );
8581 fprintf ( fileout,
" }\n" );
8590 fprintf ( fileout,
" Normal { \n" );
8591 fprintf ( fileout,
" vector [\n" );
8594 for ( icor3 = 0; icor3 <
cor3_num; icor3++ ) {
8595 fprintf ( fileout,
" %f %f %f,\n",
8602 fprintf ( fileout,
" ]\n" );
8603 fprintf ( fileout,
" }\n" );
8611 fprintf ( fileout,
" IndexedLineSet {\n" );
8615 fprintf ( fileout,
" coordIndex [\n" );
8622 if ( length == 0 ) {
8623 fprintf ( fileout,
" " );
8626 fprintf ( fileout,
" %d,",
line_dex[j] );
8627 length = length + 1;
8630 fprintf ( fileout,
"\n" );
8636 fprintf ( fileout,
" ]\n" );
8641 fprintf ( fileout,
" materialIndex [\n" );
8648 if ( length == 0 ) {
8649 fprintf ( fileout,
" " );
8653 length = length + 1;
8656 fprintf ( fileout,
"\n" );
8662 fprintf ( fileout,
" ]\n" );
8663 fprintf ( fileout,
" }\n" );
8671 fprintf ( fileout,
" IndexedFaceSet {\n" );
8672 fprintf ( fileout,
" coordIndex [\n" );
8675 for ( iface = 0; iface <
face_num; iface++ ) {
8677 fprintf ( fileout,
" " );
8679 for ( ivert = 0; ivert <
face_order[iface]; ivert++ ) {
8680 fprintf ( fileout,
" %d,",
face[ivert][iface] );
8682 fprintf ( fileout,
" -1,\n" );
8686 fprintf ( fileout,
" ]\n" );
8691 fprintf ( fileout,
" normalIndex [\n" );
8694 for ( iface = 0; iface <
face_num; iface++ ) {
8696 fprintf ( fileout,
" " );
8698 for ( ivert = 0; ivert <
face_order[iface]; ivert++ ) {
8699 fprintf ( fileout,
" %d,",
face[ivert][iface] );
8701 fprintf ( fileout,
" -1,\n" );
8704 fprintf ( fileout,
" ]\n" );
8709 fprintf ( fileout,
" materialIndex [\n" );
8712 for ( iface = 0; iface <
face_num; iface++ ) {
8714 fprintf ( fileout,
" " );
8716 for ( ivert = 0; ivert <
face_order[iface]; ivert++ ) {
8719 fprintf ( fileout,
" -1,\n" );
8723 fprintf ( fileout,
" ]\n" );
8728 fprintf ( fileout,
" textureCoordIndex [\n" );
8733 for ( iface = 0; iface <
face_num; iface++ ) {
8735 fprintf ( fileout,
" " );
8737 for ( ivert = 0; ivert <
face_order[iface]; ivert++ ) {
8738 fprintf ( fileout,
" %d,", itemp );
8741 fprintf ( fileout,
" -1,\n" );
8745 fprintf ( fileout,
" ]\n" );
8747 fprintf ( fileout,
" }\n" );
8753 fprintf ( fileout,
" }\n" );
8754 fprintf ( fileout,
"}\n" );
8760 printf (
"IV_WRITE - Wrote %d text lines;\n",
text_num );
8794 for (
i = 1;
i < n;
i++ ) {
8805 int leqi (
char* string1,
char* string2 )
8828 nchar1 = strlen ( string1 );
8829 nchar2 = strlen ( string2 );
8831 if ( nchar1 < nchar2 ) {
8840 for (
i = 0;
i < nchar;
i++ ) {
8842 if ( toupper ( string1[
i] ) != toupper ( string2[
i] ) ) {
8850 if ( nchar1 > nchar ) {
8851 for (
i = nchar;
i < nchar1;
i++ ) {
8852 if ( string1[
i] !=
' ' ) {
8857 else if ( nchar2 > nchar ) {
8858 for (
i = nchar;
i < nchar2;
i++ ) {
8859 if ( string2[
i] !=
' ' ) {
8892 y.ychar[3] = fgetc ( filein );
8893 y.ychar[2] = fgetc ( filein );
8894 y.ychar[1] = fgetc ( filein );
8895 y.ychar[0] = fgetc ( filein );
8898 y.ychar[0] = fgetc ( filein );
8899 y.ychar[1] = fgetc ( filein );
8900 y.ychar[2] = fgetc ( filein );
8901 y.ychar[3] = fgetc ( filein );
8934 fputc ( y.ychar[3], fileout );
8935 fputc ( y.ychar[2], fileout );
8936 fputc ( y.ychar[1], fileout );
8937 fputc ( y.ychar[0], fileout );
8940 fputc ( y.ychar[0], fileout );
8941 fputc ( y.ychar[1], fileout );
8942 fputc ( y.ychar[2], fileout );
8943 fputc ( y.ychar[3], fileout );
8969 printf (
"Recent changes:\n" );
8971 printf (
" 04 July 2000\n" );
8972 printf (
" Added preliminary XGL_WRITE.\n" );
8973 printf (
" 26 September 1999\n" );
8974 printf (
" After ASE_READ, call NODE_TO_VERTEX_MAT and VERTEX_TO_FACE_MATERIAL.\n" );
8975 printf (
" 27 July 1999\n" );
8976 printf (
" Corrected TMAT_ROT_VECTOR.\n" );
8977 printf (
" 17 July 1999\n" );
8978 printf (
" Added null edge and face deletion.\n" );
8979 printf (
" Corrected a string problem in SMF_READ.\n" );
8980 printf (
" 03 July 1999\n" );
8981 printf (
" Fixed a problem with BINDING variables in SMF_READ.\n" );
8982 printf (
" 02 July 1999\n" );
8983 printf (
" Added limited texture support in 3DS/IV.\n" );
8984 printf (
" 26 June 1999\n" );
8985 printf (
" BYU_READ added.\n" );
8986 printf (
" 25 June 1999\n" );
8987 printf (
" BYU_WRITE added.\n" );
8988 printf (
" 22 June 1999\n" );
8989 printf (
" TRIB_READ added.\n" );
8990 printf (
" 16 June 1999\n" );
8991 printf (
" TRIB_WRITE Greg Hood binary triangle output routine added.\n" );
8992 printf (
" 10 June 1999\n" );
8993 printf (
" TRIA_WRITE Greg Hood ASCII triangle output routine added.\n" );
8994 printf (
" 09 June 1999\n" );
8995 printf (
" TEC_WRITE TECPLOT output routine added.\n" );
8996 printf (
" IV_READ and IV_WRITE use TRANSFORM_MATRIX now.\n" );
8997 printf (
" 26 May 1999\n" );
8998 printf (
" LINE_PRUNE option added for VLA_WRITE.\n" );
8999 printf (
" 24 May 1999\n" );
9000 printf (
" Added << command to append new graphics data to old.\n" );
9001 printf (
" Stuck in first draft STLB_READ/STLB_WRITE routines.\n" );
9002 printf (
" STLA_WRITE and STLB_WRITE automatically decompose \n" );
9003 printf (
" non-triangular faces before writing.\n" );
9004 printf (
" 23 May 1999\n" );
9005 printf (
" Stuck in first draft WRL_WRITE routine.\n" );
9006 printf (
" 22 May 1999\n" );
9007 printf (
" Faces converted to lines before calling VLA_WRITE.\n" );
9008 printf (
" Added UCD_WRITE.\n" );
9009 printf (
" Added MATERIAL/PATCH/TAGGEDPOINTS fields in HRC_READ.\n" );
9010 printf (
" 17 May 1999\n" );
9011 printf (
" Updated SMF_WRITE, SMF_READ to match code in IVREAD.\n" );
9012 printf (
" Added transformation matrix routines.\n" );
9013 printf (
" 16 May 1999\n" );
9014 printf (
" Zik Saleeba improved DXF support to handle polygons.\n" );
9015 printf (
" 15 April 1999\n" );
9016 printf (
" Zik Saleeba added Golgotha GMOD file format support.\n" );
9017 printf (
" 03 December 1998\n" );
9018 printf (
" Set up simple hooks in TDS_READ_MATERIAL_SECTION.\n" );
9019 printf (
" 02 December 1998\n" );
9020 printf (
" Set up simple hooks for texture map names.\n" );
9021 printf (
" 19 November 1998\n" );
9022 printf (
" IV_WRITE uses PER_VERTEX normal binding.\n" );
9023 printf (
" 18 November 1998\n" );
9024 printf (
" Added node normals.\n" );
9025 printf (
" Finally added the -RN option.\n" );
9026 printf (
" 17 November 1998\n" );
9027 printf (
" Added face node ordering reversal option.\n" );
9028 printf (
" 20 October 1998\n" );
9029 printf (
" Added DATA_REPORT.\n" );
9030 printf (
" 19 October 1998\n" );
9031 printf (
" SMF_READ and SMF_WRITE added.\n" );
9032 printf (
" 16 October 1998\n" );
9033 printf (
" Fixing a bug in IV_READ that chokes on ]} and other\n" );
9034 printf (
" cases where brackets aren't properly spaced.\n" );
9035 printf (
" 11 October 1998\n" );
9036 printf (
" Added face subset selection option S.\n" );
9037 printf (
" 09 October 1998\n" );
9038 printf (
" Reworking normal vector treatments.\n" );
9039 printf (
" Synchronizing IVREAD and IVCON.\n" );
9040 printf (
" POV_WRITE added.\n" );
9041 printf (
" 02 October 1998\n" );
9042 printf (
" IVCON reproduces BOX.3DS and CONE.3DS exactly.\n" );
9043 printf (
" 30 September 1998\n" );
9044 printf (
" IVCON compiled on the PC.\n" );
9045 printf (
" Interactive BYTE_SWAP option added for binary files.\n" );
9046 printf (
" 25 September 1998\n" );
9047 printf (
" OBJECT_NAME made available to store object name.\n" );
9048 printf (
" 23 September 1998\n" );
9049 printf (
" 3DS binary files can be written.\n" );
9050 printf (
" 15 September 1998\n" );
9051 printf (
" 3DS binary files can be read.\n" );
9052 printf (
" 01 September 1998\n" );
9053 printf (
" COR3_RANGE, FACE_NORMAL_AVE added.\n" );
9054 printf (
" Major modifications to normal vectors.\n" );
9055 printf (
" 24 August 1998\n" );
9056 printf (
" HRC_READ added.\n" );
9057 printf (
" 21 August 1998\n" );
9058 printf (
" TXT_WRITE improved.\n" );
9059 printf (
" 20 August 1998\n" );
9060 printf (
" HRC_WRITE can output lines as linear splines.\n" );
9061 printf (
" 19 August 1998\n" );
9062 printf (
" Automatic normal computation for OBJ files.\n" );
9063 printf (
" Added normal vector computation.\n" );
9064 printf (
" HRC_WRITE is working.\n" );
9065 printf (
" 18 August 1998\n" );
9066 printf (
" IV_READ/IV_WRITE handle BASECOLOR RGB properly now.\n" );
9067 printf (
" Improved treatment of face materials and normals.\n" );
9068 printf (
" 17 August 1998\n" );
9069 printf (
" ORDER_MAX increased to 35.\n" );
9070 printf (
" FACE_PRINT routine added.\n" );
9071 printf (
" INIT_DATA routine added.\n" );
9072 printf (
" 14 August 1998\n" );
9073 printf (
" IV_READ is working.\n" );
9074 printf (
" 13 August 1998\n" );
9075 printf (
" ASE_WRITE is working.\n" );
9076 printf (
" IV_WRITE is working.\n" );
9077 printf (
" 12 August 1998\n" );
9078 printf (
" ASE_READ is working.\n" );
9079 printf (
" 10 August 1998\n" );
9080 printf (
" DXF_WRITE is working.\n" );
9081 printf (
" DXF_READ is working.\n" );
9082 printf (
" 27 July 1998\n" );
9083 printf (
" Interactive mode is working.\n" );
9084 printf (
" OBJ_READ is working.\n" );
9085 printf (
" 25 July 1998\n" );
9086 printf (
" OBJ_WRITE is working.\n" );
9087 printf (
" 24 July 1998\n" );
9088 printf (
" DATA_CHECK checks the input data.\n" );
9089 printf (
" VLA_READ is working.\n" );
9090 printf (
" VLA_WRITE is working.\n" );
9091 printf (
" 23 July 1998\n" );
9092 printf (
" STL_WRITE is working.\n" );
9093 printf (
" 22 July 1998\n" );
9094 printf (
" STL_READ is working.\n" );
9095 printf (
" TXT_WRITE is working.\n" );
9127 for ( iface = 0; iface <
face_num; iface++ ) {
9128 for ( ivert = 0; ivert <
face_order[iface]; ivert++ ) {
9129 node =
face[ivert][iface];
9182 int vertex_normal_num;
9192 vertex_normal_num = 0;
9202 for ( next =
input; *next !=
'\0' && isspace(*next); next++ ) {
9208 if ( *next ==
'\0' ) {
9212 if ( *next ==
'#' || *next ==
'$' ) {
9219 sscanf ( next,
"%s%n", token, &width );
9224 next = next + width;
9229 if (
leqi ( token,
"BEVEL" ) ==
TRUE ) {
9236 else if (
leqi ( token,
"BMAT" ) ==
TRUE ) {
9243 else if (
leqi ( token,
"C_INTERP" ) ==
TRUE ) {
9250 else if (
leqi ( token,
"CON" ) ==
TRUE ) {
9257 else if (
leqi ( token,
"CSTYPE" ) ==
TRUE ) {
9264 else if (
leqi ( token,
"CTECH" ) ==
TRUE ) {
9271 else if (
leqi ( token,
"CURV" ) ==
TRUE ) {
9278 else if (
leqi ( token,
"CURV2" ) ==
TRUE ) {
9285 else if (
leqi ( token,
"D_INTERP" ) ==
TRUE ) {
9292 else if (
leqi ( token,
"DEG" ) ==
TRUE ) {
9299 else if (
leqi ( token,
"END" ) ==
TRUE ) {
9318 else if (
leqi ( token,
"F" ) ==
TRUE ) {
9328 count = sscanf ( next,
"%s%n", token2, &width );
9329 next = next + width;
9335 count = sscanf ( token2,
"%d%n", &node, &width );
9336 next2 = token2 + width;
9351 if ( *next2 ==
'/' ) {
9353 for ( next3 = next2 + 1; next3 < token2 +
LINE_MAX_LEN; next3++ ) {
9355 if ( *next3 ==
'/' ) {
9357 count = sscanf ( next3,
"%d%n", &node, &width );
9360 if ( 0 <= node && node < vertex_normal_num ) {
9361 for (
i = 0;
i < 3;
i++ ) {
9379 else if (
leqi ( token,
"G" ) ==
TRUE ) {
9386 else if (
leqi ( token,
"HOLE" ) ==
TRUE ) {
9395 else if (
leqi ( token,
"L" ) ==
TRUE ) {
9399 count = sscanf ( next,
"%d%n", &node, &width );
9400 next = next + width;
9426 else if (
leqi ( token,
"LOD" ) ==
TRUE ) {
9433 else if (
leqi ( token,
"MG" ) ==
TRUE ) {
9441 else if (
leqi ( token,
"MTLLIB" ) ==
TRUE ) {
9448 else if (
leqi ( token,
"O" ) ==
TRUE ) {
9455 else if (
leqi ( token,
"P" ) ==
TRUE ) {
9462 else if (
leqi ( token,
"PARM" ) ==
TRUE ) {
9469 else if (
leqi ( token,
"S" ) ==
TRUE ) {
9476 else if (
leqi ( token,
"SCRV" ) ==
TRUE ) {
9483 else if (
leqi ( token,
"SHADOW_OBJ" ) ==
TRUE ) {
9490 else if (
leqi ( token,
"SP" ) ==
TRUE ) {
9497 else if (
leqi ( token,
"STECH" ) ==
TRUE ) {
9504 else if (
leqi ( token,
"CURV" ) ==
TRUE ) {
9511 else if (
leqi ( token,
"SURF" ) ==
TRUE ) {
9518 else if (
leqi ( token,
"TRACE_OBJ" ) ==
TRUE ) {
9525 else if (
leqi ( token,
"TRIM" ) ==
TRUE ) {
9532 else if (
leqi ( token,
"USEMTL" ) ==
TRUE ) {
9543 else if (
leqi ( token,
"V" ) ==
TRUE ) {
9545 sscanf ( next,
"%e %e %e", &r1, &r2, &r3 );
9561 else if (
leqi ( token,
"VN" ) ==
TRUE ) {
9563 sscanf ( next,
"%e %e %e", &r1, &r2, &r3 );
9571 vertex_normal_num = vertex_normal_num + 1;
9578 else if (
leqi ( token,
"VT" ) ==
TRUE ) {
9585 else if (
leqi ( token,
"VP" ) ==
TRUE ) {
9651 fprintf ( fileout,
"# %s created by IVCON.\n",
fileout_name );
9652 fprintf ( fileout,
"# Original data in %s.\n",
filein_name );
9653 fprintf ( fileout,
"\n" );
9655 fprintf ( fileout,
"\n" );
9662 fprintf ( fileout,
"v %f %f %f\n",
9671 fprintf ( fileout,
"\n" );
9675 for ( iface = 0; iface <
face_num; iface++ ) {
9677 for ( ivert = 0; ivert <
face_order[iface]; ivert++ ) {
9679 fprintf ( fileout,
"vn %f %f %f\n",
vertex_normal[0][ivert][iface],
9688 fprintf ( fileout,
"\n" );
9694 for ( iface = 0; iface <
face_num; iface++ ) {
9696 fprintf ( fileout,
"f" );
9697 for ( ivert = 0; ivert <
face_order[iface]; ivert++ ) {
9698 indexvn = indexvn + 1;
9699 fprintf ( fileout,
" %d//%d",
face[ivert][iface]+1, indexvn );
9701 fprintf ( fileout,
"\n" );
9708 fprintf ( fileout,
"\n" );
9719 fprintf ( fileout,
"\n" );
9724 if (
new ==
TRUE ) {
9725 fprintf ( fileout,
"l" );
9728 fprintf ( fileout,
" %d",
k+1 );
9733 fprintf ( fileout,
"\n" );
9739 printf (
"OBJ_WRITE - Wrote %d text lines.\n",
text_num );
9817 fprintf ( fileout,
"// %s created by IVCON.\n",
fileout_name );
9818 fprintf ( fileout,
"// Original data in %s.\n",
filein_name );
9823 fprintf ( fileout,
"\n" );
9824 fprintf ( fileout,
"#version 3.0\n" );
9825 fprintf ( fileout,
"#include \"colors.inc\"\n" );
9826 fprintf ( fileout,
"#include \"shapes.inc\"\n" );
9827 fprintf ( fileout,
"global_settings { assumed_gamma 2.2 }\n" );
9828 fprintf ( fileout,
"\n" );
9829 fprintf ( fileout,
"camera {\n" );
9830 fprintf ( fileout,
" right < 4/3, 0, 0>\n" );
9831 fprintf ( fileout,
" up < 0, 1, 0 >\n" );
9832 fprintf ( fileout,
" sky < 0, 1, 0 >\n" );
9833 fprintf ( fileout,
" angle 20\n" );
9834 fprintf ( fileout,
" location < 0, 0, -300 >\n" );
9835 fprintf ( fileout,
" look_at < 0, 0, 0>\n" );
9836 fprintf ( fileout,
"}\n" );
9837 fprintf ( fileout,
"\n" );
9838 fprintf ( fileout,
"light_source { < 20, 50, -100 > color White }\n" );
9839 fprintf ( fileout,
"\n" );
9840 fprintf ( fileout,
"background { color SkyBlue }\n" );
9846 fprintf ( fileout,
"\n" );
9847 fprintf ( fileout,
"#declare RedText = texture {\n" );
9848 fprintf ( fileout,
" pigment { color rgb < 0.8, 0.2, 0.2> }\n" );
9849 fprintf ( fileout,
" finish { ambient 0.2 diffuse 0.5 }\n" );
9850 fprintf ( fileout,
"}\n" );
9851 fprintf ( fileout,
"\n" );
9852 fprintf ( fileout,
"#declare GreenText = texture {\n" );
9853 fprintf ( fileout,
" pigment { color rgb < 0.2, 0.8, 0.2> }\n" );
9854 fprintf ( fileout,
" finish { ambient 0.2 diffuse 0.5 }\n" );
9855 fprintf ( fileout,
"}\n" );
9856 fprintf ( fileout,
"\n" );
9857 fprintf ( fileout,
"#declare BlueText = texture {\n" );
9858 fprintf ( fileout,
" pigment { color rgb < 0.2, 0.2, 0.8> }\n" );
9859 fprintf ( fileout,
" finish { ambient 0.2 diffuse 0.5 }\n" );
9860 fprintf ( fileout,
"}\n" );
9864 fprintf ( fileout,
"mesh {\n" );
9874 fprintf ( fileout,
" smooth_triangle {\n" );
9877 for ( j = jlo; j < jlo + 3; j++ ) {
9888 fprintf ( fileout,
"<%f, %f, %f>, <%f, %f, %f>",
9894 if ( j < jlo + 2 ) {
9895 fprintf ( fileout,
",\n" );
9898 fprintf ( fileout,
"\n" );
9905 fprintf ( fileout,
"texture { RedText } }\n" );
9907 else if (
i%2 == 0 ) {
9908 fprintf ( fileout,
"texture { BlueText } }\n" );
9911 fprintf ( fileout,
"texture { GreenText } }\n" );
9919 fprintf ( fileout,
"}\n" );
9925 printf (
"POV_WRITE - Wrote %d text lines.\n",
text_num );
9964 for ( j = 0; j < n; j++ ) {
9965 for (
i = 0;
i < m;
i++ ) {
9966 if ( a[
i][j] != r[
i] ) {
10039 else if ( r > 1.0 ) {
10046 else if ( g > 1.0 ) {
10053 else if ( b > 1.0 ) {
10060 if ( g > rgbmax ) {
10063 if ( b > rgbmax ) {
10068 if ( g < rgbmin ) {
10071 if ( b < rgbmin ) {
10077 if ( rgbmax == rgbmin ) {
10085 if ( r == rgbmax ) {
10086 h = ( g - b ) / ( rgbmax - rgbmin );
10088 else if ( g == rgbmax ) {
10089 h = 2.0 + ( b - r ) / ( rgbmax - rgbmin );
10091 else if ( b == rgbmax ) {
10092 h = 4.0 + ( r - g ) / ( rgbmax - rgbmin );
10102 else if ( h > 1.0 ) {
10133 c1 = fgetc ( filein );
10134 c2 = fgetc ( filein );
10136 ival = c1 | ( c2 << 8 );
10165 y.yint = short_int_val;
10168 fputc ( y.ychar[1], fileout );
10169 fputc ( y.ychar[0], fileout );
10172 fputc ( y.ychar[0], fileout );
10173 fputc ( y.ychar[1], fileout );
10310 int vertex_correction;
10325 vertex_correction = 0;
10334 printf (
"SMF_READ: DEBUG: Reading line #%d\n",
text_num );
10339 for ( next =
input; *next !=
'\0' && isspace(*next); next++ ) {
10345 if ( *next ==
'\0' ) {
10351 if ( *next ==
'#' || *next ==
'$' ) {
10358 sscanf ( next,
"%s%n", token, &width );
10362 next = next + width;
10370 if (
leqi ( token,
"BEGIN" ) ==
TRUE ) {
10384 else if (
leqi ( token,
"BIND" ) ==
TRUE ) {
10386 sscanf ( next,
"%s%n", cnr, &width );
10387 next = next + width;
10390 printf (
"CNR = %s\n", cnr );
10393 sscanf ( next,
"%s%n", type, &width );
10394 next = next + width;
10397 printf (
"TYPE = %s\n", type );
10400 if (
leqi ( cnr,
"C" ) ==
TRUE ) {
10402 if (
leqi ( type,
"VERTEX" ) ==
TRUE ) {
10405 else if (
leqi ( type,
"FACE" ) ==
TRUE ) {
10410 else if (
leqi ( cnr,
"N" ) ==
TRUE ) {
10412 if (
leqi ( type,
"VERTEX" ) ==
TRUE ) {
10415 else if (
leqi ( type,
"FACE" ) ==
TRUE ) {
10420 else if (
leqi ( cnr,
"R" ) ==
TRUE ) {
10422 if (
leqi ( type,
"VERTEX" ) ==
TRUE ) {
10425 else if (
leqi ( type,
"FACE" ) ==
TRUE ) {
10436 else if (
leqi ( token,
"C" ) ==
TRUE ) {
10438 sscanf ( next,
"%f%n", &r, &width );
10439 next = next + width;
10441 sscanf ( next,
"%f%n", &g, &width );
10442 next = next + width;
10444 sscanf ( next,
"%f%n", &b, &width );
10445 next = next + width;
10459 for (
k = 0;
k < 4;
k++ ) {
10475 face_count = face_count + 1;
10481 node_count = node_count + 1;
10488 printf (
"SMF_READ - Fatal error!\n" );
10489 printf (
" Material binding undefined!\n" );
10499 else if (
leqi ( token,
"END" ) ==
TRUE ) {
10505 printf (
"SMF_READ - Fatal error!\n" );
10506 printf (
" More END statements than BEGINs!\n" );
10521 else if (
leqi ( token,
"F" ) ==
TRUE ) {
10531 count = sscanf ( next,
"%s%n", token2, &width );
10532 next = next + width;
10534 if ( count != 1 ) {
10538 count = sscanf ( token2,
"%d%n", &node, &width );
10540 if ( count != 1 ) {
10557 else if (
leqi ( token,
"N" ) ==
TRUE ) {
10559 sscanf ( next,
"%f%n", &x, &width );
10560 next = next + width;
10562 sscanf ( next,
"%f%n", &y, &width );
10563 next = next + width;
10565 sscanf ( next,
"%f%n", &z, &width );
10566 next = next + width;
10574 iface_normal = iface_normal + 1;
10583 icor3_normal = icor3_normal + 1;
10589 printf (
"SMF_READ - Fatal error!\n" );
10590 printf (
" Normal binding undefined!\n" );
10599 else if (
leqi ( token,
"R" ) ==
TRUE ) {
10601 sscanf ( next,
"%f%n", &u, &width );
10602 next = next + width;
10604 sscanf ( next,
"%f%n", &v, &width );
10605 next = next + width;
10612 icor3_tex_uv = icor3_tex_uv + 1;
10620 icor3_tex_uv = icor3_tex_uv + 1;
10624 printf (
"SMF_READ - Fatal error!\n" );
10625 printf (
" Texture binding undefined!\n" );
10633 else if (
leqi ( token,
"ROT" ) ==
TRUE ) {
10635 sscanf ( next,
"%c%n", &axis, &width );
10636 next = next + width;
10638 sscanf ( next,
"%f%n", &angle, &width );
10639 next = next + width;
10647 else if (
leqi ( token,
"SCALE" ) ==
TRUE ) {
10649 sscanf ( next,
"%f%n", &sx, &width );
10650 next = next + width;
10652 sscanf ( next,
"%f%n", &sy, &width );
10653 next = next + width;
10655 sscanf ( next,
"%f%n", &sz, &width );
10656 next = next + width;
10664 else if (
leqi ( token,
"SET" ) ==
TRUE ) {
10666 sscanf ( next,
"%s%n", cnr, &width );
10667 next = next + width;
10669 sscanf ( next,
"%d%n", &vertex_correction, &width );
10670 next = next + width;
10677 else if (
leqi ( token,
"T_SCALE" ) ==
TRUE ) {
10679 sscanf ( next,
"%f%n", &dx, &width );
10680 next = next + width;
10682 sscanf ( next,
"%f%n", &dy, &width );
10683 next = next + width;
10690 else if (
leqi ( token,
"T_TRANS" ) ==
TRUE ) {
10692 sscanf ( next,
"%f%n", &dx, &width );
10693 next = next + width;
10695 sscanf ( next,
"%f%n", &dy, &width );
10696 next = next + width;
10704 else if (
leqi ( token,
"TEX" ) ==
TRUE ) {
10706 sscanf ( next,
"%s%n",
string, &width );
10710 if (
string[
i] ==
'\0' ) {
10721 else if (
leqi ( token,
"TRANS" ) ==
TRUE ) {
10723 sscanf ( next,
"%f%n", &x, &width );
10724 next = next + width;
10726 sscanf ( next,
"%f%n", &y, &width );
10727 next = next + width;
10729 sscanf ( next,
"%f%n", &z, &width );
10730 next = next + width;
10738 else if (
leqi ( token,
"V" ) ==
TRUE ) {
10740 sscanf ( next,
"%e %e %e", &r1, &r2, &r3 );
10753 for (
i = 0;
i < 3;
i++ ) {
10770 printf (
"SMF_READ: Bad data on line %d.\n",
text_num );
10906 fprintf ( fileout,
"#$SMF 2.0\n" );
10907 fprintf ( fileout,
"#$vertices %d\n",
cor3_num );
10908 fprintf ( fileout,
"#$faces %d\n",
face_num );
10909 fprintf ( fileout,
"#\n" );
10910 fprintf ( fileout,
"# %s created by IVCON.\n",
fileout_name );
10911 fprintf ( fileout,
"# Original data in %s.\n",
filein_name );
10912 fprintf ( fileout,
"#\n" );
10919 fprintf ( fileout,
"v %f %f %f\n",
10927 fprintf ( fileout,
"\n" );
10931 for ( iface = 0; iface <
face_num; iface++ ) {
10933 fprintf ( fileout,
"f" );
10934 for ( ivert = 0; ivert <
face_order[iface]; ivert++ ) {
10935 fprintf ( fileout,
" %d",
face[ivert][iface]+1 );
10937 fprintf ( fileout,
"\n" );
10943 fprintf ( fileout,
"bind c vertex\n" );
10948 for ( icor3 = 0; icor3 <
cor3_num; icor3++ ) {
10960 fprintf ( fileout,
"bind n vertex\n" );
10965 for ( icor3 = 0; icor3 <
cor3_num; icor3++ ) {
10967 fprintf ( fileout,
"n %f %f %f\n",
cor3_normal[0][icor3],
10982 fprintf ( fileout,
"bind r vertex\n" );
10987 for ( icor3 = 0; icor3 <
cor3_num; icor3++ ) {
10988 fprintf ( fileout,
"r %f %f\n",
cor3_tex_uv[0][icor3],
10998 printf (
"SMF_WRITE - Wrote %d text lines.\n",
text_num );
11063 for ( next =
input; *next !=
'\0' && isspace(*next); next++ ) {
11068 if ( *next ==
'\0' || *next ==
'#' || *next ==
'!' || *next ==
'$' ) {
11074 sscanf ( next,
"%s%n", token, &width );
11078 next = next + width;
11082 if (
leqi ( token,
"facet" ) ==
TRUE ) {
11086 sscanf ( next,
"%*s %e %e %e", &r1, &r2, &r3 );
11104 count = sscanf (
input,
"%*s %e %e %e", &r1, &r2, &r3 );
11106 if ( count != 3 ) {
11121 if ( icor3 == -1 ) {
11126 for (
i = 0;
i < 3;
i++ ) {
11139 for (
i = 0;
i < 3;
i++ ) {
11161 else if (
leqi ( token,
"color" ) ==
TRUE ) {
11162 sscanf ( next,
"%*s %f %f %f %f", &r1, &r2, &r3, &r4 );
11167 else if (
leqi ( token,
"solid" ) ==
TRUE ) {
11173 else if (
leqi ( token,
"endsolid" ) ==
TRUE ) {
11180 printf (
"STLA_READ - Fatal error!\n" );
11181 printf (
" Unrecognized first word on line.\n" );
11246 fprintf ( fileout,
"solid MYSOLID created by IVCON, original data in %s\n",
11251 for ( iface = 0; iface <
face_num; iface++ ) {
11253 for ( jvert = 2; jvert <
face_order[iface]; jvert++ ) {
11255 face_num2 = face_num2 + 1;
11257 fprintf ( fileout,
" facet normal %f %f %f\n",
11260 fprintf ( fileout,
" outer loop\n" );
11262 icor3 =
face[0][iface];
11263 fprintf ( fileout,
" vertex %f %f %f\n",
11266 icor3 =
face[jvert-1][iface];
11267 fprintf ( fileout,
" vertex %f %f %f\n",
11270 icor3 =
face[jvert][iface];
11271 fprintf ( fileout,
" vertex %f %f %f\n",
11274 fprintf ( fileout,
" endloop\n" );
11275 fprintf ( fileout,
" endfacet\n" );
11280 fprintf ( fileout,
"endsolid MYSOLID\n" );
11286 printf (
"STLA_WRITE - Wrote %d text lines.\n",
text_num );
11289 printf (
" Number of faces in original data was %d.\n",
face_num );
11290 printf (
" Number of triangular faces in decomposed data is %d.\n",
11330 short int attribute = 0;
11340 for (
i = 0;
i < 80;
i++ ) {
11343 printf (
"%d\n", c );
11358 for ( iface = 0; iface <
face_num; iface++ ) {
11363 for (
i = 0;
i < 3;
i++ ) {
11368 for ( ivert = 0; ivert <
face_order[iface]; ivert++ ) {
11370 for (
i = 0;
i < 3;
i++ ) {
11382 if ( icor3 == -1 ) {
11395 face[ivert][iface] = icor3;
11400 printf (
"ATTRIBUTE = %d\n", attribute );
11448 short int attribute = 0;
11458 for (
i = 0;
i < 80;
i++ ) {
11466 for ( iface = 0; iface <
face_num; iface++ ) {
11467 face_num2 = face_num2 +
face_order[iface] - 2;
11477 for ( iface = 0; iface <
face_num; iface++ ) {
11479 for ( jvert = 2; jvert <
face_order[iface]; jvert++ ) {
11481 for (
i = 0;
i < 3;
i++ ) {
11485 icor3 =
face[0][iface];
11486 for (
i = 0;
i < 3;
i++ ) {
11490 icor3 =
face[jvert-1][iface];
11491 for (
i = 0;
i < 3;
i++ ) {
11495 icor3 =
face[jvert][iface];
11496 for (
i = 0;
i < 3;
i++ ) {
11509 printf (
"STLB_WRITE - Wrote %d bytes.\n",
bytes_num );
11512 printf (
" Number of faces in original data was %d.\n",
face_num );
11513 printf (
" Number of triangular faces in decomposed data is %d.\n",
11570 unsigned long int chunk_begin;
11571 unsigned long int chunk_end;
11572 unsigned long int chunk_length;
11573 unsigned long int chunk_length2;
11574 unsigned long int position;
11575 unsigned short int temp_int;
11585 if ( temp_int == 0x4d4d ) {
11588 printf (
"TDS_READ: DEBUG: Read magic number %0X.\n", temp_int );
11594 fseek ( filein, (
long ) position, SEEK_SET );
11595 version = fgetc ( filein );
11597 if ( version < 3 ) {
11599 printf (
"TDS_READ - Fatal error!\n" );
11600 printf (
" This routine can only read 3DS version 3 or later.\n" );
11601 printf (
" The input file is version %d.\n" ,version );
11606 printf (
"TDS_READ: DEBUG: Version number is %d.\n", version );
11615 fseek ( filein, (
long ) position, SEEK_SET );
11620 chunk_end = chunk_begin + chunk_length;
11623 printf (
"TDS_READ:\n" );
11624 printf (
" Chunk begin = %lu.\n", chunk_begin );
11625 printf (
" Chunk length = %lu.\n", chunk_length );
11626 printf (
" Chunk end = %lu.\n", chunk_end );
11629 while ( position + 2 < chunk_end ) {
11632 position = position + 2;
11635 printf (
"TDS_READ: Short int = %0X, position = %lu.\n", temp_int, position );
11638 if ( temp_int == 0x0002 ) {
11640 printf (
"TDS_READ: Read_Initial_Section:\n" );
11643 position = position + 4;
11644 position = position - 6 + chunk_length2;
11645 fseek ( filein, (
long ) position, SEEK_SET );
11647 else if ( temp_int == 0x3d3d ) {
11649 printf (
"TDS_READ: Read_Edit_Section:\n" );
11651 position = position - 2;
11654 else if ( temp_int == 0xb000 ) {
11656 printf (
"TDS_READ: Read_Keyframe_Section:\n" );
11659 position = position - 2;
11664 printf (
"TDS_READ - Fatal error!\n" );
11665 printf (
" Unexpected input, position = %lu.\n", position );
11666 printf (
" TEMP_INT = %hux\n", temp_int );
11670 position = chunk_begin + chunk_length;
11671 fseek ( filein, (
long ) position, SEEK_SET );
11675 printf (
"TDS_READ - Fatal error!\n" );
11676 printf (
" Could not find the main section tag.\n" );
11689 unsigned long int current_pointer;
11690 unsigned char end_found =
FALSE;
11694 unsigned short int temp_int;
11695 unsigned long int temp_pointer;
11696 unsigned long int teller;
11697 unsigned char true_c_val[3];
11699 current_pointer = ftell ( filein ) - 2;
11703 while ( end_found ==
FALSE ) {
11706 teller = teller + 2;
11708 switch ( temp_int ) {
11711 printf (
" COLOR_F color definition section tag of %0X\n",
11714 for (
i = 0;
i < 3;
i++ ) {
11718 printf (
"RGB_VAL = %f %f %f\n", rgb_val[0], rgb_val[1], rgb_val[2] );
11720 teller = teller + 3 *
sizeof ( float );
11724 printf (
" COLOR_24 24 bit color definition section tag of %0X\n",
11728 for (
i = 0;
i < 3;
i++ ) {
11729 true_c_val[
i] = fgetc ( filein );
11732 printf (
"TRUE_C_VAL = %d %d %d\n", true_c_val[0], true_c_val[1],
11735 teller = teller + 3;
11741 if ( teller >= temp_pointer ) {
11747 pointer = ( long ) ( current_pointer + temp_pointer );
11748 fseek ( filein, pointer, SEEK_SET );
11750 return ( temp_pointer );
11759 unsigned long int current_pointer;
11760 unsigned char end_found =
FALSE;
11764 unsigned short int temp_int;
11765 unsigned long int temp_pointer;
11766 unsigned long int teller;
11767 unsigned char true_c_val[3];
11769 current_pointer = ftell ( filein ) - 2;
11773 while ( end_found ==
FALSE ) {
11776 teller = teller + 2;
11778 switch ( temp_int ) {
11781 printf (
" COLOR_F RGB color definition section tag of %0X\n",
11784 for (
i = 0;
i < 3;
i++ ) {
11788 printf (
"RGB_VAL = %f %f %f\n", rgb_val[0], rgb_val[1], rgb_val[2] );
11790 teller = teller + 3 *
sizeof ( float );
11794 printf (
" COLOR_24 24 bit color definition section tag of %0X\n",
11798 for (
i = 0;
i < 3;
i++ ) {
11799 true_c_val[
i] = fgetc ( filein );
11802 printf (
"TRUE_C_VAL = %d %d %d\n", true_c_val[0], true_c_val[1],
11805 teller = teller + 3;
11811 if ( teller >= temp_pointer ) {
11817 pointer = ( long ) ( current_pointer + temp_pointer );
11818 fseek ( filein, pointer, SEEK_SET );
11820 return ( temp_pointer );
11829 unsigned long current_pointer;
11831 unsigned long temp_pointer;
11833 current_pointer = ftell ( filein ) - 2;
11836 *
boolean = fgetc ( filein );
11838 pointer = ( long ) ( current_pointer + temp_pointer );
11839 fseek ( filein, pointer, SEEK_SET );
11841 return ( temp_pointer );
11849 float camera_eye[3];
11850 float camera_focus[3];
11851 unsigned long int current_pointer;
11855 unsigned long int temp_pointer;
11856 unsigned short int u_short_int_val;
11858 current_pointer = ftell ( filein ) - 2;
11873 printf (
" Found camera viewpoint at XYZ = %f %f %f.\n",
11874 camera_eye[0], camera_eye[1], camera_eye[2] );
11875 printf (
" Found camera focus coordinates at XYZ = %f %f %f.\n",
11876 camera_focus[0], camera_focus[1], camera_focus[2] );
11877 printf (
" Rotation of camera is: %f.\n", rotation );
11878 printf (
" Lens in used camera is: %f mm.\n", lens );
11881 if ( ( temp_pointer-38 ) > 0 ) {
11884 printf (
" Found extra camera sections.\n" );
11889 if ( u_short_int_val == 0x4710 ) {
11891 printf (
" CAM_SEE_CONE.\n" );
11898 if ( u_short_int_val == 0x4720 ) {
11900 printf (
" CAM_RANGES.\n" );
11907 pointer = ( long ) ( current_pointer + temp_pointer );
11908 fseek ( filein, pointer, SEEK_SET );
11910 return ( temp_pointer );
11924 unsigned long int chunk_length;
11925 unsigned long int current_pointer;
11926 unsigned char end_found =
FALSE;
11928 unsigned long int teller;
11929 unsigned short int temp_int;
11931 current_pointer = ftell ( filein ) - 2;
11935 while ( end_found ==
FALSE ) {
11938 teller = teller + 2;
11941 printf (
" TDS_READ_EDIT_SECTION processing tag %0X\n", temp_int );
11944 switch ( temp_int ) {
11947 printf (
" BIT_MAP section tag of %0X\n", temp_int );
11953 printf (
" USE_SOLID_BGND section tag of %0X\n", temp_int );
11959 printf (
" V_GRADIENT section tag of %0X\n", temp_int );
11995 printf (
" AMBIENT_LIGHT section tag of %0X\n", temp_int );
12001 printf (
" SOLID_BGND section tag of %0X\n", temp_int );
12007 printf (
" MASTER_SCALE section tag of %0X\n", temp_int );
12013 printf (
" MESH_VERSION section tag of %0X\n", temp_int );
12019 printf (
" MAT_ENTRY section tag of %0X\n", temp_int );
12025 printf (
" NAMED_OBJECT section tag of %0X\n", temp_int );
12031 printf (
" VIEWPORT_LAYOUT section tag of %0X\n",
12038 printf (
" VIEWPORT_DATA_3 section tag of %0X\n", temp_int );
12044 printf (
" VIEWPORT_DATA section tag of %0X\n", temp_int );
12050 printf (
" VIEWPORT_SIZE section tag of %0X\n", temp_int );
12056 printf (
" Junk.\n" );
12061 if ( teller >= chunk_length ) {
12067 pointer = ( long ) ( current_pointer + chunk_length );
12069 fseek ( filein, pointer, SEEK_SET );
12071 return ( chunk_length );
12079 unsigned long int current_pointer;
12080 unsigned char end_found =
FALSE;
12082 unsigned short int temp_int;
12083 unsigned long int temp_pointer;
12084 unsigned long int teller;
12086 current_pointer = ftell ( filein ) - 2;
12090 while ( end_found ==
FALSE ) {
12093 teller = teller + 2;
12095 switch ( temp_int ) {
12098 printf (
" VIEWPORT_LAYOUT main definition section tag of %0X\n",
12105 printf (
" KFSEG frames section tag of %0X\n", temp_int );
12111 printf (
" OBJECT_NODE_TAG object description section tag of %0X\n",
12118 printf (
" KFCURTIME section tag of %0X\n", temp_int );
12124 printf (
" KFHDR section tag of %0X\n", temp_int );
12132 if ( teller >= temp_pointer ) {
12138 pointer = ( long ) ( current_pointer + temp_pointer );
12139 fseek ( filein, pointer, SEEK_SET );
12141 return ( temp_pointer );
12155 unsigned long int chunk_size;
12156 unsigned long int current_pointer;
12157 unsigned char end_found =
FALSE;
12159 unsigned short int temp_int;
12160 unsigned long int temp_pointer;
12161 unsigned long int teller;
12162 unsigned long int u_long_int_val;
12163 unsigned short int u_short_int_val;
12165 current_pointer = ftell ( filein ) - 2;
12169 while ( end_found ==
FALSE ) {
12172 teller = teller + 2;
12174 switch ( temp_int ) {
12177 printf (
" INSTANCE_NAME section tag of %0X\n", temp_int );
12183 printf (
" NODE_HDR section tag of %0X\n", temp_int );
12189 printf (
" POS_TRACK_TAG section tag of %0X\n", temp_int );
12193 printf (
" chunk_size = %d\n", chunk_size );
12205 printf (
"u_short_int_val = %d\n", u_short_int_val );
12206 printf (
"u_long_int_val = %d\n", u_long_int_val );
12211 teller = teller + 32;
12215 printf (
" PIVOT section tag of %0X\n", temp_int );
12221 teller = teller + 12;
12225 printf (
" BOUNDBOX section tag of %0X\n", temp_int );
12231 printf (
" MORPH_SMOOTH section tag of %0X\n", temp_int );
12237 printf (
" ROT_TRACK_TAG section tag of %0X\n", temp_int );
12243 printf (
" SCL_TRACK_TAG section tag of %0X\n", temp_int );
12249 printf (
" NODE_ID section tag of %0X\n", temp_int );
12257 if ( teller >= temp_pointer ) {
12263 pointer = ( long ) ( current_pointer+temp_pointer );
12264 fseek ( filein, pointer, SEEK_SET );
12266 return ( temp_pointer );
12274 unsigned char boolean;
12275 unsigned long int current_pointer;
12276 unsigned char end_found =
FALSE;
12278 float light_coors[3];
12281 unsigned long int teller;
12282 unsigned short int temp_int;
12283 unsigned long int temp_pointer;
12284 unsigned char true_c_val[3];
12286 current_pointer = ftell ( filein ) - 2;
12294 teller = teller + 3 * 4;
12297 printf (
" Found light at coordinates XYZ = %f %f %f.\n",
12298 light_coors[0], light_coors[1], light_coors[2] );
12301 while ( end_found ==
FALSE ) {
12304 teller = teller + 2;
12306 switch ( temp_int ) {
12309 printf (
" COLOR_F RGB color definition section tag of %0X\n",
12312 for (
i = 0;
i < 3;
i++ ) {
12316 printf (
" RGB_VAL value set to %f %f %f\n", rgb_val[0],
12317 rgb_val[1], rgb_val[2] );
12319 teller = teller + 3 *
sizeof ( float );
12323 printf (
" COLOR_24 24 bit color definition section tag of %0X\n",
12327 for (
i = 0;
i < 3;
i++ ) {
12328 true_c_val[
i] = fgetc ( filein );
12331 printf (
" TRUE_C_VAL value set to %d %d %d\n", true_c_val[0],
12332 true_c_val[1], true_c_val[2] );
12334 teller = teller + 3;
12338 printf (
" DL_OFF section: %0X\n", temp_int );
12342 if (
boolean ==
TRUE ) {
12343 printf (
" Light is on\n" );
12346 printf (
" Light is off\n" );
12352 printf (
" DL_SPOTLIGHT section tag of %0X\n", temp_int );
12358 printf (
" DL_OUTER_RANGE section tag of %0X\n", temp_int );
12366 if ( teller >= temp_pointer ) {
12372 pointer = ( long ) ( current_pointer + temp_pointer );
12373 fseek ( filein, pointer, SEEK_SET );
12375 return ( temp_pointer );
12394 unsigned long int yint;
12399 y.ychar[3] = fgetc ( filein );
12400 y.ychar[2] = fgetc ( filein );
12401 y.ychar[1] = fgetc ( filein );
12402 y.ychar[0] = fgetc ( filein );
12405 y.ychar[0] = fgetc ( filein );
12406 y.ychar[1] = fgetc ( filein );
12407 y.ychar[2] = fgetc ( filein );
12408 y.ychar[3] = fgetc ( filein );
12419 unsigned char letter;
12420 unsigned int teller;
12423 letter = fgetc ( filein );
12427 if ( letter == 0 ) {
12433 teller = teller + 1;
12436 letter = fgetc ( filein );
12438 teller = teller + 1;
12439 }
while ( letter != 0 );
12444 printf (
" tds_read_long_name found name: %s.\n",
temp_name );
12455 unsigned long int current_pointer;
12458 unsigned long int temp_pointer;
12460 current_pointer = ftell ( filein ) - 2;
12465 if ( teller == -1 ) {
12467 printf (
" No material name found.\n" );
12473 printf (
" Material name %s.\n",
mat_name );
12477 pointer = ( long ) ( current_pointer + temp_pointer );
12478 fseek ( filein, pointer, SEEK_SET );
12480 return ( temp_pointer );
12488 unsigned long int current_pointer;
12489 unsigned char end_found =
FALSE;
12491 unsigned short int temp_int;
12492 unsigned long int temp_pointer;
12493 unsigned long int teller;
12495 current_pointer = ftell ( filein ) - 2;
12500 while ( end_found ==
FALSE ) {
12503 teller = teller + 2;
12505 switch ( temp_int ) {
12509 printf (
" MAT_NAME definition section tag of %0X\n",
12516 printf (
" MAT_AMBIENT definition section tag of %0X\n",
12523 printf (
" MAT_DIFFUSE definition section tag of %0X\n",
12530 printf (
" MAT_SPECULAR definition section tag of %0X\n",
12537 printf (
" MAT_SHININESS definition section tag of %0X\n",
12544 printf (
" MAT_SHIN2PCT definition section tag of %0X\n",
12551 printf (
" MAT_SHIN3PCT definition section tag of %0X\n",
12558 printf (
" MAT_TRANSPARENCY definition section tag of %0X\n",
12565 printf (
" MAT_XPFALL definition section tag of %0X\n",
12572 printf (
" MAT_REFBLUR definition section tag of %0X\n",
12579 printf (
" MAT_SELF_ILLUM definition section tag of %0X\n",
12586 printf (
" MAT_TWO_SIDE definition section tag of %0X\n",
12593 printf (
" MAT_DECAL definition section tag of %0X\n",
12600 printf (
" MAT_ADDITIVE definition section tag of %0X\n",
12607 printf (
" MAT_SELF_ILPCT definition section tag of %0X\n",
12614 printf (
" MAT_WIRE definition section tag of %0X\n",
12621 printf (
" MAT_SUPERSMP definition section tag of %0X\n",
12628 printf (
" MAT_WIRESIZE definition section tag of %0X\n",
12635 printf (
" MAT_FACEMAP definition section tag of %0X\n",
12642 printf (
" MAT_XPFALLIN definition section tag of %0X\n",
12649 printf (
" MAT_PHONGSOFT definition section tag of %0X\n",
12656 printf (
" MAT_WIREABS definition section tag of %0X\n",
12663 printf (
" MAT_SHADING definition section tag of %0X\n",
12670 printf (
" MAT_TEXMAP definition section tag of %0X\n",
12680 printf (
" MAT_SPECMAP definition section tag of %0X\n",
12687 printf (
" MAT_OPACMAP definition section tag of %0X\n",
12694 printf (
" MAT_REFLMAP definition section tag of %0X\n",
12701 printf (
" MAT_BUMPMAP definition section tag of %0X\n",
12708 printf (
" MAT_MAP_TEXBLUR definition section tag of %0X\n",
12715 printf (
" Junk section tag of %0X\n", temp_int );
12720 if ( teller >= temp_pointer ) {
12725 pointer = ( long ) ( current_pointer + temp_pointer );
12727 fseek ( filein, pointer, SEEK_SET );
12729 return ( temp_pointer );
12737 unsigned char letter;
12738 unsigned int teller;
12741 letter = fgetc ( filein );
12746 if ( letter == 0 ) {
12752 teller = teller + 1;
12755 letter = fgetc ( filein );
12757 teller = teller + 1;
12758 }
while ( ( letter != 0 ) && ( teller < 12 ) );
12763 printf (
" tds_read_name found name: %s.\n",
temp_name );
12784 unsigned short int b;
12785 unsigned long int chunk_size;
12786 unsigned short int color_index;
12787 unsigned long int current_pointer;
12788 unsigned char end_found =
FALSE;
12789 unsigned short int g;
12796 unsigned short int r;
12797 unsigned short int temp_int;
12798 unsigned long int temp_pointer;
12799 unsigned long int temp_pointer2;
12800 unsigned long int teller;
12802 current_pointer = ftell ( filein ) - 2;
12807 while ( end_found ==
FALSE ) {
12810 teller = teller + 2;
12812 switch ( temp_int ) {
12816 printf (
" NAMED_OBJECT section tag of %0X\n",
12824 printf (
" N_TRI_OBJECT section tag of %0X\n",
12833 printf (
" POINT_ARRAY section tag of %0X\n", temp_int );
12836 current_pointer = ftell ( filein ) - 2;
12847 teller = teller + temp_pointer2;
12852 printf (
" POINT_FLAG_ARRAY faces (2) section tag of %0X\n",
12861 printf (
" FACE_ARRAY section tag of %0X\n",
12881 r = ( temp_int & 0x0004 ) >> 2;
12882 g = ( temp_int & 0x0002 ) >> 1;
12883 b = ( temp_int & 0x0001 );
12885 for ( j = 0; j < 3; j++ ) {
12894 if ( temp_int == 0x4150 ) {
12901 teller = ftell ( filein );
12906 printf (
" MSH_MAT_GROUP section tag of %0X\n",
12914 printf (
" TEX_VERTS section tag of %0X\n",
12922 printf (
" SMOOTH_GROUP section tag of %0X\n",
12931 printf (
" MESH_MATRIX section tag of %0X\n",
12937 for ( j = 0; j < 4; j++ ) {
12938 for (
i = 0;
i < 3;
i++ ) {
12947 teller = teller + 12 *
sizeof ( float );
12953 printf (
" MESH_COLOR section tag of %0X\n", temp_int );
12958 if ( chunk_size == 7 ) {
12959 color_index = fgetc ( filein );
12960 teller = teller + 5;
12964 teller = teller + 6;
12967 printf (
" Color index set to %d\n", color_index );
12973 printf (
" MESH_TEXTURE_INFO section tag of %0X\n",
12981 printf (
" JUNK section tag of %0X\n", temp_int );
12986 if ( teller >= temp_pointer ) {
12992 pointer = (
long int ) ( current_pointer + temp_pointer );
12993 fseek ( filein, pointer, SEEK_SET );
12995 return ( temp_pointer );
13003 unsigned char end_found =
FALSE;
13004 unsigned long int current_pointer;
13007 unsigned short int temp_int;
13008 unsigned long int temp_pointer;
13009 unsigned long int teller;
13011 current_pointer = ftell ( filein ) - 2;
13019 if ( int_val == -1 ) {
13021 printf (
" Dummy Object found\n" );
13028 while ( end_found ==
FALSE ) {
13031 teller = teller + 2;
13033 switch ( temp_int ) {
13036 printf (
" N_CAMERA section tag of %0X\n", temp_int );
13042 printf (
" N_DIRECT_LIGHT section tag of %0X\n", temp_int );
13048 printf (
" OBJ_TRIMESH section tag of %0X\n", temp_int );
13054 printf (
" OBJ_HIDDEN section tag of %0X\n", temp_int );
13060 printf (
" OBJ_DOESNT_CAST section tag of %0X\n", temp_int );
13068 if ( teller >= temp_pointer ) {
13074 pointer = ( long ) ( current_pointer + temp_pointer );
13076 fseek ( filein, pointer, SEEK_SET );
13078 return ( temp_pointer );
13106 unsigned long int current_pointer;
13109 unsigned long int temp_pointer;
13110 unsigned short int n2;
13112 current_pointer = ftell ( filein ) - 2;
13115 pointer = (
long int ) ( current_pointer + temp_pointer );
13119 for ( icor3 = 0; icor3 < n2; icor3++ ) {
13124 fseek ( filein, pointer, SEEK_SET );
13126 return ( temp_pointer );
13153 unsigned long int current_pointer;
13156 unsigned long int temp_pointer;
13160 current_pointer = ftell ( filein ) - 2;
13178 if ( teller == -1 ) {
13180 printf (
" No TEXMAP name found.\n" );
13190 pointer = ( long ) ( current_pointer + temp_pointer );
13191 fseek ( filein, pointer, SEEK_SET );
13193 return ( temp_pointer );
13205 c1 = fgetc ( filein );
13206 c2 = fgetc ( filein );
13208 ival = c1 | ( c2 << 8 );
13218 unsigned long int current_pointer;
13223 unsigned long int temp_pointer;
13225 current_pointer = ftell ( filein ) - 2;
13235 printf (
" The target of the spot is XYZ = %f %f %f.\n",
13236 target[0], target[1], target[2] );
13237 printf (
" The hotspot of this light is %f.\n", hotspot );
13238 printf (
" The falloff of this light is %f.\n", falloff );
13241 pointer = ( long ) ( current_pointer + temp_pointer );
13243 fseek ( filein, pointer, SEEK_SET );
13245 return ( temp_pointer );
13253 unsigned long int current_pointer;
13255 unsigned long int temp_pointer;
13257 current_pointer = ftell ( filein ) - 2;
13260 pointer = (
long int ) ( current_pointer + temp_pointer );
13262 fseek ( filein, pointer, SEEK_SET );
13264 return ( temp_pointer );
13272 unsigned long int current_pointer;
13273 unsigned char end_found =
FALSE;
13275 unsigned short int temp_int;
13276 unsigned long int temp_pointer;
13277 unsigned long int teller;
13279 current_pointer = ftell ( filein ) - 2;
13283 while ( end_found ==
FALSE ) {
13286 teller = teller + 2;
13288 switch ( temp_int ) {
13291 printf (
" VIEWPORT_DATA_3 section tag of %0X\n", temp_int );
13297 printf (
" VIEWPORT_DATA section tag of %0X\n", temp_int );
13303 printf (
" VIEWPORT_SIZE section tag of %0X\n", temp_int );
13311 if ( teller >= temp_pointer ) {
13315 if ( *views_read > 3 ) {
13320 pointer = (
long int ) ( current_pointer + temp_pointer );
13322 fseek ( filein, pointer, SEEK_SET );
13324 return ( temp_pointer );
13332 unsigned int attribs;
13333 unsigned long int current_pointer;
13338 unsigned long int temp_pointer;
13339 char *viewports[11] = {
13353 *views_read = *views_read + 1;
13355 current_pointer = ftell ( filein ) - 2;
13360 if ( attribs == 3 ) {
13362 printf (
"<Snap> active in viewport.\n" );
13366 if ( attribs == 5 ) {
13368 printf (
"<Grid> active in viewport.\n" );
13374 for (
i = 1;
i < 6;
i++ ) {
13382 if ( ( port == 0xffff ) || ( port == 0 ) ) {
13384 for (
i = 0;
i < 12;
i++ ) {
13390 if ( int_val == -1 ) {
13392 printf (
" No Camera name found\n" );
13400 printf (
"Reading [%s] information with tag:%d\n", viewports[port], port );
13403 pointer = (
long int ) ( current_pointer + temp_pointer );
13405 fseek ( filein, pointer, SEEK_SET );
13407 return ( temp_pointer );
13457 long int long_int_val;
13459 short int short_int_val;
13460 unsigned short int u_short_int_val;
13468 l4120 = 2 + 4 + 2 + 4 *
face_num * 2 + l4150;
13469 l4160 = 2 + 4 + 4 * 12;
13470 l4110 = 2 + 4 + 2 +
cor3_num * 3 * 4;
13471 l4100 = 2 + 4 + l4110 + l4160 + l4120;
13472 l4000 = 2 + 4 + ( name_length + 1 ) + l4100;
13475 l3d3d = 2 + 4 + l3d3e + l0100 + l4000;
13477 lb022 = 2 + 4 + 32;
13478 lb021 = 2 + 4 + 9 * 4;
13479 lb020 = 2 + 4 + 8 * 4;
13480 lb013 = 2 + 4 + 6 * 2;
13481 lb010 = 2 + 4 + ( name_length + 1 ) + 3 * 2;
13483 lb002 = 2 + 4 + lb030 + lb010 + lb013 + lb020 + lb021 + lb022;
13485 lb008 = 2 + 4 + 2 * 4;
13486 lb00a = 2 + 4 + 2 + 9 + 2 * 2;
13487 lb000 = 2 + 4 + lb00a + lb008 + lb009 + lb002;
13489 l4d4d = 2 + 4 + l0002 + l3d3d + lb000;
13494 short_int_val = ( short ) 0x4d4d;
13501 short_int_val = ( short ) 0x0002;
13511 short_int_val = ( short ) 0x3d3d;
13518 short_int_val = ( short ) 0x3d3e;
13528 short_int_val = ( short ) 0x0100;
13538 short_int_val = ( short ) 0x4000;
13546 short_int_val = ( short ) 0x4100;
13554 short_int_val = ( short ) 0x4110;
13558 u_short_int_val = (
unsigned short )
cor3_num;
13561 for ( icor3 = 0; icor3 <
cor3_num; icor3++ ) {
13562 for ( j = 0; j < 3; j++ ) {
13571 short_int_val = ( short ) 0x4160;
13575 for (
i = 0;
i < 4;
i++ ) {
13576 for ( j = 0; j < 3; j++ ) {
13587 short_int_val = ( short ) 0x4120;
13591 u_short_int_val = (
unsigned short )
face_num;
13594 for ( iface = 0; iface <
face_num; iface++ ) {
13595 for ( j = 0; j < 3; j++ ) {
13596 short_int_val =
face[j][iface];
13606 short_int_val = ( short ) 0x4150;
13610 for ( iface = 0; iface <
face_num; iface++ ) {
13622 short_int_val = ( short ) 0xb000;
13629 short_int_val = ( short ) 0xb00a;
13635 short_int_val = 100;
13644 short_int_val = ( short ) 0xb008;
13649 long_int_val = 100;
13656 short_int_val = ( short ) 0xb009;
13666 short_int_val = ( short ) 0xb002;
13673 short_int_val = ( short ) 0xb030;
13683 short_int_val = ( short ) 0xb010;
13687 short_int_val = 16384;
13691 short_int_val = -1;
13698 short_int_val = ( short ) 0xb013;
13701 for (
i = 0;
i < 3;
i++ ) {
13710 short_int_val = ( short ) 0xb020;
13731 for (
i = 0;
i < 3;
i++ ) {
13740 short_int_val = ( short ) 0xb021;
13771 short_int_val = ( short ) 0xb022;
13806 printf (
"TDS_WRITE wrote %d bytes.\n",
bytes_num );
13831 for ( c =
string; nchar < 12; c++ ) {
13833 fputc ( *c, fileout );
13861 unsigned short int yint;
13865 y.yint = short_int_val;
13868 fputc ( y.ychar[1], fileout );
13869 fputc ( y.ychar[0], fileout );
13872 fputc ( y.ychar[0], fileout );
13873 fputc ( y.ychar[1], fileout );
13943 for ( iface = 0; iface <
face_num; iface++ ) {
13944 for ( j = 0; j <
face_order[iface] - 2; j++ ) {
13945 face_num2 = face_num2 + 1;
13951 fprintf ( fileout,
"\"%s created by IVCON.\"\n",
fileout_name );
13952 fprintf ( fileout,
"VARIABLES = \"X\", \"Y\", \"Z\", \"R\", \"G\", \"B\"\n" );
13954 "ZONE T=\"TRIANGLES\", N=%d, E=%d, F=FEPOINT, ET=TRIANGLE\n",
13961 for ( icor3 = 0; icor3 <
cor3_num; icor3++ ) {
13966 fprintf ( fileout,
"%f %f %f %f %f %f\n",
cor3[0][icor3],
cor3[1][icor3],
13967 cor3[2][icor3], r, g, b );
13973 for ( iface = 0; iface <
face_num; iface++ ) {
13977 for ( j = 0; j <
face_order[iface] - 2; j++ ) {
13979 face2[0] =
face[ 0][iface] + 1;
13980 face2[1] =
face[j+1][iface] + 1;
13981 face2[2] =
face[j+2][iface] + 1;
13983 fprintf ( fileout,
"%d %d %d\n", face2[0], face2[1], face2[2] );
13993 printf (
"TEC_WRITE - Wrote %d text lines.\n",
text_num );
14056 for (
i = 0;
i < 4;
i++ ) {
14057 for ( j = 0; j < 4; j++ ) {
14070 void tmat_mxm (
float a[4][4],
float b[4][4],
float c[4][4] )
14113 for (
i = 0;
i < 4;
i++ ) {
14114 for (
k = 0;
k < 4;
k++ ) {
14116 for ( j = 0; j < 4; j++ ) {
14117 d[
i][
k] = d[
i][
k] + a[
i][j] * b[j][
k];
14122 for (
i = 0;
i < 4;
i++ ) {
14123 for ( j = 0; j < 4; j++ ) {
14170 for (
i = 0;
i < 3;
i++ ) {
14172 for ( j = 0; j < 3; j++ ) {
14173 z[
i] = z[
i] + a[
i][j] * x[j];
14177 for (
i = 0;
i < 3;
i++ ) {
14184 void tmat_mxp2 (
float a[4][4],
float x[][3],
float y[][3],
int n )
14224 for (
k = 0;
k < n;
k++ ) {
14226 for (
i = 0;
i < 3;
i++ ) {
14228 for ( j = 0; j < 3; j++ ) {
14229 z[
i] = z[
i] + a[
i][j] * x[
k][j];
14233 for (
i = 0;
i < 3;
i++ ) {
14281 for (
i = 0;
i < 3;
i++ ) {
14283 for ( j = 0; j < 3; j++ ) {
14284 z[
i] = z[
i] + a[
i][j] * x[j];
14286 z[
i] = z[
i] + a[
i][3];
14289 for (
i = 0;
i < 3;
i++ ) {
14343 if ( axis ==
'X' || axis ==
'x' ) {
14344 c[1][1] = cos ( theta );
14345 c[1][2] = - sin ( theta );
14346 c[2][1] = sin ( theta );
14347 c[2][2] = cos ( theta );
14349 else if ( axis ==
'Y' || axis ==
'y' ) {
14350 c[0][0] = cos ( theta );
14351 c[0][2] = sin ( theta );
14352 c[2][0] = - sin ( theta );
14353 c[2][2] = cos ( theta );
14355 else if ( axis ==
'Z' || axis ==
'z' ) {
14356 c[0][0] = cos ( theta );
14357 c[0][1] = - sin ( theta );
14358 c[1][0] = sin ( theta );
14359 c[1][1] = cos ( theta );
14363 printf (
"TMAT_ROT_AXIS - Fatal error!\n" );
14364 printf (
" Illegal rotation axis: %c.\n", axis );
14365 printf (
" Legal choices are 'X', 'Y', or 'Z'.\n" );
14371 for (
i = 0;
i < 4;
i++ ) {
14372 for ( j = 0; j < 4; j++ ) {
14381 float v1,
float v2,
float v3 )
14426 if ( v1 * v1 + v2 * v2 + v3 * v3 == 0.0 ) {
14434 ca = cos ( theta );
14435 sa = sin ( theta );
14437 c[0][0] = v1 * v1 + ca * ( 1.0 - v1 * v1 );
14438 c[0][1] = ( 1.0 - ca ) * v1 * v2 - sa * v3;
14439 c[0][2] = ( 1.0 - ca ) * v1 * v3 + sa * v2;
14441 c[1][0] = ( 1.0 - ca ) * v2 * v1 + sa * v3;
14442 c[1][1] = v2 * v2 + ca * ( 1.0 - v2 * v2 );
14443 c[1][2] = ( 1.0 - ca ) * v2 * v3 - sa * v1;
14445 c[2][0] = ( 1.0 - ca ) * v3 * v1 - sa * v2;
14446 c[2][1] = ( 1.0 - ca ) * v3 * v2 + sa * v1;
14447 c[2][2] = v3 * v3 + ca * ( 1.0 - v3 * v3 );
14451 for (
i = 0;
i < 4;
i++ ) {
14452 for ( j = 0; j < 4; j++ ) {
14508 for (
i = 0;
i < 4;
i++ ) {
14509 for ( j = 0; j < 4; j++ ) {
14517 void tmat_shear (
float a[4][4],
float b[4][4],
char *axis,
float s )
14567 if ( strcmp ( axis,
"XY" ) == 0 || strcmp ( axis,
"xy" ) == 0 ) {
14570 else if ( strcmp ( axis,
"XZ" ) == 0 || strcmp ( axis,
"xz" ) == 0 ) {
14573 else if ( strcmp ( axis,
"YX" ) == 0 || strcmp ( axis,
"yx" ) == 0 ) {
14576 else if ( strcmp ( axis,
"YZ" ) == 0 || strcmp ( axis,
"yz" ) == 0 ) {
14579 else if ( strcmp ( axis,
"ZX" ) == 0 || strcmp ( axis,
"zx" ) == 0 ) {
14582 else if ( strcmp ( axis,
"ZY" ) == 0 || strcmp ( axis,
"zy" ) == 0 ) {
14587 printf (
"TMAT_SHEAR - Fatal error!\n" );
14588 printf (
" Illegal shear axis: %s.\n", axis );
14589 printf (
" Legal choices are XY, XZ, YX, YZ, ZX, or ZY.\n" );
14595 for (
i = 0;
i < 4;
i++ ) {
14596 for ( j = 0; j < 4; j++ ) {
14642 for (
i = 0;
i < 4;
i++ ) {
14643 for ( j = 0; j < 4; j++ ) {
14647 b[0][3] = b[0][3] + x;
14648 b[1][3] = b[1][3] + y;
14649 b[2][3] = b[2][3] + z;
14704 sscanf (
input,
"%d", &face_num2 );
14711 for ( iface = iface_lo; iface < iface_hi; iface++ ) {
14720 for ( ivert = 0; ivert <
face_order[iface]; ivert++ ) {
14724 sscanf (
input,
"%e %e %e %e %e %e", &r1, &r2, &r3, &r4, &r5, &r6 );
14737 if ( icor3 == -1 ) {
14752 face[ivert][iface] = icor3;
14821 for ( iface = 0; iface <
face_num; iface++ ) {
14822 for ( jlo = 0; jlo <
face_order[iface] - 2; jlo ++ ) {
14823 face_num2 = face_num2 + 1;
14827 fprintf ( fileout,
"%d\n", face_num2 );
14832 for ( iface = 0; iface <
face_num; iface++ ) {
14836 for ( jlo = 0; jlo <
face_order[iface] - 2; jlo ++ ) {
14838 face2[0] =
face[ 0][iface];
14839 face2[1] =
face[jlo+1][iface];
14840 face2[2] =
face[jlo+2][iface];
14842 for (
k = 0;
k < 3;
k++ ) {
14846 x =
cor3[0][icor3];
14847 y =
cor3[1][icor3];
14848 z =
cor3[2][icor3];
14854 fprintf ( fileout,
"%f %f %f %f %f %f\n", x, y, z, nx, ny, nz );
14867 printf (
"TRIA_WRITE - Wrote %d text lines.\n",
text_num );
14924 for ( iface = iface_lo; iface < iface_hi; iface++ ) {
14931 for ( ivert = 0; ivert <
face_order[iface]; ivert++ ) {
14933 for (
i = 0;
i < 3;
i++ ) {
14945 if ( icor3 == -1 ) {
14960 face[ivert][iface] = icor3;
14963 for (
i = 0;
i < 3;
i++ ) {
15038 for ( iface = 0; iface <
face_num; iface++ ) {
15039 for ( jlo = 0; jlo <
face_order[iface] - 2; jlo ++ ) {
15040 face_num2 = face_num2 + 1;
15048 for ( iface = 0; iface <
face_num; iface++ ) {
15052 for ( jlo = 0; jlo <
face_order[iface] - 2; jlo ++ ) {
15054 face2[0] =
face[ 0][iface];
15055 face2[1] =
face[jlo+1][iface];
15056 face2[2] =
face[jlo+2][iface];
15058 for (
k = 0;
k < 3;
k++ ) {
15062 x =
cor3[0][icor3];
15063 y =
cor3[1][icor3];
15064 z =
cor3[2][icor3];
15086 printf (
"TRIB_WRITE - Wrote %d bytes.\n",
bytes_num );
15120 fprintf ( fileout,
"%s created by IVCON.\n",
fileout_name );
15121 fprintf ( fileout,
"Original data in %s.\n",
filein_name );
15122 fprintf ( fileout,
"Object name is %s.\n",
object_name );
15123 fprintf ( fileout,
"Object origin at %f %f %f.\n",
origin[0],
origin[1],
15125 fprintf ( fileout,
"Object pivot at %f %f %f.\n",
pivot[0],
pivot[1],
15131 fprintf ( fileout,
"\n" );
15132 fprintf ( fileout,
"Transformation matrix:\n" );
15133 fprintf ( fileout,
"\n" );
15136 for (
i = 0;
i < 4;
i++ ) {
15144 fprintf ( fileout,
"\n" );
15145 fprintf ( fileout,
" %d nodes.\n",
cor3_num );
15150 fprintf ( fileout,
"\n" );
15151 fprintf ( fileout,
" Node coordinate data:\n" );
15152 fprintf ( fileout,
"\n" );
15156 fprintf ( fileout,
" %d %f %f %f\n ",
i,
cor3[0][
i],
cor3[1][
i],
15161 fprintf ( fileout,
"\n" );
15162 fprintf ( fileout,
" Node normal vectors:\n" );
15163 fprintf ( fileout,
"\n" );
15167 fprintf ( fileout,
" %d %f %f %f\n ",
i,
cor3_normal[0][
i],
15172 fprintf ( fileout,
"\n" );
15173 fprintf ( fileout,
" Node materials:\n" );
15174 fprintf ( fileout,
"\n" );
15183 fprintf ( fileout,
"\n" );
15184 fprintf ( fileout,
" Node texture coordinates:\n" );
15185 fprintf ( fileout,
"\n" );
15198 fprintf ( fileout,
"\n" );
15199 fprintf ( fileout,
" %d line data items.\n",
line_num );
15204 fprintf ( fileout,
"\n" );
15205 fprintf ( fileout,
" Line index data:\n" );
15206 fprintf ( fileout,
"\n" );
15211 for ( iline = 0; iline <
line_num; iline++ ) {
15213 fprintf ( fileout,
" %d",
line_dex[iline] );
15218 fprintf ( fileout,
"\n" );
15224 fprintf ( fileout,
"\n" );
15225 fprintf ( fileout,
" Line materials:\n" );
15226 fprintf ( fileout,
"\n" );
15231 for ( iline = 0; iline <
line_num; iline++ ) {
15238 fprintf ( fileout,
"\n" );
15247 fprintf ( fileout,
"\n" );
15248 fprintf ( fileout,
" %d colors.\n",
color_num );
15253 fprintf ( fileout,
"\n" );
15254 fprintf ( fileout,
" %d faces.\n",
face_num );
15259 fprintf ( fileout,
"\n" );
15260 fprintf ( fileout,
" Face, Material, Number of vertices, Smoothing, Flags:\n" );
15261 fprintf ( fileout,
"\n" );
15264 for ( iface = 0; iface <
face_num; iface++ ) {
15265 fprintf ( fileout,
" %d %d %d %d %d\n", iface,
face_material[iface],
15270 fprintf ( fileout,
"\n" );
15271 fprintf ( fileout,
" Face, Vertices\n" );
15272 fprintf ( fileout,
"\n" );
15275 for ( iface = 0; iface <
face_num; iface++ ) {
15277 fprintf ( fileout,
"%d ", iface );
15278 for ( ivert = 0; ivert <
face_order[iface]; ivert++ ) {
15279 fprintf ( fileout,
" %d",
face[ivert][iface] );
15282 fprintf ( fileout,
"\n" );
15286 fprintf ( fileout,
"\n" );
15287 fprintf ( fileout,
" Face normal vectors:\n" );
15288 fprintf ( fileout,
"\n" );
15291 for ( iface = 0; iface <
face_num; iface++ ) {
15292 fprintf ( fileout,
" %d %f %f %f\n", iface,
face_normal[0][iface],
15299 fprintf ( fileout,
"\n" );
15300 fprintf ( fileout,
" Face texture coordinates:\n" );
15301 fprintf ( fileout,
"\n" );
15304 for ( iface = 0; iface <
face_num; iface++ ) {
15305 fprintf ( fileout,
" %d %f %f\n", iface,
face_tex_uv[0][iface],
15316 fprintf ( fileout,
"\n" );
15317 fprintf ( fileout,
"Vertex normal vectors:\n" );
15320 for ( iface = 0; iface <
face_num; iface++ ) {
15321 fprintf ( fileout,
"\n" );
15323 for ( ivert = 0; ivert <
face_order[iface]; ivert++ ) {
15324 fprintf ( fileout,
" %d %d %f %f %f\n", iface, ivert,
15331 fprintf ( fileout,
"\n" );
15332 fprintf ( fileout,
"Vertex materials:\n" );
15333 fprintf ( fileout,
"\n" );
15336 for ( iface = 0; iface <
face_num; iface++ ) {
15337 fprintf ( fileout,
"%d", iface );
15338 for ( ivert = 0; ivert <
face_order[iface]; ivert++ ) {
15341 fprintf ( fileout,
"\n" );
15347 fprintf ( fileout,
"\n" );
15348 fprintf ( fileout,
"Vertex UV texture coordinates:\n" );
15349 fprintf ( fileout,
"\n" );
15352 for ( iface = 0; iface <
face_num; iface++ ) {
15353 for ( ivert = 0; ivert <
face_order[iface]; ivert++ ) {
15354 fprintf ( fileout,
"%d %d %f %f\n", iface, ivert,
15364 fprintf ( fileout,
"\n" );
15366 fprintf ( fileout,
"\n" );
15367 fprintf ( fileout,
"Index Name R G B A\n" );
15368 fprintf ( fileout,
"\n" );
15373 fprintf ( fileout,
"%d %s %f %f %f %f\n", imat,
material_name[imat],
15381 fprintf ( fileout,
"\n" );
15382 fprintf ( fileout,
"%d textures.\n",
texture_num );
15386 fprintf ( fileout,
"\n" );
15387 fprintf ( fileout,
"Index Name\n" );
15388 fprintf ( fileout,
"\n" );
15398 printf (
"TXT_WRITE - Wrote %d text lines.\n",
text_num );
15478 fprintf ( fileout,
"# %s created by IVREAD.\n",
fileout_name );
15479 fprintf ( fileout,
"#\n" );
15480 fprintf ( fileout,
"# Material RGB to Hue map:\n" );
15481 fprintf ( fileout,
"#\n" );
15482 fprintf ( fileout,
"# material R G B Alpha Hue\n" );
15483 fprintf ( fileout,
"#\n" );
15493 fprintf ( fileout,
"# %d %f %f %f %f %f\n", j, r, g, b, a, h );
15497 fprintf ( fileout,
"#\n" );
15498 fprintf ( fileout,
"# The node data is\n" );
15499 fprintf ( fileout,
"# node # / material # / RGBA / Hue\n" );
15500 fprintf ( fileout,
"#\n" );
15506 for ( j = 0; j <
cor3_num; j++ ) {
15507 fprintf ( fileout,
"%d %f %f %f\n", j,
cor3[0][j],
cor3[1][j],
15516 for ( j = 0; j <
face_num; j++ ) {
15521 fprintf ( fileout,
" tri" );
15524 fprintf ( fileout,
" quad" );
15527 fprintf ( fileout,
" ???" );
15531 fprintf ( fileout,
"%d",
face[
i][j] );
15533 fprintf ( fileout,
"\n" );
15538 fprintf ( fileout,
"3 1 4 1\n" );
15539 fprintf ( fileout,
"material, 0...%d\n",
material_num - 1 );
15540 fprintf ( fileout,
"RGBA, 0-1/0-1/0-1/0-1\n" );
15541 fprintf ( fileout,
"Hue, 0-1\n" );
15544 for ( j = 0; j <
cor3_num; j++ ) {
15552 fprintf ( fileout,
"%d %d %f %f %f %f %f\n", j, imat, r, g, b, a, h );
15559 printf (
"UCD_WRITE - Wrote %d text lines.\n",
text_num );
15615 for ( iface = 0; iface <
face_num; iface++ ) {
15617 for ( ivert = 0; ivert <
face_order[iface]; ivert++ ) {
15620 for (
i = 0;
i < 3;
i++ ) {
15622 norm = norm + temp * temp;
15624 norm = ( float ) sqrt ( norm );
15626 if ( norm == 0.0 ) {
15630 i0 =
face[ivert][iface];
15639 i1 =
face[jp1][iface];
15648 i2 =
face[jp2][iface];
15653 xc = ( y1 - y0 ) * ( z2 - z0 ) - ( z1 - z0 ) * ( y2 - y0 );
15654 yc = ( z1 - z0 ) * ( x2 - x0 ) - ( x1 - x0 ) * ( z2 - z0 );
15655 zc = ( x1 - x0 ) * ( y2 - y0 ) - ( y1 - y0 ) * ( x2 - x0 );
15657 norm = ( float ) sqrt ( xc * xc + yc * yc + zc * zc );
15659 if ( norm == 0.0 ) {
15660 xc = ( float ) 1.0 / sqrt ( 3.0 );
15661 yc = ( float ) 1.0 / sqrt ( 3.0 );
15662 zc = ( float ) 1.0 / sqrt ( 3.0 );
15680 printf (
"VERTEX_NORMAL_SET: Recomputed %d face vertex normals.\n", nfix );
15715 for ( iface = 0; iface <
face_num; iface++ ) {
15755 for ( iface = 0; iface <
face_num; iface++ ) {
15756 for ( ivert = 0; ivert <
face_order[iface]; ivert++ ) {
15757 node =
face[ivert][iface];
15833 for ( next =
input; *next !=
'\0' && isspace(*next); next++ ) {
15838 if ( *next ==
'\0' || *next ==
';' ) {
15844 sscanf ( next,
"%s%n", token, &width );
15848 next = next + width;
15852 if (
leqi ( token,
"set" ) ==
TRUE ) {
15860 if (
leqi ( token,
"P" ) ==
TRUE ) {
15870 sscanf ( next,
"%e %e %e", &r1, &r2, &r3 );
15883 if ( icor3 == -1 ) {
15888 for (
i = 0;
i < 3;
i++ ) {
15909 printf (
"VLA_READ - Fatal error!\n" );
15910 printf (
" Unrecognized first word on line.\n" );
15979 float intense = 1.0;
15987 fprintf ( fileout,
"set comment %s created by IVCON.\n",
fileout_name );
15988 fprintf ( fileout,
"set comment Original data in %s.\n",
filein_name );
15989 fprintf ( fileout,
"set comment\n" );
15990 fprintf ( fileout,
"set intensity EXPLICIT\n" );
15991 fprintf ( fileout,
"set parametric NON_PARAMETRIC\n" );
15992 fprintf ( fileout,
"set filecontent LINES\n" );
15993 fprintf ( fileout,
"set filetype NEW\n" );
15994 fprintf ( fileout,
"set depthcue 0\n" );
15995 fprintf ( fileout,
"set defaultdraw stellar\n" );
15996 fprintf ( fileout,
"set coordsys RIGHT\n" );
15997 fprintf ( fileout,
"set author IVCON\n" );
15998 fprintf ( fileout,
"set site Buhl Planetarium\n" );
15999 fprintf ( fileout,
"set library_id UNKNOWN\n" );
16005 for ( iline = 0; iline <
line_num; iline++ ) {
16015 fprintf ( fileout,
"%c %f %f %f %f\n",
16027 printf (
"VLA_WRITE - Wrote %d text lines.\n",
text_num );
16120 fprintf ( fileout,
"#VRML V2.0 utf8\n" );
16121 fprintf ( fileout,
"\n" );
16122 fprintf ( fileout,
" WorldInfo {\n" );
16124 fprintf ( fileout,
" info \"WRL file generated by IVREAD.\"\n" );
16125 fprintf ( fileout,
" info \"Original data in %s\"\n",
filein_name );
16126 fprintf ( fileout,
" }\n" );
16127 fprintf ( fileout,
"\n" );
16128 fprintf ( fileout,
" Group {\n" );
16129 fprintf ( fileout,
" children [\n" );
16130 fprintf ( fileout,
" Shape {\n" );
16131 fprintf ( fileout,
" appearance Appearance {\n" );
16132 fprintf ( fileout,
" material Material {\n" );
16133 fprintf ( fileout,
" diffuseColor 0.0 0.0 0.0\n" );
16134 fprintf ( fileout,
" emissiveColor 0.0 0.0 0.0\n" );
16135 fprintf ( fileout,
" shininess 1.0\n" );
16136 fprintf ( fileout,
" }\n" );
16137 fprintf ( fileout,
" }\n" );
16145 fprintf ( fileout,
" geometry IndexedLineSet {\n" );
16149 fprintf ( fileout,
" coord Coordinate {\n" );
16150 fprintf ( fileout,
" point [\n" );
16154 for ( icor3 = 0; icor3 <
cor3_num; icor3++ ) {
16155 fprintf ( fileout,
" %f %f %f\n",
cor3[0][icor3],
16160 fprintf ( fileout,
" ]\n" );
16161 fprintf ( fileout,
" }\n" );
16166 fprintf ( fileout,
" coordIndex [\n" );
16171 for ( j = 0; j <
line_num; j++ ) {
16172 fprintf ( fileout,
"%d ",
line_dex[j] );
16173 length = length + 1;
16175 fprintf ( fileout,
"\n" );
16181 fprintf ( fileout,
" ]\n" );
16186 fprintf ( fileout,
" color Color {\n" );
16187 fprintf ( fileout,
" color [\n" );
16196 fprintf ( fileout,
" ]\n" );
16197 fprintf ( fileout,
" }\n" );
16198 fprintf ( fileout,
" colorPerVertex TRUE\n" );
16202 fprintf ( fileout,
" colorIndex [\n" );
16207 for ( j = 0; j <
line_num; j++ ) {
16209 length = length + 1;
16211 fprintf ( fileout,
"\n" );
16217 fprintf ( fileout,
" ]\n" );
16218 fprintf ( fileout,
" }\n" );
16229 fprintf ( fileout,
" geometry IndexedFaceSet {\n" );
16233 fprintf ( fileout,
" coord Coordinate {\n" );
16234 fprintf ( fileout,
" point [\n" );
16238 for ( icor3 = 0; icor3 <
cor3_num; icor3++ ) {
16239 fprintf ( fileout,
" %f %f %f\n",
cor3[0][icor3],
16245 fprintf ( fileout,
" ]\n" );
16246 fprintf ( fileout,
" }\n" );
16250 fprintf ( fileout,
" coordIndex [\n" );
16256 for ( iface = 0; iface <
face_num; iface++ ) {
16258 for ( ivert = 0; ivert <=
face_order[iface]; ivert++ ) {
16261 itemp =
face[ivert][iface];
16267 fprintf ( fileout,
"%d ", itemp );
16268 length = length + 1;
16270 if ( itemp == -1 || length >= 10 ||
16272 fprintf ( fileout,
"\n" );
16281 fprintf ( fileout,
" ]\n" );
16286 fprintf ( fileout,
" colorIndex [\n" );
16292 for ( iface = 0; iface <
face_num; iface++ ) {
16294 for ( ivert = 0; ivert <=
face_order[iface]; ivert++ ) {
16304 fprintf ( fileout,
"%d ", itemp );
16305 length = length + 1;
16307 if ( itemp == -1 || length >= 10 ||
16310 fprintf ( fileout,
"\n" );
16320 fprintf ( fileout,
" ]\n" );
16321 fprintf ( fileout,
" }\n" );
16333 fprintf ( fileout,
" }\n" );
16334 fprintf ( fileout,
" ]\n" );
16335 fprintf ( fileout,
" }\n" );
16342 printf (
"WRL_WRITE - Wrote %d text lines.\n",
text_num );
16511 float light_ambient_rgb[3];
16512 float light_diffuse_rgb[3];
16513 float light_direction[3];
16514 float light_specular_rgb[3];
16516 float material_alpha;
16517 float material_amb_rgb[3];
16518 float material_diff_rgb[3];
16519 float material_emiss_rgb[3];
16520 float material_shine;
16521 float material_spec_rgb[3];
16525 float transform_forward[3];
16526 float transform_position[3];
16527 float transform_scale[3];
16528 float transform_up[3];
16532 light_ambient_rgb[0] = 0.2;
16533 light_ambient_rgb[1] = 0.1;
16534 light_ambient_rgb[2] = 0.1;
16536 light_diffuse_rgb[0] = 0.1;
16537 light_diffuse_rgb[1] = 0.2;
16538 light_diffuse_rgb[2] = 0.1;
16540 light_direction[0] = 0.0;
16541 light_direction[1] = 0.0;
16542 light_direction[2] = 100.0;
16544 light_specular_rgb[0] = 0.1;
16545 light_specular_rgb[1] = 0.1;
16546 light_specular_rgb[2] = 0.2;
16548 material_alpha = 0.9;
16550 material_amb_rgb[0] = 0.1;
16551 material_amb_rgb[1] = 0.1;
16552 material_amb_rgb[2] = 0.1;
16554 material_diff_rgb[0] = 0.2;
16555 material_diff_rgb[1] = 0.1;
16556 material_diff_rgb[2] = 0.1;
16558 material_emiss_rgb[0] = 0.1;
16559 material_emiss_rgb[1] = 0.2;
16560 material_emiss_rgb[2] = 0.1;
16562 material_shine = 0.8;
16564 material_spec_rgb[0] = 0.1;
16565 material_spec_rgb[1] = 0.1;
16566 material_spec_rgb[2] = 0.2;
16568 transform_forward[0] = 0.0;
16569 transform_forward[1] = 0.0;
16570 transform_forward[2] = 0.0;
16572 transform_position[0] = 0.0;
16573 transform_position[1] = 0.0;
16574 transform_position[2] = 0.0;
16576 transform_scale[0] = 1.0;
16577 transform_scale[1] = 1.0;
16578 transform_scale[2] = 1.0;
16580 transform_up[0] = 1.0;
16581 transform_up[1] = 1.0;
16582 transform_up[2] = 1.0;
16588 fprintf ( fileout,
"<WORLD>\n" );
16589 fprintf ( fileout,
"\n" );
16593 fprintf ( fileout,
" <BACKGROUND>\n" );
16594 fprintf ( fileout,
" <BACKCOLOR> %f, %f, %f </BACKCOLOR>\n",
16596 fprintf ( fileout,
" </BACKGROUND>\n" );
16597 fprintf ( fileout,
"\n" );
16598 fprintf ( fileout,
" <LIGHTING>\n" );
16599 fprintf ( fileout,
" <AMBIENT> %f, %f, %f </AMBIENT>\n",
16600 light_ambient_rgb[0], light_ambient_rgb[1], light_ambient_rgb[2] );
16601 fprintf ( fileout,
" <DIRECTIONALLIGHT>\n" );
16602 fprintf ( fileout,
" <DIFFUSE> %f, %f, %f </DIFFUSE>\n",
16603 light_diffuse_rgb[0], light_diffuse_rgb[1], light_diffuse_rgb[2] );
16604 fprintf ( fileout,
" <DIRECTION> %f, %f, %f </DIRECTION>\n",
16605 light_direction[0], light_direction[1], light_direction[2] );
16606 fprintf ( fileout,
" <SPECULAR> %f, %f, %f </SPECULAR>\n",
16607 light_specular_rgb[0], light_specular_rgb[1], light_specular_rgb[2] );
16608 fprintf ( fileout,
" </DIRECTIONALLIGHT>\n" );
16609 fprintf ( fileout,
" </LIGHTING>\n" );
16613 for ( mesh = 0; mesh < mesh_num; mesh++ ) {
16615 fprintf ( fileout,
"\n" );
16616 fprintf ( fileout,
" <MESH ID = \"%d\">\n", mesh );
16617 fprintf ( fileout,
"\n" );
16620 for ( j = 0; j <
cor3_num; j++ ) {
16621 fprintf ( fileout,
" <P ID=\"%d\"> %f, %f, %f </P>\n", j,
16626 fprintf ( fileout,
"\n" );
16628 for ( j = 0; j <
cor3_num; j++ ) {
16629 fprintf ( fileout,
" <N ID=\"%d\"> %f, %f, %f </N>\n", j,
16634 for ( material = 0; material <
material_num; material++ ) {
16635 fprintf ( fileout,
"\n" );
16636 fprintf ( fileout,
" <MAT ID=\"%d\">\n", material );
16637 fprintf ( fileout,
" <ALPHA> %f </ALPHA>\n", material_alpha );
16638 fprintf ( fileout,
" <AMB> %f, %f, %f </AMB>\n",
16639 material_amb_rgb[0], material_amb_rgb[1], material_amb_rgb[2] );
16640 fprintf ( fileout,
" <DIFF> %f, %f, %f </DIFF>\n",
16641 material_diff_rgb[0], material_diff_rgb[1], material_diff_rgb[2] );
16642 fprintf ( fileout,
" <EMISS> %f, %f, %f </EMISS>\n",
16643 material_emiss_rgb[0], material_emiss_rgb[1], material_emiss_rgb[2] );
16644 fprintf ( fileout,
" <SHINE> %f </SHINE>\n", material_shine );
16645 fprintf ( fileout,
" <SPEC> %f, %f, %f </SPEC>\n",
16646 material_spec_rgb[0], material_spec_rgb[1], material_spec_rgb[2] );
16647 fprintf ( fileout,
" </MAT>\n" );
16651 fprintf ( fileout,
"\n" );
16654 for ( iface = 0; iface <
face_num; iface++ ) {
16655 fprintf ( fileout,
" <F>\n" );
16656 fprintf ( fileout,
" <MATREF> %d </MATREF>\n",
face_material[iface] );
16658 for ( ivert = 0; ivert <
face_order[iface]; ivert++ ) {
16660 " <FV%d><PREF> %d </PREF><NREF> %d </NREF></FV%d>\n",
16661 ivert+1,
face[ivert][iface],
face[ivert][iface], ivert+1 );
16664 fprintf ( fileout,
" </F>\n" );
16668 fprintf ( fileout,
" </MESH>\n" );
16673 fprintf ( fileout,
"\n" );
16676 for (
object = 0;
object <
object_num;
object++ ) {
16678 fprintf ( fileout,
" <OBJECT>\n" );
16679 fprintf ( fileout,
" <TRANSFORM>\n" );
16680 fprintf ( fileout,
" <FORWARD> %f, %f, %f </FORWARD>\n",
16681 transform_forward[0], transform_forward[1], transform_forward[2] );
16682 fprintf ( fileout,
" <POSITION> %f, %f, %f </POSITION>\n",
16683 transform_position[0], transform_position[1], transform_position[2] );
16684 fprintf ( fileout,
"' <SCALE> %f, %f, %f </SCALE>\n",
16685 transform_scale[0], transform_scale[1], transform_scale[2] );
16686 fprintf ( fileout,
" <UP> %f, %f, %f </UP>\n",
16687 transform_up[0], transform_up[1], transform_up[2] );
16688 fprintf ( fileout,
" </TRANSFORM>\n" );
16690 fprintf ( fileout,
" <MESHREF> %d </MESHREF>\n", mesh );
16691 fprintf ( fileout,
" </OBJECT>\n" );
16696 fprintf ( fileout,
"\n" );
16697 fprintf ( fileout,
"</WORLD>\n" );
16704 printf (
"XGL_WRITE - Wrote %d text lines.\n",
text_num );