Updates proejct with tree spawning, json loader etc.

This commit is contained in:
2021-09-19 04:04:15 +02:00
parent e1c2ce6e97
commit 6061266db2
18 changed files with 388 additions and 2 deletions

1
.idea/.idea.lidarforest/.idea/.name generated Normal file
View File

@@ -0,0 +1 @@
lidarforest

View File

@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="RiderProjectSettingsUpdater">
<option name="vcsConfiguration" value="2" />
</component>
</project>

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -0,0 +1,17 @@
[
{"Name":"1","x":"-15.12","y":"7.64","z":"-5.40682839506173","r":"0.0479799561281845","dbh":"9.6","h":"9.444"},
{"Name":"2","x":"-6.88","y":"10.26","z":"-0.243574999999998","r":"0.0419804284258564","dbh":"8.4","h":"11.3532"},
{"Name":"3","x":"-2.06999999999999","y":"10.64","z":"2.45335828877006","r":"0.190900975744225","dbh":"38.2","h":"9.707"},
{"Name":"4","x":"-4.83","y":"14.3","z":"1.67841221122112","r":"0.143288313874472","dbh":"28.7","h":"10.4663"},
{"Name":"5","x":"-15.92","y":"15.29","z":"-4.08376397058823","r":"0.25582628359995","dbh":"51.2","h":"13.2696"},
{"Name":"6","x":"0.510000000000005","y":"15.66","z":"5.12503727272727","r":"0.248212293732132","dbh":"49.6","h":"10.5504"},
{"Name":"7","x":"-15.5","y":"17.96","z":"-2.80311261682243","r":"0.207707718070789","dbh":"41.5","h":"10.5709"},
{"Name":"8","x":"-5.98","y":"18.47","z":"2.27009333333334","r":"0.0690890157121087","dbh":"13.8","h":"11.7931"},
{"Name":"9","x":"-14.43","y":"20.64","z":"-2.49187435897436","r":"0.224657636678472","dbh":"44.9","h":"11.1663"},
{"Name":"10","x":"-3.3","y":"20.26","z":"4.4628838362069","r":"0.234632402008446","dbh":"46.9","h":"26.1493"},
{"Name":"11","x":"-7.28","y":"21.27","z":"1.90214520958084","r":"0.122116516019407","dbh":"24.4","h":"8.8303"},
{"Name":"12","x":"-5.36","y":"21.83","z":"3.32361354166667","r":"0.221026336614948","dbh":"44.2","h":"26.4361"},
{"Name":"13","x":"-9.16","y":"23.43","z":"1.50600110132159","r":"0.276642239001447","dbh":"55.3","h":"9.0957"},
{"Name":"14","x":"-9","y":"26.02","z":"2.61905555555556","r":"0.0254846663744571","dbh":"5.1","h":"23.765"},
{"Name":"15","x":"-0.109999999999999","y":"27.19","z":"7.17721333333334","r":"0.159445021558632","dbh":"31.9","h":"25.2112"}
]

Binary file not shown.

BIN
Plugins/ForestImporter/Resources/Icon128.png (Stored with Git LFS) Normal file

Binary file not shown.

View File

@@ -0,0 +1,56 @@
// Copyright Epic Games, Inc. All Rights Reserved.
using UnrealBuildTool;
public class ForestImporter : ModuleRules
{
public ForestImporter(ReadOnlyTargetRules Target) : base(Target)
{
PCHUsage = ModuleRules.PCHUsageMode.UseExplicitOrSharedPCHs;
PublicIncludePaths.AddRange(
new string[] {
// ... add public include paths required here ...
}
);
PrivateIncludePaths.AddRange(
new string[] {
// ... add other private include paths required here ...
}
);
PublicDependencyModuleNames.AddRange(
new string[]
{
"Core",
// ... add other public dependencies that you statically link with here ...
}
);
PrivateDependencyModuleNames.AddRange(
new string[]
{
"CoreUObject",
"Engine",
"Slate",
"SlateCore",
"InputCore",
"UnrealEd",
"LevelEditor",
// ... add private dependencies that you statically link with here ...
}
);
DynamicallyLoadedModuleNames.AddRange(
new string[]
{
// ... add any modules that your module loads dynamically here ...
}
);
}
}

View File

