#include<Windows.h>
#include <osgViewer/Viewer>
#include <osgDB/ReadFile>
#include <osgGA/GUIEventHandler>
#include <osgFX/Outline>
#include<osgViewer/ViewerEventHandlers>
//osgGA相关的库
#include<osgGA/StateSetManipulator>
class nodePick :public osgGA::GUIEventHandler
{
virtual bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& aa)
{
osgViewer::Viewer *viewer = dynamic_cast<osgViewer::Viewer*> (&aa);
switch (ea.getEventType())
{
case osgGA::GUIEventAdapter::PUSH:
{
//存储点选到的节点所在的分支上
osgUtil::LineSegmentIntersector::Intersections intersections;
osg::ref_ptr<osg::Node> node = new osg::Node;
if (viewer->computeIntersections(ea.getX(), ea.getY(), intersections))
{
//得到选择的节点
osgUtil::LineSegmentIntersector::Intersection intersection = *intersections.begin();
//每一个分支,包含所点击的节点及其父节点
osg::NodePath& nodePath =
osg模型点选高亮切换
于 2022-04-01 15:33:38 首次发布