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


C++ MeshPrimitive::getBinormalIndices方法代码示例

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


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

示例1: Load

SubMesh* ColladaSubMeshReader::Load( void )
{  
	COLLADAFW::MeshPrimitiveArray& primitives = m_pMesh->getMeshPrimitives();

	//若没有几何图元信息
	if( 0 == primitives.getCount() )
	{
		return NULL;
	}

	COLLADAFW::MeshPrimitive* pPrimitive = primitives[0]; 
 
	if(  COLLADAFW::MeshPrimitive::TRIANGLES != pPrimitive->getPrimitiveType()  )
	{
		return NULL;
	}

	COLLADAFW::UIntValuesArray& positionIndices = pPrimitive->getPositionIndices(); 
	//若没有位置索引 则直接退出
	if( 0 == positionIndices.getCount() )
	{
		return NULL;
	} 

	COLLADAFW::UIntValuesArray& normalIndices = pPrimitive->getNormalIndices(); 
	m_bHasNormals = ( normalIndices.getCount() != 0 );  
	COLLADAFW::UIntValuesArray& tangentIndices = pPrimitive->getTangentIndices(); 
	m_bHasTangents = ( tangentIndices.getCount() != 0 ); 
	COLLADAFW::UIntValuesArray& binormalIndices = pPrimitive->getBinormalIndices(); 
	m_bHasBinormals = ( binormalIndices.getCount() != 0 );
	COLLADAFW::IndexList* pUVs = NULL;
	if( pPrimitive->getUVCoordIndicesArray().getCount() )
	{
		pUVs = pPrimitive->getUVCoordIndicesArray()[0]; 
		m_bHasUVs = ( pUVs->getIndices().getCount() != 0 );
	} 

	SubMesh* pSubMesh = new SubMesh;
	pSubMesh->SetName( m_pMesh->getName() );  
	Resource::Material* pMaterial = Resource::MaterialManager::GetInstance()->CreateOrRetrieveMaterial( m_pMesh->getName() );
	pSubMesh->SetMaterial( pMaterial );

	Render::VertexBuffer& vertexBuf =  pSubMesh->RenderData().VertexBuf();
	pSubMesh->RenderData().PrimitiveType( Render::TYPE_TRIANGLES );

	vertexBuf.ChannelFlag() = Render::POSITION_CH;
	if( m_bHasNormals )
	{
		vertexBuf.ChannelFlag() |= Render::NORMAL_CH;
	}
	if( m_bHasUVs )
	{
		vertexBuf.ChannelFlag() |= Render::TEXCOORD_CH;
	}
	if( m_bHasTangents )
	{
		vertexBuf.ChannelFlag() |= Render::TANGENT_CH;
	}
	if( m_bHasBinormals )
	{
		vertexBuf.ChannelFlag() |= Render::BINORMAL_CH;
	}

	unsigned int uiCurrIndex = 0;
	unsigned int uiIndicesCount = positionIndices.getCount();

	for( unsigned int uiIndex = 0 ; uiIndex < uiIndicesCount ; uiIndex++ )
	{
		Tuple tuple;
		tuple.m_posIndex = positionIndices[uiIndex];
		if( m_bHasNormals )
		{
			tuple.m_normIndex = normalIndices[uiIndex];
		}
		if( m_bHasUVs )
		{
			tuple.m_uvIndex = pUVs->getIndices()[uiIndex];
		}
		if( m_bHasTangents )
		{
			tuple.m_tangentIndex = tangentIndices[uiIndex];
		}
		if( m_bHasBinormals )
		{
			tuple.m_binormalIndex = binormalIndices[uiIndex];
		}

		indicesTable_t::iterator itIndex = m_indicesMap.find(tuple); 
		if( itIndex == m_indicesMap.end() )
		{
			Render::Vertex newVert;
			LoadVertexByTuple( tuple , newVert );
			vertexBuf.AppendVertex( newVert );
			m_indicesMap.insert( std::make_pair( tuple , uiCurrIndex ) );
			pSubMesh->RenderData().AppendIndex( uiCurrIndex );
			uiCurrIndex++;
		}else{
			pSubMesh->RenderData().AppendIndex( itIndex->second );
		}

//.........这里部分代码省略.........
开发者ID:spawn66336,项目名称:ZPSoftRender,代码行数:101,代码来源:ColladaSubMeshReader.cpp


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