Botcraft 1.21.11
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
37#endif
38
39 class Model
40 {
41
42 private:
43 // Constructor from a json file
44 Model(const std::string& filepath, const bool custom);
45 // Fluid constructor
46 Model(const double height, const std::string& texture);
47 public:
48 // Base constructor
49 Model();
50 static const Model& GetModel(const std::string& filepath, const bool custom);
51 static Model GetModel(const double height, const std::string& texture);
52
53 Model& operator+=(const Model& m);
54
55 friend Model operator+(Model m1, const Model& m2)
56 {
57 m1 += m2;
58 return m1;
59 }
60
61 /// @brief Compare two models. Will never return true if compiled with GUI
62 /// @param other Model to compare to
63 /// @return True if both models are the same, false otherwise
64 bool IsSame(const Model& other) const;
65
66 const std::set<AABB>& GetColliders() const;
67 void SetColliders(const std::set<AABB>& colliders_);
68
69 static void ClearCache();
70
71#if USE_GUI
72 const std::vector<FaceDescriptor>& GetFaces() const;
73 std::vector<FaceDescriptor>& GetFaces();
74#endif
75 private:
76 static std::unordered_map<std::string, Model> cached_models;
77
78#if USE_GUI
80 std::map<std::string, std::string> textures_variables;
81 std::map<std::string, std::pair<int, int> > textures_base_size;
82
83 //All the faces of this model
84 std::vector<FaceDescriptor> faces;
85#endif
86 std::set<AABB> colliders;
87 };
88} // 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:76
std::map< std::string, std::string > textures_variables
Definition Model.hpp:80
const std::vector< FaceDescriptor > & GetFaces() const
Definition Model.cpp:601
std::map< std::string, std::pair< int, int > > textures_base_size
Definition Model.hpp:81
std::vector< FaceDescriptor > faces
Definition Model.hpp:84
static const Model & GetModel(const std::string &filepath, const bool custom)
Definition Model.cpp:23
std::set< AABB > colliders
Definition Model.hpp:86
friend Model operator+(Model m1, const Model &m2)
Definition Model.hpp:55
bool ambient_occlusion
Definition Model.hpp:79
bool IsSame(const Model &other) const
Compare two models.
Definition Model.cpp:574
Renderer::FaceTransformation transformations
Definition Model.hpp:30
std::vector< bool > use_tintindexes
Definition Model.hpp:35
Orientation cullface_direction
Definition Model.hpp:34
std::vector< std::string > texture_names
Definition Model.hpp:33
Renderer::Face face
Definition Model.hpp:32
Orientation orientation
Definition Model.hpp:31