Game of Ur 0.3.3
This is a computer adaptation of Game of Ur, written in C++ mainly using SDL and OpenGL.
Loading...
Searching...
No Matches
model.hpp
Go to the documentation of this file.
1
11
12#ifndef FOOLSENGINE_MODEL_H
13#define FOOLSENGINE_MODEL_H
14
15#include <vector>
16#include <string>
17#include <map>
18#include <unordered_set>
19
20#include <GL/glew.h>
21#include <glm/glm.hpp>
22
23#include <assimp/Importer.hpp>
24#include <assimp/scene.h>
25#include <assimp/material.h>
26
27#include "core/ecs_world_resource_ext.hpp" // this instead of the regular ECS and resource includes
28#include "vertex.hpp"
29#include "mesh.hpp"
30#include "texture.hpp"
31#include "shader_program.hpp"
32#include "material.hpp"
33
34
35namespace ToyMaker {
36
54 class StaticModel : public Resource<StaticModel>{
55 public:
61 inline static std::string getResourceTypeName() { return "StaticModel"; }
62
68 inline static std::string getComponentTypeName() { return "StaticModel"; }
69
79 StaticModel(const std::vector<std::shared_ptr<StaticMesh>>& meshHandles, const std::vector<std::shared_ptr<Material>>& materialHandles);
80
83
85 StaticModel(StaticModel&& other);
87 StaticModel(const StaticModel& other);
88
92 StaticModel& operator=(const StaticModel& other);
93
99 std::vector<std::shared_ptr<StaticMesh>> getMeshHandles() const;
100
106 std::vector<std::shared_ptr<Material>> getMaterialHandles() const;
107
108 private:
112 std::vector<std::shared_ptr<StaticMesh>> mMeshHandles {};
117 std::vector<std::shared_ptr<Material>> mMaterialHandles {};
118
123 void free();
124
129 void stealResources(StaticModel& other);
130
135 void copyResources(const StaticModel& other);
136
141 void destroyResource();
142
147 void releaseResource();
148 };
149
186 class StaticModelFromFile: public ResourceConstructor<StaticModel, StaticModelFromFile> {
187 public:
193
199 inline static std::string getResourceConstructorName() { return "fromFile"; }
200
201 private:
202
210 std::shared_ptr<IResource> createResource(const nlohmann::json& methodParameters) override;
211 };
212}
213
214#endif
ResourceConstructor(int explicitlyInitializeMe)
Definition resource_database.hpp:491
Resource(int explicitlyInitializeMe)
Definition resource_database.hpp:389
StaticModelFromFile()
Creates a StaticModelFromFile object.
Definition model.cpp:91
std::shared_ptr< IResource > createResource(const nlohmann::json &methodParameters) override
Creates a StaticModel resource based on its parameters.
Definition model.cpp:95
static std::string getResourceConstructorName()
Gets the resource constructor type string for this constructor.
Definition model.hpp:199
This engine's representation of a single unrigged 3D model.
Definition model.hpp:54
void destroyResource()
Destroys the resources associated with this object.
Definition model.cpp:86
std::vector< std::shared_ptr< StaticMesh > > getMeshHandles() const
Gets the list of StaticMeshes associated with this Model object.
Definition model.cpp:68
std::vector< std::shared_ptr< StaticMesh > > mMeshHandles
The meshes that make up this model.
Definition model.hpp:112
StaticModel(const std::vector< std::shared_ptr< StaticMesh > > &meshHandles, const std::vector< std::shared_ptr< Material > > &materialHandles)
Constructs a model out of a list of handles to meshes and materials.
Definition model.cpp:28
void stealResources(StaticModel &other)
Utility method for taking resources from another instance of this class.
Definition model.cpp:74
std::vector< std::shared_ptr< Material > > getMaterialHandles() const
Gets the materials associated with this model object.
Definition model.cpp:69
void free()
Utility method for destroying resources associated with this model.
Definition model.cpp:70
void releaseResource()
Releases resources associated with this object so that they may be claimed by another part of the pro...
Definition model.cpp:89
~StaticModel()
Model destructor.
Definition model.cpp:37
std::vector< std::shared_ptr< Material > > mMaterialHandles
The materials that correspond to each mesh on this model.
Definition model.hpp:117
static std::string getResourceTypeName()
Gets the resource type string for this object.
Definition model.hpp:61
static std::string getComponentTypeName()
Gets the component type string for this object.
Definition model.hpp:68
StaticModel & operator=(StaticModel &&other)
Move assignment.
Definition model.cpp:45
void copyResources(const StaticModel &other)
Utility method for deeply replicating resources from another instance of this class.
Definition model.cpp:82
Header file that makes Resource objects useable as ECS components.
Functions related to rendering materials.
A file containing the ToyMaker::StaticMesh class and related structures.
Namespace containing all class definitions and functions related to the ToyMaker engine.
Definition camera_system.hpp:20
A file containing class definitions for wrappers over OpenGL shader programs.
Header containing definitions of classes and functions related to loading and using Texture resources...
Contains engine's built-in vertex definitions, along with their associated attribute locations in the...