Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Load skin
- for(gtaRwInt32 j = 0; j < clump.frameList.frameCount; j++)
- {
- if(clump.frameList.frames[j].Extension.hAnim.enabled && clump.frameList.frames[j].Extension.hAnim.numNodes > 0)
- {
- gtaRwFrameHAnim &anim = clump.frameList.frames[j].Extension.hAnim;
- for(gtaRwInt32 i = 0; i < clump.geometryList.geometryCount; i++)
- {
- gtaRwGeometry &geom = clump.geometryList.geometries[i];
- if(geom.Extension.skin.enabled)
- {
- Modifier *skin = (Modifier *)gi->CreateInstance(SClass_ID(OSM_CLASS_ID), SKIN_CLASSID);
- ISkinImportData *skinImportData = (ISkinImportData *)skin->GetInterface(I_SKINIMPORTDATA);
- GetCOREInterface7()->AddModifier(*objects[i].frame, *skin);
- objects[i].frame->EvalWorldState(0);
- if(geom.Extension.skin.numBoneIds == 0)
- geom.Extension.skin.FindUsedBoneIds(geom.numVertices, geom.Extension.skin.numBones);
- for(gtaRwInt32 bone = 0; bone < geom.Extension.skin.numBoneIds; bone++)
- {
- for(gtaRwInt32 frame = 0; frame < clump.frameList.frameCount; frame++)
- {
- if(clump.frameList.frames[frame].Extension.hAnim.enabled &&
- clump.frameList.frames[frame].Extension.hAnim.id == anim.nodes[geom.Extension.skin.boneIds[bone]].nodeID)
- {
- skinImportData->AddBoneEx(nodes[frame], true);
- break;
- }
- }
- }
- objects[i].frame->EvalWorldState(gi->GetTime());
- Tab<INode*> bones;
- Tab<gtaRwReal> weights;
- bones.SetCount(4, TRUE);
- weights.SetCount(4, TRUE);
- for(gtaRwInt32 vertex = 0; vertex < geom.numVertices; vertex++)
- {
- for(gtaRwInt32 n = 0; n < 4; n++)
- {
- bones[n] = NULL;
- if(geom.Extension.skin.vertexBoneWeights[vertex].aw[n] != 0.0f)
- {
- for(gtaRwInt32 frame = 0; frame < clump.frameList.frameCount; frame++)
- {
- if(clump.frameList.frames[frame].Extension.hAnim.enabled &&
- clump.frameList.frames[frame].Extension.hAnim.id ==
- anim.nodes[geom.Extension.skin.vertexBoneIndices[vertex].ai[n]].nodeID)
- {
- bones[n] = nodes[frame];
- break;
- }
- }
- }
- weights[n] = geom.Extension.skin.vertexBoneWeights[vertex].aw[n];
- }
- skinImportData->AddWeights(objects[i].frame, vertex, bones, weights);
- }
- }
- }
- break;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement