本文整理汇总了C++中Skeleton::addBone方法的典型用法代码示例。如果您正苦于以下问题:C++ Skeleton::addBone方法的具体用法?C++ Skeleton::addBone怎么用?C++ Skeleton::addBone使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Skeleton
的用法示例。
在下文中一共展示了Skeleton::addBone方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: storeSkeletons
void BlenderSceneExporter::storeSkeletons( TamySkeleton* arrSkeletons, int skeletonsCount )
{
ResourcesManager& resMgr = TSingleton< ResourcesManager >::getInstance();
m_exportedSkeletons.clear();
m_exportedSkeletons.resize( skeletonsCount );
Matrix boneLocalMtx;
for ( int skeletonIdx = 0; skeletonIdx < skeletonsCount; ++skeletonIdx )
{
const TamySkeleton& exportedSkeleton = arrSkeletons[skeletonIdx];
FilePath skeletonPath( m_animationsExportDir + exportedSkeleton.name + "." + Skeleton::getExtension() );
Skeleton* skeleton = resMgr.create< Skeleton >( skeletonPath );
skeleton->clear();
m_exportedSkeletons[skeletonIdx] = skeleton;
// set skeleton bones
for ( int boneIdx = 0; boneIdx < exportedSkeleton.bonesCount; ++boneIdx )
{
const TamyBone& exportedBone = exportedSkeleton.bones[boneIdx];
Matrix boneLocalTransform, invBoneMSTransform;
if ( exportedBone.parentBoneIdx >= 0 )
{
const TamyBone& parentBone = exportedSkeleton.bones[exportedBone.parentBoneIdx];
parentBone.modelSpaceTransform.applyTo( invBoneMSTransform );
invBoneMSTransform.invert();
Matrix boneMSTransform;
exportedBone.modelSpaceTransform.applyTo( boneMSTransform );
boneLocalTransform.setMul( boneMSTransform, invBoneMSTransform );
}
else
{
exportedBone.modelSpaceTransform.applyTo( boneLocalTransform );
}
skeleton->addBone( exportedBone.name, boneLocalTransform, exportedBone.parentBoneIdx, exportedBone.boneLength );
}
// calculate skeleton's bind pose
skeleton->buildSkeleton();
// save the skeleton
if ( m_exportSettings.saveAnimations )
{
skeleton->saveResource();
}
}
}
示例2: loadModelAndSkeletonDae
//.........这里部分代码省略.........
for (unsigned int i = 0; i < 16; i++)
m[i / 4][i % 4] = mat[i];
s.setRootTransformMatrix(glm::transpose(m));
}
s.setBonesNumber(bindPoses.size());
//load skeleton
while (fileStream.good())
{
getline(fileStream, line);
if (line.find("</node>") != std::string::npos) {
int last = findLastOpen(closed);
if (last < 0)
break;
closed[last] = true;;
}
else if ((pos = line.find("<node id=")) != std::string::npos) {
int parent = findLastOpen(closed);
std::string name = line.substr((pos = line.find_first_of("\"")) + 1, line.find_first_of("\"", pos + 1) - (pos + 1));
getline(fileStream, line);
std::string::iterator begIt = line.begin() + (pos = line.find_first_of(">")) + 1;
std::string::iterator endIt = line.begin() + line.find_first_of("<", pos + 1);
std::vector<float> mat; mat.reserve(16);
split(begIt, endIt, ' ', mat);
glm::mat4 m;
for (unsigned int i = 0; i < 16; i++)
m[i / 4][i % 4] = mat[i];
s.addBone(glm::transpose(m), findLastOpen(closed));
closed.push_back(false);
}
}
if (!fileStream.good()) {
std::cout << "File is in incorrect format " << path << std::endl;
return false;
}
//add inverse bind pose matrices
for (unsigned int i = 0; i < bindPoses.size(); i++) {
s.getBone(i)->inverseBindMatrix = glm::transpose(bindPoses[i]) * bindShapeMatrix;
}
s.fixScale();
//sort weights
std::vector<std::vector<float> > wSorted;
std::vector<std::vector<int> > jSorted;
wSorted.reserve(weightJoints.size());
jSorted.reserve(weightJoints.size());
for (unsigned int i = 0; i < weightJoints.size(); i++) {
wSorted.push_back(std::vector<float>()); wSorted.back().reserve(weightJoints[i].size());
jSorted.push_back(std::vector<int>()); jSorted.back().reserve(weightJoints[i].size());
for (unsigned int j = 0; j < weightJoints[i].size(); j++) {
if (j == 0) {
wSorted[i].push_back(w[weightWeights[i][j]]);
jSorted[i].push_back(weightJoints[i][j]);
}
else {