2017-10-26 17:17:30 +08:00
|
|
|
|
#include "..\egeometry.h"
|
|
|
|
|
|
#include "..\Win\winbase.h"
|
2017-10-28 18:48:21 +08:00
|
|
|
|
#include "..\enodes.h"
|
2017-10-26 17:17:30 +08:00
|
|
|
|
|
|
|
|
|
|
e2d::EGeometry::EGeometry()
|
2017-10-29 23:48:32 +08:00
|
|
|
|
: m_bTransformed(false)
|
|
|
|
|
|
, m_nColor(EColor::RED)
|
|
|
|
|
|
, m_fOpacity(1)
|
2017-10-26 17:17:30 +08:00
|
|
|
|
, m_pParentNode(nullptr)
|
2017-10-28 18:48:21 +08:00
|
|
|
|
, m_pTransformedGeometry(nullptr)
|
2017-10-26 17:17:30 +08:00
|
|
|
|
{
|
2017-10-29 23:48:32 +08:00
|
|
|
|
this->autoRelease();
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
e2d::EGeometry::~EGeometry()
|
|
|
|
|
|
{
|
|
|
|
|
|
SafeReleaseInterface(&m_pTransformedGeometry);
|
2017-10-26 17:17:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-10-28 18:48:21 +08:00
|
|
|
|
e2d::ENode * e2d::EGeometry::getParentNode() const
|
|
|
|
|
|
{
|
|
|
|
|
|
return m_pParentNode;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-10-29 23:48:32 +08:00
|
|
|
|
void e2d::EGeometry::setColor(UINT32 color)
|
|
|
|
|
|
{
|
|
|
|
|
|
m_nColor = color;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void e2d::EGeometry::setOpacity(float opacity)
|
|
|
|
|
|
{
|
|
|
|
|
|
m_fOpacity = opacity;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void e2d::EGeometry::_onRender()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (m_pTransformedGeometry)
|
|
|
|
|
|
{
|
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ˢ
|
|
|
|
|
|
GetRenderTarget()->CreateSolidColorBrush(
|
|
|
|
|
|
D2D1::ColorF(
|
|
|
|
|
|
m_nColor,
|
|
|
|
|
|
m_fOpacity),
|
|
|
|
|
|
&GetSolidColorBrush()
|
|
|
|
|
|
);
|
|
|
|
|
|
// <20><><EFBFBD>Ƽ<EFBFBD><C6BC><EFBFBD><EFBFBD><EFBFBD>״
|
|
|
|
|
|
GetRenderTarget()->DrawGeometry(m_pTransformedGeometry, GetSolidColorBrush());
|
|
|
|
|
|
// <20>ͷ<EFBFBD><CDB7><EFBFBD>ʱ<EFBFBD><CAB1>Դ
|
|
|
|
|
|
SafeReleaseInterface(&GetSolidColorBrush());
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-10-28 18:48:21 +08:00
|
|
|
|
e2d::EPhysicsMsg::INTERSECT_RELATION e2d::EGeometry::_intersectWith(EGeometry * pGeometry)
|
2017-10-26 17:17:30 +08:00
|
|
|
|
{
|
2017-10-29 23:48:32 +08:00
|
|
|
|
if (m_pTransformedGeometry && pGeometry->m_pTransformedGeometry)
|
|
|
|
|
|
{
|
|
|
|
|
|
D2D1_GEOMETRY_RELATION relation;
|
2017-10-26 17:17:30 +08:00
|
|
|
|
|
2017-10-29 23:48:32 +08:00
|
|
|
|
m_pTransformedGeometry->CompareWithGeometry(
|
|
|
|
|
|
pGeometry->m_pTransformedGeometry,
|
|
|
|
|
|
D2D1::Matrix3x2F::Identity(),
|
|
|
|
|
|
&relation
|
|
|
|
|
|
);
|
2017-10-26 17:17:30 +08:00
|
|
|
|
|
2017-10-29 23:48:32 +08:00
|
|
|
|
return EPhysicsMsg::INTERSECT_RELATION(relation);
|
|
|
|
|
|
}
|
|
|
|
|
|
return EPhysicsMsg::INTERSECT_RELATION::UNKNOWN;
|
2017-10-28 18:48:21 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void e2d::EGeometry::_transform()
|
|
|
|
|
|
{
|
2017-10-29 23:48:32 +08:00
|
|
|
|
if (m_pParentNode)
|
2017-10-26 17:17:30 +08:00
|
|
|
|
{
|
2017-10-28 18:48:21 +08:00
|
|
|
|
SafeReleaseInterface(&m_pTransformedGeometry);
|
2017-10-26 17:17:30 +08:00
|
|
|
|
|
2017-10-28 18:48:21 +08:00
|
|
|
|
GetFactory()->CreateTransformedGeometry(
|
|
|
|
|
|
_getD2dGeometry(),
|
|
|
|
|
|
m_pParentNode->m_Matri,
|
|
|
|
|
|
&m_pTransformedGeometry
|
|
|
|
|
|
);
|
2017-10-29 23:48:32 +08:00
|
|
|
|
|
|
|
|
|
|
this->m_bTransformed = true;
|
2017-10-28 18:48:21 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|