goat3d

annotate 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
rev   line source
nuclear@0 1 #include "goat3d.h"
nuclear@0 2 #include "goat3d_impl.h"
nuclear@0 3
nuclear@0 4 static void delete_node_tree(Node *n);
nuclear@0 5
nuclear@0 6 Scene::Scene()
nuclear@0 7 : name("unnamed"), ambient(0.05, 0.05, 0.05)
nuclear@0 8 {
nuclear@0 9 }
nuclear@0 10
nuclear@0 11 Scene::~Scene()
nuclear@0 12 {
nuclear@0 13 clear();
nuclear@0 14 }
nuclear@0 15
nuclear@0 16 void Scene::clear()
nuclear@0 17 {
nuclear@0 18 for(size_t i=0; i<materials.size(); i++) {
nuclear@0 19 delete materials[i];
nuclear@0 20 }
nuclear@0 21 materials.clear();
nuclear@0 22
nuclear@0 23 for(size_t i=0; i<meshes.size(); i++) {
nuclear@0 24 delete meshes[i];
nuclear@0 25 }
nuclear@0 26 meshes.clear();
nuclear@0 27
nuclear@0 28 for(size_t i=0; i<lights.size(); i++) {
nuclear@0 29 delete lights[i];
nuclear@0 30 }
nuclear@0 31 lights.clear();
nuclear@0 32
nuclear@0 33 for(size_t i=0; i<cameras.size(); i++) {
nuclear@0 34 delete cameras[i];
nuclear@0 35 }
nuclear@0 36 cameras.clear();
nuclear@0 37
nuclear@0 38 for(size_t i=0; i<nodes.size(); i++) {
nuclear@0 39 delete_node_tree(nodes[i]);
nuclear@0 40 }
nuclear@0 41 nodes.clear();
nuclear@0 42
nuclear@0 43 name = "unnamed";
nuclear@0 44 }
nuclear@0 45
nuclear@0 46 static void delete_node_tree(Node *n)
nuclear@0 47 {
nuclear@0 48 for(int i=0; i<n->get_num_children(); i++) {
nuclear@0 49 delete_node_tree(n->get_child(i));
nuclear@0 50 }
nuclear@0 51 delete n;
nuclear@0 52 }
nuclear@0 53
nuclear@0 54 void Scene::set_name(const char *name)
nuclear@0 55 {
nuclear@0 56 this->name = name;
nuclear@0 57 }
nuclear@0 58
nuclear@0 59 const char *Scene::get_name() const
nuclear@0 60 {
nuclear@0 61 return name.c_str();
nuclear@0 62 }