void AssimpApp::draw() { gl::clear( Color::black() ); gl::setMatrices( mMayaCam.getCamera() ); gl::enableDepthWrite(); gl::enableDepthRead(); gl::color( Color::white() ); if ( mEnableWireframe ) gl::enableWireframe(); gl::Light light( gl::Light::DIRECTIONAL, 0 ); light.setAmbient( Color::white() ); light.setDiffuse( Color::white() ); light.setSpecular( Color::white() ); light.lookAt( Vec3f( 0, 5, -20 ), Vec3f( 0, 5, 0 ) ); light.update( mMayaCam.getCamera() ); light.enable(); gl::enable( GL_LIGHTING ); gl::enable( GL_NORMALIZE ); mAssimpLoader.draw(); gl::disable( GL_LIGHTING ); if ( mEnableWireframe ) gl::disableWireframe(); if ( mDrawBBox ) gl::drawStrokedCube( mAssimpLoader.getBoundingBox() ); params::InterfaceGl::draw(); }
void EpicMonsterApp::flockToBody() { if(timer.getSeconds() > mTimerSlower) { timer.stop(); timer.start(); gl::setMatricesWindow( mPPFbo.getSize(), false ); // false to prevent vertical flipping; mPPFbo.updateBind(); mBakeShader.bind(); mBakeShader.uniform( "positions", 0 ); mBakeShader.uniform( "scale", mNormalScale ); mBakeShader.uniform( "velocities", 1 ); mBakeShader.uniform( "n", n); mBakeShader.uniform( "attractorPos", mAttractor); mBakeShader.uniform( "offset", Vec3f(mParTexOffset.x, mParTexOffset.y, mParIteration)); glDisable(GL_CULL_FACE); mAssimpLoader.draw(); mBakeShader.unbind(); mPPFbo.updateUnbind(); mPPFbo.swap(); mParIteration+= triangles; if(mParIteration > (6*n.x*n.x)) mParIteration = 0; // TODO: baketuksessa overflowaa tyylikkäästi takaisin alkuun, jos menee yli } }
void EpicMonsterApp::draw() { gl::clear( Color::black() ); gl::setMatrices( mMayaCam.getCamera() ); gl::setViewport( getWindowBounds() ); gl::enableDepthWrite(); gl::enableDepthRead(); gl::color( Color::white() ); if ( mEnableWireframe ) gl::enableWireframe(); gl::Light light( gl::Light::DIRECTIONAL, 0 ); light.setAmbient( Color::white() ); light.setDiffuse( Color::white() ); light.setSpecular( Color::white() ); light.lookAt( Vec3f( 0, 0, 0 ), Vec3f( 0, 5, 0 ) ); light.update( mMayaCam.getCamera() ); light.enable(); gl::enable( GL_LIGHTING ); gl::enable( GL_NORMALIZE ); mAssimpLoader.draw(); mNormalMap.bind( 2 ); mPPFbo.bindTexture(0); mPPFbo.bindTexture(1); mDisplacementShader.bind(); mDisplacementShader.uniform("displacementMap", 0 ); mDisplacementShader.uniform("velocityMap", 1); mDisplacementShader.uniform("normalMap", 2); mDisplacementShader.uniform("fallDirection", mFallDirection); gl::draw( mVboMesh ); mDisplacementShader.unbind(); mPPFbo.unbindTexture(); if(mEnableDebugTexture) { gl::Texture tex = mPPFbo.getTexture(0); //console() << getWindowBounds(); gl::draw(tex, Rectf(-5.0f, -5.0f, 5.0f, 5.0f)); } //gl::setMatricesWindow(getWindowSize()); gl::drawString( toString( SIDE*SIDE ) + " vertices", Vec2f(32.0f, 32.0f)); gl::drawString( toString((int) getAverageFps()) + " fps", Vec2f(32.0f, 52.0f)); gl::disable( GL_LIGHTING ); if ( mEnableWireframe ) gl::disableWireframe(); mScreenSyphon.publishScreen(); //publish the screen params::InterfaceGl::draw(); }