void DemoInputInterpreter::interpretInput(Mouse* mouse) { //static bool hideMouse= false; if(mouse->isHidden() != mHideMouse) { mouse->setHidden(mHideMouse); } if(mouse->getRecentEvent() == Mouse::MOUSE_EVENT_BUTTON_CHANGED) { if(mouse->getRecentButton() == GLFW_MOUSE_BUTTON_LEFT ) { // if(mouse->getRecentButtonStatus() == GLFW_PRESS) // { // LOG<<DEBUG_LOG_LEVEL<<"left mouse button pressed;\n"; // } // else // { // LOG<<DEBUG_LOG_LEVEL<<"left mouse button released;\n"; // } } // if(mouse->getRecentButton() == GLFW_MOUSE_BUTTON_RIGHT ) // { // if(mouse->getRecentButtonStatus() == GLFW_PRESS) // { // //LOG<<DEBUG_LOG_LEVEL<<"right mouse button pressed; toggling mouse hide status;\n"; // hideMouse = !hideMouse; // mouse->setHidden(hideMouse); // } // else // { // // } // } } else { if( (mouse->getRecentEvent() == Mouse::MOUSE_EVENT_POSITION_CHANGED) && (mouse->isHidden()) ) { // LOG<<DEBUG_LOG_LEVEL<<"mouse moved from (" // <<mouse->getLastPosition().x // <<"," // <<mouse->getLastPosition().y // <<") to (" // <<mouse->getRecentPosition().x // <<"," // <<mouse->getRecentPosition().y // <<");\n" // ; Camera* mainCamera = //SimulationResourceManager::getInstance().getMainCamera(); URE_INSTANCE->getCurrentlyActiveCamera(); // getSimulator(VISUAL_SIM_DOMAIN)->toLightingSimulator()->getMainCamera(); //Matrix4x4 lookAtMatrix = mainCamera->getViewMatrix(); float differenceHorizontal = static_cast<float>(mouse->getRecentPosition().x - mouse->getLastPosition().x); float differenceVertical = static_cast<float>(mouse->getRecentPosition().y - mouse->getLastPosition().y); //self made initial sensivity rule of thumb: moving the mouse about half the screen //shall rotate the view about 90 degrees (pi/2); we assume a screen size of 1600*1600 //pixels for this rule of thumb: a compromize between full hd and notebook displays ("HD ready ;( ) //4* half thumbrule screen size= 4* 1600 / 2: const float pixelsCausingFullRotation = 3200.0f; float degreesToYaw = (-360.0f / pixelsCausingFullRotation) * differenceHorizontal * mCameraLookMouseSensivity; //negative as mouse coord go from top to bottom float degreesToPitch = (-360.0f / pixelsCausingFullRotation) * differenceVertical * mCameraLookMouseSensivity; mainCamera->getGlobalTransform().yawRelativeToUpVector(degreesToYaw); mainCamera->getGlobalTransform().pitchRelativeToDirection(degreesToPitch); } else { if(mouse->getRecentEvent() == Mouse::MOUSE_EVENT_WHEEL_CHANGED) { WindowManager::getInstance().setWindowPosition( Vector2Di(mouse->getRecentWheelValue()+100, 500)); } } } }
bool ParticleLiquidDrawStage::stepSimulation() throw(SimulatorException) { URE_INSTANCE->getSimulator(VISUAL_SIM_DOMAIN)->toLightingSimulator()->getMainCamera() ->setGLViewPort( Vector2Di(0,0), Vector2Di(WindowManager::getInstance().getWindowResolution()) ); // if(! mRenderToScreen) // { // //render to FBO // mUsedRenderTarget->bind(); // RenderTarget::setEnableDepthTest(true); // mUsedRenderTarget->attachStoredColorTexture(FINAL_RENDERING_SEMANTICS,0); // mUsedRenderTarget->renderToAttachedTextures(); // } //TODO continue //ensure that render target is unbound so that it's not used on accident by following stages RenderTarget::renderToScreen(); //TODO maybe clear srceen? should actualle be done by dimulator at the beginning... //-------------------------------------------------- //TEST: just render the result from previous stage as texture show to test the render target stuff //enable the texture show shader with the respective texture bound RenderTarget* rt = dynamic_cast<LightingSimStageBase*>( URE_INSTANCE->getSimulator(VISUAL_SIM_DOMAIN) ->getStage("DefaultLightingStage"))->getUsedRenderTarget(); assert(rt); Texture* renderingOfDefaultLightingStage = dynamic_cast<Texture*>( URE_INSTANCE->getSimulator(VISUAL_SIM_DOMAIN) ->getStage("DefaultLightingStage")->getRenderingResult(FINAL_RENDERING_SEMANTICS) ); assert("The DefaultLightingStage must expose a Texture with final rendering semantics! " && renderingOfDefaultLightingStage); //render to FBO rt->bind(); rt->detachAllColorTextures(); //free from previous stage's relicts rt->attachColorTexture(mCompositedRendering,0); //attach own texture RenderTarget::setEnableDepthTest(true); rt->attachStoredDepthBuffer(); rt->renderToAttachedTextures(); //haxx: just copy the texture to have both an image to sample from //and to amend by direct fluid rendering mTextureShowShader->use(renderingOfDefaultLightingStage); WindowManager::getInstance().drawFullScreenQuad(); RenderTarget::setEnableDepthTest(true); //now, render fluid onto the just copied texture; //again: this hack is needed to have a consistent depth buffer! int numCurrentFluids = dynamic_cast<ParticleMechanicsStage*>( URE_INSTANCE->getSimulator(MECHANICAL_SIM_DOMAIN) ->getStage("ParticleMechanicsStage") )->getParticleSceneRepresentation() ->getNumCurrentFluids(); for(int i=0; i< numCurrentFluids; i++) { ParticleFluid* fluid = dynamic_cast<ParticleMechanicsStage*>( URE_INSTANCE->getSimulator(MECHANICAL_SIM_DOMAIN) ->getStage("ParticleMechanicsStage") )->getParticleSceneRepresentation() ->getFluid(i); assert( ! fluid->getSubObjects(VISUAL_SIM_DOMAIN).empty()); SubObject* so = fluid->getSubObjects(VISUAL_SIM_DOMAIN)[0]; ParticleLiquidVisualMaterial* mat = dynamic_cast<ParticleLiquidVisualMaterial*>(so->getMaterial()); assert(mat); RenderTarget::setEnableDepthTest(true); mat->mCompositionShader->use(so); so->getGeometry()->draw(); //draw fullscreenquad //WindowManager::getInstance().drawFullScreenQuad(); } //now, just show the result rendered into the FBO //damn, so many useless copies, but time pressure is forcing me to do so... RenderTarget::renderToScreen(); mTextureShowShader->use(mCompositedRendering); WindowManager::getInstance().drawFullScreenQuad(); //------------------- return true; }