erebus

view liberebus/src/scene.cc @ 5:9621beb22694

huh?
author John Tsiombikas <nuclear@member.fsf.org>
date Sat, 24 May 2014 02:20:44 +0300
parents 59a72293f9bd
children e2d9bf168a41
line source
1 #include "scene.h"
3 Scene::Scene()
4 {
5 active_cam = 0;
6 root = new SceneNode;
7 }
9 Scene::~Scene()
10 {
11 for(auto obj : objects) {
12 delete obj;
13 }
14 for(auto node : nodes) {
15 delete node;
16 }
17 delete root;
18 }
20 void Scene::add_object(Object *obj)
21 {
22 objects.push_back(obj);
23 }
25 int Scene::get_object_count() const
26 {
27 return (int)objects.size();
28 }
30 Object *Scene::get_object(int idx) const
31 {
32 return objects[idx];
33 }
35 void Scene::add_node(SceneNode *node)
36 {
37 nodes.push_back(node);
39 if(!node->get_parent()) {
40 root->add_child(node);
41 }
42 }
44 int Scene::get_node_count() const
45 {
46 return (int)nodes.size();
47 }
49 SceneNode *Scene::get_node(int idx) const
50 {
51 return nodes[idx];
52 }
54 void Scene::use_camera(Camera *cam)
55 {
56 active_cam = cam;
57 }
59 Camera *Scene::get_active_camera() const
60 {
61 return active_cam;
62 }
64 void Scene::update(long msec)
65 {
66 root->update(msec);
67 }
69 bool Scene::intersect(const Ray &ray, RayHit *hit) const
70 {
71 return root->intersect(ray, hit);
72 }
74 bool Scene::load(const char *fname)
75 {
76 return false; // TODO
77 }