23 #define PARSE_INTERNAL 27 #define ERROR_READBUF_SIZE 65536 32 static int stringcmp(
const char * a,
const char * b) {
42 if (toupper(a[i]) != b[i]) {
54 ph->textable = (texentry *) malloc(ph->maxtextures *
sizeof(texentry));
55 memset(ph->textable, 0, ph->maxtextures *
sizeof(texentry));
75 for (i=0; i<ph->numtextures; i++) {
76 free(ph->textable[i].name);
85 static errcode
add_texture(parsehandle * ph,
void * tex,
const char * name) {
86 ph->textable[ph->numtextures].tex=tex;
87 ph->textable[ph->numtextures].name = malloc(strlen(name) + 1);
88 strcpy(ph->textable[ph->numtextures].name, name);
89 rt_hash_insert(&ph->texhash, ph->textable[ph->numtextures].name, ph->numtextures);
92 if (ph->numtextures >= ph->maxtextures) {
96 newsize = 2 * ph->maxtextures;
97 newblock = realloc(ph->textable, newsize *
sizeof(texentry));
98 if (newblock != NULL) {
99 ph->maxtextures = newsize;
100 ph->textable = newblock;
103 printf(
"Parse: %d textures allocated, texture slots full!\n", ph->numtextures);
117 return ph->textable[i].tex;
120 printf(
"Undefined texture '%s', using default. \n", name);
121 return(ph->defaulttex.tex);
126 tmp=deg * 3.1415926 / 180.0;
140 rot->rx1=cos(y)*cos(z);
141 rot->rx2=sin(x)*sin(y)*cos(z) - cos(x)*sin(z);
142 rot->rx3=sin(x)*sin(z) + cos(x)*cos(z)*sin(y);
144 rot->ry1=cos(y)*sin(z);
145 rot->ry2=cos(x)*cos(z) + sin(x)*sin(y)*sin(z);
146 rot->ry3=cos(x)*sin(y)*sin(z) - sin(x)*cos(z);
149 rot->rz2=sin(x)*cos(y);
150 rot->rz3=cos(x)*cos(y);
155 tmp.
x=(vec->
x*(rot->rx1) + vec->
y*(rot->rx2) + vec->
z*(rot->rx3));
156 tmp.
y=(vec->
x*(rot->ry1) + vec->
y*(rot->ry2) + vec->
z*(rot->ry3));
157 tmp.
z=(vec->
x*(rot->rz1) + vec->
y*(rot->rz2) + vec->
z*(rot->rz3));
162 vec->
x=vec->
x * scale->
x;
163 vec->
y=vec->
y * scale->
y;
164 vec->
z=vec->
z * scale->
z;
174 const char *
string,
const char * found) {
175 long streampos, readsize;
176 long i, j, linecount;
179 streampos = ftell(ph->ifp);
182 fseek(ph->ifp, 0, SEEK_SET);
186 while (i < streampos) {
190 readsize = streampos - i;
193 fread(cbuf, readsize, 1, ph->ifp);
195 for (j=0; j<readsize; j++) {
196 if (cbuf[j] ==
'\n') {
202 printf(
"Parse Error:\n");
203 printf(
" Encountered a syntax error in file %s\n", ph->filename);
204 printf(
" Expected to find %s\n",
string);
205 printf(
" Actually found: %s\n", found);
206 printf(
" Error occured at or prior to file offset %ld, line %ld\n",
207 streampos, linecount);
208 printf(
" Error position is only approximate, but should be close\n\n");
210 fseek(ph->ifp, streampos, SEEK_SET);
213 static errcode
GetString(parsehandle * ph,
const char *
string) {
216 fscanf(ph->ifp,
"%s", data);
230 memset(&ph, 0,
sizeof(ph));
232 ph.filename = modelfile;
233 ph.ifp=fopen(modelfile,
"r");
234 if (ph.ifp == NULL) {
246 fscanf(ph.ifp,
"%s", tmp);
254 if (c == EOF || c ==
'\n')
266 ph.numobjectsparsed=0;
268 ph.numobjectsparsed++;
284 const char * oldfilename = ph->filename;
285 FILE * oldfp = ph->ifp;
287 if (strcmp(includefile, ph->filename) == 0) {
288 printf(
"Warning: possible self-recursive include of file %s\n",
292 ph->filename=includefile;
293 ph->ifp=fopen(includefile,
"r");
294 if (ph->ifp == NULL) {
295 printf(
"Parser failed trying to open file: %s\n", includefile);
298 ph->filename=oldfilename;
305 ph->numobjectsparsed++;
310 ph->filename=oldfilename;
325 fscanf(ph->ifp,
"%d %d", &xres, &yres);
338 fscanf(ph->ifp,
"%s", data);
348 printf(
"Bad token '%s' while reading shader mode block\n", data);
353 fscanf(ph->ifp,
"%s", data);
354 if (!
stringcmp(data,
"END_SHADER_MODE")) {
356 }
else if (!
stringcmp(data,
"SHADOW_FILTER_ON")) {
358 }
else if (!
stringcmp(data,
"SHADOW_FILTER_OFF")) {
360 }
else if (!
stringcmp(data,
"TRANS_MAX_SURFACES")) {
362 fscanf(ph->ifp,
"%d", &transmaxsurf);
364 }
else if (!
stringcmp(data,
"TRANS_ORIG")) {
367 }
else if (!
stringcmp(data,
"TRANS_RASTER3D")) {
370 }
else if (!
stringcmp(data,
"TRANS_VMD")) {
373 }
else if (!
stringcmp(data,
"FOG_VMD")) {
375 }
else if (!
stringcmp(data,
"AMBIENT_OCCLUSION")) {
383 fscanf(ph->ifp,
"%s", tmp);
385 fscanf(ph->ifp,
"%f", &maxdist);
388 fscanf(ph->ifp,
"%f %f %f", &aoambient.
r, &aoambient.
g, &aoambient.
b);
389 }
else if (!
stringcmp(tmp,
"AMBIENT_COLOR")) {
390 fscanf(ph->ifp,
"%f %f %f", &aoambient.
r, &aoambient.
g, &aoambient.
b);
394 fscanf(ph->ifp,
"%f", &aodirect);
397 fscanf(ph->ifp,
"%d", &aosamples);
402 printf(
"Bad token '%s' while reading optional shader modes\n", data);
412 apiflt zoom, aspectratio, eyesep;
413 int raydepth, antialiasing;
420 fscanf(ph->ifp,
"%s", data);
421 if (
stringcmp(data,
"PROJECTION") == 0) {
422 fscanf(ph->ifp,
"%s", data);
423 if (
stringcmp(data,
"EQUIRECTANGULAR") == 0) {
425 }
else if (
stringcmp(data,
"FISHEYE") == 0) {
427 }
else if (
stringcmp(data,
"PERSPECTIVE") == 0) {
429 }
else if (
stringcmp(data,
"PERSPECTIVE_DOF") == 0) {
433 fscanf(ph->ifp,
"%f", &a);
436 fscanf(ph->ifp,
"%f", &b);
439 }
else if (
stringcmp(data,
"ORTHOGRAPHIC") ==0) {
441 }
else if (
stringcmp(data,
"STEREO_EQUIRECTANGULAR") == 0) {
444 fscanf(ph->ifp,
"%f", &a);
449 fscanf(ph->ifp,
"%f", &a);
451 }
else if (
stringcmp(data,
"ZOOM") == 0) {
452 fscanf(ph->ifp,
"%f", &a);
460 fscanf(ph->ifp,
"%f", &b);
464 fscanf(ph->ifp,
"%d", &antialiasing);
467 fscanf(ph->ifp,
"%d", &raydepth);
470 fscanf(ph->ifp,
"%f %f %f", &a, &b, &c);
476 fscanf(ph->ifp,
"%f %f %f", &a, &b, &c);
482 fscanf(ph->ifp,
"%f %f %f", &a, &b, &c);
488 Ccenter, Cview, Cup);
495 fscanf(ph->ifp,
"%s", data);
497 fscanf(ph->ifp,
"%f %f %f %f", &a, &b, &c, &d);
499 fscanf(ph->ifp,
"%s", data);
500 if (
stringcmp(data,
"END_CAMERA") != 0) {
504 }
else if (
stringcmp(data,
"END_CAMERA") != 0) {
516 if (fscanf(ph->ifp,
"%s", objtype) == EOF) {
528 if (!
stringcmp(objtype,
"VERTEXARRAY")) {
535 if (!
stringcmp(objtype,
"SPHEREARRAY")) {
536 return GetSphereArray(ph, scene);
545 if (!
stringcmp(objtype,
"POLYCYLINDER")) {
572 if (!
stringcmp(objtype,
"DIRECTIONAL_LIGHT")) {
584 if (!
stringcmp(objtype,
"SHADER_MODE")) {
595 return GetMGFFile(ph, scene);
597 printf(
"MGF File Parsing is not available in this build.\n");
605 if (c == EOF || c ==
'\n')
612 if (!
stringcmp(objtype,
"BACKGROUND_GRADIENT")) {
619 char includefile[FILENAME_MAX];
620 fscanf(ph->ifp,
"%s", includefile);
623 if (!
stringcmp(objtype,
"START_CLIPGROUP")) {
626 if (!
stringcmp(objtype,
"END_CLIPGROUP")) {
638 static errcode
GetInt(parsehandle * ph,
int * i) {
640 if (fscanf(ph->ifp,
"%d", &a) != 1)
651 if (fscanf(ph->ifp,
"%f %f %f", &a, &b, &c) != 3)
662 static errcode GetFloat(parsehandle * ph,
apiflt * f) {
664 if (fscanf(ph->ifp,
"%f", &a) != 1)
678 fscanf(ph->ifp,
"%f %f %f", &r, &g, &b);
687 char texname[TEXNAMELEN];
690 unsigned char *rgb=NULL;
691 int xres=0, yres=0, zres=0;
693 fscanf(ph->ifp,
"%s", texname);
703 rgb = (
unsigned char *) malloc(xres * yres * zres * 3);
709 for (z=0; z<zres; z++) {
710 for (y=0; y<yres; y++) {
711 for (x=0; x<xres; x++) {
713 int red, green, blue;
714 int addr = ((z*xres*yres) + (y*xres) + x) * 3;
717 fscanf(ph->ifp,
"%s", clrstr);
722 switch (strlen(clrstr)) {
724 n = sscanf(clrstr,
"%01x%01x%01x", &red, &green, &blue);
726 green |= (green << 4);
731 n = sscanf(clrstr,
"%02x%02x%02x", &red, &green, &blue);
735 n = sscanf(clrstr,
"%03x%03x%03x", &red, &green, &blue);
742 n = sscanf(clrstr,
"%04x%04x%04x", &red, &green, &blue);
754 rgb[addr ] = red & 0xff;
755 rgb[addr + 1] = green & 0xff;
756 rgb[addr + 2] = blue & 0xff;
769 char texname[TEXNAMELEN];
771 fscanf(ph->ifp,
"%s", texname);
778 char texname[TEXNAMELEN];
779 char aliasname[TEXNAMELEN];
781 fscanf(ph->ifp,
"%s", texname);
782 fscanf(ph->ifp,
"%s", aliasname);
793 fscanf(ph->ifp,
"%s", tmp);
807 float outline, outlinewidth;
808 float phong, phongexp;
823 fscanf(ph->ifp,
"%f", &a);
827 fscanf(ph->ifp,
"%f", &b);
831 fscanf(ph->ifp,
"%f", &c);
835 fscanf(ph->ifp,
"%f", &d);
838 fscanf(ph->ifp,
"%s", tmp);
840 fscanf(ph->ifp,
"%s", tmp);
844 fscanf(ph->ifp,
"%s", tmp);
848 fscanf(ph->ifp,
"%f", &outline);
850 fscanf(ph->ifp,
"%f", &outlinewidth);
851 fscanf(ph->ifp,
"%s", tmp);
855 fscanf(ph->ifp,
"%s", tmp);
864 fscanf(ph->ifp,
"%f", &phong);
866 fscanf(ph->ifp,
"%f", &phongexp);
867 fscanf(ph->ifp,
"%s", tmp);
881 fscanf(ph->ifp,
"%f %f %f", &a, &b, &c);
912 fscanf(ph->ifp,
"%s", tex.
imap);
922 fscanf(ph->ifp,
"%s", tex.
imap);
936 fscanf(ph->ifp,
"%s", tex.
imap);
983 fscanf(ph->ifp,
"%s", tmp);
985 fscanf(ph->ifp,
"%f %f %f", &r, &g, &b);
1010 fscanf(ph->ifp,
"%f", &a);
1013 fscanf(ph->ifp,
"%s", tmp);
1015 fscanf(ph->ifp,
"%f %f %f", &r, &g, &b);
1027 fscanf(ph->ifp,
"%f", &a);
1030 fscanf(ph->ifp,
"%f", &a);
1033 fscanf(ph->ifp,
"%f", &a);
1049 int numsamples = 128;
1056 fscanf(ph->ifp,
"%d", &numsamples);
1059 fscanf(ph->ifp,
"%s", tmp);
1061 fscanf(ph->ifp,
"%f", &maxdist);
1064 fscanf(ph->ifp,
"%f %f %f", &ambcol.
r, &ambcol.
g, &ambcol.
b);
1066 fscanf(ph->ifp,
"%f %f %f", &ambcol.
r, &ambcol.
g, &ambcol.
b);
1090 fscanf(ph->ifp,
"%f", &a);
1096 fscanf(ph->ifp,
"%f",&a);
1099 fscanf(ph->ifp,
"%f", &a);
1102 fscanf(ph->ifp,
"%s", tmp);
1104 fscanf(ph->ifp,
"%f %f %f", &r, &g, &b);
1115 fscanf(ph->ifp,
"%f", &a);
1118 fscanf(ph->ifp,
"%f", &a);
1121 fscanf(ph->ifp,
"%f", &a);
1136 float start, end, density;
1139 fscanf(ph->ifp,
"%s", tmp);
1151 fscanf(ph->ifp,
"%f", &start);
1154 fscanf(ph->ifp,
"%f", &end);
1157 fscanf(ph->ifp,
"%f", &density);
1171 fscanf(ph->ifp,
"%f %f %f", &r, &g, &b);
1182 char gradienttype[1024];
1183 float topval, botval;
1184 float topcol[3], botcol[3];
1188 fscanf(ph->ifp,
"%s", gradienttype);
1191 if (!
stringcmp(gradienttype,
"SKY_SPHERE")) {
1193 }
else if (!
stringcmp(gradienttype,
"SKY_ORTHO_PLANE")) {
1196 printf(
"Expected either a sky sphere or sky ortho plane background\n");
1197 printf(
"gradient texture definition.\n");
1202 fscanf(ph->ifp,
"%f %f %f", &updir[0], &updir[1], &updir[2]);
1205 fscanf(ph->ifp,
"%f", &topval);
1208 fscanf(ph->ifp,
"%f", &botval);
1211 fscanf(ph->ifp,
"%f %f %f", &topcol[0], &topcol[1], &topcol[2]);
1214 fscanf(ph->ifp,
"%f %f %f", &botcol[0], &botcol[1], &botcol[2]);
1217 rt_vector(updir[0], updir[1], updir[2]),
1219 rt_color(topcol[0], topcol[1], topcol[2]),
1220 rt_color(botcol[0], botcol[1], botcol[2]));
1237 fscanf(ph->ifp,
"%f", &a);
1261 axis.
x=pnt2.
x - pnt1.
x;
1262 axis.
y=pnt2.
y - pnt1.
y;
1263 axis.
z=pnt2.
z - pnt1.
z;
1266 fscanf(ph->ifp,
"%f", &a);
1284 fscanf(ph->ifp,
"%d", &numpts);
1288 for (i=0; i<numpts; i++) {
1293 fscanf(ph->ifp,
"%f", &a);
1315 fscanf(ph->ifp,
"%f", &a);
1354 fscanf(ph->ifp,
"%d %d %d ", &x, &y, &z);
1356 fscanf(ph->ifp,
"%s", fname);
1359 rt_scalarvol(scene, tex, min, max, x, y, z, fname, NULL);
1375 rt_box(scene, tex, min, max);
1392 fscanf(ph->ifp,
" %f ", &a);
1394 fscanf(ph->ifp,
" %f ", &b);
1397 rt_ring(scene, tex, ctr, normal, a, b);
1418 rt_tri(scene, tex, v0, v1, v2);
1448 rt_stri(scene, tex, v0, v1, v2, n0, n1, n2);
1480 fscanf(ph->ifp,
"%f %f %f", &a, &b, &c);
1486 fscanf(ph->ifp,
"%f %f %f", &a, &b, &c);
1492 fscanf(ph->ifp,
"%f %f %f", &a, &b, &c);
1499 rt_vcstri(scene, tex, v0, v1, v2, n0, n1, n2, c0, c1, c2);
1506 static errcode GetSphereArray(parsehandle * ph,
SceneHandle scene) {
1507 char arraytype[1024];
1517 rc |=
GetInt(ph, &spherecount);
1521 fscanf(ph->ifp,
"%s", arraytype);
1525 v = (
float *) malloc(spherecount * 3 *
sizeof(
float));
1526 for (i=0; i<spherecount * 3; i+=3) {
1527 fscanf(ph->ifp,
"%f %f %f", &v[i], &v[i+1], &v[i+2]);
1530 printf(
"Expected sphere array centers block\n");
1535 tex = ph->defaulttex.tex;
1536 fscanf(ph->ifp,
"%s", arraytype);
1540 r = (
float *) malloc(spherecount *
sizeof(
float));
1541 for (i=0; i<spherecount; i++) {
1542 fscanf(ph->ifp,
"%f", &r[i]);
1545 printf(
"Expected sphere array radii block\n");
1551 c = (
float *) malloc(spherecount * 3 *
sizeof(
float));
1552 for (i=0; i<spherecount * 3; i+=3) {
1553 fscanf(ph->ifp,
"%f %f %f", &c[i], &c[i+1], &c[i+2]);
1556 printf(
"Expected sphere array colors block\n");
1567 printf(
"Failed to parse vertex array texture block\n");
1574 for (i=0; i<spherecount * 3; i+=3) {
1585 char arraytype[1024];
1586 int done, i, texusecount;
1595 rc |=
GetInt(ph, &vertexcount);
1599 fscanf(ph->ifp,
"%s", arraytype);
1603 v = (
float *) malloc(vertexcount * 3 *
sizeof(
float));
1604 for (i=0; i<vertexcount * 3; i+=3) {
1605 fscanf(ph->ifp,
"%f %f %f", &v[i], &v[i+1], &v[i+2]);
1607 fscanf(ph->ifp,
"%s", arraytype);
1609 printf(
"Expected vertex array coords block\n");
1615 n = (
float *) malloc(vertexcount * 3 *
sizeof(
float));
1616 for (i=0; i<vertexcount * 3; i+=3) {
1617 fscanf(ph->ifp,
"%f %f %f", &n[i], &n[i+1], &n[i+2]);
1619 fscanf(ph->ifp,
"%s", arraytype);
1622 printf(
"Expected vertex array normals block\n");
1628 tex = ph->defaulttex.tex;
1635 c = (
float *) malloc(vertexcount * 3 *
sizeof(
float));
1636 for (i=0; i<vertexcount * 3; i+=3) {
1637 fscanf(ph->ifp,
"%f %f %f", &c[i], &c[i+1], &c[i+2]);
1640 }
else if (!
stringcmp(arraytype,
"TEXCOORDS3")) {
1643 t = (
float *) malloc(vertexcount * 3 *
sizeof(
float));
1644 for (i=0; i<vertexcount * 3; i++) {
1645 fscanf(ph->ifp,
"%f %f %f", &t[i], &t[i+1], &t[i+2]);
1647 }
else if (!
stringcmp(arraytype,
"TEXCOORDS2")) {
1649 t = (
float *) malloc(vertexcount * 2 *
sizeof(
float));
1650 for (i=0; i<vertexcount * 3; i++) {
1651 fscanf(ph->ifp,
"%f %f", &t[i], &t[i+1]);
1654 }
else if (!
stringcmp(arraytype,
"TEXTURE")) {
1660 printf(
"Failed to parse vertex array texture block\n");
1665 }
else if (!
stringcmp(arraytype,
"TRISTRIP")) {
1668 int stripaddr[2][3] = { {0, 1, 2}, {1, 0, 2} };
1675 facets = (
int *) malloc(numv *
sizeof(
int));
1676 for (i=0; i<numv; i++) {
1677 fscanf(ph->ifp,
"%d", &facets[i]);
1685 for (t=0; t < (numv - 2); t++) {
1687 int v0 = facets[t + (stripaddr[t & 0x01][0])];
1688 int v1 = facets[t + (stripaddr[t & 0x01][1])];
1689 int v2 = facets[t + (stripaddr[t & 0x01][2])];
1691 if ((v0 >= 0) && (v0 < vertexcount) &&
1692 (v1 >= 0) && (v1 < vertexcount) &&
1693 (v2 >= 0) && (v2 < vertexcount)) {
1699 if (texusecount > 0)
1709 rt_color(c[v0], c[v0 + 1], c[v0 + 2]),
1710 rt_color(c[v1], c[v1 + 1], c[v1 + 2]),
1711 rt_color(c[v2], c[v2 + 1], c[v2 + 2]));
1719 rt_vector(n[v2], n[v2 + 1], n[v2 + 2]));
1722 printf(
"tristrip error: skipping invalid strip vertex %d\n", t);
1723 printf(
" vertexcount: %d\n", vertexcount);
1724 printf(
" verts: %d %d %d\n", v0, v1, v2);
1734 }
else if (!
stringcmp(arraytype,
"TRIMESH")) {
1738 rc |=
GetInt(ph, &numfacets);
1742 facets = (
int *) malloc(numfacets * 3 *
sizeof(
int));
1743 for (i=0; i<numfacets*3; i+=3) {
1744 fscanf(ph->ifp,
"%d %d %d", &facets[i], &facets[i+1], &facets[i+2]);
1748 for (i=0; i < numfacets*3; i+=3) {
1749 int v0 = facets[i ];
1750 int v1 = facets[i + 1];
1751 int v2 = facets[i + 2];
1754 if ((v0 >= 0) && (v0 < vertexcount) &&
1755 (v1 >= 0) && (v1 < vertexcount) &&
1756 (v2 >= 0) && (v2 < vertexcount)) {
1762 if (texusecount > 0)
1771 rt_color(c[v0], c[v0 + 1], c[v0 + 2]),
1772 rt_color(c[v1], c[v1 + 1], c[v1 + 2]),
1773 rt_color(c[v2], c[v2 + 1], c[v2 + 2]));
1781 rt_vector(n[v2], n[v2 + 1], n[v2 + 2]));
1784 printf(
"trimesh error: skipping invalid vertex in facet %d\n", i/3);
1785 printf(
" numfacets: %d vertexcount: %d\n", numfacets, vertexcount);
1786 printf(
" verts: %d %d %d\n", v0, v1, v2);
1796 }
else if (!
stringcmp(arraytype,
"END_VERTEXARRAY")) {
1799 printf(
"Unrecognized vertex array block `%s`\n", arraytype);
1805 fscanf(ph->ifp,
"%s", arraytype);
1829 fscanf(ph->ifp,
"%d %d", &m, &n);
1832 fscanf(ph->ifp,
"%f %f", &a, &b);
1874 fscanf(ph->ifp,
"%s", ifname);
1878 if ((ifp=fopen(ifname,
"r")) == NULL) {
1879 printf(
"Can't open data file %s for input!! Aborting...\n", ifname);
1883 while (!feof(ifp)) {
1884 fscanf(ifp,
"%d", &v);
1885 if (v != 3) {
break; }
1906 rt_tri(scene, tex, v1, v0, v2);
1918 if (fscanf(ph->ifp,
"%s", objtype) == EOF) {
1926 if (fscanf(ph->ifp,
"%d", &numplanes) != 1)
1929 planes = (
float *) malloc(numplanes * 4 *
sizeof(
float));
1931 for (i=0; i<(numplanes * 4); i++) {
1932 if (fscanf(ph->ifp,
"%f", &planes[i]) != 1)
1953 static errcode GetMGFFile(parsehandle * ph,
SceneHandle scene) {
1956 fscanf(ph->ifp,
"%s", ifname);
void rt_background_gradient(SceneHandle voidscene, apivector up, flt topval, flt botval, apicolor topcol, apicolor botcol)
Set parameters for gradient (sky plane or sphere) background texturing.
static errcode GetPlane(parsehandle *ph, SceneHandle scene)
static errcode GetBackGndGradient(parsehandle *ph, SceneHandle scene)
#define HASH_FAIL
Return code when a hash key is not find, or there's no collision upon insertion.
void rt_hash_init(rt_hash_t *tptr, int buckets)
float g
Green color component.
void rt_camera_setup(SceneHandle voidscene, flt zoom, flt aspectratio, int antialiasing, int raydepth, apivector camcent, apivector viewvec, apivector upvec)
Define a camera for a perspective projection, given the specified zoom factor, aspect ratio...
void rt_hash_destroy(rt_hash_t *tptr)
float r
Red color component.
static errcode GetVol(parsehandle *ph, SceneHandle scene)
#define RT_TEXTURE_GRIT
"grit" procedural texture
void * rt_texture(SceneHandle sc, apitexture *apitex)
Translate a texture definition into the internal format used by Tachyon, and returns an opaque pointe...
static errcode GetVCSTri(parsehandle *ph, SceneHandle scene)
void rt_camera_eye_separation(SceneHandle voidscene, flt eyesep)
Set camera stereoscopic eye separation.
static errcode GetScenedefs(parsehandle *ph, SceneHandle scene)
apicolor col
base object color
static errcode GetSphere(parsehandle *ph, SceneHandle scene)
static void Trans3d(apivector *trans, apivector *vec)
void rt_shadermode(SceneHandle voidscene, int mode)
Set the shading mode for the specified scene.
apivector rot
rotation of texture around origin
void rt_resolution(SceneHandle voidscene, int hres, int vres)
Set the horizontal and vertical resolution (in pixels) for the specified scene.
static errcode GetSpotLight(parsehandle *ph, SceneHandle scene)
static errcode GetBackGnd(parsehandle *ph, SceneHandle scene)
#define RT_FOG_LINEAR
linear fog
void rt_light_attenuation(void *vli, flt Kc, flt Kl, flt Kq)
Set light attenuation parameters for an existing light.
#define RT_TRANS_VMD
mult shaded color by opacity, for VMD
void rt_trans_mode(SceneHandle voidscene, int mode)
Set transparency rendering mode.
flt diffuse
diffuse reflection
flt opacity
how opaque the object is
#define RT_TEXTURE_3D_CHECKER
checkerboard texture
void rt_trans_max_surfaces(SceneHandle voidscene, int count)
Set the maximum number of transparent surfaces that will be rendered.
void rt_fog_rendering_mode(SceneHandle voidscene, int mode)
Set fog rendering mode, either radial fog (native Tachyon behavior), or an OpenGL- or VMD-like planar...
#define RT_TEXTURE_WOOD
"wood" procedural texture
static errcode GetFCylinder(parsehandle *ph, SceneHandle scene)
static errcode GetCylinder(parsehandle *ph, SceneHandle scene)
#define RT_PROJECTION_EQUIRECTANGULAR
360 lat-long equirectangular
flt specular
specular reflection
#define RT_TEXTURE_MARBLE
"marble" procedural texture
#define RT_SHADER_LOW
low quality shading
#define RT_TEXTURE_CONSTANT
solid color
#define RT_TRANS_ORIG
original transparency mode
#define RT_TEXTURE_CYLINDRICAL_IMAGE
cylindrical image map
static errcode GetVector(parsehandle *ph, apivector *v1)
void rt_landscape(SceneHandle scene, void *tex, int m, int n, apivector ctr, flt wx, flt wy)
Define an auto-generated height field.
#define RT_SHADER_FULL
Highest quality shading available.
static errcode GetObject(parsehandle *ph, SceneHandle scene)
void rt_fog_parms(SceneHandle voidscene, apicolor col, flt start, flt end, flt density)
Set fog rendering parameters.
apicolor rt_color(flt r, flt g, flt b)
Helper function to make colors.
void * rt_spotlight(SceneHandle voidscene, void *tex, apivector ctr, flt rad, apivector dir, flt start, flt end)
Define a spotlight with associated texture, position, radius, direction, falloff start, and falloff end parameters.
apivector ctr
origin of texture
static errcode GetLandScape(parsehandle *ph, SceneHandle scene)
static void * find_texture(parsehandle *ph, const char *name)
static errcode GetCamera(parsehandle *ph, SceneHandle scene)
unsigned int ParseMGF(char *mgfname, SceneHandle scene, int defaultflag)
#define RT_TEXTURE_VOLUME_IMAGE
volumetric image map
char imap[96]
name of image map
static errcode add_texture(parsehandle *ph, void *tex, const char *name)
static errcode GetTexAlias(parsehandle *ph)
void rt_fog_mode(SceneHandle voidscene, int mode)
Set fog style (linear, exponential, exponential-squared).
static errcode ReadIncludeFile(parsehandle *ph, const char *includefile, SceneHandle scene)
void rt_box(SceneHandle scene, void *tex, apivector min, apivector max)
Define an axis-aligned box.
void rt_sphere(SceneHandle scene, void *tex, apivector ctr, flt rad)
Define a sphere with associated texture, center, and radius.
void rt_ambient_occlusion(SceneHandle voidscene, int numsamples, apiflt maxdist, apicolor col)
Ambient occlusion lighting, with monte carlo sampling of omnidirectional "sky" light.
unsigned int readmodel(const char *modelfile, SceneHandle scene)
void rt_sphere3fv(SceneHandle scene, void *tex, const float *ctr, float rad)
Define a sphere with associated texture, center, and radius.
static errcode GetInt(parsehandle *ph, int *i)
#define RT_TRANS_RASTER3D
angle-dependent opacity modulation
static apicolor scenebackcol
#define RT_PROJECTION_FISHEYE
Fisheye projection mode.
void rt_rescale_lights(SceneHandle voidscene, flt lightscale)
Rescale all light sources in the scene by factor lightscale.
#define RT_BACKGROUND_TEXTURE_SKY_SPHERE
gradient bg, persp
#define RT_PROJECTION_STEREO_EQUIRECTANGULAR
over/under omnistereo equirectangular
apiflt degtorad(apiflt deg)
static errcode GetTexture(parsehandle *ph, SceneHandle scene, void **tex)
static errcode GetSkyLight(parsehandle *ph, SceneHandle scene)
#define RT_FOG_VMD
planar OpenGL-like fog
void rt_scalarvol(SceneHandle scene, void *tex, apivector min, apivector max, int xs, int ys, int zs, const char *fname, void *voidvol)
Define an axis-aligned scalar volumetric data set, loaded from a file.
void rt_tri(SceneHandle voidscene, void *tex, apivector v0, apivector v1, apivector v2)
Define a flat-shaded triangle.
static void PrintSyntaxError(parsehandle *ph, const char *string, const char *found)
#define RT_SHADER_LOWEST
lowest quality shading available
static errcode GetBox(parsehandle *ph, SceneHandle scene)
static errcode GetTexDef(parsehandle *ph, SceneHandle scene)
flt x
X coordinate or direction component.
void * rt_directional_light(SceneHandle voidscene, void *tex, apivector dir)
Define a directional light with associated texture and direction.
void rt_clip_fv(SceneHandle voidscene, int numplanes, const float *planes)
Enable or update a clipping plane group.
#define RT_PROJECTION_PERSPECTIVE
Perspective projection mode.
void rt_camera_projection(SceneHandle voidscene, int mode)
Set camera projection mode.
flt apiflt
for backward compatibility
#define RT_AO_MAXDIST_UNLIMITED
unlimited AO distaned macro
flt y
Y coordinate or direction component.
#define RT_TEXTURE_SPHERICAL_IMAGE
spherical image map
apivector scale
scale of texture in x,y,z
static void Scale3d(apivector *scale, apivector *vec)
static errcode GetVertexArray(parsehandle *ph, SceneHandle scene)
void rt_tex_transmode(void *voidtex, int transmode)
Set transparent surface shading parameters for an existing texture, enabling or disabling angle-modul...
void rt_fcylinder(SceneHandle scene, void *tex, apivector ctr, apivector axis, flt rad)
Define a finite-length cylinder.
static void degvectoradvec(apivector *degvec)
void rt_outputfile(SceneHandle voidscene, const char *outname)
Set the filename for the output image for the specified scene.
apivector uaxs
planar map u axis
static errcode GetImageDef(parsehandle *ph, SceneHandle scene)
void * GetTexBody(parsehandle *ph, SceneHandle scene, int modeflag)
static errcode GetLight(parsehandle *ph, SceneHandle scene)
#define ERROR_READBUF_SIZE
static errcode GetClipGroup(parsehandle *ph, SceneHandle scene)
static int stringcmp(const char *a, const char *b)
static void InitRot3d(RotMat *rot, apiflt x, apiflt y, apiflt z)
static errcode GetFog(parsehandle *ph, SceneHandle scene)
void rt_camera_dof(SceneHandle voidscene, flt focaldist, flt aperture)
Set depth-of-field rendering options.
void rt_stri(SceneHandle voidscene, void *tex, apivector v0, apivector v1, apivector v2, apivector n0, apivector n1, apivector n2)
Define a smooth-shaded triangle using interpolated vertex normals.
int texturefunc
which texture function to use
apivector rt_vector(flt x, flt y, flt z)
Helper function to make vectors.
static errcode GetSTri(parsehandle *ph, SceneHandle scene)
flt ambient
ambient lighting
apivector vaxs
planar map v axis
static errcode GetShaderMode(parsehandle *ph, SceneHandle scene)
static errcode GetTri(parsehandle *ph, SceneHandle scene)
void rt_background(SceneHandle voidscene, apicolor col)
Set the background color of the specified scene.
void rt_clip_off(SceneHandle voidscene)
Disable active clipping plane group.
void rt_camera_frustum(SceneHandle voidscene, flt left, flt right, flt bottom, flt top)
Set view frustum for active camera.
#define RT_PHONG_PLASTIC
Dielectric Phong highlight.
void * rt_texture_copy_vcstri(SceneHandle sc, void *oldvoidtex)
Do not use this unless you know what you're doing, this is a short-term workaround until new object t...
int rt_hash_insert(rt_hash_t *tptr, const char *key, int data)
#define RT_SHADER_MEDIUM
Medium quality shading.
#define RT_BACKGROUND_TEXTURE_SKY_ORTHO_PLANE
gradient bg, ortho
static errcode GetPolyCylinder(parsehandle *ph, SceneHandle scene)
#define RT_FOG_EXP2
exponential-squared fog
#define RT_TEXTURE_GRADIENT
gradient noise procedural texture
static errcode GetColor(parsehandle *ph, apicolor *c1)
float b
Blue color component.
void rt_define_teximage_rgb24(const char *name, int xs, int ys, int zs, unsigned char *rgb)
Define a named 1-D, 2-D, or 3-D texture image with a 24-bit RGB image buffer, without any file refere...
static errcode GetClipGroupEnd(parsehandle *ph, SceneHandle scene)
static void free_tex_table(parsehandle *ph, SceneHandle scene)
void rt_tex_phong(void *voidtex, flt phong, flt phongexp, int type)
Set Phong shading parameters for an existing texture.
#define RT_FOG_NONE
no fog
#define RT_FOG_EXP
exponential fog
#define RT_PROJECTION_PERSPECTIVE_DOF
Perspective projection mode.
static void Rotate3d(RotMat *rot, apivector *vec)
void rt_polycylinder(SceneHandle scene, void *tex, apivector *points, int numpts, flt rad)
Define a sequence of connected cylinders.
void rt_plane(SceneHandle scene, void *tex, apivector ctr, apivector norm)
Define a plane.
void rt_ring(SceneHandle scene, void *tex, apivector ctr, apivector norm, flt inner, flt outer)
Define an annular ring.
void rt_background_mode(SceneHandle voidscene, int mode)
Set the background texturing mode to use.
#define RT_PROJECTION_ORTHOGRAPHIC
Orthographic projection mode.
void rt_tex_outline(void *voidtex, flt outline, flt outlinewidth)
Set edge cueing outline shading parameters for an existing texture.
Tachyon public API function prototypes and declarations used to drive the ray tracing engine...
apivector waxs
volume map W axis
int rt_hash_lookup(rt_hash_t *tptr, const char *key)
static errcode GetDirLight(parsehandle *ph, SceneHandle scene)
void rt_cylinder(SceneHandle scene, void *tex, apivector ctr, apivector axis, flt rad)
Define an infinite cylinder.
static errcode GetRing(parsehandle *ph, SceneHandle scene)
static errcode GetTPolyFile(parsehandle *ph, SceneHandle scene)
static void reset_tex_table(parsehandle *ph, SceneHandle scene)
void * rt_light(SceneHandle voidscene, void *tex, apivector ctr, flt rad)
Define a point light with associated texture, position, and radius.
flt z
Z coordinate or direction component.
#define RT_TEXTURE_PLANAR_IMAGE
planar image map
#define RT_PHONG_METAL
Metallic Phong highlight.
void rt_verbose(SceneHandle voidscene, int v)
Enables or Disables verbose messages from the Tachyon library during rendering.
void rt_vcstri(SceneHandle voidscene, void *tex, apivector v0, apivector v1, apivector v2, apivector n0, apivector n1, apivector n2, apicolor c0, apicolor c1, apicolor c2)
Define a smooth-shaded triangle using interpolated vertex normals and per-vertex colors.
static errcode GetString(parsehandle *ph, const char *string)
#define RT_TEXTURE_CYLINDRICAL_CHECKER
cylindrical checkerboard
void rt_shadow_filtering(SceneHandle voidscene, int onoff)
Control whether or not transparent surfaces modulate incident light or not.