24 #define PARSE_INTERNAL    43     if (toupper(a[i]) != toupper(b[i])) {
    56    while ((!feof(dfile)) && ((c = fgetc(dfile)) != 
'"'));
    59    while ((!feof(dfile)) && ((c = fgetc(dfile)) != 
'"')) {
    71 static errcode 
add_texture(
void * tex, 
char name[TEXNAMELEN]) {
    77     printf(
"Parse: %d textures allocated, texture slots full!\n", 
numtextures);
    85 static errcode 
GetString(FILE * dfile, 
char * 
string) {
    88   fscanf(dfile,
"%s",data);
    90     printf(
"parse: Expected %s, got %s \n",
string, data);
   106   dfile=fopen(modelfile,
"r");
   111   fscanf(dfile, 
"%s", filehdr);
   112   if (strcmp(filehdr, 
"AC3Db")) {
   113     printf(
"Unknown version of AC3D Model File Format\n");
   144   int raydepth, antialiasing;
   168               Ccenter, Cview, Cup);
   192   if (fscanf(dfile, 
"%s", objtype) != 1) {
   202   printf(
"Found bad token: %s expected an object type\n", objtype);
   211   char texname[TEXNAMELEN];
   213   fscanf(dfile, 
"%s", texname);
   216   fscanf(dfile, 
"%f %f %f", &a, &b, &c); 
   220   tex.
diffuse = (a + b + c) / 3.0;
   223   fscanf(dfile, 
"%f %f %f", &a, &b, &c); 
   224   tex.
ambient= ((a + b + c) / 3.0);
   227   fscanf(dfile, 
"%f %f %f", &a, &b, &c);
   230   fscanf(dfile, 
"%f %f %f", &a, &b, &c);
   234   fscanf(dfile, 
"%d", &e);
   237   fscanf(dfile, 
"%f", &d);  
   238   tex.
opacity= (d > 0.99) ? 0.0 : (1.0 - d);
   248   for (j=0; j<3; j++) {
   249     for (i=0; i<3; i++) {
   258 static void RmatMult(RotMat A, RotMat B, RotMat C) {
   261   for (k=0; k<3; k++) {
   262     for (j=0; j<3; j++) {
   264       for (i=0; i<3; i++) {
   265         A[k][j] += B[k][i] * C[i][j];  
   273   for (j=0; j<3; j++) {
   275     for (i=0; i<3; i++) {
   276       NT[j] += R[j][i] * T[i];
   282                           int smooth, 
int texnum) {
   285   newlist = (tri_list *) malloc(
sizeof(tri_list));
   289   newlist->smooth = smooth;
   290   newlist->texnum = texnum;
   291   newlist->next = *tlist;  
   302   while (tmp != NULL) {
   316   tmp.
x = tmp.
y = tmp.
z = 0.0;
   318   for (i=0; i<numverts; i++) {
   326   length = sqrt((vec->
x * vec->
x) + (vec->
y * vec->
y) + (vec->
z * vec->
z));
   335   for (i=0; i<numverts; i++) {
   352   norm.
x = (U.
y * V.
z) - (U.
z * V.
y);
   353   norm.
y = (U.
z * V.
x) - (U.
x * V.
z);
   354   norm.
z = (U.
x * V.
y) - (U.
y * V.
x);  
   366   while (cur != NULL) {
   369         vertex[cur->v0], vertex[cur->v1], vertex[cur->v2],
   370         normal[cur->v0], normal[cur->v1], normal[cur->v2]);
   375         vertex[cur->v0], vertex[cur->v1], vertex[cur->v2]);
   384                                 RotMat rmat, TransMat tmat) {
   385   char token[256], objname[128], name[128], texname[128], urlname[100];
   386   RotMat localrmat, newrmat;
   387   TransMat localtmat, newtmat;
   388   float txrepa, txrepb, a, b;
   389   int numvert, numsurf, surf, materialnum, numrefs, numkids, data;
   393   int * refarray = NULL;
   394   tri_list * tlist = NULL;
   398   numvert = numsurf = surf = materialnum = numrefs = numkids = data = 0;
   404   fscanf(dfile, 
"%s", objname);
   405   fscanf(dfile, 
"%s", token);
   408     fscanf(dfile, 
"%s", token);
   411     fscanf(dfile, 
"%d", &data);
   412     fscanf(dfile, 
"%s", token);
   415     fscanf(dfile, 
"%s", texname);
   416     fscanf(dfile, 
"%s", token);
   419     fscanf(dfile, 
"%f %f", &txrepa, &txrepb);
   420     fscanf(dfile, 
"%s", token);
   423     for (j=0; j<3; j++) {
   425         fscanf(dfile, 
"%f", &localrmat[j][i]);
   428     fscanf(dfile, 
"%s", token);
   431     for (j=0; j<3; j++) {
   432       fscanf(dfile, 
"%f", &localtmat[j]);
   434     fscanf(dfile, 
"%s", token);
   437     for (j=0; j<3; j++) {
   439         fscanf(dfile, 
"%f", &localrmat[j][i]);
   442     fscanf(dfile, 
"%s", token);
   447   newtmat[0] += tmat[0]; 
   448   newtmat[1] += tmat[1]; 
   449   newtmat[2] += tmat[2]; 
   453     fscanf(dfile, 
"%s", urlname);
   454     fscanf(dfile, 
"%s", token);
   458     fscanf(dfile, 
"%s", token);
   463     fscanf(dfile, 
"%d", &numvert);
   472     for (i=0; i<numvert; i++) {
   473       fscanf(dfile, 
"%f %f %f", &vtx[0], &vtx[1], &vtx[2]);
   476       vertexarray[i].
x = tvtx[0] + newtmat[0];
   477       vertexarray[i].
y = tvtx[1] + newtmat[1];
   478       vertexarray[i].
z = tvtx[2] + newtmat[2];
   481     fscanf(dfile, 
"%s", token);
   484     fscanf(dfile, 
"%d", &numsurf);
   485     fscanf(dfile, 
"%s", token);
   487     for (j=0; j<numsurf; j++) {
   488       numrefs = surf = materialnum = 0;
   498         fscanf(dfile, 
"%s", token);
   499         sscanf(token, 
"%x", &surf);
   501         fscanf(dfile, 
"%x", &surf);
   503         fscanf(dfile, 
"%s", token);
   506         fscanf(dfile, 
"%d", &materialnum);
   507         fscanf(dfile, 
"%s", token);
   510         fscanf(dfile, 
"%d", &numrefs);  
   514       refarray = (
int *) malloc(numrefs * 
sizeof(
int));
   515       for (i=0; i<numrefs; i++) {
   516         fscanf(dfile, 
"%d %f %f", &refarray[i], &a, &b);  
   521       if ((surf & 0xF) == 0) {
   526         trinorm = 
tri_normal(&vertexarray[refarray[1]],         
   527                              &vertexarray[refarray[0]], 
   528                              &vertexarray[refarray[2]]); 
   530         for (i=0; i<numrefs; i++) {
   531           normalarray[refarray[i]].
x += trinorm.
x;
   532           normalarray[refarray[i]].
y += trinorm.
y;
   533           normalarray[refarray[i]].
z += trinorm.
z;
   539         for (i=2; i<numrefs; i++) {
   541           tlist_add_tri(&tlist, vold, v0, vnew, surf & 0x10, materialnum);
   548       fscanf(dfile, 
"%s", token);
   552   if ((vertexarray != NULL) && (normalarray != NULL)) {
   561   if (vertexarray != NULL) 
   565   if (normalarray != NULL) 
   572     fscanf(dfile, 
"%d", &numkids);
   577   while (numkids > 0) {
   588   TransMat defaulttmat;
   592   defaulttmat[0] = 0.0;
   593   defaulttmat[1] = 0.0;
   594   defaulttmat[2] = 0.0;
 static void RmatTmatMult(TransMat NT, RotMat R, TransMat T)
 
unsigned int ParseAC3D(char *modelfile, SceneHandle scene)
 
static errcode GetMaterial(FILE *dfile, SceneHandle scene)
 
static void RmatMult(RotMat A, RotMat B, RotMat C)
 
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...
 
float r
Red color component. 
 
void * rt_texture(SceneHandle sc, apitexture *apitex)
Translate a texture definition into the internal format used by Tachyon, and returns an opaque pointe...
 
apicolor col
base object color 
 
static errcode GetString(FILE *dfile, char *string)
 
static void tlist_add_tri(tri_list **tlist, int v0, int v1, int v2, int smooth, int texnum)
 
void rt_resolution(SceneHandle voidscene, int hres, int vres)
Set the horizontal and vertical resolution (in pixels) for the specified scene. 
 
static apivector tri_normal(apivector *v0, apivector *v1, apivector *v2)
 
flt diffuse
diffuse reflection 
 
flt opacity
how opaque the object is 
 
static errcode GetScenedefs(FILE *dfile, SceneHandle scene)
 
flt specular
specular reflection 
 
static int numobjectsparsed
 
static errcode add_texture(void *tex, char name[TEXNAMELEN])
 
static void renormalize_normals(apivector *normals, int numverts)
 
static void GetAC3DString(FILE *dfile, char *str)
 
static apicolor scenebackcol
 
void rt_tri(SceneHandle voidscene, void *tex, apivector v0, apivector v1, apivector v2)
Define a flat-shaded triangle. 
 
static void reset_tex_table(void)
 
static void tlist_delete(tri_list **tlist)
 
flt x
X coordinate or direction component. 
 
flt apiflt
for backward compatibility 
 
flt y
Y coordinate or direction component. 
 
void rt_outputfile(SceneHandle voidscene, const char *outname)
Set the filename for the output image for the specified scene. 
 
static errcode GetScene(FILE *dfile, SceneHandle scene)
 
static void RmatIdentity(RotMat rmat)
 
static errcode GetRecurseObject(SceneHandle scene, FILE *dfile, RotMat rmat, TransMat tmat)
 
static void normalize(apivector *vec)
 
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 
 
flt ambient
ambient lighting 
 
void rt_background(SceneHandle voidscene, apicolor col)
Set the background color of the specified scene. 
 
static void clear_normals(apivector *normals, int numverts)
 
static int stringcmp(char *a, char *b)
 
float b
Blue color component. 
 
__host__ __device__ float length(const float3 &v)
 
static texentry textable[NUMTEXS]
 
static void gen_triangles(SceneHandle scene, tri_list *tlist, apivector *vertex, apivector *normal)
 
Tachyon public API function prototypes and declarations used to drive the ray tracing engine...
 
void * rt_light(SceneHandle voidscene, void *tex, apivector ctr, flt rad)
Define a point light with associated texture, position, and radius. 
 
static errcode GetObject(FILE *dfile, SceneHandle scene)
 
flt z
Z coordinate or direction component. 
 
void rt_verbose(SceneHandle voidscene, int v)
Enables or Disables verbose messages from the Tachyon library during rendering.