示例#1
0
//--------------------------------------------------------------
bool ofxOpenVR::init()
{
	// Loading the SteamVR Runtime
	vr::EVRInitError eError = vr::VRInitError_None;
	_pHMD = vr::VR_Init(&eError, vr::VRApplication_Scene);

	if (eError != vr::VRInitError_None)
	{
		_pHMD = NULL;
		char buf[1024];
		sprintf_s(buf, sizeof(buf), "Unable to init VR runtime: %s", vr::VR_GetVRInitErrorAsEnglishDescription(eError));
		return false;
	}

	// This is not used for now
	_pRenderModels = (vr::IVRRenderModels *)vr::VR_GetGenericInterface(vr::IVRRenderModels_Version, &eError);
	if (!_pRenderModels)
	{
		_pHMD = NULL;
		vr::VR_Shutdown();

		char buf[1024];
		sprintf_s(buf, sizeof(buf), "Unable to get render model interface: %s", vr::VR_GetVRInitErrorAsEnglishDescription(eError));
		return false;
	}
	_strTrackingSystemName = "No Driver";
	_strTrackingSystemModelNumber = "No Display";

	_strTrackingSystemName = getTrackedDeviceString(_pHMD, vr::k_unTrackedDeviceIndex_Hmd, vr::Prop_TrackingSystemName_String);
	_strTrackingSystemModelNumber = getTrackedDeviceString(_pHMD, vr::k_unTrackedDeviceIndex_Hmd, vr::Prop_ModelNumber_String);

	_fNearClip = 0.1f;
	_fFarClip = 30.0f;

	_bIsGLInit = initGL();
	if (!_bIsGLInit)
	{
		printf("%s - Unable to initialize OpenGL!\n", __FUNCTION__);
		return false;
	}

	if (!initCompositor())
	{
		printf("%s - Failed to initialize VR Compositor!\n", __FUNCTION__);
		return false;
	}

	return true;
}
示例#2
0
void StereoManager::init(Ogre::Viewport* leftViewport, Ogre::Viewport* rightViewport)
{
	if(mStereoMode == SM_NONE)
		return;
	if(!leftViewport)
        OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "At least left viewport must be provided",
        "StereoManager::init");

	mCamera = leftViewport->getCamera();
	if(!mCamera && rightViewport && !rightViewport->getCamera())
        OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Viewports must have cameras associated",
        "StereoManager::init");

	if(rightViewport && mCamera != rightViewport->getCamera())
        OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Left and right viewports must have the same camera associated",
        "StereoManager::init");


	if(mAvailableModes[mStereoMode].mUsesCompositor)
	{
		Ogre::Viewport *newLeft, *newRight;
		initCompositor(leftViewport, mAvailableModes[mStereoMode].mMaterialName, newLeft, newRight);
		leftViewport = newLeft;
		rightViewport = newRight;
	}

	initListeners(leftViewport, rightViewport);

    RenderTargetList::iterator it;
	RenderTargetList::iterator end = mRenderTargetList.end();
	for(it = mRenderTargetList.begin(); it != end; ++it)
	{
		it->first->setAutoUpdated(false);
	}

	bool infinite = mFocalLengthInfinite;
	setFocalLength(mFocalLength); // setFocalLength will erase the infinite focal length option, so backup it and restore it
	setFocalLengthInfinite(infinite);

	if(mIsFocalPlaneFixed)
		updateCamera(0);
}
示例#3
0
    void StereoManager::init(Ogre::Viewport* leftViewport, Ogre::Viewport* rightViewport)
    {
        if(stereo_mode_ == SM_NONE)
            return;
        if(!leftViewport)
            OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "At least left viewport must be provided",
            "StereoManager::init");

        camera_ = leftViewport->getCamera();
        if(!camera_ && rightViewport && !rightViewport->getCamera())
            OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Viewports must have cameras associated",
            "StereoManager::init");

        if(rightViewport && camera_ != rightViewport->getCamera())
            OGRE_EXCEPT(Ogre::Exception::ERR_INVALIDPARAMS, "Left and right viewports must have the same camera associated",
            "StereoManager::init");

        if(available_nodes_[stereo_mode_].uses_compositor_)
        {
            Ogre::Viewport *newLeft, *newRight;
            initCompositor(leftViewport, available_nodes_[stereo_mode_].mat_name_, newLeft, newRight);
            leftViewport = newLeft;
            rightViewport = newRight;
        }

        initListeners(leftViewport, rightViewport);

        RenderTargetList::iterator it;
        RenderTargetList::iterator end = rendertarget_list_.end();
        for(it = rendertarget_list_.begin(); it != end; ++it)
        {
            it->first->setAutoUpdated(false);
        }

        bool infinite = infinite_focal_length_;
        setFocalLength(focal_length_); // setFocalLength will erase the infinite focal length option, so backup it and restore it
        setFocalLengthInfinite(infinite);

        if(focal_plane_fixed_)
            updateCamera(0);
    }