Exemplo n.º 1
0
void OculusDisplay::onInitialize()
{
  fullscreen_property_ = new rviz::BoolProperty( "Render to Oculus", false,
    "If checked, will render fullscreen on your secondary screen. Otherwise, shows a window.",
    this, SLOT(onFullScreenChanged()));

  prediction_dt_property_ = new rviz::FloatProperty( "Motion prediction (ms)", 30.0,
    "Time in ms to predict head motion. Decreases overall latency and motion sickness.",
    this, SLOT(onPredictionDtChanged()) );

  near_clip_property_ = new rviz::FloatProperty( "Near Clip Distance", 0.02,
    "Minimum rendering distance for Oculus camera.",
    this );

  horizontal_property_ = new rviz::BoolProperty( "Fixed Horizon", true,
    "If checked, will ignore the pitch component of the RViz camera.", this);

  follow_cam_property_ = new rviz::BoolProperty( "Follow RViz Camera", true,
    "If checked, will set the Oculus camera to the same position as the main view camera.",
    this, SLOT( onFollowCamChanged() ) );

  tf_frame_property_ = new rviz::TfFrameProperty( "Target Frame", "<Fixed Frame>",
    "Tf frame that the Oculus camera should follow.", this, context_->getFrameManager(), true );

  offset_property_ = new rviz::VectorProperty( "Offset", Ogre::Vector3(0,0,0),
    "Additional offset of the Oculus camera from the followed RViz camera or target frame.", this );

  pub_tf_property_ = new rviz::BoolProperty( "Publish tf", true,
    "If checked, will publish the pose of the Oculus camera as a tf frame.",
    this, SLOT( onPubTfChanged() ) );

  pub_tf_frame_property_ = new rviz::StringProperty( "Tf Frame", "oculus",
    "Name of the published tf frame.", this );

  render_widget_ = new rviz::RenderWidget( rviz::RenderSystem::get() );
  render_widget_->setVisible(false);
  render_widget_->setWindowTitle( "Oculus View" );

  render_widget_->setParent( context_->getWindowManager()->getParentWindow() );
  render_widget_->setWindowFlags( Qt::Window | Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowMaximizeButtonHint );

  Ogre::RenderWindow *window = render_widget_->getRenderWindow();
  window->setVisible(false);
  window->setAutoUpdated(false);
  window->addListener(this);

  scene_node_ = scene_manager_->getRootSceneNode()->createChildSceneNode();
}
Exemplo n.º 2
0
void GraphicsImpl::createScene()
{
	// Set ambient light
	sceneMgr->setAmbientLight(Ogre::ColourValue(0.5, 0.5, 0.5));

	// Create a light
	Ogre::Light* l = sceneMgr->createLight("MainLight");
	l->setPosition(20,80,50);

	caelumSystem = new Caelum::CaelumSystem(root, sceneMgr, Caelum::CaelumSystem::CAELUM_COMPONENTS_NONE);

	try {
		caelumSystem->setSkyDome(new Caelum::SkyDome(sceneMgr, caelumSystem->getCaelumCameraNode()));
	} catch (Caelum::UnsupportedException& ex) {
		Dout << ex.getFullDescription();
	}

	try {
		caelumSystem->setSun(new Caelum::SphereSun(sceneMgr, caelumSystem->getCaelumCameraNode()));
	} catch (Caelum::UnsupportedException& ex) {
		Dout << ex.getFullDescription();
	}

	try {
		caelumSystem->setMoon(new Caelum::Moon(sceneMgr, caelumSystem->getCaelumCameraNode()));
	} catch (Caelum::UnsupportedException& ex) {
		Dout << ex.getFullDescription();
	}

	try {
		caelumSystem->setCloudSystem(new Caelum::CloudSystem(sceneMgr, caelumSystem->getCaelumGroundNode()));
	} catch (Caelum::UnsupportedException& ex) {
		Dout << ex.getFullDescription();
	}

	try {
		caelumSystem->setPointStarfield(new Caelum::PointStarfield(sceneMgr, caelumSystem->getCaelumCameraNode()));
	} catch (Caelum::UnsupportedException& ex) {
		Dout << ex.getFullDescription();
	}

	// Register caelum.
	// Don't make it a frame listener; update it by hand.
	//Root::getSingletonPtr ()->addFrameListener (caelumSystem.get ());
	caelumSystem->attachViewport(viewPort);

	try {
		caelumSystem->setPrecipitationController(new Caelum::PrecipitationController(sceneMgr));
	} catch (Caelum::UnsupportedException& ex) {
		Dout << ex.getFullDescription();
	}

	caelumSystem->setSceneFogDensityMultiplier(0.0015);

	caelumSystem->setManageAmbientLight(true);
	caelumSystem->setMinimumAmbientLight(Ogre::ColourValue(0.1, 0.1, 0.1));

	// Setup sun options

	if (caelumSystem->getSun()) {
		// Make the sun very obvious:
		//caelumSystem->getSun ()->setDiffuseMultiplier (Ogre::ColourValue (1, 10, 1));

		caelumSystem->getSun()->setAutoDisableThreshold(0.05);
		caelumSystem->getSun()->setAutoDisable(false);
	}

	if (caelumSystem->getMoon()) {
		// Make the moon very obvious:
		//caelumSystem->getMoon ()->setDiffuseMultiplier (Ogre::ColourValue (1, 1, 10));

		caelumSystem->getMoon()->setAutoDisableThreshold(0.05);
		caelumSystem->getMoon()->setAutoDisable(false);
	}

	if (caelumSystem->getCloudSystem()) {
		try {
			caelumSystem->getCloudSystem()->createLayerAtHeight(2000);
			caelumSystem->getCloudSystem()->createLayerAtHeight(5000);
			caelumSystem->getCloudSystem()->getLayer(0)->setCloudSpeed(Ogre::Vector2(0.000005, -0.000009));
			caelumSystem->getCloudSystem()->getLayer(1)->setCloudSpeed(Ogre::Vector2(0.0000045, -0.0000085));
		}

		catch (Caelum::UnsupportedException& ex) {
			Dout << ex.getFullDescription();
		}
	}

	if (caelumSystem->getPrecipitationController()) {
		caelumSystem->getPrecipitationController()->setIntensity(0);
	}

	// Set time acceleration.
	//caelumSystem->getUniversalClock ()->setTimeScale (0);

	// Sunrise with visible moon.
	caelumSystem->getUniversalClock()->setGregorianDateTime(2007, 4, 9, 9, 33, 0);

	caelumSystem->getUniversalClock()->setTimeScale(1024);

	window->addListener(caelumSystem);

	root->addFrameListener(caelumSystem);
}