コード例 #1
0
ファイル: ICollisionSystem.cpp プロジェクト: ItsJackson/gqe
  void ICollisionSystem::ProjectOntoAxis(const sf::Shape& theShape, const sf::Vector2f& theAxis, float& theMin, float& theMax)
	{
    sf::Vector2f anPoint=theShape.getTransform().transformPoint(theShape.getPoint(0));
  	GQE::Uint32 anPointCount=theShape.getPointCount();
		theMin = (anPoint.x*theAxis.x+anPoint.y*theAxis.y);
		theMax = theMin;
		for (int j = 1; j<anPointCount; j++)
		{
			anPoint=theShape.getTransform().transformPoint(theShape.getPoint(j));
			float Projection = (anPoint.x*theAxis.x+anPoint.y*theAxis.y);

			if (Projection<theMin)
				theMin=Projection;
			if (Projection>theMax)
				theMax=Projection;
		}
	}
コード例 #2
0
void TEALShow::OrientedBox( sf::Shape &s, sf::Color col)
{
	AddTransformedRectanglePoints( s.getLocalBounds(), s.getTransform(), col );
}
コード例 #3
0
ファイル: TrackChunk.cpp プロジェクト: Kojirion/Tracks
bool TrackChunk::collidesWith(const sf::Shape &shape) const{
    bg::model::ring<sf::Vector2f> ring;
    for (std::size_t i=0; i<shape.getPointCount(); ++i)
        bg::append(ring, shape.getTransform().transformPoint(shape.getPoint(i)));
    return bg::intersects(ring, m_points);
}