当前位置: 首页>>代码示例>>C++>>正文


C++ Bone::attachVertices方法代码示例

本文整理汇总了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;
    }
}
开发者ID:malloch,项目名称:Animata,代码行数:22,代码来源:Skeleton.cpp

示例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;
	}
}
开发者ID:BruceJawn,项目名称:animata,代码行数:101,代码来源:IO.cpp


注:本文中的Bone::attachVertices方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。