|
| 1 | +/// Copyright 2025 Ana Oliveira, Humberto Gomes, Mariana Rocha, Sara Lopes |
| 2 | +/// |
| 3 | +/// Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | +/// you may not use this file except in compliance with the License. |
| 5 | +/// You may obtain a copy of the License at |
| 6 | +/// |
| 7 | +/// http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | +/// |
| 9 | +/// Unless required by applicable law or agreed to in writing, software |
| 10 | +/// distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | +/// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | +/// See the License for the specific language governing permissions and |
| 13 | +/// limitations under the License. |
| 14 | + |
| 15 | +#pragma once |
| 16 | + |
| 17 | +#include <filesystem> |
| 18 | +#include <memory> |
| 19 | +#include <string> |
| 20 | +#include <tinyxml2.h> |
| 21 | +#include <unordered_map> |
| 22 | +#include <vector> |
| 23 | + |
| 24 | +#include "engine/Camera.hpp" |
| 25 | +#include "engine/Entity.hpp" |
| 26 | +#include "engine/RenderPipeline.hpp" |
| 27 | + |
| 28 | +namespace engine { |
| 29 | + |
| 30 | +class Scene { |
| 31 | +private: |
| 32 | + int windowWidth, windowHeight; |
| 33 | + std::string windowTitle; |
| 34 | + Camera camera; |
| 35 | + |
| 36 | + // TODO - Phase 2 - add support for groups (linear scene is going to make it harder for phase 3) |
| 37 | + std::vector<std::unique_ptr<Entity>> entities; |
| 38 | + |
| 39 | +public: |
| 40 | + Scene(const std::string &file); |
| 41 | + Scene(const Scene &scene) = delete; |
| 42 | + Scene(Scene &&scene) = delete; |
| 43 | + |
| 44 | + int getWindowWidth() const; |
| 45 | + int getWindowHeight() const; |
| 46 | + Camera &getCamera(); |
| 47 | + |
| 48 | + void draw(const RenderPipeline &pipeline) const; |
| 49 | + void setWindowSize(int width, int height); |
| 50 | + |
| 51 | +private: |
| 52 | + const tinyxml2::XMLElement *getOnlyOneNodeFromXML(const tinyxml2::XMLNode *parent, |
| 53 | + const std::string &name); |
| 54 | + glm::vec3 getVectorFromXML(const tinyxml2::XMLElement *element); |
| 55 | + |
| 56 | + void getWindowFromXML(const tinyxml2::XMLElement *worldElement); |
| 57 | + void getCameraFromXML(const tinyxml2::XMLElement *worldElement); |
| 58 | + |
| 59 | + void getEntitiesFromWorldXML( |
| 60 | + const std::filesystem::path &sceneDirectory, |
| 61 | + std::unordered_map<std::string, std::shared_ptr<Model>> &loadedModels, |
| 62 | + const tinyxml2::XMLElement *worldElement); |
| 63 | + void getEntitiesFromGroupXML( |
| 64 | + const std::filesystem::path &sceneDirectory, |
| 65 | + std::unordered_map<std::string, std::shared_ptr<Model>> &loadedModels, |
| 66 | + const tinyxml2::XMLElement *groupdElement); |
| 67 | +}; |
| 68 | + |
| 69 | +} |
0 commit comments