/*
	Project 1 Startup File:
	Author: Josh Barczak (jbarcz1@cs.umbc.edu)

	This is a simple RenderMan program to get you started on Project 1.

	We will be using the copy of 3delight installed in Dr. Marc Olano's public GL directory.
	which is: ~olano/public/435

	In order for it this thing to compile, you will first need to set up your environment
	to use 3delight by typing:  

	source ~olano/public/435/3delight/.3delight_csh
		OR, if you're using BASH:
	source ~olano/public/435/3delight/.3delight_bash

	Once you've done that, you should be able to build it with the Makefile we've given you

	When this program is run, it will invoke 3delight and create an output file
	called "objects.tif", which should contain an image of a shiny red sphere.
*/		

#include <ri.h>


int main()
{
	/* fov is the angle between the camera's top and bottom viewing planes */
	RtFloat fov = 45;

	/* material properties for the sphere */
	/* kd is the amount of diffuse reflection (scattering due to a rough surface)               */
	/* ks is the amount of specular reflection (the white highlight created by the lightsource) */
	RtFloat sphere_kd = 0.6;
	RtFloat sphere_ks = 0.5;
	RtColor sphere_color = {1,0,0};

	/* light information */
	/* the points 'to' and 'from' define the light direction */
	RtPoint light_to = {0,0,1};
	RtPoint light_from = {0,0,0};
	RtFloat light_intensity = 1.0;

	/* start the renderer */
	RiBegin(RI_NULL);

	/* tell it to render to an image file called sphere.tif */
	RiDisplay("objects.tif", "file", "rgb", RI_NULL);

	/* set up the perspective transformation */
	RiProjection("perspective", "fov", &fov, RI_NULL);

	RiWorldBegin();
	
		/* create a light source */
		/* 
                   A distantlight is a light in which all incoming light rays are parallel to one another 
		   distantlights are good for modeling light from very bright, far away things (like the sun)
                   where attenuation is insignificant, and the photons are all coming from roughly the same direction when they hit
		*/ 
		RiLightSource("distantlight", "from", light_from, "to", light_to, "intensity", &light_intensity, RI_NULL);


		/* tell the renderer to use the 'plastic' surface shader with the specified parameters */
		/* this shader will be used for all subsequent objects                                 */
		RiSurface("plastic", "ks", &sphere_ks, "kd", &sphere_kd,  RI_NULL);

		/* tell the renderer to use this color for all subsequent objects */
		RiColor(sphere_color);

		/* create a sphere, translated forwards along the Z axis (so the camera isn't inside it) */
		RiTransformBegin();
			RiTranslate(0,0,5);
			RiSphere(1,-2,2,360,RI_NULL);
		RiTransformEnd();

	RiWorldEnd();

	RiEnd();

	/* thats it, we're done */
	return 0;
}

