void Base3DView::frameAll() { Vector3F coi = sceneCenter(); Vector3F eye = coi + Vector3F(0.f, 0.f, 100.f); getCamera()->lookFromTo(eye, coi); }
void TrackballViewer::resetCamera() { // assume only one dispObjects MainCanvas exist here Bound* scene_bounds = dynamic_cast<TrackballCanvas*>(dispObjects[0])->getBoundBox(); qglviewer::Vec scene_center; scene_center = qglviewer::Vec((scene_bounds->minX + scene_bounds->maxX) / 2, (scene_bounds->minY + scene_bounds->maxY) / 2, (scene_bounds->minZ + scene_bounds->maxZ) / 2); setSceneCenter(scene_center); float x_span = (scene_bounds->maxX - scene_bounds->minX) / 2; float y_span = (scene_bounds->maxY - scene_bounds->minY) / 2; float z_span = (scene_bounds->maxZ - scene_bounds->minZ) / 2; float scene_radius = x_span>y_span ? (x_span > z_span ? x_span : z_span) : (y_span > z_span ? y_span : z_span); scene_radius *= 1.5; setSceneRadius(scene_radius); camera()->fitSphere(scene_center, scene_radius); setStateFileName(QString((dynamic_cast<TrackballCanvas*>(dispObjects[0])->getFilePath()+"/camera_info.xml").c_str())); if (restoreStateFromFile()) std::cout << "Load camera info successes...\n"; else std::cout << "Load camera info failed...\n"; // set the scene in MainCanvasViewer syncCamera(); main_canvas_viewer->setSceneCenter(sceneCenter()); main_canvas_viewer->setSceneRadius(sceneRadius()); main_canvas_viewer->camera()->setZClippingCoefficient(camera()->zClippingCoefficient()); }
void Base3DView::resetView() { getCamera()->reset(sceneCenter()); if(getCamera()->isOrthographic()) updateOrthoProjection(); else updatePerspProjection(); }
void Viewer::render_video() { setSnapshotFormat("PNG"); for (int alpha=0 ; alpha <= 100 ; alpha++ ) { emit (valueChanged(alpha)); std::cout<<alpha<<std::endl; QString alpha_str; alpha_str.setNum(alpha); displayMessage(QString("alpha: ") + alpha_str + QString("%"),10000); for (int fr=0 ; fr < 50 ; fr++) { Vec cam = camera()->position(); Vec ori = sceneCenter(); Vec new_cam = next_around_circle(0.01f,cam,ori); camera()->setPosition(new_cam); camera()->lookAt(ori); this->showEntireScene(); saveSnapshot(true); } } }
virtual void init(){ restoreStateFromFile(); glDisable(GL_LIGHTING); setGridIsDrawn(false); //help(); setAnimationPeriod(0); // fast as possible startAnimation(); showEntireScene(); // Make world axis visible setAxisIsDrawn(true); // Move camera according to viewer type (on X, Y or Z axis) camera()->setPosition(qglviewer::Vec(2.0,2.0,2.0)); camera()->setUpVector(qglviewer::Vec(0.0,0.0,1.0)); camera()->lookAt(sceneCenter()); /* // Forbid rotation qglviewer::WorldConstraint* constraint = new qglviewer::WorldConstraint(); constraint->setRotationConstraintType(qglviewer::AxisPlaneConstraint::FORBIDDEN); camera()->frame()->setConstraint(constraint); */ }
void resizeEvent() { helpItem->setPos(QPointF(sceneCenter().toPoint())); }