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


C++ Armature::getBoneId方法代码示例

本文整理汇总了C++中Armature::getBoneId方法的典型用法代码示例。如果您正苦于以下问题:C++ Armature::getBoneId方法的具体用法?C++ Armature::getBoneId怎么用?C++ Armature::getBoneId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Armature的用法示例。


在下文中一共展示了Armature::getBoneId方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: readAssimpMesh


//.........这里部分代码省略.........
			unsigned int a, aSize = scene->mNumAnimations;
		
			Object3dAnim * bonesAnim = armatureAnim->allocBonesAnim(armature->getBonesNumber());
		
			
			// node infos (for multiple anims merging)
			map <string, NodeInfos> nodesInfos;
			for(a=0; a<aSize; a++)
			{
				aiAnimation * anim = scene->mAnimations[a];
			
				unsigned int c, cSize;
				for(c=0; c<anim->mNumChannels; c++)
				{
					aiNodeAnim * channel = anim->mChannels[c];
					NodeInfos * infos = &(nodesInfos[channel->mNodeName.data]);
					
					infos->nbKeyPos += channel->mNumPositionKeys;
					infos->nbKeyRot	+= channel->mNumRotationKeys;
					infos->nbKeyScale += channel->mNumScalingKeys;
				}
			}
			
			
			// alloc keys
			{
				map<string, NodeInfos>::iterator
					mit (nodesInfos.begin()),
					mend(nodesInfos.end());

				for(; mit!=mend; mit++)
				{
					unsigned int boneId;
					if(armature->getBoneId(mit->first.c_str(), &boneId))
					{
						Object3dAnim * boneAnim = &(bonesAnim[boneId]);
					
						if(mit->second.nbKeyPos > 0)
							boneAnim->allocPositionKeys(mit->second.nbKeyPos);
						
						if(mit->second.nbKeyRot > 0)
							boneAnim->allocRotationKeys(mit->second.nbKeyRot);
							
						if(mit->second.nbKeyScale > 0)
							boneAnim->allocScaleKeys(mit->second.nbKeyScale);
							
						mit->second.nbKeyPos = 0;
						mit->second.nbKeyRot = 0;
						mit->second.nbKeyScale = 0;
					}
				}
			}
			
			
			// anims
			int prevT = 0;
			for(a=0; a<aSize; a++)
			{
				aiAnimation * anim = scene->mAnimations[a];
			
				animRanges[a].start = prevT;
				animRanges[a].end = prevT + getMaratisTick(anim->mDuration, anim->mTicksPerSecond);
				
				
				unsigned int c, cSize;
				for(c=0; c<anim->mNumChannels; c++)
开发者ID:joewan,项目名称:NeoEditor,代码行数:67,代码来源:AssimpMeshLoader.cpp

示例2: initBones

static void initBones(const aiScene * scene, const aiMesh * nodeMesh, Mesh * mesh, SubMesh * subMesh)
{
	Armature * armature = mesh->getArmature();
	
	BoneData bdata;
	map<unsigned int, AssimpSkinData> skinDatas;
	
	
	// bones
	for(unsigned int i=0; i<nodeMesh->mNumBones; i++)
	{
		aiBone * nodeBone = nodeMesh->mBones[i];
		
		unsigned int boneId;
		if(! armature->getBoneId(nodeBone->mName.data, &boneId))
			continue;
		
		OBone * bone = armature->getBone(boneId);
		
		aiMatrix4x4 offsetMat = nodeBone->mOffsetMatrix;
		aiTransposeMatrix4(&offsetMat);
		Matrix4x4 matrix = (*bone->getMatrix()) * Matrix4x4((float*)&offsetMat);
		
		
		// pose skinning
		Vector3 * vertices = subMesh->getVertices();
		Vector3 * normals = subMesh->getNormals();
		Vector3 * tangents = subMesh->getTangents();
		
		unsigned int w;
		for(w=0; w<nodeBone->mNumWeights; w++)
		{
			unsigned int vid = nodeBone->mWeights[w].mVertexId;
			float weight = nodeBone->mWeights[w].mWeight; 
			
			bdata.id = boneId;
			bdata.weight = weight;
			skinDatas[vid].bones.push_back(bdata);

			if(skinDatas[vid].bones.size() == 1)
			{
				if(vertices) vertices[vid] = Vector3(0, 0, 0);
				if(normals) normals[vid] = Vector3(0, 0, 0);
				if(tangents) tangents[vid] = Vector3(0, 0, 0);
			}
			
			if(vertices)
				vertices[vid] += matrix * Vector3(nodeMesh->mVertices[vid].x, nodeMesh->mVertices[vid].y, nodeMesh->mVertices[vid].z) * weight;
			
			if(normals)
				normals[vid] += matrix.getRotatedVector3(Vector3(nodeMesh->mNormals[vid].x, nodeMesh->mNormals[vid].y, nodeMesh->mNormals[vid].z)) * weight;
			
			if(tangents)
				tangents[vid] += matrix.getRotatedVector3(Vector3(nodeMesh->mTangents[vid].x, nodeMesh->mTangents[vid].y, nodeMesh->mTangents[vid].z)) * weight;
		}
	}
	
	
	// alloc skin
	unsigned int skinSize = skinDatas.size();
	if(skinSize > 0)
	{
		SkinData * skin = subMesh->createSkinData();
		SkinPoint * skinPoints = skin->allocPoints(skinSize);
		
		map<unsigned int, AssimpSkinData>::iterator
			mit (skinDatas.begin()),
			mend(skinDatas.end());
		
		unsigned int p = 0;
		for(; mit!=mend; ++mit)
		{
			unsigned int vertexId = mit->first;
			AssimpSkinData * sdata = &mit->second;
			
			unsigned int b, bSize = sdata->bones.size();
			
			if(skinPoints[p].allocateBonesLinks(bSize))
			{
				skinPoints[p].setVertexId(vertexId);
				
				unsigned short * ids = skinPoints[p].getBonesIds();
				float * weights = skinPoints[p].getBonesWeights();
				
				for(b=0; b<bSize; b++)
				{
					ids[b] = sdata->bones[b].id;
					weights[b] = sdata->bones[b].weight;
				}
			}
			
			p++;
		}
	}
}
开发者ID:joewan,项目名称:NeoEditor,代码行数:95,代码来源:AssimpMeshLoader.cpp


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