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


C++ vector::GetVertex方法代码示例

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


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

示例1: SetFace

void CBSPMapData_LW::SetFace(vector<CMapFace>* pvecFace, list<LWO2_Layer>::iterator thislayer)
{
	int i;
	WORD j;
	DWORD pnt_index;
	MAPVERTEX vDest;
	SPlane plane;
	LWO2_Object& lwobject = this->m_LWO2Object;
	LWO2_TextureUVMap* pTexuvmap = NULL;
	LWO2_VertexColorMap* pVertexColorMap = NULL;

	int iSurfaceIndex;

	int offset = pvecFace->size();

	// caution : this is a temporary solution. this will not work when multiple PNTS chunks exist
	// in a single layer.
	LWO2_TextureUVMap *pLightmapTextureUVMap = lwobject.FindTextureUVMapByName( "TUV_Lightmap", *thislayer );

	vector<LWO2_Face>& rvecPolygon = thislayer->GetFace();
	int iNumFaces = rvecPolygon.size();

	for(i=0; i<iNumFaces; i++)  // How many faces in the layer
	{
		LWO2_Face& rSrcFace = rvecPolygon[i];

		if( rSrcFace.GetNumPoints() <= 2 )
			continue;

		CMapFace new_face;

		// Find the surface mapped on this face
		LWO2_Surface& rSurf = lwobject.FindSurfaceFromTAG( rSrcFace.GetSurfaceIndex() );
		iSurfaceIndex = lwobject.GetSurfaceIndexFromSurfaceTAG( rSrcFace.GetSurfaceIndex() );

		strcpy( new_face.m_acSurfaceName, rSurf.GetName().c_str() );

		// set material index
		new_face.m_iSurfaceMaterialIndex = GetMaterialIndex( rSurf );


		// if the surface name contains "_NoClip"		
		if( strstr(rSurf.GetName().c_str(),"_NoClip") )
			new_face.RaiseTypeFlag(CMapFace::TYPE_NOCLIP);		// no collision detection against this face
		else
			new_face.ClearTypeFlag(CMapFace::TYPE_NOCLIP);	// usual case

		if( strstr(rSurf.GetName().c_str(),"_Invisible") )	//if the surface name contains "_Invisible"
			new_face.RaiseTypeFlag(CMapFace::TYPE_INVISIBLE);	// this face is not rendered
		else
			new_face.ClearTypeFlag(CMapFace::TYPE_INVISIBLE);	// usual case

		// find the image mapped on this face and get its index
		new_face.m_sTextureID = iSurfaceIndex;

		// The value of TextureID is given as the order of the still image 
		// in vector<m_clipstill> 
		// If a still image is the first element in vector<m_clipstill>, 
		// the TextureID of its owner face is 0

		// The image index of CLIP chunk in LWO2 file starts from 1. Therefore, if a surface doesn't
		// have any image, imagetag of the surface should be 0.  << Is this right?
		// And the 'm_sTextureID' remains -1

		// find the texture uvmap of this face	
		pTexuvmap = lwobject.FindTextureUVMapFromSurface(rSurf, ID_COLR, *thislayer);

		// find the vertex color map applied to this face		
		pVertexColorMap= lwobject.FindVertexColorMapFromSurface(rSurf, *thislayer);

		int iNumPoints = rSrcFace.GetNumPoints();
		for(j=0; j<iNumPoints ;j++)  // the number of points in this face
		{
			memset(&vDest, 0, sizeof(MAPVERTEX));
			vDest.color = 0xFFFFFFFF;	//default vertex color: white and opaque

			pnt_index = rSrcFace.GetVertexIndex()[j];   // the index to a point in the PNTS chunk
			vDest.vPosition = thislayer->GetVertex().at( pnt_index );

			// set texture-uv to the vertex
			// search uv map (VMAP chunk) until the corresponding uv-point is found
			if( pTexuvmap )  // if (pTexuvmap == NULL), we have no uv points for this face
			{
				if( !thislayer->GetUV( vDest.vTex0.u, vDest.vTex0.v, pnt_index, pTexuvmap ) )
				{
					vDest.vTex0.u = 32767;
					vDest.vTex0.v = 32767;
				}
			}

			new_face.m_sLightMapID = -1;
/*			if( pLightmapTextureUVMap )
			{
				if( !thislayer->GetUV( vDest.vTex1.u, vDest.vTex1.v, pnt_index, pLightmapTextureUVMap ) )
				{
					vDest.vTex1.u = -1;
					vDest.vTex1.v = -1;
				}
				else
					new_face.m_sLightMapID = 0;	// TODO: support for multiple lightmap textures
//.........这里部分代码省略.........
开发者ID:HermanHGF,项目名称:amorphous,代码行数:101,代码来源:BSPMapData_LW.cpp


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