I think I worked out this by myself. From the documentation here. I just used this code to initialise the viewer,
void Viewer::initializeGL()
{
QGLViewer::initializeGL();
this->setSceneRadius(10000.0);
}
But this sets the default scene camera too, if the radius is high, the default perspective's position is changed too, so this setSceneRadius is not only changing the near/far clipping plane.
Actually, there are different methods from the documentation here.
So this one maybe better. The formula to calculate the real near and far is in the documentation of the last link. Smaller near coef and larger Clipping coef means larger range of the viewing area.
void Viewer::initializeGL()
{
QGLViewer::initializeGL();
this->camera()->setZNearCoefficient(0.00001);
this->camera()->setZClippingCoefficient(1000.0);
}
Of course you can override your own version of near and far definition.
class myCamera :: public qglviewer::Camera
{
virtual float Camera::zNear() const { return 0.001; };
virtual float Camera::zFar() const { return 100.0; };
}
And construct your QGLViewer object with this customised camera.