Example #1
0
double Scene::compute_radius() const
{
    double square_radius = 0.0;
    const GAABB3 bbox = compute_bbox();

    if (bbox.is_valid())
    {
        for (size_t i = 0; i < 8; ++i)
        {
            const double square_distance =
                static_cast<double>(square_norm(bbox.compute_corner(i)));

            square_radius = max(square_radius, square_distance);
        }
    }

    return sqrt(square_radius);
}
Example #2
0
SPPMPassCallback::SPPMPassCallback(
    const Scene&            scene,
    const LightSampler&     light_sampler,
    const TraceContext&     trace_context,
    TextureStore&           texture_store,
#ifdef APPLESEED_WITH_OIIO
    OIIO::TextureSystem&    oiio_texture_system,
#endif
#ifdef APPLESEED_WITH_OSL
    OSL::ShadingSystem&     shading_system,
#endif
    const SPPMParameters&   params)
  : m_params(params)
  , m_photon_tracer(
        scene,
        light_sampler,
        trace_context,
        texture_store,
#ifdef APPLESEED_WITH_OIIO
        oiio_texture_system,
#endif
#ifdef APPLESEED_WITH_OSL
        shading_system,
#endif
        params)
  , m_pass_number(0)
{
    // Compute the initial lookup radius.
    const GAABB3 scene_bbox = scene.compute_bbox();
    const float scene_diameter =
        scene_bbox.is_valid()
            ? static_cast<float>(scene_bbox.diameter())
            : 0.0f;
    const float diameter_factor = m_params.m_initial_radius_percents / 100.0f;
    m_initial_lookup_radius = scene_diameter * diameter_factor;

    // Start with the initial lookup radius.
    m_lookup_radius = m_initial_lookup_radius;
}
void CameraController::configure_controller(const Scene* scene)
{
    Camera* camera = m_scene->get_camera();

    // Set the controller orientation and position based on the scene camera.
    m_controller.set_transform(
        camera->transform_sequence().get_earliest_transform().get_local_to_parent());

    if (camera->get_parameters().strings().exist("controller_target"))
    {
        // The camera already has a target position, use it.
        m_controller.set_target(
            camera->get_parameters().get_optional<Vector3d>(
                "controller_target",
                Vector3d(0.0)));
    }
    else
    {
        // Otherwise, if the scene is not empty, use its center as the target position.
        const GAABB3 scene_bbox = scene->compute_bbox();
        if (scene_bbox.is_valid())
            m_controller.set_target(Vector3d(scene_bbox.center()));
    }
}
Example #4
0
GAABB3 Scene::compute_bbox() const
{
    const AssemblyInstanceContainer& instances = assembly_instances();
    const GAABB3 bbox = compute_parent_bbox<GAABB3>(instances.begin(), instances.end());
    return bbox.is_valid() ? bbox : GAABB3(GVector3(0.0f), GVector3(0.0f));
}