int UBaseViewController::InitGME(std::string sdkAppId, std::string sdkAppKey, std::string userId) {int nAppid = atoi(sdkAppId.c_str());int ret = ITMGContextGetInstance()->Init(sdkAppId.c_str(), userId.c_str());ITMGContextGetInstance()->SetTMGDelegate(this);int RetCode = (int) ITMGContextGetInstance()->CheckMicPermission();FString msg = FString::Printf(TEXT("check Permission retcode =%d"), RetCode);GEngine->AddOnScreenDebugMessage(INDEX_NONE, 10.0f, FColor::Yellow, *msg);char strSig[128] = {0};unsigned int nLength = 128;nLength = QAVSDK_AuthBuffer_GenAuthBuffer(nAppid, "0", userId.c_str(), sdkAppKey.c_str(), (unsigned char *)strSig, nLength);ITMGContextGetInstance()->GetPTT()->ApplyPTTAuthbuffer(strSig, nLength);m_appId = sdkAppId;m_appKey = sdkAppKey;m_userId = userId;m_isEnableTips = false;m_tipsMark = 0;return ret;}
void AUEDemoLevelScriptActor::Tick(float DeltaSeconds) {Super::Tick(DeltaSeconds);m_pTestDemoViewController->UpdateTips();m_pCurrentViewController->UpdatePosition();ITMGContextGetInstance()->Poll();}
void UBaseViewController::EnterRoom(std::string roomID, ITMG_ROOM_TYPE roomType) {int nAppid = atoi(m_appId.c_str());UserConfig::SetRoomID(roomID);char strSig[128] = {0};unsigned int nLength = 128;nLength = QAVSDK_AuthBuffer_GenAuthBuffer(nAppid, roomID.c_str(), m_userId.c_str(), m_appKey.c_str(), (unsigned char *)strSig, nLength);GEngine->AddOnScreenDebugMessage(INDEX_NONE, 10.0f, FColor::Yellow, TEXT("onEnterRoom"));ITMGContextGetInstance()->EnterRoom(roomID.c_str(), roomType, strSig, nLength);}
if (eventType == ITMG_MAIN_EVENT_TYPE_ENTER_ROOM) {int32 result = JsonObject->GetIntegerField(TEXT("result"));FString error_info = JsonObject->GetStringField(TEXT("error_info"));if (result == 0) {GEngine->AddOnScreenDebugMessage(INDEX_NONE, 20.0f, FColor::Yellow, TEXT("Enter room success."));}else {FString msg = FString::Printf(TEXT("Enter room failed. result=%d, info = %ls"), result, *error_info);GEngine->AddOnScreenDebugMessage(INDEX_NONE, 20.0f, FColor::Yellow, *msg);}onEnterRoomCompleted(result, error_info);
void UExperientialDemoViewController::onCheckMic(bool isChecked) {//GEngine->AddOnScreenDebugMessage(INDEX_NONE, 10.0f, FColor::Yellow, L"onCheckMic");ITMGContext *pContext = ITMGContextGetInstance();if (pContext) {ITMGAudioCtrl *pTmgCtrl = pContext->GetAudioCtrl();if (pTmgCtrl) {pTmgCtrl->EnableMic(isChecked);}}}void UExperientialDemoViewController::onCheckSpeaker(bool isChecked) {//GEngine->AddOnScreenDebugMessage(INDEX_NONE, 10.0f, FColor::Yellow, L"onCheckSpeaker");ITMGContext *pContext = ITMGContextGetInstance();if (pContext) {ITMGAudioCtrl *pTmgCtrl = pContext->GetAudioCtrl();if (pTmgCtrl) {pTmgCtrl->EnableSpeaker(isChecked);}}}
void UExperientialDemoViewController::onCheckSpatializer(bool isChecked) {char buffer[256]={0};// snprintf(buffer, sizeof(buffer), "%s3d_model", getFilePath().c_str());snprintf(buffer, sizeof(buffer), "%sgme_2.8_3d_model.dat", getFilePath().c_str());int ret1 = ITMGContextGetInstance()->GetAudioCtrl()->InitSpatializer(buffer);int ret2 = ITMGContextGetInstance()->GetAudioCtrl()->EnableSpatializer(isChecked, false);FString msg = FString::Printf(TEXT("InitSpatializer=%d, EnableSpatializer ret=%d"), ret1, ret2);GEngine->AddOnScreenDebugMessage(INDEX_NONE, 10.0f, FColor::Yellow, msg);}
void AUEDemoLevelScriptActor::Tick(float DeltaSeconds) {Super::Tick(DeltaSeconds);m_pTestDemoViewController->UpdateTips();m_pCurrentViewController->UpdatePosition();ITMGContextGetInstance()->Poll();}void UBaseViewController::UpdatePosition() {if (!m_isCreated)return;ITMGRoom *pTmgRoom = ITMGContextGetInstance()->GetRoom();if (!pTmgRoom){return;}int nRange = GetRange();pTmgRoom->UpdateAudioRecvRange(nRange);FVector cameraLocation = UGameplayStatics::GetPlayerCameraManager(m_pActor->GetWorld(), 0)->GetCameraLocation();FRotator cameraRotation = UGameplayStatics::GetPlayerCameraManager(m_pActor->GetWorld(), 0)->GetCameraRotation();FString msg = FString::Printf(TEXT("location(x=%.2f,y=%.2f,z=%.2f), rotation(pitch=%.2f,yaw=%.2f,roll=%.2f)"),cameraLocation.X, cameraLocation.Y, cameraLocation.Z, cameraRotation.Pitch, cameraRotation.Yaw, cameraRotation.Roll);int position[] = { (int)cameraLocation.X,(int)cameraLocation.Y, (int)cameraLocation.Z };FMatrix matrix = ((FRotationMatrix)cameraRotation);float forward[] = { matrix.GetColumn(0).X,matrix.GetColumn(1).X,matrix.GetColumn(2).X };float right[] = { matrix.GetColumn(0).Y,matrix.GetColumn(1).Y,matrix.GetColumn(2).Y };float up[] = { matrix.GetColumn(0).Z,matrix.GetColumn(1).Z,matrix.GetColumn(2).Z };pTmgRoom->UpdateSelfPosition(position, forward, right, up);SetPositionInfo(msg);}
void UExperientialDemoViewController::onCheckSpatializer(bool isChecked) {char buffer[256]={0};// snprintf(buffer, sizeof(buffer), "%s3d_model", getFilePath().c_str());snprintf(buffer, sizeof(buffer), "%sgme_2.8_3d_model.dat", getFilePath().c_str());int ret1 = ITMGContextGetInstance()->GetAudioCtrl()->InitSpatializer(buffer);int ret2 = ITMGContextGetInstance()->GetAudioCtrl()->EnableSpatializer(isChecked, false);FString msg = FString::Printf(TEXT("InitSpatializer=%d, EnableSpatializer ret=%d"), ret1, ret2);GEngine->AddOnScreenDebugMessage(INDEX_NONE, 10.0f, FColor::Yellow, msg);}
本页内容是否解决了您的问题?