Added AdjustSphereSegmentCallback to provide '<' and '>' key controls over the azim and elev range of the sphere segment
This commit is contained in:
parent
a87a6f0851
commit
a1ab1a0ecc
@ -354,6 +354,51 @@ osg::Vec3 computeTerrainIntersection(osg::Node* subgraph,float x,float y)
|
||||
}
|
||||
|
||||
|
||||
class AdjustSphereSegmentCallback : public osgGA::GUIEventHandler
|
||||
{
|
||||
public:
|
||||
void scaleSphereSegment(osgSim::SphereSegment* ss, float scale)
|
||||
{
|
||||
if (!ss) return;
|
||||
|
||||
|
||||
osg::Vec3 direction_vec;
|
||||
float azRange, elevRange;
|
||||
ss->getArea(direction_vec, azRange, elevRange);
|
||||
|
||||
OSG_NOTICE<<std::endl<<"AdjustSphereSegmentCallback : scaling azRange"<<azRange<<", scale="<<scale<<std::endl;
|
||||
ss->setArea(direction_vec, azRange*scale, elevRange*scale);
|
||||
}
|
||||
|
||||
virtual bool handle(const osgGA::GUIEventAdapter& ea,osgGA::GUIActionAdapter& /*aa*/, osg::Object* object, osg::NodeVisitor* /*nv*/)
|
||||
{
|
||||
if (ea.getHandled()) return false;
|
||||
|
||||
switch(ea.getEventType())
|
||||
{
|
||||
case(osgGA::GUIEventAdapter::KEYDOWN):
|
||||
{
|
||||
if (ea.getKey()=='>')
|
||||
{
|
||||
scaleSphereSegment(dynamic_cast<osgSim::SphereSegment*>(object), 1.1f);
|
||||
return true;
|
||||
}
|
||||
else if (ea.getKey()=='<')
|
||||
{
|
||||
scaleSphereSegment(dynamic_cast<osgSim::SphereSegment*>(object), 1.0f/1.1f);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
// MAIN SCENE GRAPH BUILDING FUNCTION
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
@ -605,6 +650,8 @@ void build_world(osg::Group *root, unsigned int testCase, bool useOverlay, osgSi
|
||||
ss->getParent(0)->addChild(ss->computeIntersectionSubgraph(terrainToSS, terrainGeode.get()));
|
||||
}
|
||||
|
||||
ss->setEventCallback(new AdjustSphereSegmentCallback);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user