void CannonBall::trace( const RayGenCameraData& camera_data ) { // Update Camera m_context["eye"]->setFloat( camera_data.eye ); m_context["U"]->setFloat( camera_data.U ); m_context["V"]->setFloat( camera_data.V ); m_context["W"]->setFloat( camera_data.W ); // Get new buffer optix::Buffer buffer = m_context["output_buffer"]->getBuffer(); RTsize buffer_width, buffer_height; buffer->getSize( buffer_width, buffer_height ); if(m_animate){ // Update PhysX if (gScene) StepPhysX(); // Update Geometry updateGeometry(); } m_context->launch( 0, static_cast<unsigned int>(buffer_width), static_cast<unsigned int>(buffer_height) ); }
// **OnRender** void kzsPhysXFramework::OnRender() { totalFrames++; int current = glutGet( GLUT_ELAPSED_TIME ); if ( (current - startTime ) > 1000 ) { float elapsedTime = float ( current - startTime ); fps = ( ( totalFrames * 1000.0f ) / elapsedTime ); startTime = current; totalFrames = 0; } if ( gScene ) StepPhysX(); glClearColor( 0.1f, 0.1f, 0.1f, 1.0f ); glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); glLoadIdentity(); glutSwapBuffers(); }