void MeshViewer::trace( const RayGenCameraData& camera_data ) { if (m_animation && GLUTDisplay::isBenchmark()) { static float angleU = 0.0f, angleV = 0.0f, scale = 1.0f, dscale = 0.96f, backside = 0.0f; static int phase = 0, accumed_frames = 0; const float maxang = M_PIf * 0.2f; const float rotvel = M_2_PIf*0.1f; float3 c = m_aabb.center(); float3 e = camera_data.eye; Matrix3x3 m = make_matrix3x3(Matrix4x4::rotate(angleV + backside, normalize(camera_data.V)) * Matrix4x4::rotate(angleU, normalize(camera_data.U)) * Matrix4x4::scale(make_float3(scale, scale, scale))); m_context["eye"]->setFloat( c-m*(c-e) ); m_context["U"]->setFloat( m*camera_data.U ); m_context["V"]->setFloat( m*camera_data.V ); m_context["W"]->setFloat( m*camera_data.W ); } else { 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 ); } //Buffer buffer = m_context["output_buffer"]->getBuffer(); //RTsize buffer_width, buffer_height; //buffer->getSize( buffer_width, buffer_height ); //float3 V = m_context["V"]->getFloat3(); //float pixel_size = V.y * (-(((0 / (float) HEIGHT) * 2.f) - ((1 / (float) HEIGHT) * 2.f))); //m_context["pixel_size"]->setFloat(pixel_size); //m_context->launch( 0, static_cast<unsigned int>(buffer_width), 1 ); Buffer buffer = m_context["output_buffer"]->getBuffer(); RTsize buffer_width, buffer_height; buffer->getSize( buffer_width, buffer_height ); float3 V = m_context["V"]->getFloat3(); float pixel_size = V.y * (-(((0 / (float) HEIGHT) * 2.f) - ((1 / (float) HEIGHT) * 2.f))); m_context["pixel_size"]->setFloat(pixel_size); m_context->launch( 0, WIDTH, HEIGHT); m_context->launch( 1, static_cast<unsigned int>(buffer_width), 1 ); }
Quaternion make_quaternion(const float4x4 &rot) { return make_quaternion(make_matrix3x3(rot)); }