36 #include <MyGUI_UString.h>
41 MumbleIntegration::MumbleIntegration() : lm(NULL)
46 MumbleIntegration::~MumbleIntegration()
52 void MumbleIntegration::initMumble()
55 HANDLE hMapObject = OpenFileMappingW(FILE_MAP_ALL_ACCESS, FALSE, L
"MumbleLink");
56 if (hMapObject == NULL)
59 lm = (LinkedMem *) MapViewOfFile(hMapObject, FILE_MAP_ALL_ACCESS, 0, 0,
sizeof(LinkedMem));
62 CloseHandle(hMapObject);
68 snprintf(memname, 256,
"/MumbleLink.%d", getuid());
70 int shmfd = shm_open(memname, O_RDWR, S_IRUSR | S_IWUSR);
77 lm = (LinkedMem *)(mmap(NULL,
sizeof(
struct LinkedMem), PROT_READ | PROT_WRITE, MAP_SHARED, shmfd,0));
79 if (lm == (
void *)(-1))
87 void MumbleIntegration::SetNonPositionalAudio()
94 Ogre::Vector3(0.0f, 0.0f, 1.0f),
95 Ogre::Vector3(0.0f, 1.0f, 0.0f),
97 Ogre::Vector3(0.0f, 0.0f, 1.0f),
98 Ogre::Vector3(0.0f, 1.0f, 0.0f));
101 void MumbleIntegration::Update()
103 if (
App::app_state->getEnum<AppState>() == AppState::SIMULATION &&
108 Ogre::Vector3 avatarDir = Ogre::Vector3(Math::Cos(avatar->
getRotation()), 0.0f, Math::Sin(avatar->
getRotation()));
113 App::GetGameContext()->GetPlayerCharacter()->getPosition() + Vector3(0, 1.8f, 0), avatarDir, Ogre::Vector3(0.0f, 1.0f, 0.0f));
117 this->SetNonPositionalAudio();
121 void MumbleIntegration::updateMumble(Ogre::Vector3 cameraPos, Ogre::Vector3 cameraDir, Ogre::Vector3 cameraUp, Ogre::Vector3 avatarPos, Ogre::Vector3 avatarDir, Ogre::Vector3 avatarUp)
126 if (lm->uiVersion != 2)
128 wcsncpy(lm->name, L
"Rigs of Rods", 256);
129 wcsncpy(lm->description, L
"This plugin links Rigs of Rods with Mumble", 2048);
149 avatarDir.normalise();
150 avatarUp.normalise();
151 cameraDir.normalise();
152 cameraUp.normalise();
155 lm->fAvatarPosition[0] = avatarPos.x;
156 lm->fAvatarPosition[1] = avatarPos.y;
157 lm->fAvatarPosition[2] = -avatarPos.z;
160 lm->fAvatarFront[0] = avatarDir.x;
161 lm->fAvatarFront[1] = avatarDir.y;
162 lm->fAvatarFront[2] = -avatarDir.z;
165 lm->fAvatarTop[0] = avatarUp.x;
166 lm->fAvatarTop[1] = avatarUp.y;
167 lm->fAvatarTop[2] = -avatarUp.z;
170 lm->fCameraPosition[0] = cameraPos.x;
171 lm->fCameraPosition[1] = cameraPos.y;
172 lm->fCameraPosition[2] = -cameraPos.z;
174 lm->fCameraFront[0] = cameraDir.x;
175 lm->fCameraFront[1] = cameraDir.y;
176 lm->fCameraFront[2] = -cameraDir.z;
178 lm->fCameraTop[0] = cameraUp.x;
179 lm->fCameraTop[1] = cameraUp.y;
180 lm->fCameraTop[2] = -cameraUp.z;
184 wcsncpy(lm->identity, player_name.asWStr_c_str(), 256);
197 port = (port != 0) ? port : 1337;
199 lm->context_len = (int)
strnlen((
char *)lm->context, 256);