Exemple #1
0
void GR2ImportImpl::OrderBones(INodeTab& bones)
{
   if (info.Skeletons.size() == 1)
   {
      NameNodeMap nodes;
      INodeTab rv = ImportSkeleton(*info.Skeletons[0]);
      // Strip out auto-generated bones.  Place in order found in ini file
      for (size_t i = 0, n = rv.Count(); i<n; ++i)
      {
         INode *node = rv[i];

         bool found = false;
         for (stringlist::const_iterator itr=boneMatch.begin(), end=boneMatch.end(); itr != end; ++itr)
         {
            if (wildmatch(*itr, node->GetName())) {
               nodes[*itr].Append(1, &node);
               found = true;
            }
         }
         if (!found)
         {
            node->SetUserPropInt("MDBBoneIndex", int(bones.Count()));
            bones.Append(1, &node);
         }
      }
      for (stringlist::const_iterator itr=boneMatch.begin(), end=boneMatch.end(); itr != end; ++itr)
      {
         INodeTab& map = nodes[*itr];
         for (size_t i = 0, n = map.Count(); i<n; ++i)
         {
            INode *node = map[i];
            node->SetUserPropInt("MDBBoneIndex", int(bones.Count()));
            bones.Append(1, &node);
         }
      }
      // When in face mode, swap the Face Bones for the first N bones in the skeleton.  
      //   Some of the later bones like Head, Neck, Ribcage are still used so we cannot 
      //   discard the whole skeleton.
      if (enableFaceMode)
      {
         size_t curIdx = 0;
         for (size_t i = 0, n = bones.Count(); i<n; ++i)
         {
            INode *node = bones[i];
            for (stringlist::const_iterator itr=faceBoneMatch.begin(), end=faceBoneMatch.end(); itr != end; ++itr)
            {
               if (wildmatch(*itr, node->GetName())) {
                  bones[i] = bones[curIdx];
                  bones[curIdx] = node;
                  node->SetUserPropInt("MDBBoneIndex", int(curIdx));
                  ++curIdx;
                  break;
               }
            }
         }
      }
   }
}
Exemple #2
0
void printStringList( const stringlist& lst )
{
	for(auto it=lst.begin();it!=lst.end();it++) {
		cout << (*it) << ' ';
	}
	cout << endl;
}