goat3d

view src/goat3d.cc @ 2:f358b482d286

added a couple of stuff in the chunk description
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 18 Aug 2013 23:49:22 +0300
parents
children cd71f0b92f44
line source
1 #include "goat3d.h"
2 #include "goat3d_impl.h"
4 static void delete_node_tree(Node *n);
6 Scene::Scene()
7 : name("unnamed"), ambient(0.05, 0.05, 0.05)
8 {
9 }
11 Scene::~Scene()
12 {
13 clear();
14 }
16 void Scene::clear()
17 {
18 for(size_t i=0; i<materials.size(); i++) {
19 delete materials[i];
20 }
21 materials.clear();
23 for(size_t i=0; i<meshes.size(); i++) {
24 delete meshes[i];
25 }
26 meshes.clear();
28 for(size_t i=0; i<lights.size(); i++) {
29 delete lights[i];
30 }
31 lights.clear();
33 for(size_t i=0; i<cameras.size(); i++) {
34 delete cameras[i];
35 }
36 cameras.clear();
38 for(size_t i=0; i<nodes.size(); i++) {
39 delete_node_tree(nodes[i]);
40 }
41 nodes.clear();
43 name = "unnamed";
44 }
46 static void delete_node_tree(Node *n)
47 {
48 for(int i=0; i<n->get_num_children(); i++) {
49 delete_node_tree(n->get_child(i));
50 }
51 delete n;
52 }
54 void Scene::set_name(const char *name)
55 {
56 this->name = name;
57 }
59 const char *Scene::get_name() const
60 {
61 return name.c_str();
62 }