2018-02-03 22:04:43 +08:00
|
|
|
|
#include "..\eshape.h"
|
|
|
|
|
|
#include "..\emanagers.h"
|
|
|
|
|
|
#include "..\enodes.h"
|
|
|
|
|
|
|
2018-04-01 00:04:33 +08:00
|
|
|
|
e2d::ShapeBase::ShapeBase()
|
2018-03-31 18:12:01 +08:00
|
|
|
|
: m_bIsVisiable(true)
|
2018-02-07 16:37:12 +08:00
|
|
|
|
, m_nColor(Color::RED)
|
2018-02-03 22:04:43 +08:00
|
|
|
|
, m_fOpacity(1)
|
|
|
|
|
|
, m_pParentNode(nullptr)
|
|
|
|
|
|
, m_pTransformedShape(nullptr)
|
|
|
|
|
|
, m_bEnable(true)
|
2018-03-07 20:14:58 +08:00
|
|
|
|
, m_bAutoResize(true)
|
2018-02-03 22:04:43 +08:00
|
|
|
|
{
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-04-01 00:04:33 +08:00
|
|
|
|
e2d::ShapeBase::~ShapeBase()
|
2018-02-03 22:04:43 +08:00
|
|
|
|
{
|
|
|
|
|
|
SafeReleaseInterface(&m_pTransformedShape);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-04-01 00:04:33 +08:00
|
|
|
|
e2d::Node * e2d::ShapeBase::getParentNode() const
|
2018-02-03 22:04:43 +08:00
|
|
|
|
{
|
|
|
|
|
|
return m_pParentNode;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-04-01 00:04:33 +08:00
|
|
|
|
void e2d::ShapeBase::setEnable(bool bEnable)
|
2018-02-03 22:04:43 +08:00
|
|
|
|
{
|
|
|
|
|
|
m_bEnable = bEnable;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-04-01 00:04:33 +08:00
|
|
|
|
void e2d::ShapeBase::setVisiable(bool bVisiable)
|
2018-02-03 22:04:43 +08:00
|
|
|
|
{
|
|
|
|
|
|
m_bIsVisiable = bVisiable;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-04-01 00:04:33 +08:00
|
|
|
|
void e2d::ShapeBase::setColor(UINT32 color)
|
2018-02-03 22:04:43 +08:00
|
|
|
|
{
|
|
|
|
|
|
m_nColor = color;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-04-01 00:04:33 +08:00
|
|
|
|
void e2d::ShapeBase::setOpacity(double opacity)
|
2018-02-03 22:04:43 +08:00
|
|
|
|
{
|
2018-02-27 21:07:43 +08:00
|
|
|
|
m_fOpacity = min(max(static_cast<float>(opacity), 0), 1);
|
2018-02-03 22:04:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-04-01 00:04:33 +08:00
|
|
|
|
void e2d::ShapeBase::setAutoResize(bool bEnable)
|
2018-03-07 20:14:58 +08:00
|
|
|
|
{
|
|
|
|
|
|
m_bAutoResize = bEnable;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-04-01 00:04:33 +08:00
|
|
|
|
void e2d::ShapeBase::_render()
|
2018-02-03 22:04:43 +08:00
|
|
|
|
{
|
|
|
|
|
|
if (m_pTransformedShape && m_bEnable)
|
|
|
|
|
|
{
|
2018-02-07 16:37:12 +08:00
|
|
|
|
ID2D1SolidColorBrush * pBrush = Renderer::getSolidColorBrush();
|
2018-02-03 22:04:43 +08:00
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˢ
|
2018-02-07 16:37:12 +08:00
|
|
|
|
Renderer::getRenderTarget()->CreateSolidColorBrush(
|
2018-02-03 22:04:43 +08:00
|
|
|
|
D2D1::ColorF(
|
|
|
|
|
|
m_nColor,
|
|
|
|
|
|
m_fOpacity),
|
|
|
|
|
|
&pBrush
|
|
|
|
|
|
);
|
|
|
|
|
|
// <20><><EFBFBD>Ƽ<EFBFBD><C6BC><EFBFBD><EFBFBD><EFBFBD>״
|
2018-02-07 16:37:12 +08:00
|
|
|
|
Renderer::getRenderTarget()->DrawGeometry(m_pTransformedShape, pBrush);
|
2018-02-03 22:04:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-04-01 00:04:33 +08:00
|
|
|
|
e2d::Relation e2d::ShapeBase::getRelationWith(ShapeBase * pShape) const
|
2018-02-03 22:04:43 +08:00
|
|
|
|
{
|
|
|
|
|
|
if (m_pTransformedShape && pShape->m_pTransformedShape)
|
|
|
|
|
|
{
|
|
|
|
|
|
if (m_bEnable && pShape->m_bEnable)
|
|
|
|
|
|
{
|
|
|
|
|
|
D2D1_GEOMETRY_RELATION relation;
|
|
|
|
|
|
|
|
|
|
|
|
m_pTransformedShape->CompareWithGeometry(
|
|
|
|
|
|
pShape->m_pTransformedShape,
|
|
|
|
|
|
D2D1::Matrix3x2F::Identity(),
|
|
|
|
|
|
&relation
|
|
|
|
|
|
);
|
|
|
|
|
|
|
2018-03-31 22:34:18 +08:00
|
|
|
|
return Relation(relation);
|
2018-02-03 22:04:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2018-03-31 22:34:18 +08:00
|
|
|
|
return Relation::UNKNOWN;
|
2018-02-03 22:04:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2018-04-01 00:04:33 +08:00
|
|
|
|
void e2d::ShapeBase::_transform()
|
2018-02-03 22:04:43 +08:00
|
|
|
|
{
|
|
|
|
|
|
if (m_pParentNode && m_bEnable)
|
|
|
|
|
|
{
|
2018-03-07 20:14:58 +08:00
|
|
|
|
if (m_bAutoResize)
|
|
|
|
|
|
{
|
|
|
|
|
|
this->_resize();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2018-02-03 22:04:43 +08:00
|
|
|
|
// <20>ͷ<EFBFBD>ԭ<EFBFBD><D4AD>״
|
|
|
|
|
|
SafeReleaseInterface(&m_pTransformedShape);
|
|
|
|
|
|
|
|
|
|
|
|
// <20><><EFBFBD>ݸ<EFBFBD><DDB8>ڵ<EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>
|
2018-02-07 16:37:12 +08:00
|
|
|
|
Renderer::getID2D1Factory()->CreateTransformedGeometry(
|
2018-03-30 01:41:29 +08:00
|
|
|
|
getD2dGeometry(),
|
2018-02-03 22:04:43 +08:00
|
|
|
|
m_pParentNode->m_MatriFinal,
|
|
|
|
|
|
&m_pTransformedShape
|
|
|
|
|
|
);
|
|
|
|
|
|
|
2018-03-31 18:12:01 +08:00
|
|
|
|
CollisionManager::__updateShape(this);
|
2018-02-03 22:04:43 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|