@@ -0,0 +1,24 @@
// Copyright Epic Games, Inc. All Rights Reserved.
#include "ForestImporter.h"
#include "ForestImporterEdMode.h"
#define LOCTEXT_NAMESPACE "FForestImporterModule"
void FForestImporterModule::StartupModule()
{
// This code will execute after your module is loaded into memory; the exact timing is specified in the .uplugin file per-module
FEditorModeRegistry::Get().RegisterMode<FForestImporterEdMode>(FForestImporterEdMode::EM_ForestImporterEdModeId,
LOCTEXT("ForestImporterEdModeName", "ForestImporterEdMode"), FSlateIcon(), true);
}
void FForestImporterModule::ShutdownModule()
{
// This function may be called during shutdown to clean up your module. For modules that support dynamic reloading,
// we call this function before unloading the module.
FEditorModeRegistry::Get().UnregisterMode(FForestImporterEdMode::EM_ForestImporterEdModeId);
}
#undef LOCTEXT_NAMESPACE
IMPLEMENT_MODULE(FForestImporterModule, ForestImporter)

View File

@@ -0,0 +1,50 @@
// Copyright Epic Games, Inc. All Rights Reserved.
#include "ForestImporterEdMode.h"
#include "ForestImporterEdModeToolkit.h"
#include "Toolkits/ToolkitManager.h"
#include "EditorModeManager.h"
const FEditorModeID FForestImporterEdMode::EM_ForestImporterEdModeId = TEXT("EM_ForestImporterEdMode");
FForestImporterEdMode::FForestImporterEdMode()
{
}
FForestImporterEdMode::~FForestImporterEdMode()
{
}
void FForestImporterEdMode::Enter()
{
FEdMode::Enter();
if (!Toolkit.IsValid() && UsesToolkits())
{
Toolkit = MakeShareable(new FForestImporterEdModeToolkit);
Toolkit->Init(Owner->GetToolkitHost());
}
}
void FForestImporterEdMode::Exit()
{
if (Toolkit.IsValid())
{
FToolkitManager::Get().CloseToolkit(Toolkit.ToSharedRef());
Toolkit.Reset();
}
// Call base Exit method to ensure proper cleanup
FEdMode::Exit();
}
bool FForestImporterEdMode::UsesToolkits() const
{
return true;
}

View File

@@ -0,0 +1,124 @@
// Copyright Epic Games, Inc. All Rights Reserved.
#include "ForestImporterEdModeToolkit.h"
#include "ForestImporterEdMode.h"
#include "Engine/Selection.h"
#include "Widgets/Input/SButton.h"
#include "Widgets/Text/STextBlock.h"
#include "EditorModeManager.h"
#define LOCTEXT_NAMESPACE "FForestImporterEdModeToolkit"
FForestImporterEdModeToolkit::FForestImporterEdModeToolkit()
{
}
void FForestImporterEdModeToolkit::Init(const TSharedPtr<IToolkitHost>& InitToolkitHost)
{
struct Locals
{
static bool IsWidgetEnabled()
{
return GEditor->GetSelectedActors()->Num() != 0;
}
static FReply OnButtonClick(FVector InOffset)
{
USelection* SelectedActors = GEditor->GetSelectedActors();
// Let editor know that we're about to do something that we want to undo/redo
GEditor->BeginTransaction(LOCTEXT("MoveActorsTransactionName", "MoveActors"));
// For each selected actor
for (FSelectionIterator Iter(*SelectedActors); Iter; ++Iter)
{
if (AActor* LevelActor = Cast<AActor>(*Iter))
{
// Register actor in opened transaction (undo/redo)
LevelActor->Modify();
// Move actor to given location
LevelActor->TeleportTo(LevelActor->GetActorLocation() + InOffset, FRotator(0, 0, 0));
}
}
// We're done moving actors so close transaction
GEditor->EndTransaction();
return FReply::Handled();
}
static TSharedRef<SWidget> MakeButton(FText InLabel, const FVector InOffset)
{
return SNew(SButton)
.Text(InLabel)
.OnClicked_Static(&Locals::OnButtonClick, InOffset);
}
};
const float Factor = 256.0f;
SAssignNew(ToolkitWidget, SBorder)
.HAlign(HAlign_Center)
.Padding(25)
.IsEnabled_Static(&Locals::IsWidgetEnabled)
[
SNew(SVerticalBox)
+ SVerticalBox::Slot()
.AutoHeight()
.HAlign(HAlign_Center)
.Padding(50)
[
SNew(STextBlock)
.AutoWrapText(true)
.Text(LOCTEXT("HelperLabel", "Select some actors and move them around using buttons below"))
]
+ SVerticalBox::Slot()
.HAlign(HAlign_Center)
.AutoHeight()
[
Locals::MakeButton(LOCTEXT("UpButtonLabel", "Up"), FVector(0, 0, Factor))
]
+ SVerticalBox::Slot()
.HAlign(HAlign_Center)
.AutoHeight()
[
SNew(SHorizontalBox)
+ SHorizontalBox::Slot()
.AutoWidth()
[
Locals::MakeButton(LOCTEXT("LeftButtonLabel", "Left"), FVector(0, -Factor, 0))
]
+ SHorizontalBox::Slot()
.AutoWidth()
[
Locals::MakeButton(LOCTEXT("RightButtonLabel", "Right"), FVector(0, Factor, 0))
]
]
+ SVerticalBox::Slot()
.HAlign(HAlign_Center)
.AutoHeight()
[
Locals::MakeButton(LOCTEXT("DownButtonLabel", "Down"), FVector(0, 0, -Factor))
]
];
FModeToolkit::Init(InitToolkitHost);
}
FName FForestImporterEdModeToolkit::GetToolkitFName() const
{
return FName("ForestImporterEdMode");
}
FText FForestImporterEdModeToolkit::GetBaseToolkitName() const
{
return NSLOCTEXT("ForestImporterEdModeToolkit", "DisplayName", "ForestImporterEdMode Tool");
}
class FEdMode* FForestImporterEdModeToolkit::GetEditorMode() const
{
return GLevelEditorModeTools().GetActiveMode(FForestImporterEdMode::EM_ForestImporterEdModeId);
}
#undef LOCTEXT_NAMESPACE

