本文整理汇总了C++中MeshCollector::fillMesh方法的典型用法代码示例。如果您正苦于以下问题:C++ MeshCollector::fillMesh方法的具体用法?C++ MeshCollector::fillMesh怎么用?C++ MeshCollector::fillMesh使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MeshCollector
的用法示例。
在下文中一共展示了MeshCollector::fillMesh方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: makeMapBlockMesh
//.........这里部分代码省略.........
if(fastfaces_new.size() > 0)
{
// avg 0ms (100ms spikes when loading textures the first time)
//TimeTaker timer2("updateMesh() mesh building");
video::SMaterial material;
material.setFlag(video::EMF_LIGHTING, false);
material.setFlag(video::EMF_BILINEAR_FILTER, false);
material.setFlag(video::EMF_FOG_ENABLE, true);
//material.setFlag(video::EMF_ANTI_ALIASING, video::EAAM_OFF);
//material.setFlag(video::EMF_ANTI_ALIASING, video::EAAM_SIMPLE);
for(u32 i=0; i<fastfaces_new.size(); i++)
{
FastFace &f = fastfaces_new[i];
const u16 indices[] = {0,1,2,2,3,0};
const u16 indices_alternate[] = {0,1,3,2,3,1};
video::ITexture *texture = f.tile.texture.atlas;
if(texture == NULL)
continue;
material.setTexture(0, texture);
f.tile.applyMaterialOptions(material);
const u16 *indices_p = indices;
/*
Revert triangles for nicer looking gradient if vertices
1 and 3 have same color or 0 and 2 have different color.
*/
if(f.vertices[0].Color != f.vertices[2].Color
|| f.vertices[1].Color == f.vertices[3].Color)
indices_p = indices_alternate;
collector.append(material, f.vertices, 4, indices_p, 6);
}
}
/*
Add special graphics:
- torches
- flowing water
- fences
- whatever
*/
mapblock_mesh_generate_special(data, collector);
/*
Add stuff from collector to mesh
*/
scene::SMesh *mesh_new = NULL;
mesh_new = new scene::SMesh();
collector.fillMesh(mesh_new);
/*
Do some stuff to the mesh
*/
mesh_new->recalculateBoundingBox();
/*
Delete new mesh if it is empty
*/
if(mesh_new->getMeshBufferCount() == 0)
{
mesh_new->drop();
mesh_new = NULL;
}
if(mesh_new)
{
#if 0
// Usually 1-700 faces and 1-7 materials
std::cout<<"Updated MapBlock has "<<fastfaces_new.size()<<" faces "
<<"and uses "<<mesh_new->getMeshBufferCount()
<<" materials (meshbuffers)"<<std::endl;
#endif
// Use VBO for mesh (this just would set this for ever buffer)
// This will lead to infinite memory usage because or irrlicht.
//mesh_new->setHardwareMappingHint(scene::EHM_STATIC);
/*
NOTE: If that is enabled, some kind of a queue to the main
thread should be made which would call irrlicht to delete
the hardware buffer and then delete the mesh
*/
}
return mesh_new;
//std::cout<<"added "<<fastfaces.getSize()<<" faces."<<std::endl;
}