//////////// // // kiray2.cpp // // second raytracer, still hard-coded model for now // this file sets stuff up; actual tracing in kirtrace.[h/c]pp // // simply outputs kiray2.ppm // // stat: 4 spheres, 2 tri, 1 sphere light // set to read texture: "texture.ppm" in same dir // triangles are set to be textured // #include "kirtrace.hpp" #include "light.hpp" #include "sphere.hpp" #include "tri.hpp" #include "pointl.hpp" #include "spherel.hpp" #include "ppm.hpp" //#include "checkplane.hpp" //not written yet void main() { object* *objs; light* *lights; char output[80]; char input[80]; ////// create hard-coded object and light lists sprintf(input, "texture.ppm"); //first load in tex file into color array unsigned char* Texture = NULL; int texW, texH; LoadPPM(input, Texture, texW, texH); objs = new object*[6]; //change to match num objs! Vec3f cent(3.2,0,0); //first sphere float rad = 2.0; // Vec3f Ia(0.05,0.2,0.05); //aiming for some kinda green (old vers) // Vec3f kd(0.1,0.65,0.2); // Vec3f ks(0.6,0.6,0.6); //reflective // Vec3f kt(0.7,0.8,0.7); //fairly transparent Vec3f Ia(0.0,0.0,0.0); //going for plain glass now Vec3f kd(0.1,0.1,0.1); Vec3f ks(0.5,0.5,0.5); //reflective Vec3f kt(0.9,0.9,0.9); //fairly transparent float M = 1.5; //glass objs[0] = new sphere(cent,rad,Ia,kd,ks,kt,M); cent.Set(-1,1.5,-2.5); //2nd sphere rad = 1.0; Ia.Set(0.2,0.05,0.05); //aiming for some kinda red kd.Set(0.7,0.1,0.3); ks.Set(0.8,0.5,0.5); //reflective kt.Set(0.0,0.0,0.0); //NOT transparent M = 0; objs[1] = new sphere(cent,rad,Ia,kd,ks,kt,M); cent.Set(-6.5,11.5,-6.5); //this sphere is for lightbulb effect rad = 1.0; Ia.Set(0.1,0.1,0.1); kd.Set(1.0,1.0,1.0); //bright white ks.Set(0.0,0.0,0.0); //NOT reflective kt.Set(0.0,0.0,0.0); //NOT transparent M = 0; objs[2] = new sphere(cent,rad,Ia,kd,ks,kt,M); cent.Set(1,1,6); //back sphere rad = 2.5; Ia.Set(0.0,0.0,0.2); //darkish blue kd.Set(0.1,0.1,0.4); ks.Set(0.8,0.9,1.0); //very reflective kt.Set(0.0,0.0,0.0); //NOT transparent M = 0; objs[3] = new sphere(cent,rad,Ia,kd,ks,kt,M); //triangle //Vec3f a(2,6,12); //old vers //Vec3f b(7,0,12); //Vec3f c(-5,-8,14); Vec3f a(10,-4,24); //this makes the tri sort of a ground plane Vec3f b(10,-4,-5); Vec3f c(-10,-4,-10); Ia.Set(-0.01,0.05,0.05); //almost black, or TEXTURE kd.Set(0.0,0.4,0.1); //dk green ks.Set(0.95,0.95,0.95); //_very_ reflective kt.Set(0.0,0.0,0.0); //NOT transparent M = 0; objs[4] = new tri(a,b,c,Ia,kd,ks,kt,M); a.Set(10,-4,24); //second tri b.Set(-10,-4,-10); c.Set(-10,-4,20); Ia.Set(-0.01,0.05,0.05); //almost black, or TEXTURE kd.Set(0.0,0.4,0.1); ks.Set(0.95,0.95,0.95); //_very_ reflective kt.Set(0.0,0.0,0.0); //NOT transparent M = 0; objs[5] = new tri(a,b,c,Ia,kd,ks,kt,M); lights = new light*[1]; //change to match num lights!! Vec3f litpos(-5,10,-5); //upper front corner float litrad = 0.5; //light sphere radius Vec3f litcol(1.0,1.0,1.0); //white light lights[0] = new spherel(litpos,litrad,litcol); /*litpos.Set(0,-20,-8); //below litcol.Set(0.1,0.5,1.0); //bluish light lights[1] = new pointl(litpos,litcol); */ // make the main ray tracer kiray rt(512,512,objs,6,lights,1,Texture,texW,texH); //REMEMBER to set correct num objs rt.bg.Set(0.1,0.0,0.1); // dark purple background // make camera. currently using GLVU cam package. fix later. Vec3f Eye(0,5,-10), ViewRefPt(1,0,0), ViewUp(0,1,0); rt.Cam.Perspective(45,1,0.1,10); // do the render sprintf(output,"kiray2.ppm"); rt.Cam.LookAt(Eye,ViewRefPt,ViewUp); rt.traceAll(); rt.MakePPM(output); }