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


C++ Poly::AddVertex方法代码示例

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


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

示例1: Rectangle

	static Poly Rectangle(const float X1, const float Y1, const float X2, const float Y2)
	{
		Poly poly;
		poly.Begin(GL_TRIANGLE_FAN);
		poly.AddVertex(X1, Y1, 0);
		poly.AddVertex(X2, Y1, 0);
		poly.AddVertex(X2, Y2, 0);
		poly.AddVertex(X1, Y2, 0);
		poly.End();
		return poly;
	}
开发者ID:aLaix,项目名称:RadicalEngine,代码行数:11,代码来源:Poly.cpp

示例2: SplitPoly

void Poly::SplitPoly ( Poly *pPoly_, Poly **ppFront_, Poly **ppBack_ )
{
	Plane::eCP	*pCP = new Plane::eCP[ pPoly_->GetNumberOfVertices ( ) ];

	//
	// Classify all points
	//
	for ( int i = 0; i < pPoly_->GetNumberOfVertices ( ); i++ )
	{
		pCP[ i ] = plane.ClassifyPoint ( pPoly_->verts[ i ].p );
	}

	//
	// Build fragments
	//
	Poly		*pFront = new Poly;
	Poly		*pBack	= new Poly;

	pFront->TextureID	= pPoly_->TextureID;
	pBack->TextureID	= pPoly_->TextureID;
	pFront->plane		= pPoly_->plane;
	pBack->plane		= pPoly_->plane;

	for ( i = 0; i < pPoly_->GetNumberOfVertices ( ); i++ )
	{
		//
		// Add point to appropriate list
		//
		switch ( pCP[ i ] )
		{
		case Plane::eCP::FRONT:
			{
				pFront->AddVertex ( pPoly_->verts[ i ] );
			} break;

		case Plane::eCP::BACK:
			{
				pBack->AddVertex ( pPoly_->verts[ i ] );
			} break;

		case Plane::eCP::ONPLANE:
			{
				pFront->AddVertex ( pPoly_->verts[ i ] );
				pBack->AddVertex ( pPoly_->verts[ i ] );
			} break;
		}

		//
		// Check if edges should be split
		//
		int		iNext	= i + 1;
		bool	bIgnore	= false;

		if ( i == ( pPoly_->GetNumberOfVertices ( ) - 1 ) )
		{
			iNext = 0;
		}

		if ( ( pCP[ i ] == Plane::eCP::ONPLANE ) && ( pCP[ iNext ] != Plane::eCP::ONPLANE ) )
		{
			bIgnore = true;
		}
		else if ( ( pCP[ iNext ] == Plane::eCP::ONPLANE ) && ( pCP[ i ] != Plane::eCP::ONPLANE ) )
		{
			bIgnore = true;
		}

		if ( ( !bIgnore ) && ( pCP[ i ] != pCP[ iNext ] ) )
		{
			Vertex	v;	// New vertex created by splitting
			double	p;	// Percentage between the two points

			plane.GetIntersection ( pPoly_->verts[ i ].p, pPoly_->verts[ iNext ].p, v.p, p );

			v.tex[ 0 ] = pPoly_->verts[ iNext ].tex[ 0 ] - pPoly_->verts[ i ].tex[ 0 ];
			v.tex[ 1 ] = pPoly_->verts[ iNext ].tex[ 1 ] - pPoly_->verts[ i ].tex[ 1 ];

			v.tex[ 0 ] = pPoly_->verts[ i ].tex[ 0 ] + ( p * v.tex[ 0 ] );
			v.tex[ 1 ] = pPoly_->verts[ i ].tex[ 1 ] + ( p * v.tex[ 1 ] );

			pFront->AddVertex ( v );
			pBack->AddVertex ( v );
		}
	}

	delete [] pCP;

	pFront->CalculatePlane ( );
	pBack->CalculatePlane ( );

	*ppFront_ = pFront;
	*ppBack_ = pBack;
}
开发者ID:stefanha,项目名称:map-files,代码行数:93,代码来源:poly.cpp


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