nuclear@5: #include nuclear@1: #include "scene.h" nuclear@12: #include "min3d.h" nuclear@1: nuclear@1: Scene::Scene() nuclear@1: { nuclear@1: name = 0; nuclear@6: active_cam = 0; nuclear@1: } nuclear@1: nuclear@1: Scene::~Scene() nuclear@1: { nuclear@1: clear(); nuclear@1: } nuclear@1: nuclear@1: void Scene::clear() nuclear@1: { nuclear@1: delete [] name; nuclear@1: nuclear@1: size_t i; nuclear@1: for(i=0; iname; nuclear@1: this->name = new char[strlen(name) + 1]; nuclear@1: strcpy(this->name, name); nuclear@1: } nuclear@1: nuclear@1: const char *Scene::get_name() const nuclear@1: { nuclear@1: return name ? name : ""; nuclear@1: } nuclear@1: nuclear@12: void Scene::add(SceneNode *node) nuclear@6: { nuclear@12: nodes.push_back(node); nuclear@12: nuclear@12: switch(node->get_type()) { nuclear@12: case NODE_OBJECT: nuclear@12: objects.push_back((Object*)node); nuclear@12: break; nuclear@12: nuclear@12: case NODE_LIGHT: nuclear@12: lights.push_back((Light*)node); nuclear@12: break; nuclear@12: nuclear@12: case NODE_CAMERA: nuclear@12: cameras.push_back((Camera*)node); nuclear@12: break; nuclear@12: nuclear@12: default: nuclear@12: break; nuclear@12: } nuclear@12: nuclear@12: sel.clear(); nuclear@6: } nuclear@6: nuclear@12: int Scene::get_node_count() const nuclear@6: { nuclear@12: return (int)nodes.size(); nuclear@6: } nuclear@6: nuclear@6: int Scene::get_object_count() const nuclear@6: { nuclear@6: return (int)objects.size(); nuclear@6: } nuclear@6: nuclear@6: int Scene::get_light_count() const nuclear@6: { nuclear@6: return (int)lights.size(); nuclear@6: } nuclear@6: nuclear@6: int Scene::get_camera_count() const nuclear@6: { nuclear@6: return (int)cameras.size(); nuclear@6: } nuclear@6: nuclear@12: SceneNode *Scene::get_node(int idx) nuclear@12: { nuclear@12: return nodes[idx]; nuclear@12: } nuclear@12: nuclear@12: const SceneNode *Scene::get_node(int idx) const nuclear@12: { nuclear@12: return nodes[idx]; nuclear@12: } nuclear@6: nuclear@6: Object *Scene::get_object(int idx) nuclear@6: { nuclear@6: return objects[idx]; nuclear@6: } nuclear@6: nuclear@6: const Object *Scene::get_object(int idx) const nuclear@6: { nuclear@6: return objects[idx]; nuclear@6: } nuclear@6: nuclear@6: Light *Scene::get_light(int idx) nuclear@6: { nuclear@6: return lights[idx]; nuclear@6: } nuclear@6: nuclear@6: const Light *Scene::get_light(int idx) const nuclear@6: { nuclear@6: return lights[idx]; nuclear@6: } nuclear@6: nuclear@6: Camera *Scene::get_camera(int idx) nuclear@6: { nuclear@6: return cameras[idx]; nuclear@6: } nuclear@6: nuclear@6: const Camera *Scene::get_camera(int idx) const nuclear@6: { nuclear@6: return cameras[idx]; nuclear@6: } nuclear@6: nuclear@15: void Scene::set_active_camera(Camera *cam) nuclear@15: { nuclear@15: active_cam = cam; nuclear@15: } nuclear@15: nuclear@15: Camera *Scene::get_active_camera() const nuclear@15: { nuclear@15: return active_cam; nuclear@15: } nuclear@15: nuclear@1: void Scene::draw() const nuclear@1: { nuclear@6: if(active_cam) { nuclear@6: // TODO nuclear@6: } nuclear@6: nuclear@12: int num_nodes = get_node_count(); nuclear@12: for(int i=0; idraw(selected); nuclear@6: } nuclear@1: } nuclear@12: nuclear@12: void Scene::select(int s) nuclear@12: { nuclear@12: for(size_t i=0; i= 0 && idx < (int)sel.size() ? sel[idx] : -1; nuclear@12: }