#include<iostream>
#include "Vector3.h"
#include "Quat.h"
#include <cinttypes>
using namespace std;
1.定义dll中函数原型
typedef bool(*pCMHumanExtern)(char* address, uint32_t channel, uint64_t frameCount, double* attitude, int* segmentIsDetected);
typedef double(*pCMTrackerExtern)(char* address, uint32_t channel, int component, uint64_t frameCount, bool lockUpRotation);
2.创建dll函数句柄
pCMTrackerExtern CMTrackerExtern;
pCMHumanExtern CMHumanExtern;
3.加载dll,把上一步创建的句柄映射到dll中的函数
HINSTANCE handle_dll;
handle_dll = LoadLibrary("E:\\Program Files\\Autodesk\\MotionBuilder 2016\\bin\\x64\\plugins\\CMUnity.dll");
if (handle_dll == NULL)
{
//FreeLibrary(hdll);
throw "Can not load CMUnity.dll";
}
CMTrackerExtern = (pCMTrackerExtern)GetProcAddress(handle_dll, "CMTrackerExtern");
if (CMTrackerExtern == NULL)
{
FreeLibrary(handle_dll);
}
CMHumanExtern = (pCMHumanExtern)GetProcAddress(handle_dll, "CMHumanExtern");
if (CMHumanExtern == NULL)
{
FreeLibrary(handle_dll);
}
4.调用句柄函数。
CMTrackerExtern(address, channel, 0, GFrameCounter, false);
CMHumanExtern(address, channel, GFrameCounter, boneAttitude, isBoneDetected);