图形设备接口GraphicsContext
GraphicsContext是任意图形子系统的抽象层接口,它提供了统一的图形设备操作函数,用来实现渲染结果和底层设备的交互;同时它还具有平台无关性,因而将OSG的渲染过程与操作系统平台剥离开来,使两者相互独立。用户即可以将渲染的内容传递给Windows或者X11的窗口与像素缓存对象,也可以自定义一个支持OpenGL的图形设备,并将结果反映在其上。
图像用户接口GUI
osgGA的事件处理器主要有两大部分组成,即事件适配器和动作适配器。osgGA:GUIEventHandler类主要提供了窗口系统的GUI事件接口,它使用osgGA:GUIEventAdapter实例来接收更新,使用osgGA:GUIActionAdapter实例向系统发出请求。
在osgGA:GUIEventHandler中包含了一系列的枚举事情类型,如NONE、PUSH(鼠标事件)、RELEASE (松开)、DOUBLECLICK2(双击)、DRAG(拖动)、MOVE(移动)、KEYDOWN(按键)、KEYUP(松开) 。
osgGA::GUIActionAdapter主要包含系统执行的动作,如重新绘制和光标重置之类的请求。
GUIActionAdapter &us
osg::View* view = us.asView();//get the osg::View associated with this GUIActionAdapter 。
enum CoordinateFrame
{
WINDOW,
PROJECTION,
VIEW,
MODEL
};
osgUtil::LineSegmentIntersector::CoordinateFrame cf= osgUtil::Intersector::WINDOW;
osg::ref_ptr< osgUtil::LineSegmentIntersector > picker = new osgUtil::LineSegmentIntersector( cf, x, y );
osgUtil::IntersectionVisitor iv( picker.get() );
camera->accept( iv );
//return on no intersections
if( !picker->containsIntersections() )
return false;
// get all intersections
osgUtil::LineSegmentIntersector::Intersections& intersections = picker->getIntersections();
osgUtil::LineSegmentIntersector::Intersections::iterator it;
for(it = intersections.begin(); it !=intersections.end(); it++ )
{
osg::Vec3d point = (*it).getWorldIntersectPoint();
std::cout<<"inter point ="<<point.x()<<","<<point.y()<<","<<point.z()<<std::endl;
}
return true;