int main(int argc, char *argv[]) { FILE *input; char *fileName = argv[1]; Sphere **sphereList = (Sphere **) malloc(sizeof(Sphere *)); int sphereListLength = 0; View view; Point eyePoint; Light lightSource; Color ambientLight; FILE *output; tryOpen(&input, fileName); readSphereList(&input, sphereList, &sphereListLength); createView(&view); createEyePoint(&eyePoint); createLightSource(&lightSource); createAmbience(&ambientLight); output = fopen("image.ppm", "w"); fprintf(output, "P3\n"); fprintf(output, "%d %d\n", view.width, view.height); fprintf(output, "%d\n\n", 255); castAllRays(&view, &eyePoint, &ambientLight, &lightSource, sphereList, &sphereListLength, &output); free(sphereList); fclose(output); }
int main() { /* Debugging Code */ //double minX = 0.05859357, maxX = 0.44921857; //double minY = 2.03125, maxY = 2.421875; //int width = 20, height = 20; double minX = -10, maxX = 10, minY = -7.5, maxY = 7.5; int width = 512, height = 384; Canvas canvas; InitCanvas(&canvas, minX, maxX, minY, maxY, width, height); Point eye = CreatePoint(0.0, 0.0, -14.0); Point blueSphere = CreatePoint(1.0, 1.0, 0.0); Point redSphere = CreatePoint(0.5, 1.5, -3.0); Point lightPoint = CreatePoint(-100.0, 100.0, -100.0); Color blue = CreateColor(0.0, 0.0, 1.0); Color red = CreateColor(1.0, 0.0, 0.0); Color ambient = CreateColor(1.0, 1.0, 1.0); Color lightColor = CreateColor(1.5, 1.5, 1.5); Finish largeFinish = CreateFinish(0.2, 0.4, 0.5, 0.05); Finish smallFinish = CreateFinish(0.4, 0.4, 0.5, 0.05); Light light = CreateLight(lightPoint, lightColor); Sphere spheres[2]; spheres[0] = CreateSphere(blueSphere, 2.0, blue, largeFinish); spheres[1] = CreateSphere(redSphere, 0.5, red, smallFinish); castAllRays(&canvas, eye, spheres, ambient, light, 2); return 0; }