fixed Box::Extend(Vec3f&)
[MicroTrace.git] / MicroTrace.cxx
1 #ifdef _OPENMP
2 #include <omp.h>
3 #endif
4
5 #include <string>
6
7 #include "Vec3f.hxx"
8 #include "Image.hxx"
9 #include "PerspectiveCamera.hxx"
10 #include "Scene.hxx"
11
12
13 void RenderFrameCone(const std::string& fileName)
14 {
15 /* Scene definition */
16 Scene scene;
17
18 scene.ParseOBJ("cone.obj", 1.0f);
19
20 // alter the camera definition appropriately to see the cow
21 // you may need to implement some set/get routines for the scene class
22 scene.setCamera(new PerspectiveCamera(Vec3f(0,0,0.5),
23 Vec3f(0,0,-1),
24 Vec3f(0,1,0),
25 60,
26 640,
27 480));
28
29
30 Image img(scene.camera()->resX(),scene.camera()->resY()); // image array
31 // primary ray
32 #pragma omp parallel for
33 for(int y = 0; y < scene.camera()->resY(); y++)
34 {
35 for (int x = 0; x < scene.camera()->resX(); x++)
36 {
37
38 /* Initialize your ray here */
39 Ray ray;
40 scene.camera()->InitRay(x+0.5,y+0.5,ray); // initialize ray
41
42 Vec3f col = scene.RayTrace(ray);
43
44 img(x,y) = col; // store pixel color
45 }
46 }
47 img.WritePPM(fileName); // write final image
48 }
49
50
51
52 #define RESX 640 // image x-resolution
53 #define RESY 480 // image y-resolution
54
55 int main(int, char**)
56 {
57 RenderFrameCone("cone.ppm");
58 }
This page took 0.050308 seconds and 5 git commands to generate.