UE4 ProceduralMesh 绘制

UE4 ProceduralMesh 绘制

UProceduralMeshComponent 可以用来合并Mesh。

auto pProceduralMeshComponent = NewObject<UProceduralMeshComponent>(owner, FName(*elementObj.ElementID), RF_NoFlags, nullptr, false, nullptr);
pProceduralMeshComponent->AttachToComponent(owner->GetRootComponent(), FAttachmentTransformRules::KeepRelativeTransform);
for (int32 j = 0; j < items_count; j++){
    TArray<FVector>Vertices;
    TArray<int32>Triangles;
    TArray<FVector>Normals;
    TArray<FVector2D>UV0 ;
    TArray<FVector2D> EmptyArray;
    TArray<FColor> EmptyColor;
    TArray<FProcMeshTangent> EmptyTangent;
    UMaterialInstanceDynamic* pMaterial = DynamicMaterialMap[j];
    pProceduralMeshComponent->CreateMeshSection(j, Vertices, Triangles, Normals, UV0, EmptyColor, EmptyTangent, true);
    pProceduralMeshComponent->SetMaterial(j, pMaterial);
}
pProceduralMeshComponent->RegisterComponent();

UE4 ProceduralMesh 绘制_第1张图片

参考

  1. UE4 ProceduralMesh

你可能感兴趣的:(UE4,UE4,ProceduralMesh)