本文整理汇总了C++中SimulationModel::addStrainTetConstraint方法的典型用法代码示例。如果您正苦于以下问题:C++ SimulationModel::addStrainTetConstraint方法的具体用法?C++ SimulationModel::addStrainTetConstraint怎么用?C++ SimulationModel::addStrainTetConstraint使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimulationModel
的用法示例。
在下文中一共展示了SimulationModel::addStrainTetConstraint方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createMesh
//.........这里部分代码省略.........
indices.push_back(p0); indices.push_back(p2); indices.push_back(p5); indices.push_back(p1);
indices.push_back(p7); indices.push_back(p2); indices.push_back(p0); indices.push_back(p3);
indices.push_back(p5); indices.push_back(p2); indices.push_back(p7); indices.push_back(p6);
indices.push_back(p7); indices.push_back(p0); indices.push_back(p5); indices.push_back(p4);
indices.push_back(p0); indices.push_back(p2); indices.push_back(p7); indices.push_back(p5);
}
}
}
}
SimulationModel *model = Simulation::getCurrent()->getModel();
model->addTetModel(width*height*depth, (unsigned int)indices.size() / 4u, points, indices.data());
ParticleData &pd = model->getParticles();
for (unsigned int i = 0; i < pd.getNumberOfParticles(); i++)
{
pd.setMass(i, 1.0);
}
for (unsigned int i = 0; i < 1; i++)
{
for (unsigned int j = 0; j < height; j++)
{
for (unsigned int k = 0; k < depth; k++)
pd.setMass(i*height*depth + j*depth + k, 0.0);
}
}
// init constraints
for (unsigned int cm = 0; cm < model->getTetModels().size(); cm++)
{
const unsigned int nTets = model->getTetModels()[cm]->getParticleMesh().numTets();
const unsigned int *tets = model->getTetModels()[cm]->getParticleMesh().getTets().data();
const IndexedTetMesh::VertexTets *vTets = model->getTetModels()[cm]->getParticleMesh().getVertexTets().data();
if (simulationMethod == 1)
{
const unsigned int offset = model->getTetModels()[cm]->getIndexOffset();
const unsigned int nEdges = model->getTetModels()[cm]->getParticleMesh().numEdges();
const IndexedTetMesh::Edge *edges = model->getTetModels()[cm]->getParticleMesh().getEdges().data();
for (unsigned int i = 0; i < nEdges; i++)
{
const unsigned int v1 = edges[i].m_vert[0] + offset;
const unsigned int v2 = edges[i].m_vert[1] + offset;
model->addDistanceConstraint(v1, v2);
}
for (unsigned int i = 0; i < nTets; i++)
{
const unsigned int v1 = tets[4 * i];
const unsigned int v2 = tets[4 * i + 1];
const unsigned int v3 = tets[4 * i + 2];
const unsigned int v4 = tets[4 * i + 3];
model->addVolumeConstraint(v1, v2, v3, v4);
}
}
else if (simulationMethod == 2)
{
TetModel::ParticleMesh &mesh = model->getTetModels()[cm]->getParticleMesh();
for (unsigned int i = 0; i < nTets; i++)
{
const unsigned int v1 = tets[4 * i];
const unsigned int v2 = tets[4 * i + 1];
const unsigned int v3 = tets[4 * i + 2];
const unsigned int v4 = tets[4 * i + 3];
model->addFEMTetConstraint(v1, v2, v3, v4);
}
}
else if (simulationMethod == 3)
{
TetModel::ParticleMesh &mesh = model->getTetModels()[cm]->getParticleMesh();
for (unsigned int i = 0; i < nTets; i++)
{
const unsigned int v1 = tets[4 * i];
const unsigned int v2 = tets[4 * i + 1];
const unsigned int v3 = tets[4 * i + 2];
const unsigned int v4 = tets[4 * i + 3];
model->addStrainTetConstraint(v1, v2, v3, v4);
}
}
else if (simulationMethod == 4)
{
TetModel::ParticleMesh &mesh = model->getTetModels()[cm]->getParticleMesh();
for (unsigned int i = 0; i < nTets; i++)
{
const unsigned int v[4] = { tets[4 * i], tets[4 * i + 1], tets[4 * i + 2], tets[4 * i + 3] };
// Important: Divide position correction by the number of clusters
// which contain the vertex.
const unsigned int nc[4] = { vTets[v[0]].m_numTets, vTets[v[1]].m_numTets, vTets[v[2]].m_numTets, vTets[v[3]].m_numTets };
model->addShapeMatchingConstraint(4, v, nc);
}
}
model->getTetModels()[cm]->updateMeshNormals(pd);
}
LOG_INFO << "Number of tets: " << indices.size() / 4;
LOG_INFO << "Number of vertices: " << width*height*depth;
}