Skylicht Engine
Loading...
Searching...
No Matches
CTransform.h
1/*
2!@
3MIT License
4
5Copyright (c) 2019 Skylicht Technology CO., LTD
6
7Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files
8(the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify,
9merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so,
10subject to the following conditions:
11
12The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
13
14THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
15INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
16IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
17WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19
20This file is part of the "Skylicht Engine".
21https://github.com/skylicht-lab/skylicht-engine
22!#
23*/
24
25#pragma once
26
27#include "Components/CComponentSystem.h"
28
29namespace Skylicht
30{
31 class CEntity;
32
33 namespace Transform
34 {
35 SKYLICHT_EXPORT extern core::vector3df Ox;
36 SKYLICHT_EXPORT extern core::vector3df Oy;
37 SKYLICHT_EXPORT extern core::vector3df Oz;
38
39 SKYLICHT_EXPORT void getNonScaleTransform(const core::matrix4& src, core::matrix4& dst);
40 }
41
46 class SKYLICHT_API CTransform : public CComponentSystem
47 {
48 protected:
49 bool m_hasChanged;
50 bool m_attached;
51
52 bool m_isWorldTransform;
53
54 public:
55 CTransform();
56
57 virtual ~CTransform();
58
59 virtual void initComponent();
60
61 virtual void updateComponent();
62
63 void attachTransform(CEntity* entity);
64
65 virtual core::vector3df getRelativePosition() = 0;
66
67 core::vector3df getWorldPosition();
68
69 inline void setChanged(bool b)
70 {
71 m_hasChanged = b;
72 }
73
74 inline bool hasChanged()
75 {
76 return m_hasChanged;
77 }
78
79 inline bool isAttached()
80 {
81 return m_attached;
82 }
83
84 inline bool isWorldTransform()
85 {
86 return m_isWorldTransform;
87 }
88
89 inline void setIsWorldTransform(bool b)
90 {
91 m_isWorldTransform = b;
92 m_hasChanged = true;
93 }
94
95 CTransform* getParent();
96
97 CGameObject* getParentObject();
98
99 CEntity* getParentEntity();
100
101 core::matrix4 calcWorldTransform();
102
103 void setWorldMatrix(const core::matrix4& world);
104
105 public:
106
107 virtual void setRelativeTransform(const core::matrix4& mat) = 0;
108
109 virtual const core::matrix4& getRelativeTransform() = 0;
110
111 virtual void getRelativeTransform(core::matrix4& matrix) = 0;
112
113 DECLARE_GETTYPENAME(CTransform)
114 };
115}
This is the object class that describes an entity.
Definition CEntity.h:58
Everything in the Skylicht Engine. You can start by looking at the topics.
Definition AudioDebugLog.h:29