mirror of
https://github.com/originalnicodr/CinematicUnityExplorer.git
synced 2025-07-19 01:57:56 +08:00

* Initial work on supporting IGCS
* feat: Added callback when starting session, adding missing func.
* chore: tidy up math and cleanup.
* chore: tidy up some verbose code
* Added more callbacks, fixed math.
* fix: use queue command system instead of directly writing to the camera.
* lock camera while igcsdof is active.
* build system shenanigans
Now we can build the project just fine by building separately the C
project and the C# project.
* small syntax changes.
learning c# and stuff
* Refactor executeCameraCommand and improve thread-safety in FreeCamPanel
* woops, correct order of arguments for MessageBoxA
* fix: move the ourCamera check where it's actually needed.
* chore: formatting c file
* rewrite: move all igcsdof logic to its own class.
Since CUE *must* work without igcsdof, I thought it would be convenient
to handle all the logic regarding igcsdof in its own class. The
initialization is a bit of a mess because since most of what it's on
FreeCam is static I had to do some trickery.
I wanted to specifically avoid calling LoadLibrary every time so I
thought on only initializing one and having an internal flag either the
thing loaded correctly or not (`isValid`).
* fix: Pin callbacks to avoid garbage collection
* chore: removed unused code
* chore: fix typo.
* nit: more idiomatic C# usage.
Just applied what rider suggested =)
* fix: remove unnecesary GCHandle, store delegates.
* feat: Update IGCS dof camera status accordingly.
Before, we just left igcsdof always enabled, now we handle the cases
properly, avoiding the posibility of the user using igcsdof with the
freecam disabled.
* nit: fix comments and added some to UnityIGCSConnector.
* feat: Get the transform reference earlier for perf™️
* fix: Properly handle an initialization error.
* chore: remove overly verbose debugging
* fix: make sure we start with a clear queue after we end a session.
This was what maybe was causing the misaligning after you cancel a
session since we never checked if the queue was emptied by the code.
* fix: properly cast a function pointer to use what it returns.
93 lines
2.4 KiB
C
93 lines
2.4 KiB
C
// dllmain.cpp : Defines the entry point for the DLL application.
|
|
#include <Windows.h>
|
|
#include <stdint.h>
|
|
#include <stdio.h>
|
|
|
|
#define EXPOSE __declspec(dllexport)
|
|
|
|
// The function that will be the one called from the C# side, that will update the corresponding values.
|
|
typedef void (*MoveCameraCallback)(float, float, float, int);
|
|
|
|
typedef void (*SessionCallback)(void);
|
|
|
|
typedef uint8_t* (*GetCameraDataFunc)(void);
|
|
|
|
MoveCameraCallback GlobalCallback = NULL;
|
|
SessionCallback GlobalStartSession = NULL;
|
|
SessionCallback GlobalEndSession = NULL;
|
|
|
|
// There are things that only needs to be run once.
|
|
static int first_initialization = 1;
|
|
|
|
EXPOSE int IGCS_StartScreenshotSession(uint8_t _ignore) {
|
|
if (GlobalStartSession) {
|
|
GlobalStartSession();
|
|
printf("Called StartSession\n");
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
EXPOSE void IGCS_EndScreenshotSession() {
|
|
GlobalEndSession();
|
|
printf("Called EndSession\n");
|
|
}
|
|
|
|
EXPOSE uint8_t* U_IGCS_Initialize(MoveCameraCallback cb, SessionCallback start_cb, SessionCallback end_cb) {
|
|
AllocConsole();
|
|
printf("Initializing callback\n");
|
|
GlobalCallback = cb;
|
|
GlobalStartSession = start_cb;
|
|
GlobalEndSession = end_cb;
|
|
|
|
// Load IGCS
|
|
HMODULE igcs = LoadLibraryA("IgcsConnector.addon64");
|
|
|
|
if (!igcs) {
|
|
MessageBoxA(
|
|
NULL,
|
|
"IgcsConnector.addon64 was not found, make sure it is in the same directory as the executable.",
|
|
"Unable to find IgcsConnector",
|
|
MB_OK | MB_ICONERROR);
|
|
return NULL;
|
|
}
|
|
|
|
FARPROC cameraToolsFunction = GetProcAddress(igcs, "connectFromCameraTools");
|
|
GetCameraDataFunc getCameraData = (GetCameraDataFunc)GetProcAddress(igcs, "getDataFromCameraToolsBuffer");
|
|
|
|
if (first_initialization) {
|
|
cameraToolsFunction();
|
|
first_initialization = 0;
|
|
}
|
|
|
|
// TODO: move this where it belongs. Maybe at some point we should actually fill in the data.
|
|
uint8_t* cameraData = getCameraData();
|
|
cameraData[0] = 0;
|
|
|
|
printf("Camera connected!\n");
|
|
|
|
return cameraData;
|
|
|
|
}
|
|
|
|
EXPOSE void IGCS_MoveCameraPanorama() {}
|
|
|
|
EXPOSE void IGCS_MoveCameraMultishot(float step_left, float step_up, float fov, int from_start) {
|
|
GlobalCallback(step_left, step_up, fov, from_start);
|
|
return;
|
|
}
|
|
|
|
BOOL WINAPI DllMain(HMODULE hModule,
|
|
DWORD ul_reason_for_call,
|
|
LPVOID lpReserved
|
|
)
|
|
{
|
|
switch (ul_reason_for_call)
|
|
{
|
|
case DLL_PROCESS_ATTACH:
|
|
case DLL_THREAD_ATTACH:
|
|
case DLL_THREAD_DETACH:
|
|
case DLL_PROCESS_DETACH:
|
|
break;
|
|
}
|
|
return TRUE;
|
|
} |