Skip to content

Commit 9ff72cc

Browse files
authored
Use navkit-rpkg-lib instead of exe (#75)
1 parent 7c1b2aa commit 9ff72cc

31 files changed

Lines changed: 913 additions & 110 deletions

.idea/codeStyles/codeStyleConfig.xml

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/editor.xml

Lines changed: 47 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/vcs.xml

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,8 @@ if(BUILD_INSTALLER)
8585
RUNTIME DESTINATION .
8686
)
8787
install(FILES
88+
$<TARGET_FILE:glacier2obj>
8889
$<TARGET_FILE:NavWeakness>
89-
$<TARGET_FILE:nfd::nfd>
9090
$<TARGET_FILE:ResourceLib_HM3>
9191
DESTINATION .
9292
)

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ Functions available are loading and saving Navp and Navp.json, loading Airg and
8585
# How NavKit generates Navp and Airg files
8686
NavKit performs the following series of steps to be able to generate Navp files.
8787
1. Connect to the Editor server of the running Hitman game, and issue commands to: rebuild the entity tree, find the scene's ZGeomEntities, PFBox entities, and PFSeedPoint entities and send their data back to NavKit, where they are saved to `output.nav.json` in the specified output folder.
88-
1. Extract all the necessary Aloc or Prim files from the rpkg files to the `aloc` or `prim` folder of the specified output folder using glacier2obj.exe (A rust program included in the installer).
88+
1. Extract all the necessary Aloc or Prim files from the rpkg files to the `aloc` or `prim` folder of the specified output folder using glacier2obj (A rust library included in the installer).
8989
1. Open the blender cli and run the `glacier2obj.py` script to generate an obj by importing all the Aloc or Prim files, copy them the number if times they are used in the scene, and transform each one according to what was sent by the game, and save it to `output.obj` in the specified output folder.
9090
1. Load `output.obj` from the specified output folder or another specified Obj file.
9191
1. At this point, the build Navp section of the menu will be available, and you can customize the parameters with "Settings > Recast Settings" on the menu bar, then press "Build > Build Navp" on the menu bar to call Recast to generate the Navmesh. Then you can save the Navmesh as a Navp or Navp.json file by pressing the Save Navp button.

bin/glacier2obj.exe

-2.09 MB
Binary file not shown.

include/NavKit/Resource.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@
66
#define IDM_FILE_OPEN_SCENE 1000
77
#define IDM_FILE_OPEN_OBJ 1001
88
#define IDM_FILE_OPEN_NAVP 1002
9-
#define IDM_FILE_OPEN_AIRG 1003
9+
#define IDM_FILE_OPEN_NAVP_FROM_RPKG 1003
10+
#define IDM_FILE_OPEN_AIRG 1004
11+
#define IDM_FILE_OPEN_AIRG_FROM_RPKG 1005
1012
#define IDM_FILE_SAVE_SCENE 1010
1113
#define IDM_FILE_SAVE_OBJ 1011
1214
#define IDM_FILE_SAVE_BLEND 1012
@@ -147,3 +149,11 @@
147149
#define IDC_CHECK_FILTER_TO_INCLUDE_BOX 30413
148150
#define IDC_CHECK_SKIP_RPKG_EXTRACT 30414
149151
#define IDC_CHECK_SHOW_BLENDER_DEBUG_LOGS 30415
152+
153+
#define IDD_EXTRACT_NAVP_DIALOG 30500
154+
#define IDC_COMBOBOX_NAVP 30501
155+
#define IDC_BUTTON_LOAD_NAVP_FROM_RPKG 30502
156+
157+
#define IDD_EXTRACT_AIRG_DIALOG 30600
158+
#define IDC_COMBOBOX_AIRG 30601
159+
#define IDC_BUTTON_LOAD_AIRG_FROM_RPKG 30602

include/NavKit/module/Airg.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
#include <thread>
55
#include <vector>
66
#define WIN32_LEAN_AND_MEAN
7+
#include <map>
78
#include <windows.h>
89

910
struct Vec3;
@@ -74,6 +75,16 @@ class Airg {
7475

7576
void handleSaveAirgClicked();
7677

78+
void loadAirgFromFile(const std::string& fileName);
79+
80+
static void updateAirgDialogControls(HWND hwnd);
81+
82+
static INT_PTR CALLBACK extractAirgDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
83+
84+
void showExtractAirgDialog();
85+
86+
static void extractAirgFromRpkgs(const std::string& hash);
87+
7788
[[nodiscard]] bool canLoad() const;
7889

7990
[[nodiscard]] bool canSave() const;
@@ -94,6 +105,12 @@ class Airg {
94105

95106
static HWND hAirgDialog;
96107

108+
std::string loadedAirgText;
109+
110+
static std::string selectedRpkgAirg;
111+
112+
static std::map<std::string, std::string> airgHashIoiStringMap;
113+
97114
private:
98115
static INT_PTR CALLBACK AirgDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
99116

include/NavKit/module/Logger.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,5 @@ class Logger {
2525
static void log(LogCategory category, const char *format, ...);
2626

2727
static void logRunner();
28+
static void rustLogCallback(const char* message);
2829
};

include/NavKit/module/Navp.h

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
#include <map>
33
#include <string>
44
#include <vector>
5+
#define WIN32_LEAN_AND_MEAN
6+
#include <windows.h>
57

68
#include "../model/ZPathfinding.h"
79

@@ -23,8 +25,9 @@ class Navp {
2325

2426
~Navp();
2527

26-
void renderPfSeedPoints() const;
28+
static HWND hNavpDialog;
2729

30+
void renderPfSeedPoints() const;
2831
void renderPfSeedPointsForHitTest() const;
2932

3033
static Navp &getInstance() {
@@ -37,8 +40,6 @@ class Navp {
3740
return instance;
3841
}
3942

40-
void resetDefaults();
41-
4243
void renderExclusionBoxes() const;
4344

4445
void renderExclusionBoxesForHitTest() const;
@@ -49,6 +50,14 @@ class Navp {
4950

5051
void finalizeBuild();
5152

53+
static void updateNavpDialogControls(HWND hwnd);
54+
55+
static INT_PTR CALLBACK extractNavpDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam);
56+
57+
void showExtractNavpDialog();
58+
59+
static void extractNavpFromRpkgs(const std::string& hash);
60+
5261
void buildAreaMaps();
5362

5463
void setSelectedNavpAreaIndex(int index);
@@ -79,10 +88,16 @@ class Navp {
7988

8089
std::map<NavPower::Binary::Area *, int> binaryAreaToAreaIndexMap;
8190

91+
std::string loadedNavpText;
92+
93+
static std::string selectedRpkgNavp;
94+
8295
void setLastLoadFileName(const char *fileName);
8396

8497
void setLastSaveFileName(const char *fileName);
8598

99+
void loadNavpFromFile(const std::string& fileName);
100+
86101
void handleOpenNavpClicked();
87102

88103
void saveNavMesh(const std::string &fileName, const std::string &extension);
@@ -106,9 +121,14 @@ class Navp {
106121
void loadNavMesh(const std::string &fileName, bool isFromJson, bool isFromBuildingNavp, bool isFromBuildingAirg);
107122

108123
std::atomic<bool> navpBuildDone{false};
124+
109125
bool building;
126+
110127
std::optional<std::jthread> backgroundWorker;
128+
111129
void buildNavp();
130+
131+
static std::map<std::string, std::string> navpHashIoiStringMap;
112132
private:
113133

114134
static void renderArea(const NavPower::Area &area, bool selected);

0 commit comments

Comments
 (0)