fixed Box::Extend(Vec3f&)
[MicroTrace.git] / Scene.hxx
1 #ifndef SCENE_HXX
2 #define SCENE_HXX
3
4 #include <vector>
5 #include <string>
6 #include <fstream>
7
8
9 #include "Ray.hxx"
10 #include "Camera.hxx"
11 #include "Light.hxx"
12 #include "Primitive.hxx"
13
14 class Scene
15 {
16 public:
17 Scene();
18 virtual ~Scene();
19
20 // add another primitive to the scene
21 void Add(Primitive* p);
22 // add another light source to the scene
23 void Add(Light* l);
24
25 // intersect the ray with all objects in the scene
26 virtual bool Intersect(Ray& ray);
27 // find occluder
28 virtual bool Occluded(Ray& ray);
29
30 // trace the given ray and shade it, returnt the color of the shaded ray
31 Vec3f RayTrace(Ray& ray);
32
33 // acces to camera and light sources
34 const Camera* camera() const;
35 std::vector<Light*> lights() const;
36
37 // set new camera
38 void setCamera(const Camera* camera);
39
40 // reads in a scene description
41 void ParseOBJ(const std::string& file, float factor);
42 // calculate scene bounding box
43 void CalcBounds();
44
45 const Box& GetSceneBox() const;
46 private:
47 Scene(const Scene& );
48 Scene& operator=(const Scene& );
49
50 void parseOBJLine(const std::string& line);
51 void parseVertex(std::istringstream& iss);
52 void parseFace(std::istringstream& iss);
53 void buildTriangleList(float scale);
54
55 Camera* m_camera;
56 // background color
57 Vec3f m_bgColor;
58
59 // primitives
60 std::vector<Primitive*> m_primitives;
61 // lights
62 std::vector<Light*> m_lights;
63
64 // shader used by loading routine
65 Shader* m_shader;
66
67 // storage for vertices and face indices
68 std::vector<Vec3f> m_vertices, m_faces;
69 Vec3f m_centroid;
70
71 // scene bounding box
72 Box m_scene_box;
73 };
74 #endif
This page took 0.055903 seconds and 5 git commands to generate.