修改游戏底层矩阵相关
This commit is contained in:
@@ -1,4 +1,14 @@
|
||||
#include "BaseNode.h"
|
||||
#include "EngineCore/Game.h"
|
||||
BaseNode::BaseNode()
|
||||
{
|
||||
Game::GetInstance().m_nodeCount++;
|
||||
}
|
||||
|
||||
BaseNode::~BaseNode()
|
||||
{
|
||||
Game::GetInstance().m_nodeCount--;
|
||||
}
|
||||
|
||||
void BaseNode::Init()
|
||||
{
|
||||
@@ -67,7 +77,7 @@ void BaseNode::SetCallbackOnUpdate(const UpdateCallback &cb)
|
||||
|
||||
void BaseNode::SetChildIterationTransform()
|
||||
{
|
||||
TransformT n_transform;
|
||||
Transform n_transform;
|
||||
n_transform.position = transform.position + transformIter.position;
|
||||
n_transform.scale = transform.scale * transformIter.scale;
|
||||
n_transform.rotation = transform.rotation + transformIter.rotation;
|
||||
@@ -147,7 +157,7 @@ void BaseNode::AddChild(RefPtr<BaseNode> child)
|
||||
// 如果组件有transform标签,则设置其位置
|
||||
if (child->hasTag(Tag::TRANSFORM))
|
||||
{
|
||||
TransformT n_transform;
|
||||
Transform n_transform;
|
||||
n_transform.position = transform.position + transformIter.position;
|
||||
n_transform.scale = transform.scale * transformIter.scale;
|
||||
n_transform.rotation = transform.rotation + transformIter.rotation;
|
||||
@@ -172,7 +182,7 @@ void BaseNode::OnAdded(BaseNode *node)
|
||||
m_Parent = node;
|
||||
}
|
||||
|
||||
void BaseNode::SetIterationTransform(TransformT n_transform)
|
||||
void BaseNode::SetIterationTransform(Transform n_transform)
|
||||
{
|
||||
if (n_transform == transformIter)
|
||||
return;
|
||||
@@ -181,12 +191,12 @@ void BaseNode::SetIterationTransform(TransformT n_transform)
|
||||
SetChildIterationTransform();
|
||||
}
|
||||
|
||||
TransformT BaseNode::GetIterationTransform()
|
||||
Transform BaseNode::GetIterationTransform()
|
||||
{
|
||||
return transformIter;
|
||||
}
|
||||
|
||||
void BaseNode::SetTransform(TransformT n_transform)
|
||||
void BaseNode::SetTransform(Transform n_transform)
|
||||
{
|
||||
if (n_transform == transform)
|
||||
return;
|
||||
@@ -195,12 +205,12 @@ void BaseNode::SetTransform(TransformT n_transform)
|
||||
SetChildIterationTransform();
|
||||
}
|
||||
|
||||
TransformT BaseNode::GetTransform()
|
||||
Transform BaseNode::GetTransform()
|
||||
{
|
||||
return transform;
|
||||
}
|
||||
|
||||
void BaseNode::SetPos(VecFPos pos)
|
||||
void BaseNode::SetPos(Vec2 pos)
|
||||
{
|
||||
if (pos == this->transform.position)
|
||||
return;
|
||||
@@ -209,17 +219,17 @@ void BaseNode::SetPos(VecFPos pos)
|
||||
SetChildIterationTransform();
|
||||
}
|
||||
|
||||
VecFPos BaseNode::GetPos()
|
||||
Vec2 BaseNode::GetPos()
|
||||
{
|
||||
return this->transform.position;
|
||||
}
|
||||
|
||||
VecFPos BaseNode::GetWorldPos()
|
||||
Vec2 BaseNode::GetWorldPos()
|
||||
{
|
||||
return this->transform.position + this->transformIter.position;
|
||||
}
|
||||
|
||||
void BaseNode::SetScale(VecFPos scale)
|
||||
void BaseNode::SetScale(Vec2 scale)
|
||||
{
|
||||
if (scale == this->transform.scale)
|
||||
return;
|
||||
@@ -228,7 +238,7 @@ void BaseNode::SetScale(VecFPos scale)
|
||||
SetChildIterationTransform();
|
||||
}
|
||||
|
||||
VecFPos BaseNode::GetScale()
|
||||
Vec2 BaseNode::GetScale()
|
||||
{
|
||||
return this->transform.scale;
|
||||
}
|
||||
@@ -247,7 +257,7 @@ float BaseNode::GetRotation()
|
||||
return this->transform.rotation;
|
||||
}
|
||||
|
||||
void BaseNode::SetAnchor(VecFPos anchor)
|
||||
void BaseNode::SetAnchor(Vec2 anchor)
|
||||
{
|
||||
if (anchor == this->Anchor)
|
||||
return;
|
||||
@@ -255,9 +265,9 @@ void BaseNode::SetAnchor(VecFPos anchor)
|
||||
Anchor.y = anchor.y;
|
||||
}
|
||||
|
||||
VecFPos BaseNode::GetAnchor()
|
||||
Vec2 BaseNode::GetAnchor()
|
||||
{
|
||||
VecFPos P;
|
||||
Vec2 P;
|
||||
P.x = Anchor.x;
|
||||
P.y = Anchor.y;
|
||||
return P;
|
||||
@@ -298,7 +308,7 @@ float BaseNode::GetAlpha()
|
||||
return this->Alpha;
|
||||
}
|
||||
|
||||
void BaseNode::SetIterationPos(VecFPos pos)
|
||||
void BaseNode::SetIterationPos(Vec2 pos)
|
||||
{
|
||||
if (pos == this->transformIter.position)
|
||||
return;
|
||||
@@ -307,12 +317,12 @@ void BaseNode::SetIterationPos(VecFPos pos)
|
||||
SetChildIterationTransform();
|
||||
}
|
||||
|
||||
VecFPos BaseNode::GetIterationPos()
|
||||
Vec2 BaseNode::GetIterationPos()
|
||||
{
|
||||
return this->transformIter.position;
|
||||
}
|
||||
|
||||
void BaseNode::SetIterationScale(VecFPos scale)
|
||||
void BaseNode::SetIterationScale(Vec2 scale)
|
||||
{
|
||||
if (scale == this->transformIter.scale)
|
||||
return;
|
||||
@@ -321,7 +331,7 @@ void BaseNode::SetIterationScale(VecFPos scale)
|
||||
SetChildIterationTransform();
|
||||
}
|
||||
|
||||
VecFPos BaseNode::GetIterationScale()
|
||||
Vec2 BaseNode::GetIterationScale()
|
||||
{
|
||||
return this->transformIter.scale;
|
||||
}
|
||||
@@ -339,3 +349,13 @@ float BaseNode::GetIterationRotation()
|
||||
{
|
||||
return this->transformIter.rotation;
|
||||
}
|
||||
|
||||
void BaseNode::SetBlendMode(LE_BlEND_MODE mode)
|
||||
{
|
||||
this->_BlendMode = mode;
|
||||
}
|
||||
|
||||
LE_BlEND_MODE BaseNode::GetBlendMode()
|
||||
{
|
||||
return this->_BlendMode;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,9 @@
|
||||
#include "Tool/RefPtr.h"
|
||||
#include "Tool/IntrusiveList.hpp"
|
||||
#include "Tool/TagGed.h"
|
||||
#include "Tool/TransformT.h"
|
||||
#include "math/Transform.hpp"
|
||||
#include "math/Math.h"
|
||||
using namespace ember;
|
||||
class BaseNode : public RefObject, public TagGed, protected IntrusiveListValue<RefPtr<BaseNode>>
|
||||
{
|
||||
|
||||
@@ -28,23 +30,25 @@ public:
|
||||
// 渲染层级
|
||||
int m_RenderZOrder = 0;
|
||||
// 二维仿射变换
|
||||
TransformT transform;
|
||||
Transform transform;
|
||||
// 迭代的二维仿射变换
|
||||
TransformT transformIter;
|
||||
Transform transformIter;
|
||||
// 锚点
|
||||
VecFPos Anchor = {0.f, 0.f};
|
||||
Vec2 Anchor = {0.f, 0.f};
|
||||
// 大小
|
||||
VecSize Size = {0, 0};
|
||||
// 透明度
|
||||
float Alpha = 1.f;
|
||||
// 混合模式
|
||||
LE_BlEND_MODE _BlendMode = NONE;
|
||||
// 是否显示
|
||||
bool Visible = true;
|
||||
// 计算渲染信息Flag (为了保证每帧只计算一次)
|
||||
bool CalcRenderInfoFlag = true;
|
||||
|
||||
public:
|
||||
BaseNode(/* args */) = default;
|
||||
~BaseNode() = default;
|
||||
BaseNode(/* args */);
|
||||
~BaseNode();
|
||||
|
||||
public:
|
||||
virtual void Init();
|
||||
@@ -81,45 +85,45 @@ public:
|
||||
// 被添加时
|
||||
virtual void OnAdded(BaseNode *node);
|
||||
// 设置迭代的二维仿射变换
|
||||
void SetIterationTransform(TransformT transform);
|
||||
void SetIterationTransform(Transform transform);
|
||||
// 获取迭代的二维仿射变换
|
||||
TransformT GetIterationTransform();
|
||||
Transform GetIterationTransform();
|
||||
// 设置二维仿射变换
|
||||
void SetTransform(TransformT transform);
|
||||
void SetTransform(Transform transform);
|
||||
// 获取二维仿射变换
|
||||
TransformT GetTransform();
|
||||
Transform GetTransform();
|
||||
|
||||
// 设置迭代的坐标
|
||||
virtual void SetIterationPos(VecFPos pos);
|
||||
virtual void SetIterationPos(Vec2 pos);
|
||||
// 获取迭代的坐标
|
||||
VecFPos GetIterationPos();
|
||||
Vec2 GetIterationPos();
|
||||
// 设置迭代的缩放
|
||||
virtual void SetIterationScale(VecFPos scale);
|
||||
virtual void SetIterationScale(Vec2 scale);
|
||||
// 获取迭代的缩放
|
||||
VecFPos GetIterationScale();
|
||||
Vec2 GetIterationScale();
|
||||
// 设置迭代的旋转角度
|
||||
virtual void SetIterationRotation(float angle);
|
||||
// 获取迭代的旋转角度
|
||||
float GetIterationRotation();
|
||||
|
||||
// 设置坐标
|
||||
virtual void SetPos(VecFPos pos);
|
||||
virtual void SetPos(Vec2 pos);
|
||||
// 获取坐标
|
||||
VecFPos GetPos();
|
||||
Vec2 GetPos();
|
||||
// 获取世界坐标
|
||||
VecFPos GetWorldPos();
|
||||
Vec2 GetWorldPos();
|
||||
// 设置缩放
|
||||
virtual void SetScale(VecFPos scale);
|
||||
virtual void SetScale(Vec2 scale);
|
||||
// 获取缩放
|
||||
VecFPos GetScale();
|
||||
Vec2 GetScale();
|
||||
// 设置旋转角度
|
||||
virtual void SetRotation(float angle);
|
||||
// 获取旋转角度
|
||||
float GetRotation();
|
||||
// 设置中心点
|
||||
virtual void SetAnchor(VecFPos anchor);
|
||||
virtual void SetAnchor(Vec2 anchor);
|
||||
// 获取中心点
|
||||
VecFPos GetAnchor();
|
||||
Vec2 GetAnchor();
|
||||
// 设置大小
|
||||
virtual void SetSize(VecSize size);
|
||||
// 获取大小
|
||||
@@ -132,6 +136,10 @@ public:
|
||||
virtual void SetAlpha(float alpha);
|
||||
// 获取透明度
|
||||
float GetAlpha();
|
||||
// 设置混合模式
|
||||
void SetBlendMode(LE_BlEND_MODE mode);
|
||||
// 获取混合模式
|
||||
LE_BlEND_MODE GetBlendMode();
|
||||
|
||||
//获取父对象
|
||||
BaseNode *GetParent();
|
||||
|
||||
Reference in New Issue
Block a user