Камера как часть сцены
This commit is contained in:
parent
01c92f8429
commit
047a2d9614
@ -4,6 +4,7 @@
|
||||
#include <list>
|
||||
|
||||
#include "Model.h"
|
||||
#include "Camera.h"
|
||||
|
||||
// Класс сцены
|
||||
class Scene
|
||||
@ -20,6 +21,7 @@ class Scene
|
||||
// Списки объектов, выступающих узлами
|
||||
std::list<Node> nodes; // Список пустых узлов
|
||||
std::list<Model> models; // Список моделей для рендера
|
||||
std::list<Camera> cameras; // Список камер
|
||||
|
||||
protected:
|
||||
void rebuld_tree(const Scene& from); // Перестройка дерева после копирования или присваивания
|
||||
|
@ -3,12 +3,12 @@
|
||||
// Конструктор пустой сцены
|
||||
Scene::Scene()
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Конструктор копирования
|
||||
Scene::Scene(const Scene ©): root(copy.root),
|
||||
nodes(copy.nodes), models(copy.models)
|
||||
nodes(copy.nodes), models(copy.models), cameras(copy.cameras)
|
||||
{
|
||||
rebuld_tree(copy);
|
||||
}
|
||||
@ -19,6 +19,7 @@ Scene& Scene::operator=(const Scene& other)
|
||||
root = other.root;
|
||||
nodes = other.nodes;
|
||||
models = other.models;
|
||||
cameras = other.cameras;
|
||||
|
||||
rebuld_tree(other);
|
||||
|
||||
@ -51,6 +52,10 @@ void Scene::rebuild_Nodes_list(T& nodes, const Scene& from)
|
||||
// Если можно привести к модели, то ищем родителя среди моделей
|
||||
if (dynamic_cast<Model*>(parent))
|
||||
move_parent(*it, from.models, this->models);
|
||||
else
|
||||
// Иначе проверяем на принадлежность к камерам
|
||||
if (dynamic_cast<Camera*>(parent))
|
||||
move_parent(*it, from.cameras, this->cameras);
|
||||
// Иначе это пустой узел
|
||||
else
|
||||
move_parent(*it, from.nodes, this->nodes);
|
||||
@ -80,4 +85,5 @@ void Scene::rebuld_tree(const Scene& from)
|
||||
// Восстановим родителей в пустых узлах для копии
|
||||
rebuild_Nodes_list(nodes, from);
|
||||
rebuild_Nodes_list(models, from);
|
||||
rebuild_Nodes_list(cameras, from);
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user