本文整理汇总了C++中MeshDocument::getMesh方法的典型用法代码示例。如果您正苦于以下问题:C++ MeshDocument::getMesh方法的具体用法?C++ MeshDocument::getMesh怎么用?C++ MeshDocument::getMesh使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MeshDocument
的用法示例。
在下文中一共展示了MeshDocument::getMesh方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: configurationHasChanged
bool DynamicMeshSubFilter::configurationHasChanged(MeshDocument& md, RichParameterSet& par){
bool changed = m_seconds != par.getInt("seconds");
changed |= m_fps != par.getInt("fps");
changed |= m_iterations != par.getInt("iterations");
changed |= m_contacts != par.getInt("contacts");
changed |= m_bounciness != par.getFloat("bounciness");
changed |= m_gravity != par.getFloat("gravity");
changed |= m_friction != par.getFloat("friction");
if(unsigned(md.size()) == m_files.size())
for(unsigned i = 0; i < m_files.size(); i++)
changed |= m_files.at(i) != md.getMesh(i)->fileName;
else
changed = true;
m_files.clear();
for(int i = 0; i < md.size(); i++)
m_files.push_back(md.getMesh(i)->fileName);
m_seconds = par.getInt("seconds");
m_fps = par.getInt("fps");
m_iterations = par.getInt("iterations");
m_contacts = par.getInt("contacts");
m_bounciness = par.getFloat("bounciness");
m_gravity = par.getFloat("gravity");
m_friction = par.getFloat("friction");
return changed;
}
示例2: applyFilter
bool RandomFillFilter::applyFilter(QAction*, MeshDocument &md, RichParameterSet& par, vcg::CallBackPos* cb){
if(parametersAreNotCorrect(md, par))
return false;
MeshSubFilter::initialize(md, par, cb);
if(cb != 0) (*cb)(0, "Physics renderization of the scene started...");
MeshModel* container = par.getMesh("container");
MeshModel* filler = par.getMesh("filler");
int fillOffset = md.size();
float gravity[3] = {0.0f, par.getBool("useRandomVertices") ? 0.0f : -9.8f, 0.0f};
if(par.getBool("flipNormal")){
vcg::tri::Clean<CMeshO>::FlipMesh(container->cm);
tri::UpdateNormals<CMeshO>::PerVertexNormalizedPerFace(container->cm);
container->clearDataMask(MeshModel::MM_FACEFACETOPO | MeshModel::MM_FACEFLAGBORDER);
}
m_engine.clear();
m_engine.setGlobalForce(gravity);
m_engine.setIterations(par.getInt("iterations"));
m_engine.setMaxContacts(par.getInt("contacts"));
m_engine.setBounciness(par.getFloat("bounciness"));
m_engine.setFriction(par.getFloat("friction"));
m_engine.registerTriMesh(*container, true);
srand((unsigned)time(0));
vcg::tri::UpdatePosition<CMeshO>::Matrix(filler->cm, filler->cm.Tr);
filler->cm.Tr.SetIdentity();
tri::Inertia<CMeshO> inertiaContainer, inertiaFiller;
inertiaContainer.Compute(par.getMesh("container")->cm);
inertiaFiller.Compute(par.getMesh("filler")->cm);
int objects = abs(inertiaContainer.Mass()/inertiaFiller.Mass())*par.getFloat("factor");
filler->cm.Tr.SetColumn(3, - inertiaFiller.CenterOfMass());
//Restore old generated meshes
int restoredMeshes = 0;
for(int i = 0; i < md.size(); i++){
if(md.getMesh(i)->fileName.find("randomFillMesh") == 0){
m_engine.registerTriMesh(*md.getMesh(i));
restoredMeshes++;
m_engine.integrate(1.0f/par.getInt("fps"));
}
}
int frequency = 1 / par.getFloat("updateFrequency");
// To refactor when the right algorithm has be found
if(par.getBool("useRandomVertices")){
for(int i = 0; i < objects; i++){
if(cb != 0) (*cb)(50.f*i/objects, "Computing...");
addRandomObject(md, filler, getRandomOrigin(par), restoredMeshes + i);
m_engine.registerTriMesh(*md.getMesh(fillOffset++));
}
for(int j = 0; j < par.getFloat("seconds") * par.getInt("fps"); j++){
if(cb != 0) (*cb)(50 + 48.f*j/(par.getFloat("seconds") * par.getInt("fps")), "Computing...");
m_engine.integrate(1.0f/par.getInt("fps"));
}
}else{
for(int i = 0; i < objects; i++){
if(cb != 0) (*cb)(98.f*i/objects, "Computing...");
addRandomObject(md, filler, inertiaContainer.CenterOfMass(), i);
m_engine.registerTriMesh(*md.getMesh(fillOffset++));
if(i % frequency == 0)
for(int j = 0; j < par.getFloat("seconds") * par.getInt("fps"); j++)
m_engine.integrate(1.0f/par.getInt("fps"));
}
}
m_engine.updateTransform();
filler->cm.Tr.SetIdentity();
m_currentFilterType = m_filterType;
if(par.getBool("flipNormal")){
vcg::tri::Clean<CMeshO>::FlipMesh(container->cm);
tri::UpdateNormals<CMeshO>::PerVertexNormalizedPerFace(container->cm);
container->clearDataMask(MeshModel::MM_FACEFACETOPO | MeshModel::MM_FACEFLAGBORDER);
}
if(cb != 0) (*cb)(99, "Physics renderization of the scene completed...");
return true;
}