113 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			C++
		
	
	
	
			
		
		
	
	
			113 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			C++
		
	
	
	
| #include "..\egeometry.h"
 | |
| #include "..\emanagers.h"
 | |
| #include "..\enodes.h"
 | |
| 
 | |
| e2d::EGeometry::EGeometry()
 | |
| 	: m_nCategoryBitmask(0)
 | |
| 	, m_nCollisionBitmask(0)
 | |
| 	, m_bIsVisiable(true)
 | |
| 	, m_nColor(EColor::RED)
 | |
| 	, m_fOpacity(1)
 | |
| 	, m_pParentNode(nullptr)
 | |
| 	, m_pTransformedGeometry(nullptr)
 | |
| {
 | |
| }
 | |
| 
 | |
| e2d::EGeometry::~EGeometry()
 | |
| {
 | |
| 	SafeReleaseInterface(&m_pTransformedGeometry);
 | |
| }
 | |
| 
 | |
| e2d::ENode * e2d::EGeometry::getParentNode() const
 | |
| {
 | |
| 	return m_pParentNode;
 | |
| }
 | |
| 
 | |
| UINT32 e2d::EGeometry::getCategoryBitmask() const
 | |
| {
 | |
| 	return m_nCategoryBitmask;
 | |
| }
 | |
| 
 | |
| UINT32 e2d::EGeometry::getCollisionBitmask() const
 | |
| {
 | |
| 	return m_nCollisionBitmask;
 | |
| }
 | |
| 
 | |
| void e2d::EGeometry::setCategoryBitmask(UINT32 mask)
 | |
| {
 | |
| 	m_nCategoryBitmask = mask;
 | |
| }
 | |
| 
 | |
| void e2d::EGeometry::setCollisionBitmask(UINT32 mask)
 | |
| {
 | |
| 	m_nCollisionBitmask = mask;
 | |
| }
 | |
| 
 | |
| void e2d::EGeometry::setVisiable(bool bVisiable)
 | |
| {
 | |
| 	m_bIsVisiable = bVisiable;
 | |
| }
 | |
| 
 | |
| void e2d::EGeometry::setColor(UINT32 color)
 | |
| {
 | |
| 	m_nColor = color;
 | |
| }
 | |
| 
 | |
| void e2d::EGeometry::setOpacity(float opacity)
 | |
| {
 | |
| 	m_fOpacity = min(max(opacity, 0), 1);
 | |
| }
 | |
| 
 | |
| void e2d::EGeometry::_render()
 | |
| {
 | |
| 	if (m_pTransformedGeometry)
 | |
| 	{
 | |
| 		ID2D1SolidColorBrush * pBrush = ERenderer::getSolidColorBrush();
 | |
| 		// 눼쉔뺌岬
 | |
| 		ERenderer::getRenderTarget()->CreateSolidColorBrush(
 | |
| 			D2D1::ColorF(
 | |
| 				m_nColor,
 | |
| 				m_fOpacity),
 | |
| 			&pBrush
 | |
| 		);
 | |
| 		// 삥齡섯부近榴
 | |
| 		ERenderer::getRenderTarget()->DrawGeometry(m_pTransformedGeometry, pBrush);
 | |
| 	}
 | |
| }
 | |
| 
 | |
| e2d::EPhysicsEvent::INTERSECT_RELATION e2d::EGeometry::_intersectWith(EGeometry * pGeometry)
 | |
| {
 | |
| 	if (m_pTransformedGeometry && pGeometry->m_pTransformedGeometry)
 | |
| 	{
 | |
| 		D2D1_GEOMETRY_RELATION relation;
 | |
| 
 | |
| 		m_pTransformedGeometry->CompareWithGeometry(
 | |
| 			pGeometry->m_pTransformedGeometry,
 | |
| 			D2D1::Matrix3x2F::Identity(),
 | |
| 			&relation
 | |
| 		);
 | |
| 
 | |
| 		return EPhysicsEvent::INTERSECT_RELATION(relation);
 | |
| 	}
 | |
| 	return EPhysicsEvent::UNKNOWN;
 | |
| }
 | |
| 
 | |
| void e2d::EGeometry::_transform()
 | |
| {
 | |
| 	if (m_pParentNode)
 | |
| 	{
 | |
| 		// 姦렴覩近榴
 | |
| 		SafeReleaseInterface(&m_pTransformedGeometry);
 | |
| 
 | |
| 		// 몽앴만쌘듐瘻뻣섯부暠近
 | |
| 		ERenderer::getID2D1Factory()->CreateTransformedGeometry(
 | |
| 			_getD2dGeometry(),
 | |
| 			m_pParentNode->m_MatriFinal,
 | |
| 			&m_pTransformedGeometry
 | |
| 		);
 | |
| 
 | |
| 		// 털뙤近榴긴뻣빈돨헙워
 | |
| 		EPhysicsManager::PhysicsGeometryProc(this);
 | |
| 	}
 | |
| }
 |