Botcraft 1.21.4
Loading...
Searching...
No Matches
Model.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <set>
4#include <string>
5#include <unordered_map>
6#include <vector>
7
9
10#if USE_GUI
11#include <map>
12
16#endif
17
18namespace Botcraft
19{
20#if USE_GUI
35#endif
36
37 class Model
38 {
39
40 private:
41 // Constructor from a json file
42 Model(const std::string& filepath, const bool custom);
43 // Fluid constructor
44 Model(const double height, const std::string& texture);
45 public:
46 // Base constructor
47 Model();
48 static const Model& GetModel(const std::string& filepath, const bool custom);
49 static Model GetModel(const double height, const std::string& texture);
50
51 Model& operator+=(const Model& m);
52
53 friend Model operator+(Model m1, const Model& m2)
54 {
55 m1 += m2;
56 return m1;
57 }
58
59 /// @brief Compare two models. Will never return true if compiled with GUI
60 /// @param other Model to compare to
61 /// @return True if both models are the same, false otherwise
62 bool IsSame(const Model& other) const;
63
64 const std::set<AABB>& GetColliders() const;
65 void SetColliders(const std::set<AABB>& colliders_);
66
67 static void ClearCache();
68
69#if USE_GUI
70 const std::vector<FaceDescriptor>& GetFaces() const;
71 std::vector<FaceDescriptor>& GetFaces();
72#endif
73 private:
74 static std::unordered_map<std::string, Model> cached_models;
75
76#if USE_GUI
78 std::map<std::string, std::string> textures_variables;
79 std::map<std::string, std::pair<int, int> > textures_base_size;
80
81 //All the faces of this model
82 std::vector<FaceDescriptor> faces;
83#endif
84 std::set<AABB> colliders;
85 };
86} // Botcraft
const std::set< AABB > & GetColliders() const
Definition Model.cpp:585
Model & operator+=(const Model &m)
Definition Model.cpp:564
static void ClearCache()
Definition Model.cpp:595
void SetColliders(const std::set< AABB > &colliders_)
Definition Model.cpp:590
static std::unordered_map< std::string, Model > cached_models
Definition Model.hpp:74
std::map< std::string, std::string > textures_variables
Definition Model.hpp:78
const std::vector< FaceDescriptor > & GetFaces() const
Definition Model.cpp:601
std::map< std::string, std::pair< int, int > > textures_base_size
Definition Model.hpp:79
std::vector< FaceDescriptor > faces
Definition Model.hpp:82
static const Model & GetModel(const std::string &filepath, const bool custom)
Definition Model.cpp:23
std::set< AABB > colliders
Definition Model.hpp:84
friend Model operator+(Model m1, const Model &m2)
Definition Model.hpp:53
bool ambient_occlusion
Definition Model.hpp:77
bool IsSame(const Model &other) const
Compare two models.
Definition Model.cpp:574
Renderer::FaceTransformation transformations
Definition Model.hpp:28
std::vector< bool > use_tintindexes
Definition Model.hpp:33
Orientation cullface_direction
Definition Model.hpp:32
std::vector< std::string > texture_names
Definition Model.hpp:31
Renderer::Face face
Definition Model.hpp:30
Orientation orientation
Definition Model.hpp:29