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


C++ SubMesh::InitTerrainVertData方法代码示例

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


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

示例1: CreateEntity

	//------------------------------------------------------------------------------------
	void TerrainQuadTreeNode::CreateEntity()
	{
		// Create the entity.
		if (isRenderedAtCurrentLod() && !mEntity)
		{
			Mesh* pMesh = new Mesh;
			SubMesh* pSubmesh = new SubMesh;

			pMesh->SetPrimitiveType(ePrimitive_TriangleStrip);
			pSubmesh->InitTerrainVertData(getVertexDataRecord()->gpuPosVertexBuf, getVertexDataRecord()->gpuDeltaVertexBuf,
				mLodLevels[mCurrentLod]->pIndexBuf, mLodLevels[mCurrentLod]->nIndexCount);

			pMesh->AddSubMesh(pSubmesh);
			mEntity = new Entity(pMesh);
			mEntity->SetCastShadow(false);

			// vertex data is generated in terrain space
			mEntity->SetPosition(mTerrain->getPosition());

			static uint32 iMat = 0;
			++iMat;
			char szMatName[64];
			sprintf_s(szMatName, 64, "Mtl_TerrainSector_%d", iMat);

			Material* pMaterial = MaterialManager::GetSingleton().NewMaterial(szMatName, eVertexType_Terrain);

			pMaterial->SetTexture(0, mTerrain->getTerrainNormalMap());
			pMaterial->SetTexture(1, mTerrain->getLayerBlendTexture(0));

			SSamplerDesc& samDesc = pMaterial->GetSamplerStateDesc(0);
			samDesc.AddressU = eTextureAddressMode_WRAP;
			samDesc.AddressV = eTextureAddressMode_WRAP;
			samDesc.Filter = SF_MIN_MAG_MIP_LINEAR;
			pMaterial->SetSamplerStateDesc(0, samDesc);
			pMaterial->SetSamplerStateDesc(1, samDesc);

			for (uint32 i = 0; i < mTerrain->getLayerCount(); ++i)
			{
				pMaterial->SetTexture(2+i*2, g_env.pRenderer->GetRenderSys()->LoadTexture(mTerrain->getLayerTextureName(i, 0), eTextureType_2D, 0, true));
				pMaterial->SetTexture(2+i*2+1, g_env.pRenderer->GetRenderSys()->LoadTexture(mTerrain->getLayerTextureName(i, 1)));

				pMaterial->SetSamplerStateDesc(2 + i * 2, samDesc);
				pMaterial->SetSamplerStateDesc(2 + i * 2 + 1, samDesc);
			}

			pMaterial->InitShader("Terrain", eShader_Terrain, 0, nullptr, "VS_GBuffer", "PS_GBuffer");
			mEntity->SetMaterial(pMaterial);
		}

		if (mChildren[0])
		{
			mChildren[0]->CreateEntity();
			mChildren[1]->CreateEntity();
			mChildren[2]->CreateEntity();
			mChildren[3]->CreateEntity();
		}
	}
开发者ID:mavaL,项目名称:NeoEngine,代码行数:58,代码来源:TerrainQuadTreeNode.cpp


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