View File

@@ -0,0 +1,15 @@
// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "Modules/ModuleManager.h"
class FForestImporterModule : public IModuleInterface
{
public:
/** IModuleInterface implementation */
virtual void StartupModule() override;
virtual void ShutdownModule() override;
};

View File

@@ -0,0 +1,24 @@
// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "EdMode.h"
class FForestImporterEdMode : public FEdMode
{
public:
const static FEditorModeID EM_ForestImporterEdModeId;
public:
FForestImporterEdMode();
virtual ~FForestImporterEdMode();
// FEdMode interface
virtual void Enter() override;
virtual void Exit() override;
//virtual void Tick(FEditorViewportClient* ViewportClient, float DeltaTime) override;
//virtual void Render(const FSceneView* View, FViewport* Viewport, FPrimitiveDrawInterface* PDI) override;
//virtual void ActorSelectionChangeNotify() override;
bool UsesToolkits() const override;
// End of FEdMode interface
};

View File

@@ -0,0 +1,26 @@
// Copyright Epic Games, Inc. All Rights Reserved.
#pragma once
#include "CoreMinimal.h"
#include "Toolkits/BaseToolkit.h"
class FForestImporterEdModeToolkit : public FModeToolkit
{
public:
FForestImporterEdModeToolkit();
/** FModeToolkit interface */
virtual void Init(const TSharedPtr<IToolkitHost>& InitToolkitHost) override;
/** IToolkit interface */
virtual FName GetToolkitFName() const override;
virtual FText GetBaseToolkitName() const override;
virtual class FEdMode* GetEditorMode() const override;
virtual TSharedPtr<class SWidget> GetInlineContent() const override { return ToolkitWidget; }
private:
TSharedPtr<SWidget> ToolkitWidget;
};

View File

@@ -8,7 +8,7 @@ public class lidarforest : ModuleRules
{ {
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs; PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore" }); PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore", "ForestImporter"});
PrivateDependencyModuleNames.AddRange(new string[] { }); PrivateDependencyModuleNames.AddRange(new string[] { });

View File

@@ -7,7 +7,10 @@
{ {
"Name": "lidarforest", "Name": "lidarforest",
"Type": "Runtime", "Type": "Runtime",
"LoadingPhase": "Default" "LoadingPhase": "Default",
"AdditionalDependencies": [
"Engine"
]
} }
], ],
"Plugins": [ "Plugins": [
@@ -33,6 +36,31 @@
{ {
"Name": "HDRIBackdrop", "Name": "HDRIBackdrop",
"Enabled": true "Enabled": true
},
{
"Name": "FileSDK",
"Enabled": true,
"MarketplaceURL": "com.epicgames.launcher://ue/marketplace/product/4f737815666c4e7dabf2043fb55a8419"
},
{
"Name": "BlueprintJson",
"Enabled": true,
"MarketplaceURL": "com.epicgames.launcher://ue/marketplace/content/f837e4835fbc434a853fe1ead2410b84"
},
{
"Name": "EasyFileDialog",
"Enabled": true,
"MarketplaceURL": "com.epicgames.launcher://ue/marketplace/product/bcf64fe2e00c48189d8385a9c39b6e61"
},
{
"Name": "ElectronicNodes",
"Enabled": true,
"MarketplaceURL": "com.epicgames.launcher://ue/marketplace/content/5cb2a394d0c04e73891762be4cbd7216"
},
{
"Name": "DarkerNodes",
"Enabled": true,
"MarketplaceURL": "com.epicgames.launcher://ue/marketplace/content/4b3441f0228a40ec9ca986489a5bd682"
} }
] ]
} }