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


C++ CCoreDispInfo::GetTriIndices方法代码示例

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


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

示例1: Disp_AddCollisionModels

// adds all displacement faces as a series of convex objects
// UNDONE: Only add the displacements for this model?
void Disp_AddCollisionModels( CUtlVector<CPhysCollisionEntry *> &collisionList, dmodel_t *pModel, int contentsMask )
{
	int dispIndex;

	// Add each displacement to the grid hash
	for ( dispIndex = 0; dispIndex < g_CoreDispInfos.Count(); dispIndex++ )	
	{
		CCoreDispInfo *pDispInfo = &g_CoreDispInfos[ dispIndex ];
		mapdispinfo_t *pMapDisp = &mapdispinfo[ dispIndex ];

		// not solid for this pass
		if ( !(pMapDisp->contents & contentsMask) )
			continue;

		int gridIndex = Disp_GridIndex( pDispInfo );
		AddToGrid( gridIndex, dispIndex );
	}

	// now make a polysoup for the terrain in each grid
	for ( int grid = 0; grid < gDispGridList.Count(); grid++ )
	{
		int triCount = 0;
		CPhysPolysoup *pTerrainPhysics = physcollision->PolysoupCreate();

		// iterate the displacements in this grid
		for ( int listIndex = 0; listIndex < gDispGridList[grid].dispList.Count(); listIndex++ )
		{
			dispIndex = gDispGridList[grid].dispList[listIndex];
			CCoreDispInfo *pDispInfo = &g_CoreDispInfos[ dispIndex ];
			mapdispinfo_t *pMapDisp = &mapdispinfo[ dispIndex ];

			// Get the material id.
			MaterialSystemMaterial_t matID = GetMatIDFromDisp( pMapDisp );

			// Get the triangle count.
			int nTriCount = pDispInfo->GetTriCount();
			if ( nTriCount >= 0xFFFF )
			{
				// if we hit this error, it's probably time to make the grid adaptive (DISP_GRID_SIZEX,etc)
				Error("Terrain collision overflow!\n");
			}

			// Convert the tristrip into a triangle list.			
			CUtlVector<unsigned short> indices;
			indices.SetSize( nTriCount * 3 );
			for ( int iTri = 0; iTri < nTriCount; ++iTri )
			{
				unsigned short iVert0, iVert1, iVert2;
				pDispInfo->GetTriIndices( iTri, iVert0, iVert1, iVert2 );
				indices[iTri*3] =  iVert0;
				indices[iTri*3+1] = iVert1;
				indices[iTri*3+2] = iVert2;
			}

			Vector tmpVerts[3];
			for ( iTri = 0; iTri < nTriCount; ++iTri )
			{
				float flAlphaTotal = 0.0f;
				for ( int iTriVert = 0; iTriVert < 3; ++iTriVert )
				{
					pDispInfo->GetVert( indices[iTri*3+iTriVert], tmpVerts[iTriVert] );
					flAlphaTotal += pDispInfo->GetAlpha( indices[iTri*3+iTriVert] );
				}

				int nProp = g_SurfaceProperties[texinfo[pMapDisp->face.texinfo].texdata];
				if ( flAlphaTotal > DISP_ALPHA_PROP_DELTA )
				{
					int nProp2 = GetSurfaceProperties2( matID, "surfaceprop2" );
					if ( nProp2 != -1 )
					{
						nProp = nProp2;
					}
				}
				int nMaterialIndex = RemapWorldMaterial( nProp );

				physcollision->PolysoupAddTriangle( pTerrainPhysics, tmpVerts[0], tmpVerts[1], tmpVerts[2], nMaterialIndex );
			}
		}

		// convert the whole grid's polysoup to a collide and store in the collision list
		CPhysCollide *pCollide = physcollision->ConvertPolysoupToCollide( pTerrainPhysics );
		if ( pCollide )
		{
			collisionList.AddToTail( new CPhysCollisionEntryStaticMesh( pCollide, NULL ) );	
		}
		// now that we have the collide, we're done with the soup
		physcollision->PolysoupDestroy( pTerrainPhysics );
	}
}
开发者ID:RaisingTheDerp,项目名称:raisingthebar,代码行数:91,代码来源:disp_ivp.cpp


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