osgEarth worldToScreen

来源:互联网 发布:不干胶雕刻机软件 编辑:程序博客网 时间:2024/05/16 15:13

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
}
0 0