SpiecsEngine
 
Loading...
Searching...
No Matches
GltfCameras.h
Go to the documentation of this file.
1/**
2* @file GltfCameras.h.
3* @brief The GltfCameras 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 Cameras.
15 */
16 class GltfCameras : public GltfObject
17 {
18 public:
19
20 /**
21 * @brief Cameras Item data.
22 */
23 struct Item
24 {
25 float yfov; /* @brief camera fov. */
26 float znear; /* @brief camera near plane. */
27 float zfar; /* @brief camera far plane. */
28 int nodeIndex; /* @brief node index. */
29 };
30
31 public:
32
33 /**
34 * @brief Constructor Function.
35 * @param[in] data Specific Json element.
36 */
37 explicit GltfCameras(const Json& data)
39 {
41
42 m_CamerasData.resize(data.size());
43
44 for (int i = 0; i < data.size(); i++)
45 {
46 Item& item = m_CamerasData[i];
47 const Json& json = data[i];
48
49 item.yfov = GltfHelper::GetElementFloat(json, "perspective/yfov", 0.1f);
50 item.znear = GltfHelper::GetElementFloat(json, "perspective/znear", 0.1f);
51 item.zfar = GltfHelper::GetElementFloat(json, "perspective/zfar", 100.0f);
52 item.nodeIndex = -1;
53 }
54 }
55
56 /**
57 * @brief Destructor Function.
58 */
59 virtual ~GltfCameras() override = default;
60
61 private:
62
63 /**
64 * @brief Data of Gltf Json Cameras
65 */
67
68 /**
69 * @brief Allow GltfLoader and GltfCollection access all data this class.
70 */
71 friend class GltfLoader;
72 friend class GltfCollection;
73 };
74}
#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.
GltfAnimations(const Json &data)
Constructor Function.
virtual ~GltfAnimations() override=default
Destructor Function.
Wrapper of Gltf Json Animations.
GltfAsset(const Json &data)
Constructor Function.
Definition GltfAsset.h:36
virtual ~GltfAsset() override=default
Destructor Function.
Item m_AssetData
Data of Gltf Json Asset.
Definition GltfAsset.h:56
Wrapper of Gltf Json Asset.
Definition GltfAsset.h:17
virtual ~GltfBufferViews() override=default
Destructor Function.
std::vector< Item > m_BufferViewsData
Data of Gltf Json BufferViews.
GltfBufferViews(const Json &data)
Constructor Function.
Wrapper of Gltf Json BufferViews.
std::filesystem::path m_Path
gltf file directory path.
Definition GltfBuffers.h:88
std::vector< Item > m_BuffersData
Data of Gltf Json Buffers.
Definition GltfBuffers.h:93
virtual ~GltfBuffers() override=default
Destructor Function.
GltfBuffers(const Json &data, const std::filesystem::path &path)
Constructor Function.
Definition GltfBuffers.h:37
Wrapper of Gltf Json Buffers.
Definition GltfBuffers.h:17
virtual ~GltfCameras() override=default
Destructor Function.
std::vector< Item > m_CamerasData
Data of Gltf Json Cameras.
Definition GltfCameras.h:66
GltfCameras(const Json &data)
Constructor Function.
Definition GltfCameras.h:37
Wrapper of Gltf Json Cameras.
Definition GltfCameras.h:17
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.
Definition GltfHelper.h:130
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.
Definition GltfHelper.h:17
Loader of load gltf file or items.
Definition GltfLoader.h:23
GltfObject(const Json &data)
Constructor Function.
Definition GltfObject.h:33
Json m_Data
Specific Json element.
Definition GltfObject.h:45
virtual ~GltfObject()=default
Destructor Function.
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.
std::string generator
Definition GltfAsset.h:25
Asset Item data.
Definition GltfAsset.h:24
BufferViews Item data.
std::unique_ptr< std::vector< char > > buffer
Definition GltfBuffers.h:27
Buffers Item data.
Definition GltfBuffers.h:24
Cameras Item data.
Definition GltfCameras.h:24
Wrapper of 3D Transform.
Definition Transform.h:16