Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 11 additions & 0 deletions MQ2Nav.sln
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "imgui", "..\..\src\imgui\im
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "zone-utilities", "dependencies\zone-utilities\zone-utilities.vcxproj", "{200FB60C-6C01-48A7-886A-8E3683EB21BC}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "routing", "..\..\src\routing\routing.vcxproj", "{6CE4F8D6-1709-47C5-9297-1619BBC4A71E}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Expand Down Expand Up @@ -80,6 +82,14 @@ Global
{200FB60C-6C01-48A7-886A-8E3683EB21BC}.Release|Win32.Build.0 = Release|Win32
{200FB60C-6C01-48A7-886A-8E3683EB21BC}.Release|x64.ActiveCfg = Release|x64
{200FB60C-6C01-48A7-886A-8E3683EB21BC}.Release|x64.Build.0 = Release|x64
{6CE4F8D6-1709-47C5-9297-1619BBC4A71E}.Debug|Win32.ActiveCfg = Debug|Win32
{6CE4F8D6-1709-47C5-9297-1619BBC4A71E}.Debug|Win32.Build.0 = Debug|Win32
{6CE4F8D6-1709-47C5-9297-1619BBC4A71E}.Debug|x64.ActiveCfg = Debug|x64
{6CE4F8D6-1709-47C5-9297-1619BBC4A71E}.Debug|x64.Build.0 = Debug|x64
{6CE4F8D6-1709-47C5-9297-1619BBC4A71E}.Release|Win32.ActiveCfg = Release|Win32
{6CE4F8D6-1709-47C5-9297-1619BBC4A71E}.Release|Win32.Build.0 = Release|Win32
{6CE4F8D6-1709-47C5-9297-1619BBC4A71E}.Release|x64.ActiveCfg = Release|x64
{6CE4F8D6-1709-47C5-9297-1619BBC4A71E}.Release|x64.Build.0 = Release|x64
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -93,6 +103,7 @@ Global
{A219F273-6B9D-4284-84F4-368539F0A9CF} = {1C00A77D-99DC-4366-8569-E75827AAF729}
{1777E251-0F50-496A-B8C5-EC7F41A0B186} = {2884B755-835B-49DA-9E3F-E34AD401A5B9}
{200FB60C-6C01-48A7-886A-8E3683EB21BC} = {2884B755-835B-49DA-9E3F-E34AD401A5B9}
{6CE4F8D6-1709-47C5-9297-1619BBC4A71E} = {2884B755-835B-49DA-9E3F-E34AD401A5B9}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {1498B1E1-4805-4819-A304-0BE8FDA62FD8}
Expand Down
3 changes: 3 additions & 0 deletions common/MQ2Nav_Common.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@
<ClInclude Include="NavMesh.h" />
<ClInclude Include="NavMeshData.h" />
<ClInclude Include="NavModule.h" />
<ClInclude Include="proto\NavMeshClient.pb.h" />
<ClInclude Include="proto\NavMeshFile.pb.h" />
<ClInclude Include="Utilities.h" />
<ClInclude Include="ZoneData.h" />
Expand All @@ -154,13 +155,15 @@
<ClCompile Include="JsonProto.cpp" />
<ClCompile Include="NavMesh.cpp" />
<ClCompile Include="NavMeshData.cpp" />
<ClCompile Include="proto\NavMeshClient.pb.cc" />
<ClCompile Include="proto\NavMeshFile.pb.cc">
<DisableSpecificWarnings>4244;4256</DisableSpecificWarnings>
</ClCompile>
<ClCompile Include="Utilities.cpp" />
<ClCompile Include="ZoneData.cpp" />
</ItemGroup>
<ItemGroup>
<ProtocolBuffer Include="proto\NavMeshClient.proto" />
<ProtocolBuffer Include="proto\NavMeshFile.proto">
<FileType>Document</FileType>
</ProtocolBuffer>
Expand Down
9 changes: 9 additions & 0 deletions common/MQ2Nav_Common.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@
<ClInclude Include="Logging.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="proto\NavMeshClient.pb.h">
<Filter>Proto Files\Generated Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="ZoneData.cpp">
Expand All @@ -74,11 +77,17 @@
<ClCompile Include="JsonProto.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="proto\NavMeshClient.pb.cc">
<Filter>Proto Files\Generated Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ProtocolBuffer Include="proto\NavMeshFile.proto">
<Filter>Proto Files</Filter>
</ProtocolBuffer>
<ProtocolBuffer Include="proto\NavMeshClient.proto">
<Filter>Proto Files</Filter>
</ProtocolBuffer>
</ItemGroup>
<ItemGroup>
<None Include="..\cpp.hint">
Expand Down
28 changes: 28 additions & 0 deletions common/proto/NavMeshClient.proto
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
syntax = "proto3";

