bool App::onEvent(const GEvent& e) { if (viewer != NULL) { if (viewer->onEvent(e, this)) { // Viewer consumed the event return true; } } switch (e.type) { case GEventType::FILE_DROP: { Array<G3D::String> fileArray; window()->getDroppedFilenames(fileArray); setViewer(fileArray[0]); return true; } case GEventType::KEY_DOWN: if (e.key.keysym.sym == GKey::F5) { Shader::reloadAll(); return true; } else if (e.key.keysym.sym == GKey::F3) { showDebugText = ! showDebugText; return true; } else if (e.key.keysym.sym == GKey::F8) { Array<shared_ptr<Texture> > output; renderCubeMap(renderDevice, output, m_debugCamera, shared_ptr<Texture>(), 2048); const CubeMapConvention::CubeMapInfo& cubeMapInfo = Texture::cubeMapInfo(CubeMapConvention::DIRECTX); for (int f = 0; f < 6; ++f) { const CubeMapConvention::CubeMapInfo::Face& faceInfo = cubeMapInfo.face[f]; shared_ptr<Image> temp = Image::fromPixelTransferBuffer(output[f]->toPixelTransferBuffer(ImageFormat::RGB8())); temp->flipVertical(); temp->rotateCW(toRadians(90.0) * (-faceInfo.rotations)); if (faceInfo.flipY) { temp->flipVertical(); } if (faceInfo.flipX) { temp->flipHorizontal(); } temp->save(format("cube-%s.png", faceInfo.suffix.c_str())); } return true; } else if (e.key.keysym.sym == 'v') { // Event viewer if (isNull(dynamic_cast<EventViewer*>(viewer))) { setViewer("<events>"); return true; } } break; default:; } // Must call after processing events to prevent default .ArticulatedModel.Any file-drop functionality if (GApp::onEvent(e)) { return true; } return false; }
bool App::onEvent(const GEvent& e) { /** Explicitly not calling the base class' onEvent method because we do not want all of GApp's events (e.g its .am.any dropping) if (GApp::onEvent(e)) { return true; } */ if (viewer != NULL) { if (viewer->onEvent(e, this)) { // Viewer consumed the event return true; } } switch (e.type) { case GEventType::FILE_DROP: { Array<std::string> fileArray; window()->getDroppedFilenames(fileArray); setViewer(fileArray[0]); return true; } case GEventType::KEY_DOWN: if (e.key.keysym.sym == GKey::F3) { showDebugText = ! showDebugText; return true; } else if (e.key.keysym.sym == GKey::F8) { Array<shared_ptr<Texture> > output; renderCubeMap(renderDevice, output, m_debugCamera, shared_ptr<Texture>(), 2048); const Texture::CubeMapInfo& cubeMapInfo = Texture::cubeMapInfo(CubeMapConvention::DIRECTX); for (int f = 0; f < 6; ++f) { const Texture::CubeMapInfo::Face& faceInfo = cubeMapInfo.face[f]; shared_ptr<Image> temp = Image::fromPixelTransferBuffer(output[f]->toPixelTransferBuffer(ImageFormat::RGB8())); temp->flipVertical(); temp->rotateCW(toRadians(90.0) * (-faceInfo.rotations)); if (faceInfo.flipY) { temp->flipVertical(); } if (faceInfo.flipX) { temp->flipHorizontal(); } temp->save(format("cube-%s.png", faceInfo.suffix.c_str())); } return true; } else if (e.key.keysym.sym == 'v') { // Event viewer if (isNull(dynamic_cast<EventViewer*>(viewer))) { setViewer("<events>"); return true; } } break; default:; } return false; }
void Camera::renderingInstructions(VisualizationParameterSet& visParams) { // set some values graphicsManager->getShaderUsage(visParams); // prepare shadow maps while(graphicsManager->prepareLightForShadowMapping(visParams)) rootNode->quickDraw(); // prepare cube map graphicsManager->getShaderUsage(visParams); renderCubeMap(visParams); // prepare rendering glClearColor(clearColor[0], clearColor[1], clearColor[2], clearColor[3]); graphicsManager->prepareRendering(visParams, resolutionX, resolutionY, aspect, Functions::toDeg(angleY), minRange, maxRange, fbo_reg); // get motion blur values and clear view graphicsManager->setUpMotionBlurSettings(visParams); // do the motion blur render passes (if motion blur is off -> 1 pass) for(; visParams.mb_currentPass <= visParams.mb_renderPasses; visParams.mb_currentPass++) { // set the view graphicsManager->setPerspective(); setCamera(visParams); glClear(default_clear); // update light positions graphicsManager->updateLights(true, visParams.renderPasses == 2, visParams.provideUniforms); // prepare surface properties graphicsManager->renderEnvironment(maxRange); glCallList(graphicsManager->enableStateDL[visParams.surfaceStyle]); // render rootNode->draw(visParams); if(visParams.renderPasses == 2) { graphicsManager->updateLights(true, false, visParams.provideUniforms); rootNode->draw(visParams); } // undo surface properties glCallList(graphicsManager->disableStateDL[visParams.surfaceStyle]); graphicsManager->revertLightTextureUnits(visParams.provideUniforms); // load to accumulation buffer, blend with accumulation buffer or just do nothing (default) if(visParams.mb_useAccum && visParams.mb_currentPass == 1) glAccum(GL_LOAD, 1.0f/visParams.mb_renderPasses); else if(visParams.mb_useAccum) glAccum(GL_ACCUM, 1.0f/visParams.mb_renderPasses); // render post production and swap render targets if multi pass rendering with fbo usage graphicsManager->finishRendering(visParams, false); } // write back result if accum was used if(visParams.mb_useAccum) glAccum(GL_RETURN, 1.0f); glFlush(); }