TEST(OsgViewElementRenderTest, StereoView)
{
	std::shared_ptr<Runtime> runtime = std::make_shared<Runtime>();
	std::shared_ptr<OsgManager> manager = std::make_shared<OsgManager>();

	runtime->addManager(manager);
	runtime->addManager(std::make_shared<SurgSim::Framework::BehaviorManager>());

	std::shared_ptr<Scene> scene = runtime->getScene();

	/// Add a graphics component to the scene
	std::shared_ptr<OsgViewElement> viewElement = std::make_shared<OsgViewElement>("view");

	auto boxElement = std::make_shared<SurgSim::Framework::BasicSceneElement>("box");

	RigidTransform3d pose =
		makeRigidTransform(Vector3d(1.0, 1.0, 1.0), Vector3d(0.0, 0.0, 0.0), Vector3d(0.0, 1.0, 0.0));
	viewElement->setPose(pose);
	scene->addSceneElement(viewElement);

	auto box = std::make_shared<OsgBoxRepresentation>("box");
	box->setSizeXYZ(0.1, 0.1, 0.2);
	boxElement->addComponent(box);

	RigidTransform3d from =
		makeRigidTransform(Vector3d(0.2, 0.0, 0.0), Vector3d(0.0, 0.0, 0.0), Vector3d(0.0, 1.0, 0.0));
	RigidTransform3d to =
		makeRigidTransform(Vector3d(-0.2, 0.0, 0.0), Vector3d(0.0, 0.0, 0.0), Vector3d(0.0, 1.0, 0.0));
	auto interpolator = std::make_shared<SurgSim::Blocks::PoseInterpolator>("interpolator");

	interpolator->setDuration(2.0);
	interpolator->setStartingPose(from);
	interpolator->setEndingPose(to);
	interpolator->setPingPong(true);
	interpolator->setTarget(boxElement);

	boxElement->addComponent(interpolator);

	scene->addSceneElement(boxElement);

	auto osgView = std::static_pointer_cast<OsgView>(viewElement->getView());
	osgView->setStereoMode(View::STEREO_MODE_HORIZONTAL_SPLIT);
	osgView->setDisplayType(View::DISPLAY_TYPE_MONITOR);
	osgView->setEyeSeparation(0.06);
	osgView->setScreenWidth(0.486918);
	osgView->setScreenHeight(0.273812);
	osgView->setScreenDistance(1.0);


	runtime->start();
	boost::this_thread::sleep(boost::posix_time::milliseconds(1000));
	runtime->stop();
}
void QgsGlobePluginDialog::setStereoConfig()
{
  mViewer->getDatabasePager()->clear();
  //SETTING THE VALUES IN THE OEGearth instance
  setStereoMode();
  osg::DisplaySettings::instance()->setScreenDistance( screenDistance->value() );
  osg::DisplaySettings::instance()->setScreenWidth( screenWidth->value() );
  osg::DisplaySettings::instance()->setScreenHeight( screenHeight->value() );
  osg::DisplaySettings::instance()->setEyeSeparation( eyeSeparation->value() );
  osg::DisplaySettings::instance()->setSplitStereoHorizontalSeparation( splitStereoHorizontalSeparation->value() );
  osg::DisplaySettings::instance()->setSplitStereoVerticalSeparation( splitStereoVerticalSeparation->value() );
  osg::DisplaySettings::instance()->setSplitStereoHorizontalEyeMapping(
    ( osg::DisplaySettings::SplitStereoHorizontalEyeMapping ) splitStereoHorizontalEyeMapping->currentIndex() );
  osg::DisplaySettings::instance()->setSplitStereoVerticalEyeMapping(
    ( osg::DisplaySettings::SplitStereoVerticalEyeMapping ) splitStereoVerticalEyeMapping->currentIndex() );

}
Esempio n. 3
0
OculusView::OculusView(const std::string& name) : OsgView(name)
{
	SURGSIM_ADD_SERIALIZABLE_PROPERTY(OculusView, std::shared_ptr<SurgSim::Framework::Component>, InputComponent,
									  getInputComponent, setInputComponent);

	// Default Settings of Oculus DK2
	setFullScreen(true);
	setDisplayType(View::DISPLAY_TYPE_HMD);
	setStereoMode(View::STEREO_MODE_HORIZONTAL_SPLIT);
	setScreenWidth(0.0631);
	setScreenHeight(0.071);
	setEyeSeparation(0.06);
	setScreenDistance(0.10);
	setTargetScreen(1); // Assume Oculus HMD has ID '1'.

	std::array<int, 2> dimensions = {1920, 1080};
	setDimensions(dimensions);
}
void QgsGlobePluginDialog::on_comboStereoMode_currentIndexChanged( QString value )
{
  Q_UNUSED( value );
  setStereoMode();
  updateStereoDialog();
}