SpiecsEngine
 
Loading...
Searching...
No Matches
GltfAccessors.h
Go to the documentation of this file.
1/**
2* @file GltfAccessors.h.
3* @brief The GltfAccessors Class Definitions.
4* @author Spices.
5*/
6
7#pragma once
8#include "Core/Core.h"
9#include "GltfObject.h"
10
11namespace Spices {
12
13 /**
14 * @brief Wrapper of Gltf Json Accessors.
15 */
17 {
18 public:
19
20 /**
21 * @brief Accessors Item data.
22 */
23 struct Item
24 {
25 int bufferView; /* @brief Buffer View Index. */
26 int byteOffset; /* @brief Byte offset in indexed buffer view. */
27 int componentType; /* @brief Buffer data bytes type. */
28 int count; /* @brief Buffer data count. */
29 glm::vec4 max; /* @brief Buffer data max vale. */
30 glm::vec4 min; /* @brief Buffer data min vale. */
31 std::string type; /* @brief Buffer data channel type. */
32 };
33
34 public:
35
36 /**
37 * @brief Constructor Function.
38 * @param[in] data Specific Json element.
39 */
40 explicit GltfAccessors(const Json& data)
42 {
44
45 m_AccessorsData.resize(data.size());
46
47 for (int i = 0; i < data.size(); i++)
48 {
49 Item& item = m_AccessorsData[i];
50 const Json& json = data[i];
51
52 item.bufferView = GltfHelper::GetElementInt(json, "bufferView", -1);
53 item.byteOffset = GltfHelper::GetElementInt(json, "byteOffset", 0);
54 item.componentType = GltfHelper::GetElementInt(json, "componentType", -1);
55 item.count = GltfHelper::GetElementInt(json, "count", -1);
56 item.max = GltfHelper::GetVector(GltfHelper::GetElementJsonArray(json, "max", { 0.0, 0.0, 0.0, 0.0 }));
57 item.min = GltfHelper::GetVector(GltfHelper::GetElementJsonArray(json, "min", { 0.0, 0.0, 0.0, 0.0 }));
58 item.type = GltfHelper::GetElementString(json, "type", "");
59 }
60 }
61
62 /**
63 * @brief Destructor Function.
64 */
65 virtual ~GltfAccessors() override = default;
66
67 private:
68
69 /**
70 * @brief Data of Gltf Json Accessors
71 */
73
74 /**
75 * @brief Allow GltfLoader and GltfCollection access all data this class.
76 */
77 friend class GltfLoader;
78 friend class GltfCollection;
79 };
80}
#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.
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.
Definition Camera.h:59
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.
Definition EditorWorld.h:18
T & AddComponent(Args &&... args)
Template Function. Used for add specific component to entity.
Definition Entity.h:53
T & GetComponent() const
Get Component owned by this entity.
Definition Entity.h:75
void RemoveComponent() const
Remove Component owned from this entity.
Definition Entity.h:85
Entity()=default
Constructor Function.
void AddToRoot()
Add a entity to this world root.
Definition Entity.h:101
World * m_World
A specific world Pointer.
Definition Entity.h:171
const UUID GetUUID()
Get UUID form UUIDComponent.
Definition Entity.h:121
Entity(entt::entity handle, World *world)
Constructor Function. Init class variable. Usually call it.
Definition Entity.h:35
void RemoveFromRoot()
Remove a entity from this world root.
Definition Entity.h:93
operator bool() const
Empty Operation.
Definition Entity.h:127
virtual ~Entity()=default
Destructor Function.
bool HasComponent() const
If Component is owned by this entity or not.
Definition Entity.h:112
operator uint32_t() const
Empty Operation.
Definition Entity.h:133
Entity Class. This class defines the specific behaves of Entity.
Definition Entity.h:20
This Class is the basic Event Class. Inherit from it and create specific event class.
Definition Event.h:96
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.
Loader of load gltf file or items.
Definition GltfLoader.h:23
Wrapper of Gltf Json element.
Definition GltfObject.h:19
GltfPack Class. This class defines gltf type meshPack.
Definition GltfPack.h:19
This Class is inherited from KeyEvent Class.
Definition KeyEvent.h:57
void MouseZoom(float delta)
bool OnKeyPressed(KeyPressedEvent &e)
glm::vec3 GetForwardDirection() const
glm::vec3 GetRightDirection() const
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.
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
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
This Class is inherited from Event Class.
Definition MouseEvent.h:86
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.
Definition SlateEvent.h:18
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.
Definition TimeStep.h:22
TransformComponent Class. This class defines the specific behaves of TransformComponent.
UUIDComponent Class. This class defines the specific behaves of UUIDComponent.
This class helps to generate a uuid for one resource.
Definition UUID.h:16
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.
Definition World.cpp:58
void AddToRoot(Entity &entity)
Add a entity to this world root.
Definition World.cpp:67
World Class. This class defines the basic behaves of World. When we create an new world,...
Definition World.h:41
The container combines hashmap and list together. Used in the case that we want iter a hashmap in ord...
Accessors Item data.
Wrapper of 3D Transform.
Definition Transform.h:16