当前位置: 首页>>代码示例>>C++>>正文


C++ Polygon2::GetPoints方法代码示例

本文整理汇总了C++中Polygon2::GetPoints方法的典型用法代码示例。如果您正苦于以下问题:C++ Polygon2::GetPoints方法的具体用法?C++ Polygon2::GetPoints怎么用?C++ Polygon2::GetPoints使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Polygon2的用法示例。


在下文中一共展示了Polygon2::GetPoints方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: DrawPolygon

void RenderHelper::DrawPolygon( const Polygon2 & polygon, bool closed)
{
	int ptCount = polygon.pointCount;
	if (ptCount >= 2)
	{		
		vertexStream->Set(TYPE_FLOAT, 2, 0, polygon.GetPoints());
		RenderManager::Instance()->SetRenderEffect(RenderManager::FLAT_COLOR);
		RenderManager::Instance()->SetRenderData(renderDataObject);
		RenderManager::Instance()->DrawArrays(PRIMITIVETYPE_LINESTRIP, 0, ptCount);
		
		if (closed)
		{
		    Vector2 line[2] = {Vector2(polygon.GetPoints()[0]), Vector2(polygon.GetPoints()[ptCount-1])};
		    vertexStream->Set(TYPE_FLOAT, 2, 0, line);
		    RenderManager::Instance()->DrawArrays(PRIMITIVETYPE_LINESTRIP, 0, 2);
		}
	}
}
开发者ID:droidenko,项目名称:dava.framework,代码行数:18,代码来源:RenderHelper.cpp

示例2: FillPolygon

void RenderHelper::FillPolygon(const Polygon2 & polygon)
{
    int ptCount = polygon.pointCount;
	if (ptCount >= 3)
	{		
		vertexStream->Set(TYPE_FLOAT, 2, 0, polygon.GetPoints());
		RenderManager::Instance()->SetRenderEffect(RenderManager::FLAT_COLOR);
		RenderManager::Instance()->SetRenderData(renderDataObject);
		RenderManager::Instance()->DrawArrays(PRIMITIVETYPE_TRIANGLEFAN, 0, ptCount);
    }
}
开发者ID:droidenko,项目名称:dava.framework,代码行数:11,代码来源:RenderHelper.cpp

示例3: ProjectPolygon

void Collisions::ProjectPolygon(const Vector2 & axis, Polygon2 & poly, float32 & min, float32 & max)
{
	Vector2 * points = poly.GetPoints();
	float32 proj = DotProduct(points[0], axis);
	min = proj;
	max = proj;
	for (int32 pi = 1; pi < poly.GetPointCount(); ++pi)
	{
		proj = DotProduct(points[pi], axis);
		if (proj < min)
			min = proj;
		if (proj > max)
			max = proj;
	}
}
开发者ID:droidenko,项目名称:dava.framework,代码行数:15,代码来源:CollisionPolygons.cpp

示例4: DrawPolygonPoints

void RenderHelper::DrawPolygonPoints(const Polygon2 & polygon)
{
	int ptCount = polygon.pointCount;
	if (ptCount >= 1)
	{
#if defined (__DAVAENGINE_OPENGL__)
        glPointSize(3.0f);
#endif 
		vertexStream->Set(TYPE_FLOAT, 2, 0, polygon.GetPoints());
		RenderManager::Instance()->SetRenderEffect(RenderManager::FLAT_COLOR);
		RenderManager::Instance()->SetRenderData(renderDataObject);
		RenderManager::Instance()->DrawArrays(PRIMITIVETYPE_POINTLIST, 0, ptCount);
#if defined (__DAVAENGINE_OPENGL__)
		glPointSize(1.0f);
#endif		
	}
}
开发者ID:droidenko,项目名称:dava.framework,代码行数:17,代码来源:RenderHelper.cpp

示例5: IsPolygonIntersectsPolygon

bool Collisions::IsPolygonIntersectsPolygon(Polygon2 & poly1, Polygon2 & poly2)
{
//#define DEBUG_DRAW_INTERSECTIONS

	Vector2 * points1 = poly1.GetPoints();
	Vector2 * points2 = poly2.GetPoints();

	separationAxes.clear();
	
	for (int32 index1 = 0; index1 < poly1.pointCount; ++index1)
	{
		int32 index2 = (index1 + 1 != poly1.pointCount) ? (index1 + 1) : (0);
		
		Vector2 line = points1[index2] - points1[index1];
		Vector2 normal = Vector2(line.y, -line.x);
		normal.Normalize();

		AddSeparationAxis(normal);

#if defined(DEBUG_DRAW_INTERSECTIONS)
		RenderManager::Instance()->SetColor(0.0f, 0.0f, 1.0f, 1.0f);
		RenderHelper::DrawLine(points1[index1] + (line / 2), points1[index1] + (line / 2) + normal * 10);
#endif 
	}		
	
	for (int32 index1 = 0; index1 < poly2.pointCount; ++index1)
	{
		int32 index2 = (index1 + 1 != poly2.pointCount) ? (index1 + 1) : (0);
		
		Vector2 line = points2[index2] - points2[index1];
		Vector2 normal = Vector2(line.y, -line.x);
		normal.Normalize();
		AddSeparationAxis(normal);
		
#if defined(DEBUG_DRAW_INTERSECTIONS)
		RenderManager::Instance()->SetColor(0.0f, 1.0f, 0.0f, 1.0f);
		RenderHelper::DrawLine(points2[index1] + (line / 3), points2[index1] + (line / 3) + normal * 10);
#endif 
	}
	
	size_t size = separationAxes.size();
#if defined(DEBUG_DRAW_INTERSECTIONS)
	for (size_t index = 0; index < size; ++index)
	{
		Vector2 axis = separationAxes[index];
		RenderManager::Instance()->SetColor(1.0f, 0.0f, 0.0f, 1.0f);
		RenderHelper::DrawLine(Vector2(50.0f, 50.0f), Vector2(50.0f, 50.0f) + axis * 1000);
	}
#endif 

	for (size_t index = 0; index < size; ++index)
	{
		Vector2 axis = separationAxes[index];
		
		
		float32 p1Min, p1Max;
		ProjectPolygon(axis, poly1, p1Min, p1Max);
		
		float32 p2Min, p2Max;
		ProjectPolygon(axis, poly2, p2Min, p2Max);

#if defined(DEBUG_DRAW_INTERSECTIONS)
		RenderManager::Instance()->SetColor(0.0f, 1.0f, 1.0f, 1.0f);
		Vector2 norm = Vector2(axis.y, -axis.x);
		RenderHelper::DrawLine(Vector2(50.0f, 50.0f) + axis * p1Min + norm * 2.0f, Vector2(50.0f, 50.0f) + axis * p1Max + norm * 2.0f);

		RenderManager::Instance()->SetColor(1.0f, 1.0f, 0.0f, 1.0f);
		RenderHelper::DrawLine(Vector2(50.0f, 50.0f) + axis * p2Min - norm * 2.0f, Vector2(50.0f, 50.0f) + axis * p2Max - norm * 2.0f);
#endif
		
		
		if (IntervalDistance(p1Min, p1Max, p2Min, p2Max) > 0)
			return false;
	}


	return true;
}
开发者ID:droidenko,项目名称:dava.framework,代码行数:78,代码来源:CollisionPolygons.cpp


注:本文中的Polygon2::GetPoints方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。