-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathue4-findpath.cpp
54 lines (44 loc) · 1.58 KB
/
ue4-findpath.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <iostream>
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include "Detour/DetourNavMesh.h"
#include "Detour/DetourNavMeshQuery.h"
#include "UE4RecastHelper.h"
void printUsage()
{
printf("Usage:\n");
printf("\tue4-findpath.exe dtNavMesh.bin Loc1.X Loc1.Y,loc1.Z Loc2.X Loc2.Y,loc2.Z\n");
printf("\tue4-detour.exe dtNavMesh.bin 340.0 -130.709 0.0 -470.0 480.0 0.0");
}
int main(int argc, char** argv)
{
if (argc < 5 || !(argc == 5 || argc == 8))
{
printUsage();
return -1;
}
UE4RecastHelper::FVector3 InLoc1((float)std::atof(argv[2]), (float)std::atof(argv[3]), (float)std::atof(argv[4]));
UE4RecastHelper::FVector3 InLoc2((float)std::atof(argv[5]), (float)std::atof(argv[6]), (float)std::atof(argv[7]));
printf("InLoc1: X=%f\tY=%f\tZ=%f\t\n", InLoc1.X,InLoc1.Y,InLoc1.Z);
printf("InLoc2: X=%f\tY=%f\tZ=%f\t\n", InLoc2.X,InLoc2.Y,InLoc2.Z);
std::string binpath = argv[1];//"E:\\UnrealProjects\\Blank426\\NavMesh\\NewMap-NavData-2021.05.23-12.20.02.bin";
dtNavMesh* NavMeshData = UE4RecastHelper::DeSerializedtNavMesh(binpath.c_str());
if (NavMeshData)
{
printf("Deserialize %s as dtNavMesh successfuly!\n", binpath.c_str());
std::vector<UE4RecastHelper::FVector3> Paths;
UE4RecastHelper::findStraightPath(NavMeshData, NULL, InLoc1, InLoc2, Paths);
for (const auto& Point : Paths)
{
printf("Point: X=%f\tY=%f\tZ=%f\n", Point.X, Point.Y, Point.Z);
}
}
else {
printf("Deserialize %s as dtNavMesh faild!\n", argv[1]);
}
if (!!NavMeshData)
dtFreeNavMesh(NavMeshData);
return 0;
}