erebus

annotate liberebus/src/scene.cc @ 6:bb006fb96f1b

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