查看: 1212|回复: 0

立体显示的代码,本人不是很懂,希望哪位高手能够帮忙解读一下,非常感谢!

[复制链接]

该用户从未签到

发表于 2014-3-20 10:59:12 | 显示全部楼层 |阅读模式
#include <osgDB/ReadFile>
#include <osgProducer/Viewer>
#include <osgGA/GUIEventHandler>
#include <osg/DisplaySettings>
osg:isplaySettings::StereoMode stereoMode[] =
{
osg:isplaySettings:UAD_BUFFER,
  osg:isplaySettings::ANAGLYPHIC,
  osg:isplaySettings::HORIZONTAL_SPLIT,
  osg:isplaySettings::VERTICAL_SPLIT,
  osg:isplaySettings:EFT_EYE,
  osg:isplaySettings::RIGHT_EYE,
  osg:isplaySettings::HORIZONTAL_INTERLACE,
  osg:isplaySettings::VERTICAL_INTERLACE
};
osg:isplaySettings:isplayType displayType[] =
{
osg::DisplaySettings::MONITOR,
  osg::DisplaySettings:OWERWALL,
  osg::DisplaySettings::REALITY_CENTER,
  osg::DisplaySettings::HEAD_MOUNTED_DISPLAY
};
class CMyGuiEvent : public osgGA::GUIEventHandler
{
public:
CMyGuiEvent(osg::DisplaySettings* pds)
  :_stereo(true)
  ,_stereoMode(0)
  ,_displayType(0)
  ,_eyeSeperation(0.05)
{
  if (!_pds)
  {
   _pds = new osg::DisplaySettings;
  }
  _pds = pds;
  _pds->setStereo(true);
  _pds->setEyeSeparation(_eyeSeperation);
}
bool handle(const osgGA::GUIEventAdapter& ea, osgGA::GUIActionAdapter& us)
{
  if (ea.getEventType() == osgGA::GUIEventAdapter::KEYDOWN)
  {
   switch(ea.getKey())
   {
   case osgGA::GUIEventAdapter::KEY_F1:
    _stereo = !_stereo;
    _pds->setStereo(_stereo);
    break;
   case osgGA::GUIEventAdapter::KEY_Left:
    if (_stereoMode==0)
     _stereoMode=6;
    else
     _stereoMode--;
    _pds->setStereoMode(stereoMode[_stereoMode]);
    us.requestContinuousUpdate();
    break;
   case osgGA::GUIEventAdapter::KEY_Right:
    if (_stereoMode==6)
     _stereoMode=0;
    else
     _stereoMode++;
    _pds->setStereoMode(stereoMode[_stereoMode]);
    break;
   case osgGA::GUIEventAdapter::KEY_Up:
    if (_displayType==3)
     _displayType=0;
    else
     _displayType++;
    _pds->setDisplayType(displayType[_displayType]);
    break;
   case osgGA::GUIEventAdapter::KEY_Down:
    if (_displayType==0)
     _displayType=3;
    else
     _displayType--;
    _pds->setDisplayType(displayType[_displayType]);
    break;
   case osgGA::GUIEventAdapter::KEY_KP_Add:
    _eyeSeperation += 0.01;
    _pds->setEyeSeparation(_eyeSeperation);
    break;
   case osgGA::GUIEventAdapter::KEY_KP_Subtract:
    _eyeSeperation -= 0.01;
    _pds->setEyeSeparation(_eyeSeperation);
    break;
   default:
    break;
   }
   return true;
  }
  return false;
}
private:
osg::DisplaySettings* _pds;
bool _stereo;
int _stereoMode;
int _displayType;
double _eyeSeperation;
};上面立体显示的代码,本人不是很懂,希望哪位高手能够帮忙解读一下,非常感谢!
您需要登录后才可以回帖 登录 | 注册

本版积分规则

OSG中国官方论坛-有您OSG在中国才更好

网站简介:osgChina是国内首个三维相关技术开源社区,旨在为国内更多的技术开发人员提供最前沿的技术资讯,为更多的三维从业者提供一个学习、交流的技术平台。

联系我们

  • 工作时间:09:00--18:00
  • 反馈邮箱:1315785073@qq.com
快速回复 返回顶部 返回列表