rayzor
view src/scene.cc @ 6:a68dbf80d547
finally showing something ... :)
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Mon, 07 Apr 2014 06:04:11 +0300 |
parents | 5fcf72837b69 |
children | d94a69933a71 |
line source
1 #include <string.h>
2 #include "scene.h"
4 Scene::Scene()
5 {
6 name = 0;
7 active_cam = 0;
8 }
10 Scene::~Scene()
11 {
12 clear();
13 }
15 void Scene::clear()
16 {
17 delete [] name;
19 size_t i;
20 for(i=0; i<objects.size(); i++) {
21 delete objects[i];
22 }
23 for(i=0; i<lights.size(); i++) {
24 delete lights[i];
25 }
26 for(i=0; i<cameras.size(); i++) {
27 delete cameras[i];
28 }
29 }
31 void Scene::set_name(const char *name)
32 {
33 delete [] this->name;
34 this->name = new char[strlen(name) + 1];
35 strcpy(this->name, name);
36 }
38 const char *Scene::get_name() const
39 {
40 return name ? name : "<unknown>";
41 }
43 void Scene::add_object(Object *obj)
44 {
45 objects.push_back(obj);
46 }
48 void Scene::add_light(Light *lt)
49 {
50 lights.push_back(lt);
51 }
53 void Scene::add_camera(Camera *cam)
54 {
55 cameras.push_back(cam);
56 }
59 int Scene::get_object_count() const
60 {
61 return (int)objects.size();
62 }
64 int Scene::get_light_count() const
65 {
66 return (int)lights.size();
67 }
69 int Scene::get_camera_count() const
70 {
71 return (int)cameras.size();
72 }
75 Object *Scene::get_object(int idx)
76 {
77 return objects[idx];
78 }
80 const Object *Scene::get_object(int idx) const
81 {
82 return objects[idx];
83 }
85 Light *Scene::get_light(int idx)
86 {
87 return lights[idx];
88 }
90 const Light *Scene::get_light(int idx) const
91 {
92 return lights[idx];
93 }
95 Camera *Scene::get_camera(int idx)
96 {
97 return cameras[idx];
98 }
100 const Camera *Scene::get_camera(int idx) const
101 {
102 return cameras[idx];
103 }
105 void Scene::draw() const
106 {
107 if(active_cam) {
108 // TODO
109 }
111 int nobj = get_object_count();
112 for(int i=0; i<nobj; i++) {
113 objects[i]->draw();
114 }
115 }