本文整理汇总了C++中ofMesh::removeVertex方法的典型用法代码示例。如果您正苦于以下问题:C++ ofMesh::removeVertex方法的具体用法?C++ ofMesh::removeVertex怎么用?C++ ofMesh::removeVertex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ofMesh
的用法示例。
在下文中一共展示了ofMesh::removeVertex方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: fuseNeighbours
void MeshHelper::fuseNeighbours( ofMesh& mesh, float fuseDistance )
{
//@todo tex coords, normals
assert( mesh.getMode() == OF_PRIMITIVE_TRIANGLES );
int oldNumVerts = mesh.getNumVertices();
int oldNumIndices = mesh.getNumIndices();
if ( fuseDistance < 0 )
{
// fuse close-enough vertices
// first define 'close enough' as 1/10000 of smallest dimension of the bounding box width/height/depth
ofVec3f tlb, brf; // top left back, bottom right front
calculateAABoundingBox( mesh, tlb, brf );
float minDimension = min(brf.x-tlb.x,min(brf.y-tlb.y, brf.z-tlb.z));
fuseDistance = minDimension * 0.00001f;
}
// now fuse
map<ofIndexType,ofIndexType> fused;
vector<ofVec3f> newVertices;
vector<ofIndexType> remove;
for ( ofIndexType i=0; i<mesh.getNumVertices(); i++ )
{
const ofVec3f& vertex = mesh.getVertex(i);
// look at all the earlier vertices
bool didFuse = false;
for ( ofIndexType j=0; j<newVertices.size(); j++ ) {
if ( (vertex-newVertices[j]).length()<fuseDistance ) {
// fuse i to j
fused[i] = j;
remove.push_back(i);
didFuse = true;
break;
}
}
if ( !didFuse ) {
newVertices.push_back( vertex );
fused[i] = newVertices.size()-1;
}
}
// update indices
for ( int i=0; i<mesh.getNumIndices(); i++ ) {
ofIndexType originalIndex = mesh.getIndex(i);
assert( fused.find( originalIndex ) != fused.end() );
if ( fused.find(originalIndex) != fused.end() ) {
mesh.getIndices()[i] = fused[originalIndex];
}
}
// remove the fused
for ( int i=remove.size()-1; i>=0; i-- ) {
mesh.removeVertex( remove[i] );
}
ofLogNotice("MeshHelper") << "fuseNeighbours inplace: input " << oldNumVerts << " vertices/" << oldNumIndices << " indices, output " << mesh.getNumVertices() << " vertices/" << mesh.getNumIndices() << " indices";
}