#include "header.h" int GetObject(); int RayTrace(); /********************************************************** Test routine - unused **********************************************************/ #ifdef TESTS Tree_Walker(obj,num) OBJ_PTR obj; int num; { int x; for (x=0; xtype); if (obj->child!=NULL) Tree_Walker(obj->child,num+2); if (obj->nextobj!=NULL) Tree_Walker(obj->nextobj,num); } #endif /********************************************************** Initialize some observer data, like up and right vectors, focal length, etc. **********************************************************/ Setup_Observer() { if (THEWORLD.observer==NULL) Error(NO_OBSERVER,001); Normalize(&((THEWORLD.observer)->vect1)); VectEQ(&(THEWORLD.obsup),&((THEWORLD.observer)->vect2)); CrossProd(&(THEWORLD.obsright), /* right = up x dir */ &(THEWORLD.obsup), &((THEWORLD.observer)->vect1)); CrossProd(&(THEWORLD.obsup), /* up = dir x right */ &((THEWORLD.observer)->vect1), &(THEWORLD.obsright)); Normalize(&(THEWORLD.obsup)); Normalize(&(THEWORLD.obsright)); THEWORLD.flength*=5; } /********************************************************** Initialize the world and assign defaults **********************************************************/ init_world() { /* make a universe */ THEWORLD.stack = THEWORLD.observer = THEWORLD.instances = THEWORLD.sky = THEWORLD.lamps = NULL; THEWORLD.patlist = NULL; THEWORLD.outfile = NULL; THEWORLD.objcount = 0; THEWORLD.lampcount = 0; THEWORLD.flength = 50; THEWORLD.first_scan = 0; THEWORLD.last_scan = YSIZE-1; THEWORLD.skycolor_zenith.r = THEWORLD.skycolor_zenith.b = THEWORLD.skycolor_zenith.g = THEWORLD.skycolor_horiz.r = THEWORLD.skycolor_horiz.g = THEWORLD.skycolor_horiz.b = 0; THEWORLD.ray_intersects = THEWORLD.pixels_hit = THEWORLD.primary_traced = THEWORLD.to_lamp = THEWORLD.refl_trans = THEWORLD.bbox_intersects = THEWORLD.pattern_matches = THEWORLD.intersect_tests = 0; THEWORLD.globindex = 1.00; /* global index of refraction */ def.cinfo.trans.r = /* default transmittion */ def.cinfo.trans.g = def.cinfo.trans.b = 0; def.cinfo.mirror.r = /* default reflection */ def.cinfo.mirror.g = def.cinfo.mirror.b = 0; def.cinfo.amb.r = /* default ambiant light */ def.cinfo.amb.g = def.cinfo.amb.b = 25; def.cinfo.diff.r = /* default diffuse light */ def.cinfo.diff.g = def.cinfo.diff.b = CNUM; def.cinfo.density.x= def.cinfo.density.y= def.cinfo.density.z= .01; /* default glass density */ def.cinfo.fuzz = 0; def.cinfo.index = CNUM; def.cinfo.dither = 3; def.cinfo.reflect = 0; def.cinfo.sreflect = 10; def.shadow = TRUE; /* shadows */ def.vlamp = FALSE; /* no visible lamps */ def.int_x = /* no interpolation */ def.int_y = 1; def.threshold = .1; /* threshold at 10 percent */ def.ithreshold = def.threshold * CNUM; } /********************************************************** Call other stuff to load world and generate image **********************************************************/ main() { printf("Quick Ray Trace: Copyright 1988 Steve Koren\nVersion 1.4\n"); init_world(); if (!LoadWorld()) Error(SYNTAX_ERROR,002); Make_Bbox(THEWORLD.stack); /* make bboxes */ Do_Precomp(THEWORLD.stack); /* precompute stuff */ fclose(stdin); Setup_Observer(); Open_File(); Screen_Trace(); Close_File(); World_Stats(); fclose(stdout); return(NULL); }