Difference between revisions of "Link"
Line 14: | Line 14: | ||
float fFront[3]; | float fFront[3]; | ||
float fTop[3]; | float fTop[3]; | ||
+ | wchar_t name[256]; | ||
}; | }; | ||
− | static hMapObject = NULL; | + | static HANDLE hMapObject = NULL; |
LinkedMem *lm = NULL; | LinkedMem *lm = NULL; | ||
Line 30: | Line 31: | ||
return; | return; | ||
} | } | ||
+ | wcscpy_s(lm->name, 256, L"MyGameName"); | ||
} | } | ||
</pre> | </pre> | ||
Line 45: | Line 47: | ||
</pre> | </pre> | ||
− | fPosition should be the player position in 3D space. fTop and fFront should be the orientation. | + | fPosition should be the player position in 3D space. fTop and fFront should be the orientation. The coordinate system is a left-handed one, and the units are in meters. |
Mumble fetches these values 50 times a second, so please update them every frame. | Mumble fetches these values 50 times a second, so please update them every frame. |
Revision as of 12:32, 28 March 2008
Linking a game to Mumble
The "best" way to link a game to mumble is to write your own plugin. However, that may be a lot of work, so we have an alternative method.
Initialization
Somewhere in your game initalization, add these lines of code:
struct LinkedMem { DWORD dwVersion; DWORD dwTick; float fPosition[3]; float fFront[3]; float fTop[3]; wchar_t name[256]; }; static HANDLE hMapObject = NULL; LinkedMem *lm = NULL; void initMumble() { hMapObject = OpenFileMapping(FILE_MAP_ALL_ACCESS, FALSE, L"MumbleLink"); if (hMapObject == NULL) return; lm = (LinkedMem *) MapViewOfFile(hMapObject, FILE_MAP_ALL_ACCESS, 0, 0, sizeof(LinkedMem)); if (lm == NULL) { CloseHandle(hMapObject); hMapObject = NULL; return; } wcscpy_s(lm->name, 256, L"MyGameName"); }
Then, for each frame, do the following:
void updateMumble() { if (! lm) return; lm->dwVersion = 1; lm->dwTick = GetTickCount(); // Fill lm->fPosition, fTop and fFront }
fPosition should be the player position in 3D space. fTop and fFront should be the orientation. The coordinate system is a left-handed one, and the units are in meters.
Mumble fetches these values 50 times a second, so please update them every frame.