Skip to content

Commit

Permalink
v0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
hxhb committed Oct 30, 2019
1 parent f5c454a commit a52db37
Show file tree
Hide file tree
Showing 12 changed files with 433 additions and 1,754 deletions.

This file was deleted.

Binary file modified RecastDemo/solo_navmesh.bin
Binary file not shown.
Binary file removed RecastDemo/solo_navmesh_bak.bin
Binary file not shown.
60 changes: 35 additions & 25 deletions Source/ExportNav/Private/ExportNav.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,49 +60,59 @@ void FExportNavModule::ShutdownModule()
}

void FExportNavModule::PluginButtonClicked()
{
DoExportNavData();
}

void FExportNavModule::DoExportNavData()
{
UWorld* World = GEditor->GetEditorWorldContext().World();
FString MapName = World->GetMapName();

IDesktopPlatform* DesktopPlatform = FDesktopPlatformModule::Get();
FString PluginPath = FPaths::ConvertRelativePathToFull(IPluginManager::Get().FindPlugin(TEXT("ExportNav"))->GetBaseDir());

FString OutPath;
if (DesktopPlatform)
{
TArray<FString> SaveFilenames;
FString SaveName= World->GetMapName()+FString(TEXT("-RecastNavMesh-"))+FDateTime::Now().ToString();
const bool bOpened = DesktopPlatform->SaveFileDialog(
const bool bOpened = DesktopPlatform->OpenDirectoryDialog(
nullptr,
LOCTEXT("SaveNav", "Save Navigation Data").ToString(),
FPaths::Combine(PluginPath, TEXT("RecastDemo/Meshes")),
SaveName,
TEXT("*.obj|*.obj"),
EFileDialogFlags::None,
SaveFilenames
LOCTEXT("SaveNav", "Save Recast Navigation NavMesh & NavData").ToString(),
PluginPath,
OutPath
);

if (SaveFilenames.Num() > 0)
if (FPaths::DirectoryExists(OutPath))
{
FString SaveToFole = FPaths::ConvertRelativePathToFull(SaveFilenames[0]);
UFlibExportNavData::ExecExportNavMesh(SaveToFole);


// FString RecastDemoProc = FPaths::Combine(PluginPath,TEXT("RecastDemo/RecastDemo.exe"));
/*FString EndCommand = TEXT("cmd /c start /D ") + RecastDemoProc;
system(TCHAR_TO_ANSI(*EndCommand));*/
// FPlatformProcess::CreateProc(*RecastDemoProc, NULL, false, false ,false, NULL, NULL, NULL, NULL);
FString CurrentTime = FDateTime::Now().ToString();
FString NavMeshFile = FPaths::Combine(OutPath, MapName + TEXT("-NavMesh-") + CurrentTime+TEXT(".obj"));
DoExportNavMesh(NavMeshFile);
FString NavDataFile = FPaths::Combine(OutPath, MapName + TEXT("-NavData-") + CurrentTime+TEXT(".bin"));
DoExportNavData(NavDataFile);

#if PLATFORM_WINDOWS
FString FinalCommdParas = TEXT("/e,/root,");
FString OpenPath = UFlibExportNavData::ConvPath_Slash2BackSlash(OutPath);
FinalCommdParas.Append(OpenPath);
FPlatformProcess::CreateProc(TEXT("explorer "), *FinalCommdParas, true, false, false, NULL, NULL, NULL, NULL, NULL);
#endif
}
}


}

void FExportNavModule::DoExportNavMesh(const FString& SaveToFile)
{
UFlibExportNavData::ExportRecastNavMesh(SaveToFile);
}

void FExportNavModule::DoExportNavData(const FString& SaveToFile)
{
UFlibExportNavData::ExportRecastNavData(SaveToFile);

}

void FExportNavModule::AddMenuExtension(FMenuBuilder& Builder)
{
Builder.AddMenuEntry(FExportNavCommands::Get().PluginAction);
}



void FExportNavModule::AddToolbarExtension(FToolBarBuilder& Builder)
{
Builder.AddToolBarButton(FExportNavCommands::Get().PluginAction);
Expand Down
29 changes: 18 additions & 11 deletions Source/ExportNav/Private/ExternRecastNavMeshGenetator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,17 +58,24 @@ void FExternExportNavMeshGenerator::ExternExportNavigationData(const FString& Fi
{
IndexBuffer.Add(CachedGeometry.Indices[i] + CoordBuffer.Num() / 3);
}
for (int32 i = 0; i < CachedGeometry.Header.NumVerts * 3; i+=3)
//// Export unit centimeters
//for (int32 i = 0; i < CachedGeometry.Header.NumVerts * 3; i+=3)
//{
// FVector Corrd = FVector{
// CachedGeometry.Verts[i]/100.f,
// CachedGeometry.Verts[i+2]/100.f,
// CachedGeometry.Verts[i+1]/100.f,
// };
// // CoordBuffer.Add(CachedGeometry.Verts[i]);
// CoordBuffer.Add(Corrd.X);
// CoordBuffer.Add(Corrd.Z);
// CoordBuffer.Add(Corrd.Y);
//}

//// Export unit meters
for (int32 i = 0; i < CachedGeometry.Header.NumVerts * 3; i++)
{
FVector Corrd = FVector{
CachedGeometry.Verts[i]/100.f,
CachedGeometry.Verts[i+2]/100.f,
CachedGeometry.Verts[i+1]/100.f,
};
// CoordBuffer.Add(CachedGeometry.Verts[i]);
CoordBuffer.Add(Corrd.X);
CoordBuffer.Add(Corrd.Z);
CoordBuffer.Add(Corrd.Y);
CoordBuffer.Add(CachedGeometry.Verts[i]);
}
}
else
Expand Down Expand Up @@ -210,7 +217,7 @@ void FExternExportNavMeshGenerator::ExternExportNavigationData(const FString& Fi

AdditionalData += FString::Printf(TEXT("\n"));

const FString FilePathName = FileName + TEXT(".obj");// FString::Printf(TEXT("_NavDataSet%d_%s.obj"), Index, *CurrentTimeStr);
const FString FilePathName = FileName;// FString::Printf(TEXT("_NavDataSet%d_%s.obj"), Index, *CurrentTimeStr);
ExportGeomToOBJFile(FilePathName, CoordBuffer, IndexBuffer, AdditionalData);
}
}
Expand Down
Loading

0 comments on commit a52db37

Please sign in to comment.