2017-10-26 17:17:30 +08:00
|
|
|
|
#include "..\egeometry.h"
|
2017-10-31 17:19:13 +08:00
|
|
|
|
#include "..\emanagers.h"
|
2017-10-28 18:48:21 +08:00
|
|
|
|
#include "..\enodes.h"
|
2017-10-31 17:19:13 +08:00
|
|
|
|
#include "..\Win\winbase.h"
|
2017-10-26 17:17:30 +08:00
|
|
|
|
|
|
|
|
|
|
e2d::EGeometry::EGeometry()
|
2017-10-29 23:48:32 +08:00
|
|
|
|
: m_bTransformed(false)
|
2017-10-31 17:19:13 +08:00
|
|
|
|
, m_nCategoryBitmask(0)
|
|
|
|
|
|
,m_nContactBitmask(0)
|
|
|
|
|
|
, m_bIsVisiable(true)
|
2017-10-29 23:48:32 +08:00
|
|
|
|
, 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
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
e2d::EGeometry::~EGeometry()
|
|
|
|
|
|
{
|
|
|
|
|
|
SafeReleaseInterface(&m_pTransformedGeometry);
|
2017-10-26 17:17:30 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2017-10-31 17:19:13 +08:00
|
|
|
|
bool e2d::EGeometry::isContactWith(EGeometry * geometry)
|
|
|
|
|
|
{
|
|
|
|
|
|
return ((this->m_nContactBitmask & geometry->m_nCategoryBitmask) != 0);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-10-28 18:48:21 +08:00
|
|
|
|
e2d::ENode * e2d::EGeometry::getParentNode() const
|
|
|
|
|
|
{
|
|
|
|
|
|
return m_pParentNode;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-10-31 17:19:13 +08:00
|
|
|
|
UINT32 e2d::EGeometry::getCategoryBitmask() const
|
|
|
|
|
|
{
|
|
|
|
|
|
return m_nCategoryBitmask;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
UINT32 e2d::EGeometry::getContactBitmask() const
|
|
|
|
|
|
{
|
|
|
|
|
|
return m_nContactBitmask;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void e2d::EGeometry::setCategoryBitmask(UINT32 mask)
|
|
|
|
|
|
{
|
|
|
|
|
|
m_nCategoryBitmask = mask;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void e2d::EGeometry::setContactBitmask(UINT32 mask)
|
|
|
|
|
|
{
|
|
|
|
|
|
m_nContactBitmask = mask;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void e2d::EGeometry::setVisiable(bool bVisiable)
|
|
|
|
|
|
{
|
|
|
|
|
|
m_bIsVisiable = bVisiable;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2017-10-29 23:48:32 +08:00
|
|
|
|
void e2d::EGeometry::setColor(UINT32 color)
|
|
|
|
|
|
{
|
|
|
|
|
|
m_nColor = color;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void e2d::EGeometry::setOpacity(float opacity)
|
|
|
|
|
|
{
|
2017-10-31 17:19:13 +08:00
|
|
|
|
m_fOpacity = min(max(opacity, 0), 1);
|
2017-10-29 23:48:32 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
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-31 17:19:13 +08:00
|
|
|
|
// <20>ͷ<EFBFBD>ԭ<EFBFBD><D4AD>״
|
2017-10-28 18:48:21 +08:00
|
|
|
|
SafeReleaseInterface(&m_pTransformedGeometry);
|
2017-10-26 17:17:30 +08:00
|
|
|
|
|
2017-10-31 17:19:13 +08:00
|
|
|
|
// <20><><EFBFBD>ݸ<EFBFBD><DDB8>ڵ<EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ͼ<EFBFBD><CDBC>
|
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
|
|
|
|
|
2017-10-31 17:19:13 +08:00
|
|
|
|
// <20>ж<EFBFBD><D0B6><EFBFBD>״<EFBFBD>任<EFBFBD><E4BBBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
|
EPhysicsManager::PhysicsGeometryProc(this);
|
2017-10-28 18:48:21 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|