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


C++ UPrimitiveComponent::GetNumMaterials方法代码示例

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


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

示例1: if

	/**
	 * Advances to the next material
	 */
	void operator++()
	{
		// Advance to the next material
		++CurMaterialIndex;

		// Examine each component until we are out of them
		while( SelectedComponents.IsValidIndex(CurComponentIndex) )
		{
			USceneComponent* TestComponent = SelectedComponents[CurComponentIndex].Get();

			if( TestComponent != NULL )
			{
				CurComponent = TestComponent;
				int32 NumMaterials = 0;

				// Primitive components and some actor components have materials
				UPrimitiveComponent* PrimitiveComp = Cast<UPrimitiveComponent>( CurComponent );
				UDecalComponent* DecalComponent = (PrimitiveComp ? NULL : Cast<UDecalComponent>( CurComponent ));

				if( PrimitiveComp )
				{
					NumMaterials = PrimitiveComp->GetNumMaterials();
				}
				else if( DecalComponent )
				{
					// DecalComponent isn't a primitive component so we must get the materials directly from it
					NumMaterials = DecalComponent->GetNumMaterials();
				}

				// Check materials
				while( CurMaterialIndex < NumMaterials )
				{
					UMaterialInterface* Material = NULL;

					if( PrimitiveComp )
					{
						Material = PrimitiveComp->GetMaterial(CurMaterialIndex);
					}
					else if( DecalComponent )
					{
						Material = DecalComponent->GetMaterial(CurMaterialIndex);
					}

					CurMaterial = Material;
							
					// We step only once in the iterator if we have a material.  Note: A null material is considered valid
					
					// PVS-Studio has noticed that this is a fairly unorthodox return statement. Typically a break would 
					// be the expected control sequence in a nested while loop. This may be correct, however, so for now
					// we have disabled the warning.
					return; //-V612
				}
				// Out of materials on this component, reset for the next component
				CurMaterialIndex = 0;
			}
			// Advance to the next compoment
			++CurComponentIndex;
		}


		// Out of components to check, reset to an invalid state
		CurComponentIndex = INDEX_NONE;
		bReachedEnd = true;
		CurComponent = NULL;
		CurMaterial = NULL;
		CurMaterialIndex = INDEX_NONE;
	}
开发者ID:PopCap,项目名称:GameIdea,代码行数:70,代码来源:ComponentMaterialCategory.cpp


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