Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Heightmap / Landscape Create #211

Merged
merged 47 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
23df3a3
LOD4 Import 用 library update
seventhX May 23, 2023
b125636
Merge branch 'dev/v2' of https://github.com/Synesthesias/PLATEAU-SDK-…
seventhX May 23, 2023
3cdb32f
Merge branch 'dev/v2' of https://github.com/Synesthesias/PLATEAU-SDK-…
seventhX May 25, 2023
07bd5d8
Merge branch 'dev/v2' of https://github.com/Synesthesias/PLATEAU-SDK-…
seventhX May 31, 2023
c130724
Merge branch 'dev/v2' of https://github.com/Synesthesias/PLATEAU-SDK-…
seventhX May 31, 2023
91c3d54
Merge branch 'dev/v2' of https://github.com/Synesthesias/PLATEAU-SDK-…
seventhX Jun 7, 2023
0c26991
Merge branch 'dev/v2' of https://github.com/Synesthesias/PLATEAU-SDK-…
seventhX Jun 12, 2023
925b4af
Merge branch 'dev/v2' of https://github.com/Synesthesias/PLATEAU-SDK-…
seventhX Jun 16, 2023
fed7ed5
Merge branch 'dev/v2' of https://github.com/Synesthesias/PLATEAU-SDK-…
sevendev Aug 25, 2023
5980286
Merge branch 'dev/v2' of https://github.com/Synesthesias/PLATEAU-SDK-…
sevendev Aug 28, 2023
df438f6
Merge branch 'dev/v2' of https://github.com/Synesthesias/PLATEAU-SDK-…
sevendev Sep 7, 2023
d41b8d6
Merge branch 'dev/v2' of https://github.com/Synesthesias/PLATEAU-SDK-…
sevendev Sep 8, 2023
0905ac3
Merge branch 'dev/v2' of https://github.com/Synesthesias/PLATEAU-SDK-…
sevendev Sep 12, 2023
28c507d
Merge branch 'dev/v2' of https://github.com/Synesthesias/PLATEAU-SDK-…
sevendev Sep 14, 2023
7cc21dd
Merge branch 'dev/v2' of https://github.com/Synesthesias/PLATEAU-SDK-…
sevendev Oct 6, 2023
1b31f6a
Merge branch 'dev/v2' of https://github.com/Synesthesias/PLATEAU-SDK-…
sevendev Oct 17, 2023
5f087ce
Merge branch 'dev/v2' of https://github.com/Synesthesias/PLATEAU-SDK-…
sevendev Oct 17, 2023
b85cf6f
Merge branch 'dev/v2' of https://github.com/Synesthesias/PLATEAU-SDK-…
sevendev Nov 7, 2023
ffc3631
Merge branch 'dev/v2' of https://github.com/Synesthesias/PLATEAU-SDK-…
sevendev Nov 20, 2023
c5962a6
Merge branch 'dev/v2' of https://github.com/Synesthesias/PLATEAU-SDK-…
sevendev Nov 28, 2023
7944eb0
Merge branch 'dev/v2' of https://github.com/Synesthesias/PLATEAU-SDK-…
sevendev Dec 7, 2023
7805bcd
Merge branch 'dev/v2' of https://github.com/Synesthesias/PLATEAU-SDK-…
sevendev Dec 14, 2023
bc7c7a1
Merge branch 'dev/v2' of https://github.com/Synesthesias/PLATEAU-SDK-…
sevendev Dec 19, 2023
6a5a4e3
Merge branch 'dev/v2' of https://github.com/Synesthesias/PLATEAU-SDK-…
sevendev Dec 22, 2023
4a598a3
Merge branch 'dev/v2' of https://github.com/Synesthesias/PLATEAU-SDK-…
sevendev Apr 1, 2024
ff830d7
Merge branch 'dev/v2' of https://github.com/Synesthesias/PLATEAU-SDK-…
sevendev Apr 16, 2024
953194f
Heightmap creator
sevendev Apr 18, 2024
f4f94f0
lib
sevendev Apr 19, 2024
05b47d3
lib update
sevendev Apr 19, 2024
6f80241
use meshcode extent debug
sevendev Apr 24, 2024
c024e9d
Texture UV
sevendev Apr 26, 2024
1bd7895
update
sevendev Apr 30, 2024
0afd59b
landscape create from actor
sevendev May 1, 2024
e74e02d
Param 渡し Refactoring
sevendev May 1, 2024
190e0f3
OFFSET added.
sevendev May 1, 2024
7c276c3
Landscape UI
sevendev May 8, 2024
895403f
mac arm lib added.
sevendev May 8, 2024
abfe49e
未使用処理削除
sevendev May 10, 2024
6b23a07
convolution filter
sevendev May 13, 2024
3dbabcc
Debug用画像出力フラグ追加
sevendev May 14, 2024
10e0d26
Material deleted
sevendev May 14, 2024
f8ad2b4
Material default value update
sevendev May 14, 2024
30f564f
Material save
sevendev May 17, 2024
ddcc6d8
Landscape は基本Editorのみ
sevendev May 20, 2024
56b395f
ReliefFeatureをフィルタリングしない(静岡用)
sevendev May 22, 2024
29e1059
Tile で高速化
sevendev May 24, 2024
1ef255e
lib update
sevendev May 27, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Content/EUW/MainWindow.uasset
Git LFS file not shown
4 changes: 2 additions & 2 deletions Content/EUW/ModelAdjustmentTab.uasset
Git LFS file not shown
3 changes: 3 additions & 0 deletions Content/EUW/ModelLandscapeTab.uasset
Git LFS file not shown
4 changes: 2 additions & 2 deletions Content/EUW/ModelReconstructTab.uasset
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
3 changes: 3 additions & 0 deletions Content/Materials/PLATEAULandscapeMaterial.uasset
Git LFS file not shown
3 changes: 3 additions & 0 deletions Content/Materials/Textures/Black.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions Content/Materials/Textures/Black.uasset
Git LFS file not shown
3 changes: 3 additions & 0 deletions Content/Materials/Textures/White.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions Content/Materials/Textures/White.uasset
Git LFS file not shown
2 changes: 1 addition & 1 deletion Source/PLATEAURuntime/PLATEAURuntime.Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public PLATEAURuntime(ReadOnlyTargetRules Target) : base(Target)
PublicDependencyModuleNames.AddRange(
new string[]
{
"Core", "CoreUObject", "Engine", "InputCore", "Json", "JsonUtilities"
"Core", "CoreUObject", "Engine", "InputCore", "Json", "JsonUtilities" , "Landscape",
}
);

