void BrainbowApp::draw() { gl::setViewport( getWindowBounds() ); // SCREENPULSE // changes every 12.5 seconds float gray = (cos(getElapsedSeconds()/4)*.3)/2 ; float otherCol = (sin(getElapsedSeconds()/4)*.2)/2; screenCol = Vec3f (lightFade+gray, lightFade, (lightFade*2)-otherCol); if (sceneOne) gl::clear( Color(lightFade+gray, lightFade, (lightFade*2)-otherCol) ); if (sceneTwo) gl::clear( Color(1, 1, 1) ); // FADE IN INTRO if (lightFade < .5){ lightFade += .0005; } if (mHands.empty()) mLight->disable(); updateShadowMap(); gl::enableDepthRead(); gl::enableDepthWrite(); mShader.bind(); glEnable( GL_TEXTURE_2D ); mDepthFbo.bindDepthTexture(); mShader.bind(); // FIRST SCENE if (sceneOne){ // disc if (zshift > 0){ glPushMatrix(); glTranslated( 640, 400, zshift - 200); if (shift2 && discOp > 1) glScalef(discOp, discOp, 0); // cout << discOp << endl; mDisc.draw(); glPopMatrix(); } //cloud glPushMatrix(); glTranslated( getWindowWidth() * 0.5f, getWindowHeight() * 0.5f, zshift ); // if (lightFade > .45f) mCloud.update(scaledX, scaledY, scaledZ, diamondFade, 1); glPopMatrix(); if (drawDiamond){ glPushMatrix(); glTranslated( getWindowWidth() * 0.5f, getWindowHeight() * 0.5f, zshift); mDiamond.draw(); glPopMatrix(); } } // SECOND SCENE if (sceneTwo){ mLight->lookAt( Vec3f(scaledX, scaledY, scaledZ +200), Vec3f (getWindowWidth()*.05, getWindowHeight() * 0.5f, 0.0f )); // cursor glPushMatrix(); glTranslated( scaledX, scaledY, scaledZ ); mCur.draw(); if (scaledZ < 375 && scaledZ > 350) gl::drawSphere(Vec3f(0,0,0), (scaledZ-350)*.4); if (scaledZ >= 375) gl::drawSphere(Vec3f(0,0,0), 25*.4); glPopMatrix(); // rotate whole scene; implement this later: // if (targetFilled){ // glPushMatrix(); // glRotatef(getElapsedSeconds()*10, Vec3f (640, 400, 350) ); // } for (int i = 0; i < cubes.size() ; i++){ glPushMatrix(); glTranslatef(cubes[i].getLocation()); cubes[i].update(.01f, screenCol); glPopMatrix(); } offCounter = 0; for (int i = 0; i < targets.size() ; i++){ glPushMatrix(); glTranslatef(targets[i].getLocation()); targets[i].update(.01f, handPos, screenCol); if (targets[i].getBoxed() && targets[i].getBoxNumber() < 15 ){ addCube(targets[i].getLocation().x, targets[i].getLocation().y, targets[i].getLocation().z); targets[i].addBox(); if (targets[i].getBoxNumber() == 15) mAudio.playTraz("box"); } glPopMatrix(); if (targets[i].getChargeSound()){ if (!mAudio.isPlaying("charge")){ offCounter = 0; mAudio.playTraz("charge"); } } //stop charge if deactivated if (!targets[i].getChargeSound()){ offCounter++; } if (offCounter == targets.size()){ mAudio.stopTraz("charge"); } } // (from above) // if (targetFilled) // glPopMatrix(); // //cloud glPushMatrix(); glTranslated( getWindowWidth() * 0.5f, getWindowHeight() * 0.5f, zshift ); mCloud.update(0, 0, 0, 0, 2); glPopMatrix(); } mShader.unbind(); mDepthFbo.unbindTexture(); // writeImage( getHomeDirectory() / ("image_" + toString( getElapsedFrames() ) + ".png"), copyWindowSurface() ); }
void MeshViewApp::draw() { // Clear the window gl::clear(); gl::color(Color::white()); if(isInitialized()) { // Get ready to draw in 3D gl::pushMatrices(); gl::setMatrices(m_camera); gl::enableDepthRead(); gl::enableDepthWrite(); // Bind textures if(m_texDiffuse) m_texDiffuse->enableAndBind(); if (m_texNormal) m_texNormal->bind(1); if (m_texSpecular) m_texSpecular->bind(2); if(m_texAO) m_texAO->bind(3); if(m_texEmissive) m_texEmissive->bind(4); // Bind shader m_shader->bind(); m_shader->uniform("texDiffuse", 0); m_shader->uniform("texNormal", 1); m_shader->uniform("texSpecular", 2); m_shader->uniform("texAO", 3); m_shader->uniform("texEmissive", 4); m_shader->uniform("texDiffusePower", m_texDiffusePower); m_shader->uniform("texNormalPower", m_texNormalPower); m_shader->uniform("texSpecularPower", m_texSpecularPower); m_shader->uniform("texAOPower", m_texAOPower); m_shader->uniform("texEmissivePower", m_texEmissivePower); m_shader->uniform("diffuseEnabled", m_diffuseEnabled); m_shader->uniform("normalEnabled", m_normalEnabled); m_shader->uniform("specularEnabled", m_specularEnabled); m_shader->uniform("aoEnabled", m_aoEnabled); m_shader->uniform("emissiveEnabled", m_emissiveEnabled); m_shader->uniform("material.Ka", m_matAmbient); m_shader->uniform("material.Kd", m_matDiffuse); m_shader->uniform("material.Ks", m_matSpecular); m_shader->uniform("material.Shininess", m_matShininess); m_shader->uniform("gamma", m_gamma); // Enable lights m_light1->enable(); m_light2->enable(); // Render model gl::pushModelView(); gl::multModelView(m_matrix); m_assimpLoader.draw(); gl::popModelView(); // Disable lights m_light1->disable(); m_light2->disable(); // Unbind shader m_shader->unbind(); // Unbind textures gl::disable(m_texDiffuse->getTarget()); // Disable 3D rendering gl::disableDepthWrite(); gl::disableDepthRead(); // Restore matrices gl::popMatrices(); // Enable 2D rendering gl::setMatricesWindow(getWindowSize()); gl::setViewport(getWindowBounds()); // Render parameter window if(m_params) m_params->draw(); } // Render debug information Debug::get().draw(ColorAf::white()); }