本文整理汇总了C++中osg::observer_ptr::addEventHandler方法的典型用法代码示例。如果您正苦于以下问题:C++ observer_ptr::addEventHandler方法的具体用法?C++ observer_ptr::addEventHandler怎么用?C++ observer_ptr::addEventHandler使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类osg::observer_ptr
的用法示例。
在下文中一共展示了observer_ptr::addEventHandler方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: create
void Scene::create()
{
_oneSidedProgram = new osg::Program;
_oneSidedProgram->addShader(osgDB::readShaderFile(osg::Shader::VERTEX, "data/diffuse_directional1_vs.glsl"));
_oneSidedProgram->addShader(osgDB::readShaderFile(osg::Shader::FRAGMENT, "data/diffuse_directional1_fs.glsl"));
_twoSidedProgram = new osg::Program;
_twoSidedProgram->addShader(osgDB::readShaderFile(osg::Shader::VERTEX, "data/diffuse_directional2_vs.glsl"));
_twoSidedProgram->addShader(osgDB::readShaderFile(osg::Shader::FRAGMENT, "data/diffuse_directional2_fs.glsl"));
_instancedProgram = new osg::Program;
_instancedProgram->addShader(osgDB::readShaderFile(osg::Shader::VERTEX, "data/diffuse_billboard_instanced_vs.glsl"));
_instancedProgram->addShader(osgDB::readShaderFile(osg::Shader::FRAGMENT, "data/diffuse_billboard_instanced_fs.glsl"));
createPolyhedronNode();
createVertexNode();
createTextNode();
onPolyhedronChanged();
onLightModelChanged();
osg::ref_ptr<osgGA::LambdaEventHandler> eventHandler = new osgGA::LambdaEventHandler;
eventHandler->onKeyDown([&](const osgGA::GUIEventAdapter& ea) {
auto key = ea.getKey();
auto num = key - osgGA::GUIEventAdapter::KEY_0;
if (0 <= num && num <= 9)
{
_faces ^= osgKaleido::PolyhedronGeometry::FaceMaskFromSides(wild::mod(num-1, 10) + 3);
onFaceMaskChanged();
return true;
}
switch (key)
{
case osgGA::GUIEventAdapter::KEY_V:
{
_vgeode->setNodeMask(~_vgeode->getNodeMask());
return true;
}
case osgGA::GUIEventAdapter::KEY_L:
{
_twoSided = !_twoSided;
onLightModelChanged();
return true;
}
case osgGA::GUIEventAdapter::KEY_Right:
{
_faces = osgKaleido::PolyhedronGeometry::All;
_index++;
onPolyhedronChanged();
return true;
}
case osgGA::GUIEventAdapter::KEY_Left:
{
_faces = osgKaleido::PolyhedronGeometry::All;
_index--;
onPolyhedronChanged();
return true;
}
default:
return false;
}
});
_viewer->addEventHandler(eventHandler);
}