void VCameraHandling::OnHandleCallback(IVisCallbackDataObject_cl* pData) { if (pData->m_pSender == &Vision::Callbacks.OnAfterSceneLoaded) { BuildCameraList(); InitFreeCamera(); } else if (pData->m_pSender == &Vision::Callbacks.OnBeforeSceneUnloaded) { DeInitFreeCamera(); ReleaseCameraList(); } else { const int iActionIndex = GetCallbackIndex(pData); if (iActionIndex < 0) return; if (iActionIndex == m_iWASDActionIndex) { SetWASDControlsEnabled(!m_bWASDEnabled); } else { ActivateCameraByActionIndex(iActionIndex); } } }
void VDebugShadingModes::OnHandleCallback(IVisCallbackDataObject_cl* pData) { if (pData->m_pSender == &Vision::Callbacks.OnAfterSceneLoaded) { Vision::RenderLoopHelper.SetReplacementRenderLoop(NULL); m_iCurrentDebugShadingMode = -1; } else if (pData->m_pSender == &Vision::Callbacks.OnBeforeSceneUnloaded) { Vision::RenderLoopHelper.SetReplacementRenderLoop(NULL); m_iCurrentDebugShadingMode = -1; m_spBackupRendererNode = NULL; } int iIndex = GetCallbackIndex(pData); if (iIndex >= 0) { if (m_iCurrentDebugShadingMode == -1) { // Backup render node so that the debug rendering can be restored to the original rendering m_spBackupRendererNode = Vision::Renderer.GetRendererNode(0); } // Disable when currently active shading mode is triggered again if (m_iCurrentDebugShadingMode == iIndex) { m_iCurrentDebugShadingMode = -1; Vision::RenderLoopHelper.SetReplacementRenderLoop(NULL); Vision::Renderer.SetRendererNode(0, m_spBackupRendererNode); } else { m_iCurrentDebugShadingMode = iIndex; // The debug shading works by replacing the current render loop by a debug shading one which applies the different effects if (m_spDebugShadingRenderLoop == NULL) m_spDebugShadingRenderLoop = new VisDebugShadingRenderLoop_cl(); m_spDebugShadingRenderLoop->SetEffect(m_debugShadingEffects.GetAt(m_iCurrentDebugShadingMode)); // Simple render node base on the main render context which encapsulates the debug shading render loop VSimpleRendererNode* pSimpleRendererNode = new VSimpleRendererNode(Vision::Contexts.GetMainRenderContext()); pSimpleRendererNode->InitializeRenderer(); Vision::Renderer.SetRendererNode(0, pSimpleRendererNode); Vision::RenderLoopHelper.SetReplacementRenderLoop(m_spDebugShadingRenderLoop); } } }
void VHelp::OnHandleCallback(IVisCallbackDataObject_cl* pData) { if (pData->m_pSender == &Vision::Callbacks.OnUpdateSceneFinished) { if (m_bToggleEnabled && GetParent()->GetInputMap()->GetTrigger(VAPP_MENU)) SetEnabled(!IsEnabled()); if (IsEnabled()) { const int iLineHeight = 16; const int iOffset = Vision::Video.GetYRes() - (m_text.GetSize() + 3) * iLineHeight; for (int i=0; i<m_text.GetSize(); ++i) { if (m_text[i]) Vision::Message.Print(1, 10, iOffset + i*iLineHeight, m_text[i]); } } } int iIndex = GetCallbackIndex(pData); if (iIndex >= 0) SetEnabled(!IsEnabled()); }
void VDebugProfiling::OnHandleCallback(IVisCallbackDataObject_cl* pData) { if (pData->m_pSender == &Vision::Callbacks.OnUpdateSceneBegin) { #if defined(_VISION_WIN32) if (GetParent()->GetInputMap()->GetTrigger(PREV_PROFILING_PAGE)) { int iIndex = m_iCurrentProfilingPage - 1; if (iIndex < -1) iIndex = Vision::Profiling.GetNumOfGroups() - 1; OnActionTriggered(iIndex); } else if (GetParent()->GetInputMap()->GetTrigger(NEXT_PROFILING_PAGE)) { int iIndex = m_iCurrentProfilingPage + 1; if (iIndex >= (int)Vision::Profiling.GetNumOfGroups()) iIndex = -1; OnActionTriggered(iIndex); } else if (GetParent()->GetInputMap()->GetTrigger(RESET_MAX_VALUES)) { OnActionTriggered(s_iResetMaxValuesAction); } #endif } else if (pData->m_pSender == &Vision::Callbacks.OnAfterSceneLoaded) { RebuildMenu(); } else { OnActionTriggered(GetCallbackIndex(pData)); } }
void VDebugOptions::OnHandleCallback(IVisCallbackDataObject_cl* pData) { if (pData->m_pSender == &Vision::Callbacks.OnUpdateSceneBegin) { #if defined(WIN32) if (GetParent()->GetInputMap()->GetTrigger(TOGGLE_FPS)) { SetFrameRateVisible(!IsFrameRateVisible()); } else if (GetParent()->GetInputMap()->GetTrigger(TOGGLE_WIREFRAME)) { SetWireframe(!IsWireframe()); } #endif // FPS accumulation { m_iFrameCounter++; m_fTimeAccumulator += Vision::GetUITimer()->GetTimeDifference(); if (m_fTimeAccumulator >= 1.0f) { m_fCurrentFrameTime = m_fTimeAccumulator / m_iFrameCounter; m_fCurrentFps = m_iFrameCounter / m_fTimeAccumulator; m_fTimeAccumulator = 0.0f; m_iFrameCounter = 0; } } if (m_bFpsVisible) Vision::Message.Print(1, 10, Vision::Video.GetYRes() - 35, "FPS : %.1f\nFrame Time : %.2f", m_fCurrentFps, m_fCurrentFrameTime * 1000.0f); } else if (pData->m_pSender == &Vision::Callbacks.OnBeforeSwapBuffers) { if (m_bSaveScreenshot) { VScreenShotHelper helper; helper.Capture(); if (helper.PendingDataInBuffer()) { if (helper.SaveBufferToFile("", NULL, 1.0f, 1.0f)) Vision::Message.Add(0, "Screenshot saved to \"%s\".\n", helper.GetScreenShotPath()); else Vision::Message.Add(0, "Screenshot could not be saved.\n"); } // Re-enable the VAppMenu again VAppMenu* pMainMenu = GetParent()->GetAppModule<VAppMenu>(); if (pMainMenu) pMainMenu->SetVisible(true); m_bSaveScreenshot = false; } } else if (pData->m_pSender == &Vision::Callbacks.OnRenderHook) { VisRenderHookDataObject_cl *pRenderHookData = (VisRenderHookDataObject_cl *)pData; if (pRenderHookData->m_iEntryConst == VRH_PRE_SCREENMASKS) { // Debug drawing of all visible touch areas. #if defined(SUPPORTS_MULTITOUCH) if (m_bTouchAreaDebug) { IVMultiTouchInput* pMultiTouchInput = NULL; pMultiTouchInput = static_cast<IVMultiTouchInput*>(&VInputManager::GetInputDevice(INPUT_DEVICE_TOUCHSCREEN)); VPListT<VTouchArea> touchAreas = pMultiTouchInput->GetTouchAreas(); const float fBorderWidth = 3.0f; VSimpleRenderState_t alphaState(VIS_TRANSP_ALPHA, RENDERSTATEFLAG_FRONTFACE|RENDERSTATEFLAG_NOWIREFRAME|RENDERSTATEFLAG_ALWAYSVISIBLE); IVRender2DInterface *pRI = Vision::RenderLoopHelper.BeginOverlayRendering(); { for (int i=0; i<touchAreas.GetLength(); ++i) { const VRectanglef& rect = touchAreas.Get(i)->GetArea(); const VColorRef color = touchAreas.Get(i)->GetTouchPointIndex() < 0 ? VColorRef(0, 255, 0, 64) : VColorRef(0, 255, 0, 96); pRI->DrawSolidQuad(rect.m_vMin, rect.m_vMax, color, alphaState); pRI->DrawSolidQuad(rect.m_vMin, hkvVec2(rect.m_vMax.x, rect.m_vMin.y + fBorderWidth), VColorRef(0, 255, 0, 255), alphaState); pRI->DrawSolidQuad(hkvVec2(rect.m_vMin.x, rect.m_vMax.y - fBorderWidth), rect.m_vMax, VColorRef(0, 255, 0, 255), alphaState); pRI->DrawSolidQuad(hkvVec2(rect.m_vMin.x, rect.m_vMin.y + fBorderWidth), hkvVec2(rect.m_vMin.x + fBorderWidth, rect.m_vMax.y - fBorderWidth), VColorRef(0, 255, 0, 255), alphaState); pRI->DrawSolidQuad(hkvVec2(rect.m_vMax.x - fBorderWidth, rect.m_vMin.y + fBorderWidth), hkvVec2(rect.m_vMax.x, rect.m_vMax.y - fBorderWidth), VColorRef(0, 255, 0, 255), alphaState); } } Vision::RenderLoopHelper.EndOverlayRendering(); } #endif } } int iIndex = GetCallbackIndex(pData); if (iIndex >= 0) { if (iIndex == OPTION_FPS) { m_bFpsVisible = !m_bFpsVisible; } else if (iIndex == OPTION_WIREFRAME) { if (Vision::Renderer.GetWireframeMode()) Vision::Renderer.SetWireframeMode(false); else Vision::Renderer.SetWireframeMode(true); } else if (iIndex == OPTION_RELOAD_RESOURCES) { int iCount = Vision::ResourceSystem.ReloadModifiedResourceFiles(NULL, VURO_HOT_RELOAD); // Clear effect caches so that material shaders will be re-created (not re-used). Vision::Shaders.GetShaderFXLibManager().ResetCompiledEffectCaches(); // Reassign all material shaders. Vision::Shaders.ReloadAllShaderAssignmentFiles(); Vision::Message.Add(1, "%i resources were outdated and have been reloaded.", iCount); } else if (iIndex == OPTION_TIME_STEP_GRAPH) { m_pTimeStepGraph->SetVisible(!m_pTimeStepGraph->IsVisible()); } #if defined(SUPPORTS_MULTITOUCH) else if (iIndex == OPTION_MULTITOUCH) { m_bTouchAreaDebug = !m_bTouchAreaDebug; } #endif else if (iIndex == OPTION_SAVE_SCREENSHOT) { m_bSaveScreenshot = true; // We don't want the menu to be visible in the screenshot VAppMenu* pMainMenu = GetParent()->GetAppModule<VAppMenu>(); if (pMainMenu != NULL) pMainMenu->SetVisible(false); } } iIndex = GetCallbackIndex(m_debugInfos, pData); if (iIndex >= 0) Vision::Profiling.ToggleDebugRenderFlags((unsigned int)iIndex); }