int main(int argc, const char* argv[]) { rayInit(argv[0], "dlc:cube/scenes/scene.map"); rayOpenWindow("Cube World", 1376, 768); while (!rayIsQuitRequest()) { rayUpdate(); } rayTerminate(); return 0; }
int main(int argc, const char* argv[]) { rayInit(argv[0], "dlc:GI/scene/scene.map"); if (rayOpenWindow("Global illumination", 1376, 768)) { while (!rayIsQuitRequest()) rayUpdate(); } rayTerminate(); return 0; }
/* take the definition of a camera and a point within the film plane of the camera and generate a RAY x and y both have a range of -0.5 to +0.5 */ Ray *camGenerateRay(Camera *camera, double x, double y, Ray *ray){ Vec direction; Vec cameraX, cameraY; /* work out direction camera is pointing in */ vecSub(&(camera->lookAt), &(camera->at), &direction); vecNormalise(&direction, &direction); /* using that and DOWN, work out the camera axes and normalise */ vecProduct(&direction, &(camera->down), &cameraX); vecProduct(&direction, &cameraX, &cameraY); vecNormalise(&cameraX, &cameraX); vecNormalise(&cameraY, &cameraY); /* finally combine film offset and camera axes to work out film position */ vecScale(x * camera->width, &cameraX, &cameraX); vecScale(y * camera->height, &cameraY, &cameraY); vecScale(camera->depth, &direction, &direction); vecAdd(&cameraX, &direction, &direction); vecAdd(&cameraY, &direction, &direction); rayInit(&(camera->at), &direction, ray); return ray; }