osgEarth worldToScreen


const osg::Camera * cam = view()->getCamera();
const osg::Viewport * viewport = cam->getViewport();
osg::Matrixd windowMatrix = viewport->computeWindowMatrix();
osg::Matrixd viewProjectionWindowMatrix = cam->getViewMatrix() * cam->getProjectionMatrix() * windowMatrix;

osg::Vec3d v3 = position * viewProjectionWindowMatrix;
if(viewport->x() < v3.x() && v3.x() < viewport->x() + viewport->width() &&
viewport->y() < v3.y() && v3.y() < viewport->y() + viewport->height())
{
        // trigger repaint here
}
else
{
// not inside the window
}

你可能感兴趣的:(osgEarth worldToScreen)