--- ray/src/rt/lookamb.c 1990/01/19 00:00:13 1.2 +++ ray/src/rt/lookamb.c 1991/06/07 14:24:34 1.5 @@ -1,4 +1,4 @@ -/* Copyright (c) 1986 Regents of the University of California */ +/* Copyright (c) 1991 Regents of the University of California */ #ifndef lint static char SCCSid[] = "$SunId$ LBL"; @@ -14,19 +14,9 @@ static char SCCSid[] = "$SunId$ LBL"; #include "color.h" +#include "ambient.h" -typedef double FVECT[3]; -typedef struct ambval { - FVECT pos; /* position in space */ - FVECT dir; /* normal direction */ - int lvl; /* recursion level of parent ray */ - float weight; /* weight of parent ray */ - COLOR val; /* computed ambient value */ - float rad; /* validity radius */ - struct ambval *next; /* next in list */ -} AMBVAL; /* ambient value */ - int dataonly = 0; int reverse = 0; @@ -80,9 +70,13 @@ FILE *fp; printf("%f\t%f\t%f\t", av.pos[0], av.pos[1], av.pos[2]); printf("%f\t%f\t%f\t", av.dir[0], av.dir[1], av.dir[2]); printf("%d\t%f\t%f\t", av.lvl, av.weight, av.rad); - printf("%e\t%e\t%e\n", colval(av.val,RED), + printf("%e\t%e\t%e\t", colval(av.val,RED), colval(av.val,GRN), colval(av.val,BLU)); + printf("%f\t%f\t%f\t", av.gpos[0], + av.gpos[1], av.gpos[2]); + printf("%f\t%f\t%f\n", av.gdir[0], + av.gdir[1], av.gdir[2]); } else { printf("\nPosition:\t%f\t%f\t%f\n", av.pos[0], av.pos[1], av.pos[2]); @@ -92,6 +86,10 @@ FILE *fp; av.weight, av.rad); printf("Value:\t\t%e\t%e\t%e\n", colval(av.val,RED), colval(av.val,GRN), colval(av.val,BLU)); + printf("Pos.Grad:\t%f\t%f\t%f\n", av.gpos[0], + av.gpos[1], av.gpos[2]); + printf("Dir.Grad:\t%f\t%f\t%f\n", av.gdir[0], + av.gdir[1], av.gdir[2]); } if (ferror(stdout)) exit(1); @@ -105,12 +103,12 @@ FILE *fp; for ( ; ; ) { if (!dataonly) fscanf(fp, "%*s"); - if (fscanf(fp, "%lf %lf %lf", + if (fscanf(fp, "%f %f %f", &av.pos[0], &av.pos[1], &av.pos[2]) != 3) return; if (!dataonly) fscanf(fp, "%*s"); - if (fscanf(fp, "%lf %lf %lf", + if (fscanf(fp, "%f %f %f", &av.dir[0], &av.dir[1], &av.dir[2]) != 3) return; if (!dataonly) @@ -123,6 +121,17 @@ FILE *fp; if (fscanf(fp, "%f %f %f", &av.val[RED], &av.val[GRN], &av.val[BLU]) != 3) return; + if (!dataonly) + fscanf(fp, "%*s"); + if (fscanf(fp, "%f %f %f", + &av.gpos[0], &av.gpos[1], &av.gpos[2]) != 3) + return; + if (!dataonly) + fscanf(fp, "%*s"); + if (fscanf(fp, "%f %f %f", + &av.gdir[0], &av.gdir[1], &av.gdir[2]) != 3) + return; + av.next = NULL; fwrite((char *)&av, sizeof(AMBVAL), 1, stdout); if (ferror(stdout)) exit(1);