void CGlWidget::updateMinimapPos() { if (!m_is2D) return; GLint win_dims[4]; glGetIntegerv(GL_VIEWPORT, win_dims); COpenGLViewport::Ptr miniMap = getOpenGLSceneRef()->getViewport("miniMap"); float w = m_miniMapSize / win_dims[2]; float h = m_miniMapSize / win_dims[3]; miniMap->setViewportPosition(0.01, 0.01, w, h); }
void CDifodoDatasets::initializeScene() { CPose3D rel_lenspose(0, -0.022, 0, 0, 0, 0); global_settings::OCTREE_RENDER_MAX_POINTS_PER_NODE(1000000); window.resize(1000, 900); window.setPos(900, 0); window.setCameraZoom(16); window.setCameraAzimuthDeg(0); window.setCameraElevationDeg(90); window.setCameraPointingToPoint(0, 0, 0); window.setCameraPointingToPoint(0, 0, 1); scene = window.get3DSceneAndLock(); // Lights: scene->getViewport()->setNumberOfLights(1); CLight& light0 = scene->getViewport()->getLight(0); light0.light_ID = 0; light0.setPosition(0, 0, 1, 1); // Grid (ground) CGridPlaneXY::Ptr ground = mrpt::make_aligned_shared<CGridPlaneXY>(); scene->insert(ground); // Reference // CSetOfObjects::Ptr reference = stock_objects::CornerXYZ(); // scene->insert( reference ); // Cameras and points //------------------------------------------------------ // DifOdo camera CBox::Ptr camera_odo = mrpt::make_aligned_shared<CBox>( math::TPoint3D(-0.02, -0.1, -0.01), math::TPoint3D(0.02, 0.1, 0.01)); camera_odo->setPose(cam_pose + rel_lenspose); camera_odo->setColor(0, 1, 0); scene->insert(camera_odo); // Groundtruth camera CBox::Ptr camera_gt = mrpt::make_aligned_shared<CBox>( math::TPoint3D(-0.02, -0.1, -0.01), math::TPoint3D(0.02, 0.1, 0.01)); camera_gt->setPose(gt_pose + rel_lenspose); camera_gt->setColor(1, 0, 0); scene->insert(camera_gt); // Frustum opengl::CFrustum::Ptr FOV = mrpt::make_aligned_shared<opengl::CFrustum>( 0.3f, 2, 57.3f * fovh, 57.3f * fovv, 1.f, true, false); FOV->setColor(0.7, 0.7, 0.7); FOV->setPose(gt_pose); scene->insert(FOV); // Reference gt CSetOfObjects::Ptr reference_gt = stock_objects::CornerXYZ(); reference_gt->setScale(0.2f); reference_gt->setPose(gt_pose); scene->insert(reference_gt); // Camera points CPointCloudColoured::Ptr cam_points = mrpt::make_aligned_shared<CPointCloudColoured>(); cam_points->setColor(1, 0, 0); cam_points->setPointSize(2); cam_points->enablePointSmooth(1); cam_points->setPose(cam_pose); scene->insert(cam_points); // Trajectories and covariance //------------------------------------------------------------- // Dif Odometry CSetOfLines::Ptr traj_lines_odo = mrpt::make_aligned_shared<CSetOfLines>(); traj_lines_odo->setLocation(0, 0, 0); traj_lines_odo->setColor(0, 0.6, 0); traj_lines_odo->setLineWidth(6); scene->insert(traj_lines_odo); CPointCloud::Ptr traj_points_odo = mrpt::make_aligned_shared<CPointCloud>(); traj_points_odo->setColor(0, 0.6, 0); traj_points_odo->setPointSize(4); traj_points_odo->enablePointSmooth(1); scene->insert(traj_points_odo); // Groundtruth CSetOfLines::Ptr traj_lines_gt = mrpt::make_aligned_shared<CSetOfLines>(); traj_lines_gt->setLocation(0, 0, 0); traj_lines_gt->setColor(0.6, 0, 0); traj_lines_gt->setLineWidth(6); scene->insert(traj_lines_gt); CPointCloud::Ptr traj_points_gt = mrpt::make_aligned_shared<CPointCloud>(); traj_points_gt->setColor(0.6, 0, 0); traj_points_gt->setPointSize(4); traj_points_gt->enablePointSmooth(1); scene->insert(traj_points_gt); // Ellipsoid showing covariance math::CMatrixFloat33 cov3d = 20.f * est_cov.topLeftCorner(3, 3); CEllipsoid::Ptr ellip = mrpt::make_aligned_shared<CEllipsoid>(); ellip->setCovMatrix(cov3d); ellip->setQuantiles(2.0); ellip->setColor(1.0, 1.0, 1.0, 0.5); ellip->enableDrawSolid3D(true); ellip->setPose(cam_pose + rel_lenspose); scene->insert(ellip); // User-interface information utils::CImage img_legend; img_legend.loadFromXPM(legend_xpm); COpenGLViewport::Ptr legend = scene->createViewport("legend"); legend->setViewportPosition(20, 20, 332, 164); legend->setImageView(img_legend); window.unlockAccess3DScene(); window.repaint(); }