本文整理汇总了C++中USkeletalMesh::CalculateRequiredBones方法的典型用法代码示例。如果您正苦于以下问题:C++ USkeletalMesh::CalculateRequiredBones方法的具体用法?C++ USkeletalMesh::CalculateRequiredBones怎么用?C++ USkeletalMesh::CalculateRequiredBones使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类USkeletalMesh
的用法示例。
在下文中一共展示了USkeletalMesh::CalculateRequiredBones方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PyErr_Format
//.........这里部分代码省略.........
int32 vertex_index = points.Add(ss_vertex->ss_vertex.Position);
points_to_map.Add(vertex_index);
FMeshWedge wedge;
wedge.iVertex = vertex_index;
wedge.Color = ss_vertex->ss_vertex.Color;
for (int32 i = 0; i < MAX_TEXCOORDS; i++)
{
wedge.UVs[i] = ss_vertex->ss_vertex.UVs[i];
}
int32 wedge_index = wedges.Add(wedge);
for (int32 i = 0; i < MAX_TOTAL_INFLUENCES; i++)
{
FVertInfluence influence;
influence.VertIndex = wedge_index;
influence.BoneIndex = ss_vertex->ss_vertex.InfluenceBones[i];
influence.Weight = ss_vertex->ss_vertex.InfluenceWeights[i] / 255.f;
influences.Add(influence);
}
tangentsX.Add(ss_vertex->ss_vertex.TangentX);
tangentsY.Add(ss_vertex->ss_vertex.TangentY);
tangentsZ.Add(ss_vertex->ss_vertex.TangentZ);
material_indices.Add(ss_vertex->material_index);
smoothing_groups.Add(ss_vertex->smoothing_group);
}
Py_DECREF(py_iter);
if (wedges.Num() % 3 != 0)
return PyErr_Format(PyExc_Exception, "invalid number of FSoftSkinVertex, must be a multiple of 3");
for (int32 i = 0; i < wedges.Num(); i += 3)
{
FMeshFace face;
face.iWedge[0] = i;
face.iWedge[1] = i + 1;
face.iWedge[2] = i + 2;
face.MeshMaterialIndex = material_indices[i];
face.SmoothingGroups = smoothing_groups[i];
face.TangentX[0] = tangentsX[i];
face.TangentX[1] = tangentsX[i + 1];
face.TangentX[2] = tangentsX[i + 2];
face.TangentY[0] = tangentsY[i];
face.TangentY[1] = tangentsY[i + 1];
face.TangentY[2] = tangentsY[i + 2];
face.TangentZ[0] = tangentsZ[i];
face.TangentZ[1] = tangentsZ[i + 1];
face.TangentZ[2] = tangentsZ[i + 2];
faces.Add(face);
}
#if ENGINE_MINOR_VERSION < 19
FStaticLODModel & lod_model = resource->LODModels[lod_index];
#else
FSkeletalMeshLODModel & lod_model = resource->LODModels[lod_index];
#endif
IMeshUtilities::MeshBuildOptions build_settings;
build_settings.bUseMikkTSpace = (py_use_mikk && PyObject_IsTrue(py_use_mikk));
build_settings.bComputeNormals = (py_compute_normals && PyObject_IsTrue(py_compute_normals));
build_settings.bComputeTangents = (py_compute_tangents && PyObject_IsTrue(py_compute_tangents));
build_settings.bRemoveDegenerateTriangles = true;
bool success = MeshUtilities.BuildSkeletalMesh(lod_model, mesh->RefSkeleton, influences, wedges, faces, points, points_to_map, build_settings);
if (!success)
{
return PyErr_Format(PyExc_Exception, "unable to create new Skeletal LOD");
}
#if ENGINE_MINOR_VERSION < 19
for (int32 i = 0; i < lod_model.Sections.Num(); i++)
{
mesh->LODInfo[lod_index].TriangleSortSettings.AddZeroed();
}
#endif
mesh->CalculateRequiredBones(LODModel, mesh->RefSkeleton, nullptr);
mesh->CalculateInvRefMatrices();
mesh->Skeleton->RecreateBoneTree(mesh);
mesh->Skeleton->SetPreviewMesh(mesh);
mesh->Skeleton->PostEditChange();
mesh->Skeleton->MarkPackageDirty();
mesh->PostEditChange();
mesh->MarkPackageDirty();
Py_RETURN_NONE;
}
示例2: FactoryCreateText
//.........这里部分代码省略.........
ImportedResource->LODModels.Empty();
FStaticLODModel& LODModel = *new (ImportedResource->LODModels) FStaticLODModel();
SkeletalMesh->LODInfo.Empty();
SkeletalMesh->LODInfo.AddZeroed();
SkeletalMesh->LODInfo[0].LODHysteresis = 0.02f;
FSkeletalMeshOptimizationSettings Settings;
// set default reduction settings values
SkeletalMesh->LODInfo[0].ReductionSettings = Settings;
// Create initial bounding box based on expanded version of reference pose for meshes without physics assets. Can be overridden by artist.
// FBox BoundingBox(SkelMeshImportDataPtr->Points.GetData(), SkelMeshImportDataPtr->Points.Num());
// FBox Temp = BoundingBox;
// FVector MidMesh = 0.5f*(Temp.Min + Temp.Max);
// BoundingBox.Min = Temp.Min + 1.0f*(Temp.Min - MidMesh);
// BoundingBox.Max = Temp.Max + 1.0f*(Temp.Max - MidMesh);
// // Tuck up the bottom as this rarely extends lower than a reference pose's (e.g. having its feet on the floor).
// // Maya has Y in the vertical, other packages have Z.
// //BEN const int32 CoordToTuck = bAssumeMayaCoordinates ? 1 : 2;
// //BEN BoundingBox.Min[CoordToTuck] = Temp.Min[CoordToTuck] + 0.1f*(Temp.Min[CoordToTuck] - MidMesh[CoordToTuck]);
// BoundingBox.Min[2] = Temp.Min[2] + 0.1f*(Temp.Min[2] - MidMesh[2]);
// SkeletalMesh->Bounds = FBoxSphereBounds(BoundingBox);
// Store whether or not this mesh has vertex colors
// SkeletalMesh->bHasVertexColors = SkelMeshImportDataPtr->bHasVertexColors;
// Pass the number of texture coordinate sets to the LODModel. Ensure there is at least one UV coord
LODModel.NumTexCoords = 1;// FMath::Max<uint32>(1, SkelMeshImportDataPtr->NumTexCoords);
// Create the reference skeleton and update LOD0
FReferenceSkeleton& RefSkeleton = SkeletalMesh->RefSkeleton;
HierarchyBuilder.CopyToRefSkeleton(RefSkeleton);
SkeletalMesh->CalculateRequiredBones(LODModel, RefSkeleton, /*BonesToRemove=*/ nullptr);
SkeletalMesh->CalculateInvRefMatrices();
// Initialize the skeleton asset
EntitySkeleton->MergeAllBonesToBoneTree(SkeletalMesh);
// Point the mesh and skeleton at each other
SkeletalMesh->Skeleton = EntitySkeleton;
EntitySkeleton->SetPreviewMesh(SkeletalMesh);
// Create the animations
for (const FSpriterAnimation& Animation : Entity.Animations)
{
//@TODO: That thing I said...
const FString TargetAnimationName = Animation.Name;
const FString TargetAnimationPath = LongPackagePath / TEXT("Animations");
UAnimSequence* AnimationAsset = CastChecked<UAnimSequence>(CreateNewAsset(UAnimSequence::StaticClass(), TargetAnimationPath, TargetAnimationName, Flags));
AnimationAsset->SetSkeleton(EntitySkeleton);
// if you have one pose(thus 0.f duration), it still contains animation, so we'll need to consider that as MINIMUM_ANIMATION_LENGTH time length
const float DurationInSeconds = Animation.LengthInMS * 0.001f;
AnimationAsset->SequenceLength = FMath::Max<float>(DurationInSeconds, MINIMUM_ANIMATION_LENGTH);
const bool bSourceDataExists = (AnimationAsset->SourceRawAnimationData.Num() > 0);
TArray<struct FRawAnimSequenceTrack>& RawAnimationData = bSourceDataExists ? AnimationAsset->SourceRawAnimationData : AnimationAsset->RawAnimationData;
int32 TotalNumKeys = 0;
for (const FSpriterTimeline& Timeline : Animation.Timelines)