Exemple #1
0
/**
*  @brief
*    Clips the polygon against a plane
*/
Polygon Polygon::Clip(const Plane &cPlane) const
{
	uint32 nNumOfVertices = m_lstVertices.GetNumOfElements();
	Polygon cClipped;

	// Loop through all vertices of this polygon
	for (uint32 i=0; i<nNumOfVertices; i++) {
		// The 2 vertices of an edge
		const Vector3 &vA = m_lstVertices[i];
		const Vector3 &vB = m_lstVertices[(i+1) % nNumOfVertices];

		// Check on which side of the plane the vertices are on
		Plane::ESide nSideA = cPlane.GetSide(vA);
		Plane::ESide nSideB = cPlane.GetSide(vB);

		// Clip
		if (nSideA == Plane::InFront || nSideA == Plane::Coinciding) {
			cClipped.AddVertex(vA);
			if (nSideB == Plane::Behind)
				cClipped.AddVertex(cPlane.ClipEdge(vA, vB));
		} else if (nSideB == Plane::InFront) {
			cClipped.AddVertex(cPlane.ClipEdge(vA, vB));
			cClipped.AddVertex(vB);
		}

	}

	// Return the clipped polygon
	return cClipped;
}
Exemple #2
0
/**
*  @brief
*    Checks whether the polygon is completely behind the given plane
*/
bool Polygon::IsBehind(const Plane &cPlane) const
{
	for (uint32 i=0; i<m_lstVertices.GetNumOfElements(); i++) {
		if (cPlane.GetSide(m_lstVertices[i]) != Plane::Behind)
			return false; // Not behind
	}

	// Behind the given plane
	return true;
}
Exemple #3
0
/**
*  @brief
*    Checks whether the polygon is completely in front of the given plane
*/
bool Polygon::IsInFront(const Plane &cPlane) const
{
	for (uint32 i=0; i<m_lstVertices.GetNumOfElements(); i++) {
		if (cPlane.GetSide(m_lstVertices[i]) != Plane::InFront)
			return false; // Not in front
	}

	// In front of the given plane
	return true;
}
Exemple #4
0
 Boole Overlap(const AxisAlignedBox& Box, const Plane& Surface)
 {
     return ( Plane::S_Both == Surface.GetSide(Box.GetCenter(),Box.GetHalfSize()) );
 }