package nav.client;

import "NavMeshFile.proto";

message UpdateTransform
{
string shortzone = 1;
nav.vector3 position = 2;
float heading = 3;

string character_info = 10;
}

message DropClient
{
string character_info = 1;
}

message ClientMessage
{
oneof message
{
UpdateTransform transform = 1;
DropClient drop = 2;
}
}
90 changes: 90 additions & 0 deletions meshgen/Actor.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
//
// Actor.cpp
//

#include "Application.h"

#include "routing/Routing.h"
#include "common/proto/NavMeshClient.pb.h"

using namespace mq;

mq::ProtoPipeClient* s_pipeClient = nullptr; // { mq::MQ2_PIPE_SERVER_PATH };

class PipeEventsHandler : public NamedPipeEvents
{
public:
PipeEventsHandler() {}

virtual void OnIncomingMessage(PipeMessagePtr&& message) override
{
switch (message->GetMessageId())
{
case MQMessageId::MSG_ROUTE:
{
auto envelope = ProtoMessage::Parse<proto::routing::Envelope>(message);
if (envelope.has_payload())
{
nav::client::ClientMessage client_message;
client_message.ParseFromString(envelope.payload());

switch (client_message.message_case())
{
case nav::client::ClientMessage::kTransform:
ClientInformation::UpdateTransform(client_message.transform());
break;
case nav::client::ClientMessage::kDrop:
ClientInformation::DropCharacter(client_message.drop().character_info());
break;
default:
break;
}
}
break;
}

case MQMessageId::MSG_IDENTIFICATION:
{
// the launcher wants identification
proto::routing::Identification id;
id.set_name("meshgen");
id.set_pid(GetCurrentProcessId());
s_pipeClient->SendProtoMessage(MQMessageId::MSG_IDENTIFICATION, id);
break;
}

default: break;
}
}

virtual void OnClientConnected() override
{
// Send an ID message to the launcher
proto::routing::Identification id;
id.set_name("meshgen");
id.set_pid(GetCurrentProcessId());
s_pipeClient->SendProtoMessage(MQMessageId::MSG_IDENTIFICATION, id);
}
};

void StopPipeClient()
{
s_pipeClient->Stop();

delete s_pipeClient;
s_pipeClient = nullptr;
}

void StartPipeClient()
{
s_pipeClient = new mq::ProtoPipeClient(mq::MQ2_PIPE_SERVER_PATH);
s_pipeClient->SetHandler(std::make_shared<PipeEventsHandler>());
s_pipeClient->Start();
::atexit(StopPipeClient);
}

void ProcessPipeClient()
{
if (s_pipeClient != nullptr)
s_pipeClient->Process();
}
46 changes: 46 additions & 0 deletions meshgen/Application.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "meshgen/imgui/imgui_impl_opengl2.h"
#include "meshgen/imgui/imgui_impl_sdl.h"
#include "common/Utilities.h"
#include "common/proto/NavMeshClient.pb.h"

#include "imgui/ImGuiUtils.h"

Expand Down Expand Up @@ -41,6 +42,8 @@ namespace fs = std::filesystem;

static const int32_t MAX_LOG_MESSAGES = 1000;

static ClientInformation s_clientInformation;

static bool IsKeyboardBlocked() {
return ImGui::GetIO().WantCaptureKeyboard || ImGui::GetIO().WantTextInput;
}
Expand Down Expand Up @@ -296,6 +299,7 @@ int Application::RunMainLoop()
m_raye = glm::unProject(glm::vec3{ m_m.x, m_m.y, 1.0f }, m_model, m_proj, m_view);

DispatchCallbacks();
ProcessPipeClient();

// Handle input events.
HandleEvents();
Expand Down Expand Up @@ -773,6 +777,20 @@ void Application::RenderInterface()
m_cam.z = camPos[0];
}

if (!s_clientInformation.m_transforms.empty())
{
ImGui::Separator();
ImGui::Text("Connected Character Information:");
for (const auto& [charInfo, xform] : s_clientInformation.m_transforms)
{
ImGui::Text(
"[%s] %s x: %.2f y: %.2f z: %.2f h: %.2f",
charInfo.c_str(), xform.shortzone().c_str(),
xform.position().x(), xform.position().y(),
xform.position().z(), xform.heading());
}
}

if (m_geom)
{
auto* loader = m_geom->getMeshLoader();
Expand Down Expand Up @@ -1427,3 +1445,31 @@ void ImportExportSettingsDialog::Show(bool* open /* = nullptr */)

m_firstShow = false;
}

ClientInformation::ClientInformation()
{
StartPipeClient();
}

ClientInformation::~ClientInformation()
{
StopPipeClient();
}

