void CameraController::slot_entity_picked(ScenePicker::PickingResult result) { if (result.m_object_instance) { const GAABB3 object_instance_world_bbox = result.m_assembly_instance_transform.to_parent( result.m_object_instance->compute_parent_bbox()); m_pivot = Vector3d(object_instance_world_bbox.center()); } else { m_pivot = Vector3d(m_project.get_scene()->compute_bbox().center()); } }
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())); } }