nuclear@4: #include "scene.h" nuclear@4: nuclear@4: Scene::Scene() nuclear@4: { nuclear@4: active_cam = 0; nuclear@4: root = new SceneNode; nuclear@4: } nuclear@4: nuclear@4: Scene::~Scene() nuclear@4: { nuclear@4: for(auto obj : objects) { nuclear@4: delete obj; nuclear@4: } nuclear@4: for(auto node : nodes) { nuclear@4: delete node; nuclear@4: } nuclear@4: delete root; nuclear@4: } nuclear@4: nuclear@4: void Scene::add_object(Object *obj) nuclear@4: { nuclear@4: objects.push_back(obj); nuclear@4: } nuclear@4: nuclear@4: int Scene::get_object_count() const nuclear@4: { nuclear@4: return (int)objects.size(); nuclear@4: } nuclear@4: nuclear@4: Object *Scene::get_object(int idx) const nuclear@4: { nuclear@4: return objects[idx]; nuclear@4: } nuclear@4: nuclear@4: void Scene::add_node(SceneNode *node) nuclear@4: { nuclear@4: nodes.push_back(node); nuclear@4: nuclear@4: if(!node->get_parent()) { nuclear@4: root->add_child(node); nuclear@4: } nuclear@4: } nuclear@4: nuclear@4: int Scene::get_node_count() const nuclear@4: { nuclear@4: return (int)nodes.size(); nuclear@4: } nuclear@4: nuclear@4: SceneNode *Scene::get_node(int idx) const nuclear@4: { nuclear@4: return nodes[idx]; nuclear@4: } nuclear@4: nuclear@4: void Scene::use_camera(Camera *cam) nuclear@4: { nuclear@4: active_cam = cam; nuclear@4: } nuclear@4: nuclear@4: Camera *Scene::get_active_camera() const nuclear@4: { nuclear@4: return active_cam; nuclear@4: } nuclear@4: nuclear@4: void Scene::update(long msec) nuclear@4: { nuclear@4: root->update(msec); nuclear@4: } nuclear@4: nuclear@4: bool Scene::intersect(const Ray &ray, RayHit *hit) const nuclear@4: { nuclear@4: return root->intersect(ray, hit); nuclear@4: } nuclear@4: nuclear@4: bool Scene::load(const char *fname) nuclear@4: { nuclear@4: return false; // TODO nuclear@4: }