void ClientInformation::UpdateTransform(const nav::client::UpdateTransform& transform)
{
std::string characterInfo = transform.character_info();

auto it = s_clientInformation.m_transforms.find(transform.character_info());
if (it != s_clientInformation.m_transforms.end())
it->second = transform;
else
s_clientInformation.m_transforms.emplace(characterInfo, transform);
}

void ClientInformation::DropCharacter(const std::string& characterInfo)
{
auto it = s_clientInformation.m_transforms.find(characterInfo);
if (it != s_clientInformation.m_transforms.end())
s_clientInformation.m_transforms.erase(it);
}
25 changes: 25 additions & 0 deletions meshgen/Application.h
Original file line number Diff line number Diff line change
Expand Up @@ -332,3 +332,28 @@ class ImportExportSettingsDialog
PersistedDataFields m_fields = PersistedDataFields::All
& ~PersistedDataFields::MeshTiles;
};

//----------------------------------------------------------------------------

namespace nav::client {
class UpdateTransform;
}

class ClientInformation
{
friend class Application;

public:
ClientInformation();
~ClientInformation();

static void UpdateTransform(const nav::client::UpdateTransform& transform);
static void DropCharacter(const std::string& characterInfo);

private:
std::unordered_map<std::string, nav::client::UpdateTransform> m_transforms;
};

void StopPipeClient();
void StartPipeClient();
void ProcessPipeClient();
4 changes: 4 additions & 0 deletions meshgen/MeshGenerator.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">Create</PrecompiledHeader>
</ClCompile>
<ClCompile Include="Actor.cpp" />
<ClCompile Include="WaypointsTool.cpp" />
<ClCompile Include="ZonePicker.cpp" />
</ItemGroup>
Expand Down Expand Up @@ -61,6 +62,9 @@
<ProjectReference Include="..\..\..\src\imgui\imgui.vcxproj">
<Project>{1777e251-0f50-496a-b8c5-ec7f41a0b186}</Project>
</ProjectReference>
<ProjectReference Include="..\..\..\src\routing\routing.vcxproj">
<Project>{6ce4f8d6-1709-47c5-9297-1619bbc4a71e}</Project>
</ProjectReference>
<ProjectReference Include="..\common\MQ2Nav_Common.vcxproj">
<Project>{45e99b43-f47b-4aad-ac88-f95bf467f463}</Project>
</ProjectReference>
Expand Down
3 changes: 3 additions & 0 deletions meshgen/MeshGenerator.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,9 @@
<ClCompile Include="NavMeshInfoTool.cpp">
<Filter>Source Files\tools</Filter>
</ClCompile>
<ClCompile Include="Actor.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="MapGeometryLoader.h">
Expand Down
2 changes: 2 additions & 0 deletions plugin/MQ2Nav.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@
<None Include="..\resources\Zones.ini" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="MeshgenHandler.cpp" />
<ClCompile Include="pch.cpp">
<PrecompiledHeader>Create</PrecompiledHeader>
</ClCompile>
Expand Down Expand Up @@ -167,6 +168,7 @@
<ClInclude Include="imgui\imgui_impl_win32.h" />
<ClInclude Include="KeybindHandler.h" />
<ClInclude Include="MapAPI.h" />
<ClInclude Include="MeshgenHandler.h" />
<ClInclude Include="ModelLoader.h" />
<ClInclude Include="MQ2Navigation.h" />
<ClInclude Include="pch.h" />
Expand Down
6 changes: 6 additions & 0 deletions plugin/MQ2Nav.vcxproj.filters
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,9 @@
<ClCompile Include="pch.cpp">
<Filter>Source Files</Filter>
</ClCompile>
<ClCompile Include="MeshgenHandler.cpp">
<Filter>Source Files</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ClInclude Include="KeybindHandler.h">
Expand Down Expand Up @@ -140,6 +143,9 @@
<ClInclude Include="resource.h">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="MeshgenHandler.h">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="EmbedResources.rc">
Expand Down
2 changes: 2 additions & 0 deletions plugin/MQ2Navigation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include "plugin/NavMeshRenderer.h"
#include "plugin/RenderHandler.h"
#include "plugin/SwitchHandler.h"
#include "plugin/MeshgenHandler.h"
#include "plugin/UiController.h"
#include "plugin/Utilities.h"
#include "plugin/Waypoints.h"
Expand Down Expand Up @@ -562,6 +563,7 @@ void MQ2NavigationPlugin::Plugin_Initialize()
AddModule<NavMeshRenderer>();
AddModule<UiController>();
AddModule<SwitchHandler>();
AddModule<MeshgenHandler>();

for (const auto& m : m_modules)
{
Expand Down
Loading