Advertisement
Dimitri_UA

LoadSkin (3ds max)

Jul 27th, 2014
285
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.07 KB | None | 0 0
  1. // Load skin
  2. for(gtaRwInt32 j = 0; j < clump.frameList.frameCount; j++)
  3. {
  4.     if(clump.frameList.frames[j].Extension.hAnim.enabled && clump.frameList.frames[j].Extension.hAnim.numNodes > 0)
  5.     {
  6.         gtaRwFrameHAnim &anim = clump.frameList.frames[j].Extension.hAnim;
  7.         for(gtaRwInt32 i = 0; i < clump.geometryList.geometryCount; i++)
  8.         {
  9.             gtaRwGeometry &geom = clump.geometryList.geometries[i];
  10.             if(geom.Extension.skin.enabled)
  11.             {
  12.                 Modifier *skin = (Modifier *)gi->CreateInstance(SClass_ID(OSM_CLASS_ID), SKIN_CLASSID);
  13.                 ISkinImportData *skinImportData = (ISkinImportData *)skin->GetInterface(I_SKINIMPORTDATA);
  14.                 GetCOREInterface7()->AddModifier(*objects[i].frame, *skin);
  15.                 objects[i].frame->EvalWorldState(0);
  16.                 if(geom.Extension.skin.numBoneIds == 0)
  17.                     geom.Extension.skin.FindUsedBoneIds(geom.numVertices, geom.Extension.skin.numBones);
  18.                 for(gtaRwInt32 bone = 0; bone < geom.Extension.skin.numBoneIds; bone++)
  19.                 {
  20.                     for(gtaRwInt32 frame = 0; frame < clump.frameList.frameCount; frame++)
  21.                     {
  22.                         if(clump.frameList.frames[frame].Extension.hAnim.enabled &&
  23.                             clump.frameList.frames[frame].Extension.hAnim.id == anim.nodes[geom.Extension.skin.boneIds[bone]].nodeID)
  24.                         {
  25.                             skinImportData->AddBoneEx(nodes[frame], true);
  26.                             break;
  27.                         }
  28.                     }
  29.                 }
  30.                 objects[i].frame->EvalWorldState(gi->GetTime());
  31.                 Tab<INode*> bones;
  32.                 Tab<gtaRwReal> weights;
  33.                 bones.SetCount(4, TRUE);
  34.                 weights.SetCount(4, TRUE);
  35.                 for(gtaRwInt32 vertex = 0; vertex < geom.numVertices; vertex++)
  36.                 {
  37.                     for(gtaRwInt32 n = 0; n < 4; n++)
  38.                     {
  39.                         bones[n] = NULL;
  40.                         if(geom.Extension.skin.vertexBoneWeights[vertex].aw[n] != 0.0f)
  41.                         {
  42.                             for(gtaRwInt32 frame = 0; frame < clump.frameList.frameCount; frame++)
  43.                             {
  44.                                 if(clump.frameList.frames[frame].Extension.hAnim.enabled &&
  45.                                     clump.frameList.frames[frame].Extension.hAnim.id ==
  46.                                     anim.nodes[geom.Extension.skin.vertexBoneIndices[vertex].ai[n]].nodeID)
  47.                                 {
  48.                                     bones[n] = nodes[frame];
  49.                                     break;
  50.                                 }
  51.                             }
  52.                         }
  53.                         weights[n] = geom.Extension.skin.vertexBoneWeights[vertex].aw[n];
  54.                     }
  55.                     skinImportData->AddWeights(objects[i].frame, vertex, bones, weights);
  56.                 }
  57.             }
  58.         }
  59.         break;
  60.     }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement