本文整理汇总了C++中Bone::attachVertices方法的典型用法代码示例。如果您正苦于以下问题:C++ Bone::attachVertices方法的具体用法?C++ Bone::attachVertices怎么用?C++ Bone::attachVertices使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Bone
的用法示例。
在下文中一共展示了Bone::attachVertices方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: attachVertices
/**
* Attaches vertices to the selected bone.
* \param verts pointer to the vertices vector holding the vertices to
* be attached
**/
void Skeleton::attachVertices(vector<Vertex *> *verts)
{
Bone *selectedBone = NULL;
int s = 0;
for (unsigned i = 0; i < bones->size(); i++) {
if ((*bones)[i]->selected) {
selectedBone = (*bones)[i];
s++;
}
}
if (s == 1) {
selectedBone->attachVertices(verts);
delete verts;
}
}
示例2: loadSkeleton
//.........这里部分代码省略.........
const char *name;
int j0, j1;
float size, stiffness, lengthMult;
float lengthMultMin, lengthMultMax, time, tempo;
int selected;
float radius;
name = b->Attribute("name"); // can be NULL
QUERY_CRITICAL_ATTR(b, "j0", j0);
QUERY_CRITICAL_ATTR(b, "j1", j1);
QUERY_CRITICAL_ATTR(b, "size", size);
QUERY_ATTR(b, "stiffness", stiffness, BONE_DEFAULT_DAMP);
QUERY_ATTR(b, "lm", lengthMult, BONE_DEFAULT_LENGTH_MULT);
QUERY_ATTR(b, "lmmin", lengthMultMin, BONE_DEFAULT_LENGTH_MULT_MIN);
QUERY_ATTR(b, "lmmax", lengthMultMax, BONE_DEFAULT_LENGTH_MULT_MAX);
QUERY_ATTR(b, "tempo", tempo, 0);
QUERY_ATTR(b, "time", time, 0);
QUERY_ATTR(b, "selected", selected, 0);
QUERY_ATTR(b, "radius", radius, 1);
if ((j0 >= jointCount) || (j1 >= jointCount))
continue;
Joint *j0p = (*joints)[j0];
Joint *j1p = (*joints)[j1];
Bone *bone = skeleton->addBone(j0p, j1p);
if (name)
bone->setName(name);
bone->setOrigSize(size);
bone->damp = stiffness;
bone->setLengthMult(lengthMult);
bone->setLengthMultMin(lengthMultMin);
bone->setLengthMultMax(lengthMultMax);
bone->setTempo(tempo);
bone->setTime(time);
bone->selected = selected;
bone->setRadiusMult(radius);
// load attached vertices
TiXmlNode *attachedNode = boneNode->FirstChild("attached");
if (attachedNode == NULL)
continue;
TiXmlNode *vertexNode = NULL;
// vector to hold vertices to be attached
vector<Vertex *> *vertsToAttach = new vector<Vertex *>;
// all vertices in mesh
vector<Vertex *> *vertices = m->getVertices();
// iterate over children to find all vertices
while ((vertexNode = attachedNode->IterateChildren(vertexNode)))
{
TiXmlElement *vertexXML = vertexNode->ToElement();
int id;
QUERY_CRITICAL_ATTR(vertexXML, "id", id);
if ((id >= (int)(vertices->size())) || (id < 0))
continue;
Vertex *v = (*vertices)[id];
vertsToAttach->push_back(v);
}
// setup parameter arrays
vertexNode = NULL;
float *dsts, *weights, *ca, *sa;
int count = vertsToAttach->size();
dsts = new float[count];
weights = new float[count];
ca = new float[count];
sa = new float[count];
// load parameters of attached vertices
int i = 0;
while ((vertexNode = attachedNode->IterateChildren(vertexNode)))
{
TiXmlElement *vertexXML = vertexNode->ToElement();
int id;
float d, w;
float s, c;
QUERY_CRITICAL_ATTR(vertexXML, "id", id);
QUERY_CRITICAL_ATTR(vertexXML, "d", d);
QUERY_CRITICAL_ATTR(vertexXML, "w", w);
QUERY_CRITICAL_ATTR(vertexXML, "sa", s);
QUERY_CRITICAL_ATTR(vertexXML, "ca", c);
if ((id >= (int)(vertices->size())) || (id < 0))
continue;
dsts[i] = d;
weights[i] = w;
ca[i] = c;
sa[i] = s;
i++;
}
bone->attachVertices(vertsToAttach, dsts, weights, ca, sa);
vertsToAttach->clear();
delete vertsToAttach;
}
}