2
3
4
5
9#include <nlohmann/json.hpp>
14
15
26
27
28
29
33
34
35
36
40
41
42
43
44
45 static void SplitGltfAttribute(std::string attribute, std::string* semanticName, uint32_t* semanticIndex);
48
49
50
51
55
56
57
58
62
63
64
65
66
67
68 static std::string
GetElementString(
const Json::object_t& root,
const char* path,
const std::string& pDefault);
71
72
73
74
75
76
77 static float GetElementFloat(
const Json::object_t& root,
const char* path,
float pDefault);
80
81
82
83
84
85
86 static int GetElementInt(
const Json::object_t& root,
const char* path,
int pDefault);
89
90
91
92
93
94
95 static bool GetElementBoolean(
const Json::object_t& root,
const char* path,
bool pDefault);
98
99
100
101
102
103
107
108
109
110
111
112
118
119
120
121
122
123
124
125 template <
class type>
126 static type
GetElement(
const Json::object_t* pRoot,
const char* path, type pDefault);
130 inline type
GltfHelper::GetElement(
const Json::object_t* pRoot,
const char* path, type pDefault)
134 const char* p = path;
138 for (; *p !=
'/' && *p != 0 && *p !=
'['; p++);
139 memcpy(token, path, p - path);
142 auto it = pRoot->find(token);
143 if (it == pRoot->end())
152 for (; *p != 0 && *p !=
']'; p++);
153 pRoot = it->second.at(i).get_ptr<
const Json::object_t*>();
158 if (it->second.is_object())
160 pRoot = it->second.get_ptr<
const Json::object_t*>();
164 return it->second.get<type>();
#define SPICES_PROFILE_ZONE
virtual void OnEvent(Event &e) override
The interface inherited from NativeScriptComponent, which is called on the global event function poin...
glm::vec3 GetForwardDirection() const
Get Camera Forward(z) Direction.
glm::vec3 m_FocalPoint
The focus point. Init with 0.
uint32_t m_ViewportWidth
The Viewport size.
glm::vec3 GetUpDirection() const
Get Camera Up(y) Direction.
CameraController()=default
Constructor Function.
std::shared_ptr< Camera > m_Camera
The camera smart pointer get from owner's camera component.
bool OnKeyPressed(KeyPressedEvent &e)
Event OnKeyPressed. We do nothing here.
virtual void OnDeSerialize() override
The interface inherited from Component, which is used for deserialize this class.
bool OnMouseScroll(MouseScrolledEvent &e)
Event OnMouseScroll. Scale the camera.
void MousePan(const glm::vec2 &delta)
Calculate Camera Drag.
void MouseZoom(const float &delta)
Calculate Camera Zoom.
void UpdateView() const
Setting camera transform component position. We already set rotation in MouseRotate().
std::pair< float, float > PanSpeed() const
Calculate Camera Drag speed.
virtual void OnSerialize() override
The interface inherited from Component, which is used for serialize this class.
glm::vec2 m_InitialMousePosition
The mouse position. Init with 0.
glm::quat GetOrientation() const
Get Camera quaternion rotation.
virtual ~CameraController() override=default
Destructor Function.
void MouseRotate(const glm::vec2 &delta) const
Calculate Camera Rotate.
virtual void OnConstruction() override
The interface inherited from NativeScriptComponent, which is called on this attached to an entity....
bool OnSlateResized(SlateResizeEvent &e)
Event OnWindowResized. Reset Camera aspect ratio.
uint32_t m_ViewportHeight
float ZoomSpeed() const
Calculate Camera Zoom speed.
float m_Distance
The camera spring arm. Init with 10.
glm::vec3 GetRightDirection() const
Get Camera Right(x) Direction.
TransformComponent * m_CameraTranComp
The camera transform component pointer get from owner's transform component.
glm::vec3 CalculatePosition() const
Calculate camera transform component position using the class member parameters.
virtual void OnTick(TimeStep &ts) override
The interface inherited from NativeScriptComponent, which is called every engine loop frame....
float RotationSpeed() const
Calculate Camera Rotate speed.
float m_ZoomLevel
Zoom Level, for orthographic type camera.
CameraController Class. This class inherit from NativeScriptComponent. It receives Mouse Event and Ke...
Camera Class. This class just encapsulate Projection Matrix.
static std::string GetClassString(ClassType t)
Get Class Name as string.
Class Static Function Library.
virtual void OnPreActivate() override
This interface define the specific world behave before on activated.
virtual void OnDeactivate() override
This interface defines the specific world behave after on activated.
virtual void OnActivate(TimeStep &ts) override
This interface define the specific world behave on activated.
EditorWorld Class. This class defines the specific behave of EditorWorld.
T & AddComponent(Args &&... args)
Template Function. Used for add specific component to entity.
T & GetComponent() const
Get Component owned by this entity.
void RemoveComponent() const
Remove Component owned from this entity.
Entity()=default
Constructor Function.
void AddToRoot()
Add a entity to this world root.
World * m_World
A specific world Pointer.
const UUID GetUUID()
Get UUID form UUIDComponent.
Entity(entt::entity handle, World *world)
Constructor Function. Init class variable. Usually call it.
void RemoveFromRoot()
Remove a entity from this world root.
operator bool() const
Empty Operation.
virtual ~Entity()=default
Destructor Function.
bool HasComponent() const
If Component is owned by this entity or not.
operator uint32_t() const
Empty Operation.
Entity Class. This class defines the specific behaves of Entity.
This Class is the basic Event Class. Inherit from it and create specific event class.
virtual ~GltfAccessors() override=default
Destructor Function.
GltfAccessors(const Json &data)
Constructor Function.
std::vector< Item > m_AccessorsData
Data of Gltf Json Accessors.
Wrapper of Gltf Json Accessors.
std::unique_ptr< GltfBufferViews > m_BufferViews
std::unique_ptr< GltfScene > m_Scene
std::unique_ptr< GltfTextures > m_Textures
std::unique_ptr< GltfMaterials > m_Materials
std::unique_ptr< GltfBuffers > m_Buffers
std::unique_ptr< GltfSamplers > m_Samplers
Entity CreateEntityRecursive(World *world, const std::string &tag, uint32_t node, const glm::mat4 &model, std::shared_ptr< LoadingState > loadingState)
Create Entity recursive from gltf file nodes.
std::unique_ptr< GltfAnimations > m_Animations
std::unique_ptr< GltfCameras > m_Cameras
std::unique_ptr< GltfAccessors > m_Accessors
std::unique_ptr< GltfImages > m_Images
std::unique_ptr< GltfNodes > m_Nodes
GltfCollection(const std::string &path)
Constructor Function.
std::unique_ptr< GltfSkins > m_Skins
std::unique_ptr< GltfAsset > m_Asset
void CreateEntity(World *world, const std::string &tag, Transform transform={})
Create Entity instance from gltf file.
std::unique_ptr< GltfScenes > m_Scenes
std::unique_ptr< GltfLights > m_Lights
virtual ~GltfCollection()=default
Destructor Function.
std::unique_ptr< GltfMeshes > m_Meshes
Wrapper of Gltf file data.
static glm::mat4 GetMatrix(const Json::array_t &accessor)
Turn a Json::array_t to glm::mat4.
static Json::array_t GetElementJsonArray(const Json::object_t &root, const char *path, Json::array_t pDefault)
Get array value in Json::object_t.
static int GetElementInt(const Json::object_t &root, const char *path, int pDefault)
Get int value in Json::object_t.
static glm::vec4 GetElementVector(Json::object_t &root, const char *path, glm::vec4 pDefault)
Get vec4 value in Json::object_t.
static std::string GetElementString(const Json::object_t &root, const char *path, const std::string &pDefault)
Get string value in Json::object_t.
static bool GetElementBoolean(const Json::object_t &root, const char *path, bool pDefault)
Get bool value in Json::object_t.
static int GetDimensions(const std::string &str)
Get Variable Type dimensions.
static uint32_t SizeOfFormat(VkFormat format)
static float GetElementFloat(const Json::object_t &root, const char *path, float pDefault)
Get float value in Json::object_t.
static void SplitGltfAttribute(std::string attribute, std::string *semanticName, uint32_t *semanticIndex)
Split digital number in attribute.
static int GetFormatSize(int id)
Get Variable Type bytes.
static type GetElement(const Json::object_t *pRoot, const char *path, type pDefault)
Get specific type in Json::object_t.
static VkFormat GetFormat(const std::string &str, int id)
static glm::vec4 GetVector(const Json::array_t &accessor)
Turn a Json::array_t to glm::vec4.
Static functions to help resolve Gltf json.
Loader of load gltf file or items.
GltfObject(const Json &data)
Constructor Function.
Json m_Data
Specific Json element.
virtual ~GltfObject()=default
Destructor Function.
Wrapper of Gltf Json element.
GltfPack Class. This class defines gltf type meshPack.
This Class is inherited from KeyEvent Class.
void MouseZoom(float delta)
bool OnKeyPressed(KeyPressedEvent &e)
glm::vec3 GetForwardDirection() const
glm::vec3 GetRightDirection() const
glm::vec2 m_InitialMousePosition
virtual void OnEvent(Event &e) override
This interface defines the behaves on specific component event happened.
virtual void OnTick(TimeStep &ts) override
This interface defines the behaves on specific component tick every frame.
float RotationSpeed() const
virtual void OnSerialize() override
This interface defines how to serialize.
virtual void OnDeSerialize() override
This interface defines how to deserialize.
std::pair< float, float > PanSpeed() const
virtual ~MeshController() override=default
void MouseRotate(const glm::vec2 &delta) const
std::any m_CameraTranComp
glm::vec3 CalculatePosition() const
virtual void OnConstruction() override
This interface defines the behaves on specific component added.
glm::quat GetOrientation() const
void MousePan(const glm::vec2 &delta)
glm::vec3 GetUpDirection() const
NativeScriptComponent Class. This class defines the specific behaves of NativeScriptComponent....
virtual void OnSystemShutDown() override
This interface defines the behave on specific system shutdown. Called when system poped from SystemMa...
virtual void OnSystemInitialize() override
This interface defines the behave on specific system initialized. Called when system Pushed to System...
ResourceSystem(const std::string &systemName)
Constructor Function. Init class variable. Usually call it.
virtual void OnSystemUpdate(TimeStep &ts) override
This interface defines the behave on specific system updated every frame.
static std::vector< std::string > m_ResourceSearchFolder
Registry Resource Search Folder.
virtual ~ResourceSystem() override=default
Destructor Function.
static const std::vector< std::string > & GetSearchFolder()
Get Resource Search Folder.
static void RegistryResourceFolder(const std::string &folder)
Registry Resource Search Folder.
virtual void OnEvent(Event &event) override
This interface defines the behave on global event function pointer is called.
ResourceSystem Class. Handles resource load/unload event.
This Class is inherited from Event Class. Called by Viewport Resize.
static std::string WCharToChar(const wchar_t *wc)
Transform wide char to char.
static std::wstring CharToWChar(const char *c)
Transform char to wide char.
static bool StringsEqual(const char *str0, const char *str1)
Determine if the strings given are equal. Platform Specific.
static std::vector< std::string > SplitString(const std::string &input, char delimiter)
Split a string to a string vector container use a char.
String Static Function Library.
void OnEvent(Event &event)
The root event function pointer.
SystemManager()
Constructor Function.
static void Run(TimeStep &ts)
Update all system that pushed to this manager.
static SystemManager & Get()
Get Static SystemManager.
static std::unique_ptr< SystemManager > m_SystemManager
Static SystemManager variable.
SystemManager & PushSystem(Args &&... args)
Push a system to this manager.
SystemManager(const SystemManager &)=delete
Copy Constructor Function.
virtual ~SystemManager()
Destructor Function.
SystemManager & PopSystem(const std::string &systemName)
Push a system to this manager.
static scl::linked_unordered_map< std::string, std::shared_ptr< System > > m_Identities
Static System Map.
SystemManager & operator=(const SystemManager &)=delete
Copy Assignment Operation.
SystemManager Class. This class defines the behave of SystemManager.
virtual ~System()=default
Destructor Function.
System & operator=(const System &)=delete
Copy Assignment Operation.
virtual void OnSystemShutDown()
This interface defines the behave on specific system shutdown. Called when system poped from SystemMa...
std::string m_SystemName
Specific system name.
virtual void OnSystemUpdate(TimeStep &ts)
This interface defines the behave on specific system updated every frame.
System(const std::string &systemName)
Constructor Function. Init class variable. Usually call it.
System(const System &)=delete
Copy Constructor Function.
virtual void OnEvent(Event &event)
This interface defines the behave on global event function pointer is called.
virtual void OnSystemInitialize()
This interface defines the behave on specific system initialized. Called when system Pushed to System...
System Class. This class defines the basic behaves of System. When we create an new System,...
This Class handles our engine time step during frames. Global Unique.
UUIDComponent Class. This class defines the specific behaves of UUIDComponent.
This class helps to generate a uuid for one resource.
virtual void OnDeactivate() override
This interface defines the specific world behave after on activated.
virtual void OnActivate(TimeStep &ts) override
This interface define the specific world behave on activated.
virtual void OnPreActivate() override
This interface define the specific world behave before on activated.
void RemoveFromRoot(Entity &entity)
Remove a entity from this world root.
void AddToRoot(Entity &entity)
Add a entity to this world root.
World Class. This class defines the basic behaves of World. When we create an new world,...
The container combines hashmap and list together. Used in the case that we want iter a hashmap in ord...
std::atomic_uint32_t loadedMeshes