Expand Down
2 changes: 2 additions & 0 deletions Source/PLATEAURuntime/Private/PLATEAUCityModelLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#include "PLATEAUMeshLoader.h"
#include "citygml/citygml.h"
#include "Kismet/GameplayStatics.h"
#include <Reconstruct/PLATEAUMeshLoaderForLandscape.h>


#define LOCTEXT_NAMESPACE "PLATEAUCityModelLoader"

Expand Down
38 changes: 38 additions & 0 deletions Source/PLATEAURuntime/Private/PLATEAUInstancedCityModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
#include <PLATEAUExportSettings.h>
#include "Reconstruct/PLATEAUModelReconstruct.h"
#include <Reconstruct/PLATEAUModelClassification.h>
#include <Reconstruct/PLATEAUModelLandscape.h>
#include <Reconstruct/PLATEAUMeshLoaderForLandscape.h>

using namespace UE::Tasks;
using namespace plateau::granularityConvert;
Expand Down Expand Up @@ -506,3 +508,39 @@ UE::Tasks::TTask<TArray<USceneComponent*>> APLATEAUInstancedCityModel::Reconstru
});
return ConvertTask;
}


//Landscape
UE::Tasks::FTask APLATEAUInstancedCityModel::CreateLandscape(const TArray<USceneComponent*> TargetComponents, bool bDestroyOriginal, FPLATEAULandscapeParam Param) {

UE_LOG(LogTemp, Log, TEXT("CreateLandscape: %d %s"), TargetComponents.Num(), bDestroyOriginal ? TEXT("True") : TEXT("False"));
FTask CreateLandscapeTask = Launch(TEXT("CreateLandscapeTask"), [this, TargetComponents, bDestroyOriginal, Param] {

FPLATEAUModelLandscape Landscape(this);
const auto& TargetCityObjects = Landscape.GetUPLATEAUCityObjectGroupsFromSceneComponents(TargetComponents);

FPLATEAUMeshExportOptions ExtOptions;
ExtOptions.bExportHiddenObjects = false;
ExtOptions.bExportTexture = true;
ExtOptions.TransformType = EMeshTransformType::Local;
ExtOptions.CoordinateSystem = ECoordinateSystem::ESU;
FPLATEAUMeshExporter MeshExporter;
std::shared_ptr<plateau::polygonMesh::Model> smodel = MeshExporter.CreateModelFromComponents(this, TargetCityObjects, ExtOptions);

Landscape.CreateLandscape(smodel,Param);

FFunctionGraphTask::CreateAndDispatchWhenReady([&,TargetCityObjects, bDestroyOriginal]() {

//コンポーネント削除
if (bDestroyOriginal) {
for (auto comp : TargetCityObjects) {
comp->DestroyComponent();
}
}

//終了イベント通知
OnLandscapeCreationFinished.Broadcast();
}, TStatId(), NULL, ENamedThreads::GameThread);
});
return CreateLandscapeTask;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,182 @@
// Copyright 2023 Ministry of Land, Infrastructure and Transport


#include "Reconstruct/PLATEAUMeshLoaderForLandscape.h"
#include "PLATEAUCityModelLoader.h"
#include "PLATEAUCityObjectGroup.h"
#include "plateau/polygon_mesh/mesh_extractor.h"
#include <plateau/texture/heightmap_generator.h>
#include <Landscape.h>
#include <PLATEAUTextureLoader.h>
#include "Materials/MaterialInstanceConstant.h"
#include "UObject/SavePackage.h"

FPLATEAUMeshLoaderForLandscape::FPLATEAUMeshLoaderForLandscape() {}

FPLATEAUMeshLoaderForLandscape::FPLATEAUMeshLoaderForLandscape(const bool InbAutomationTest){
bAutomationTest = InbAutomationTest;
}

void FPLATEAUMeshLoaderForLandscape::CreateHeightMap(
AActor* ModelActor,
const std::shared_ptr<plateau::polygonMesh::Model> Model, FPLATEAULandscapeParam Param) {
for (int i = 0; i < Model->getRootNodeCount(); i++) {
LoadNodeRecursiveForHeightMap(Model->getRootNodeAt(i), *ModelActor, Param);
}
}

void FPLATEAUMeshLoaderForLandscape::LoadNodeRecursiveForHeightMap(
const plateau::polygonMesh::Node& InNode,
AActor& InActor, FPLATEAULandscapeParam Param) {
LoadNodeForHeightMap(InNode, InActor, Param);
const size_t ChildNodeCount = InNode.getChildCount();
for (int i = 0; i < ChildNodeCount; i++) {
const auto& TargetNode = InNode.getChildAt(i);
LoadNodeRecursiveForHeightMap( TargetNode, InActor, Param);
}
}

void FPLATEAUMeshLoaderForLandscape::LoadNodeForHeightMap(
const plateau::polygonMesh::Node& InNode,
AActor& InActor, FPLATEAULandscapeParam Param) {
if (InNode.getMesh() == nullptr || InNode.getMesh()->getVertices().size() == 0) {
const FString DesiredName = FString(UTF8_TO_TCHAR(InNode.getName().c_str()));
}
else {
CreateHeightMapFromMesh(*InNode.getMesh(), FString(UTF8_TO_TCHAR(InNode.getName().c_str())), InActor, Param);
}
}

void FPLATEAUMeshLoaderForLandscape::CreateHeightMapFromMesh(
const plateau::polygonMesh::Mesh& InMesh, const FString NodeName, AActor& Actor, FPLATEAULandscapeParam Param) {

plateau::texture::HeightmapGenerator generator;
TVec3d ExtMin, ExtMax;
TVec2f UVMin, UVMax;
std::vector<uint16_t> heightMapData = generator.generateFromMesh(InMesh, Param.TextureWidth, Param.TextureHeight, TVec2d(Param.Offset.X, Param.Offset.Y), plateau::geometry::CoordinateSystem::ESU, ExtMin, ExtMax, UVMin, UVMax);

// Heightmap Image Output
if (Param.HeightmapImageOutput == EPLATEAULandscapeHeightmapImageOutput::PNG || Param.HeightmapImageOutput == EPLATEAULandscapeHeightmapImageOutput::PNG_RAW) {
FString PngSavePath = FString::Format(*FString(TEXT("{0}PLATEAU/HM_{1}_{2}_{3}.png")), { FPaths::ProjectContentDir(),NodeName,Param.TextureWidth, Param.TextureHeight });
plateau::texture::HeightmapGenerator::savePngFile(TCHAR_TO_ANSI(*PngSavePath), Param.TextureWidth, Param.TextureHeight, heightMapData.data());
UE_LOG(LogTemp, Log, TEXT("height map png saved: %s"), *PngSavePath);
}
if (Param.HeightmapImageOutput == EPLATEAULandscapeHeightmapImageOutput::RAW || Param.HeightmapImageOutput == EPLATEAULandscapeHeightmapImageOutput::PNG_RAW) {
FString RawSavePath = FString::Format(*FString(TEXT("{0}PLATEAU/HM_{1}_{2}_{3}.raw")), { FPaths::ProjectContentDir(),NodeName,Param.TextureWidth, Param.TextureHeight });
plateau::texture::HeightmapGenerator::saveRawFile(TCHAR_TO_ANSI(*RawSavePath), Param.TextureWidth, Param.TextureHeight, heightMapData.data());
UE_LOG(LogTemp, Log, TEXT("height map raw saved: %s"), *RawSavePath);
}

TArray<uint16> HeightData(heightMapData.data(), heightMapData.size());

//Texture
FString TexturePath;
const auto& subMeshes = InMesh.getSubMeshes();
if (subMeshes.size() > 0) {
const auto& subMesh = subMeshes.at(0);
TexturePath = FString(subMesh.getTexturePath().c_str());
}

//LandScape
FFunctionGraphTask::CreateAndDispatchWhenReady(
[&, ExtMin, ExtMax, UVMin, UVMax, TexturePath, HeightData, NodeName, Param] {
CreateLandScape(Actor.GetWorld(), Param.NumSubsections, Param.SubsectionSizeQuads, Param.ComponentCountX, Param.ComponentCountY, Param.TextureWidth, Param.TextureHeight, ExtMin, ExtMax, UVMin, UVMax, TexturePath, HeightData, NodeName);
}, TStatId(), nullptr, ENamedThreads::GameThread)->Wait();
}

void FPLATEAUMeshLoaderForLandscape::CreateLandScape(UWorld* World, const int32 NumSubsections, const int32 SubsectionSizeQuads, const int32 ComponentCountX, const int32 ComponentCountY, const int32 SizeX, const int32 SizeY,
const TVec3d Min, const TVec3d Max, const TVec2f MinUV, const TVec2f MaxUV, const FString TexturePath, TArray<uint16> HeightData, const FString ActorName ) {

// Weightmap is sized the same as the component
const int32 WeightmapSize = (SubsectionSizeQuads + 1) * NumSubsections;
// Should be power of two
if (!FMath::IsPowerOfTwo(WeightmapSize)) {
UE_LOG(LogTemp, Error, TEXT("WeightmapSize not POT:%d"), WeightmapSize);
return;
}

double ActualHeight = abs(Max.z - Min.z);
double ActualXSize = abs(Max.x - Min.x);
double ActualYSize = abs(Max.y - Min.y);

float HeightScale = ActualHeight / 511.992;

float XScale = ActualXSize / (SizeX - 1 );
float YScale = ActualYSize / (SizeY - 1 );

FTransform LandscapeTransform;
FVector LandscapeScale = FVector(XScale, YScale, HeightScale);
FVector LandscapePosition = FVector(Min.x, Min.y, Min.z + ActualHeight / 2);
LandscapeTransform.SetLocation(LandscapePosition);
LandscapeTransform.SetScale3D(LandscapeScale);

UE_LOG(LogTemp, Log, TEXT("Create Landscape SizeX:%d SizeY:%d SubsectionSizeQuads:%d NumSubsections:%d ComponentCount(%d,%d)"), SizeX, SizeY, SubsectionSizeQuads, NumSubsections, ComponentCountX, ComponentCountY);

TMap<FGuid, TArray<uint16>> HeightDataPerLayers;
HeightDataPerLayers.Add(FGuid(), MoveTemp(HeightData));

TMap<FGuid, TArray<FLandscapeImportLayerInfo>> MaterialLayerDataPerLayers;
TArray<FLandscapeImportLayerInfo> MaterialImportLayers;
MaterialImportLayers.Reserve(0);
MaterialLayerDataPerLayers.Add(FGuid(), MoveTemp(MaterialImportLayers));

#if WITH_EDITOR
FActorSpawnParameters Param;
ALandscape* Landscape = World->SpawnActor<ALandscape>(Param);
Landscape->bCanHaveLayersContent = false;
Landscape->SetActorTransform(LandscapeTransform);

Landscape->Import(FGuid::NewGuid(), 0, 0, SizeX - 1 , SizeY - 1 , NumSubsections, SubsectionSizeQuads, HeightDataPerLayers, nullptr, MaterialLayerDataPerLayers, ELandscapeImportAlphamapType::Additive);

//Create Package
FString PackageName = TEXT("/Game/PLATEAU/Materials/");
PackageName += FString::Format(*FString(TEXT("{0}_{1}_{2}")), { ActorName,FPaths::GetBaseFilename(TexturePath).Replace(TEXT("."), TEXT("_")), SizeX });
UPackage* Package = CreatePackage(*PackageName);
Package->FullyLoad();

//Create Material (LandscapeはDynamicを使用するとうまく動作しないのでConstantを使用(Editorのみ動作))
const auto SourceMaterialPath = TEXT("/PLATEAU-SDK-for-Unreal/Materials/PLATEAULandscapeMaterial");
UMaterial* BaseMat = Cast<UMaterial>(StaticLoadObject(UMaterial::StaticClass(), nullptr, SourceMaterialPath));
UMaterialInstanceConstant* MatIns = NewObject<UMaterialInstanceConstant>(Package, NAME_None, RF_Public | RF_Standalone | RF_MarkAsRootSet);
MatIns->SetParentEditorOnly(BaseMat, true);
MatIns->SetScalarParameterValueEditorOnly(FMaterialParameterInfo(FName("SizeX")), SizeX);
MatIns->SetScalarParameterValueEditorOnly(FMaterialParameterInfo(FName("SizeY")), SizeY);
MatIns->SetScalarParameterValueEditorOnly(FMaterialParameterInfo(FName("MinU")), MinUV.x);
MatIns->SetScalarParameterValueEditorOnly(FMaterialParameterInfo(FName("MinV")), MinUV.y);
MatIns->SetScalarParameterValueEditorOnly(FMaterialParameterInfo(FName("MaxU")), MaxUV.x);
MatIns->SetScalarParameterValueEditorOnly(FMaterialParameterInfo(FName("MaxV")), MaxUV.y);

if (!TexturePath.IsEmpty()) {
const auto& Texture = FPLATEAUTextureLoader::Load(TexturePath, OverwriteTexture());
MatIns->SetTextureParameterValueEditorOnly(FMaterialParameterInfo(FName("MainTexture")), Texture);
}

//Save Material
const FString PackageFileName = FPackageName::LongPackageNameToFilename(
PackageName, FPackageName::GetAssetPackageExtension());
FSavePackageArgs Args;
Args.SaveFlags = SAVE_NoError;
Args.TopLevelFlags = EObjectFlags::RF_Public | EObjectFlags::RF_Standalone;
Args.Error = GError;
auto result = UPackage::Save(Package, MatIns, *PackageFileName, Args);
if(result.Result != ESavePackageResult::Success)
UE_LOG(LogTemp, Warning, TEXT("Save Material Failed: %s %s %d"), *PackageName, *PackageFileName, result.Result);

Landscape->LandscapeMaterial = MatIns;

Landscape->StaticLightingLOD = FMath::DivideAndRoundUp(FMath::CeilLogTwo((SizeX * SizeY) / (2048 * 2048) + 1), (uint32)2);

ULandscapeInfo* LandscapeInfo = Landscape->GetLandscapeInfo();
LandscapeInfo->UpdateLayerInfoMap(Landscape);
Landscape->RegisterAllComponents();

FPropertyChangedEvent MaterialPropertyChangedEvent(FindFieldChecked< FProperty >(Landscape->GetClass(), FName("LandscapeMaterial")));
Landscape->PostEditChangeProperty(MaterialPropertyChangedEvent);
Landscape->PostEditChange();
Landscape->SetActorLabel(FString(ActorName));
#endif
}

bool FPLATEAUMeshLoaderForLandscape::OverwriteTexture() {
return false;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
// Copyright 2023 Ministry of Land, Infrastructure and Transport

#include <Reconstruct/PLATEAUModelLandscape.h>
#include <Reconstruct/PLATEAUMeshLoaderForLandscape.h>

namespace {

bool HasCityObjectsType(UPLATEAUCityObjectGroup* CityObj, EPLATEAUCityObjectsType Type) {
const auto& found = CityObj->GetAllRootCityObjects().FindByPredicate([&](FPLATEAUCityObject obj) {
return obj.Type == Type;
});
return found != nullptr;
}
}

FPLATEAUModelLandscape::FPLATEAUModelLandscape() {}

FPLATEAUModelLandscape::FPLATEAUModelLandscape(APLATEAUInstancedCityModel* Actor) {
CityModelActor = Actor;
}

void FPLATEAUModelLandscape::CreateLandscape(std::shared_ptr<plateau::polygonMesh::Model> Model, FPLATEAULandscapeParam Param) {
FPLATEAUMeshLoaderForLandscape HMap = FPLATEAUMeshLoaderForLandscape(false);
HMap.CreateHeightMap(CityModelActor, Model, Param);
}

/**
* @brief ComponentのChildrenからUPLATEAUCityObjectGroupを探してtypeがTINRelief || ReliefFeatureの場合のみリストに追加します
*/
TArray<UPLATEAUCityObjectGroup*> FPLATEAUModelLandscape::GetUPLATEAUCityObjectGroupsFromSceneComponents(TArray<USceneComponent*> TargetComponents) {
TSet<UPLATEAUCityObjectGroup*> UniqueComponents;
for (auto comp : TargetComponents) {
if (comp->IsA(UActorComponent::StaticClass()) || comp->IsA(UStaticMeshComponent::StaticClass()) && StaticCast<UStaticMeshComponent*>(comp)->GetStaticMesh() == nullptr && comp->IsVisible()) {
TArray<USceneComponent*> children;
comp->GetChildrenComponents(true, children);
for (auto child : children) {
if (child->IsA(UPLATEAUCityObjectGroup::StaticClass()) && child->IsVisible()) {
auto childCityObj = StaticCast<UPLATEAUCityObjectGroup*>(child);
if (childCityObj->GetStaticMesh() != nullptr ) {
if(HasCityObjectsType(childCityObj, EPLATEAUCityObjectsType::COT_TINRelief) || HasCityObjectsType(childCityObj, EPLATEAUCityObjectsType::COT_ReliefFeature))
UniqueComponents.Add(childCityObj);
}
}
}
}
if (comp->IsA(UPLATEAUCityObjectGroup::StaticClass()) && comp->IsVisible()) {
const auto& cityObj = StaticCast<UPLATEAUCityObjectGroup*>(comp);
if (HasCityObjectsType(cityObj, EPLATEAUCityObjectsType::COT_TINRelief) || HasCityObjectsType(cityObj, EPLATEAUCityObjectsType::COT_ReliefFeature))
UniqueComponents.Add(StaticCast<UPLATEAUCityObjectGroup*>(comp));
}
}
return UniqueComponents.Array();
}
13 changes: 13 additions & 0 deletions Source/PLATEAURuntime/Public/PLATEAUInstancedCityModel.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include <plateau/dataset/city_model_package.h>
#include <PLATEAUImportSettings.h>
#include "Tasks/Task.h"
#include "Reconstruct/PLATEAUMeshLoaderForLandscape.h"
#include "PLATEAUInstancedCityModel.generated.h"


Expand Down Expand Up @@ -66,6 +67,12 @@ class PLATEAURUNTIME_API APLATEAUInstancedCityModel : public AActor {
UPROPERTY(BlueprintAssignable, Category = "PLATEAU|BPLibraries")
FOnClassifyFinishedDelegate OnClassifyFinished;

/**
* @brief ランドスケープ生成処理終了イベント
*/
UPROPERTY(BlueprintAssignable, Category = "PLATEAU|BPLibraries")
FOnClassifyFinishedDelegate OnLandscapeCreationFinished;

/**
* @brief Componentのユニーク化されていない元の名前を取得します。
* コンポーネント名の末尾に"__{数値}"が存在する場合、ユニーク化の際に追加されたものとみなし、"__"以降を削除します。
Expand Down Expand Up @@ -158,6 +165,12 @@ class PLATEAURUNTIME_API APLATEAUInstancedCityModel : public AActor {
*/
UE::Tasks::TTask<TArray<USceneComponent*>> ClassifyModel(const TArray<USceneComponent*> TargetComponents, TMap<EPLATEAUCityObjectsType, UMaterialInterface*> Materials, const EPLATEAUMeshGranularity ReconstructType, bool bDestroyOriginal);

/**
* @brief 選択されたComponentからLandscapeを生成します
* @param
*/
UE::Tasks::FTask CreateLandscape(const TArray<USceneComponent*> TargetComponents, bool bDestroyOriginal, FPLATEAULandscapeParam Param);

/**
* @brief 複数LODの形状を持つ地物について、MinLod, MaxLodで指定される範囲の内最大LOD以外の形状を非表示化します。
* @param InGmlComponent フィルタリング対象地物を含むコンポーネント
Expand Down
Loading