本文整理汇总了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();
}
}