X-Git-Url: https://git.rohieb.name/MicroTrace.git/blobdiff_plain/0e3446ceb6fd6db0cb292671f37b46daaa2aed5b..df8007c9ec4440ac2388c7a4971e708c2b697832:/Scene.hxx diff --git a/Scene.hxx b/Scene.hxx index 18deb79..baafce6 100644 --- a/Scene.hxx +++ b/Scene.hxx @@ -2,9 +2,13 @@ #define SCENE_HXX #include +#include +#include + #include "Ray.hxx" #include "Camera.hxx" +#include "Light.hxx" #include "Primitive.hxx" class Scene @@ -15,7 +19,9 @@ public: // add another primitive to the scene void Add(Primitive* p); - + // add another light source to the scene + void Add(Light* l); + // intersect the ray with all objects in the scene virtual bool Intersect(Ray& ray); // find occluder @@ -24,16 +30,45 @@ public: // trace the given ray and shade it, returnt the color of the shaded ray Vec3f RayTrace(Ray& ray); + // acces to camera and light sources const Camera* camera() const; + std::vector lights() const; + + // set new camera + void setCamera(const Camera* camera); + + // reads in a scene description + void ParseOBJ(const std::string& file, float factor); + // calculate scene bounding box + void CalcBounds(); + + const Box& GetSceneBox() const; private: Scene(const Scene& ); Scene& operator=(const Scene& ); + void parseOBJLine(const std::string& line); + void parseVertex(std::istringstream& iss); + void parseFace(std::istringstream& iss); + void buildTriangleList(float scale); + Camera* m_camera; // background color Vec3f m_bgColor; // primitives std::vector m_primitives; + // lights + std::vector m_lights; + + // shader used by loading routine + Shader* m_shader; + + // storage for vertices and face indices + std::vector m_vertices, m_faces; + Vec3f m_centroid; + + // scene bounding box + Box m_scene_box; }; #endif