Пример #1
0
void CCollider::calcDist(CTransform & transform)
{
	m_diameter = transform.GetScale();
	Vector3 centerPos;
	centerPos.z = transform.GetTranslate().z;
	// Determine center x pos
	if (m_xStart == X_LEFT)
	{
		centerPos.x = transform.GetTranslate().x + m_diameter.x * 0.5f;
	}
	else if (m_xStart == X_MIDDLE)
	{
		centerPos.x = transform.GetTranslate().x;
	}
	else if (m_xStart == X_RIGHT)
	{
		centerPos.x = transform.GetTranslate().x - m_diameter.x * 0.5f;
	}

	// Determine center y pos
	if (m_yStart == Y_BOTTOM)
	{
		centerPos.y = transform.GetTranslate().y + m_diameter.y * 0.5f;
	}
	else if (m_yStart == Y_MIDDLE)
	{
		centerPos.y = transform.GetTranslate().y;
	}
	else if (m_yStart == Y_TOP)
	{
		centerPos.y = transform.GetTranslate().y - m_diameter.y * 0.5f;
	}
	m_position = centerPos;
}
Пример #2
0
void CCollider::calcAABB(CTransform & transform)
{
	Vector3 scale = transform.GetScale();

	Vector3 centerPos;
	centerPos.z = transform.GetTranslate().z;
	// Determine center x pos
	if (m_xStart == X_LEFT)
	{
		centerPos.x = transform.GetTranslate().x + scale.x * 0.5f;
	}
	else if (m_xStart == X_MIDDLE)
	{
		centerPos.x = transform.GetTranslate().x;
	}
	else if (m_xStart == X_RIGHT)
	{
		centerPos.x = transform.GetTranslate().x - scale.x * 0.5f;
	}

	// Determine center y pos
	if (m_yStart == Y_BOTTOM)
	{
		centerPos.y = transform.GetTranslate().y + scale.y * 0.5f;
	}
	else if (m_yStart == Y_MIDDLE)
	{
		centerPos.y = transform.GetTranslate().y;
	}
	else if (m_yStart == Y_TOP)
	{
		centerPos.y = transform.GetTranslate().y - scale.y * 0.5f;
	}
	Vector3 pos = centerPos;

	m_minBound.Set(pos.x - (scale.x * 0.5f), pos.y - (scale.y * 0.5f), pos.z - (scale.z * 0.5f));
	m_maxBound.Set(pos.x + (scale.x * 0.5f), pos.y + (scale.y * 0.5f), pos.z + (scale.z * 0.5f));
}