Stereo vision manager [now as a plugin]

A place for users of OGRE to discuss ideas and experiences of utilitising OGRE in their games / demos / applications.
User avatar
Thieum
Gnome
Posts: 342
Joined: Wed Apr 26, 2006 5:13 pm
Location: Bordeaux, France
x 2

Re: Stereo vision manager [now as a plugin]

Post by Thieum »

you should not use patch.exe but svn patch function

but nevermind, in the meantime i converted the patch and now you can apply it with patch.exe on the source release of ogre 1.6.3 (the one you downloaded on ogre3d.org, not the one you checkouted with svn).
See the attachment

But I am not sure I did not added any bug because I had to merge new code from the patch and the new code from the version 1.6.3. I will check this with the author of the patch
but the patch is now easy to apply
You do not have the required permissions to view the files attached to this post.
lygyue
Greenskin
Posts: 122
Joined: Wed Nov 29, 2006 4:07 pm

Re: Stereo vision manager [now as a plugin]

Post by lygyue »

Thankyou very much! I had patched it. I 'll biuld the source and have a test. :D :D :D
lygyue
Greenskin
Posts: 122
Joined: Wed Nov 29, 2006 4:07 pm

Re: Stereo vision manager [now as a plugin]

Post by lygyue »

I had build the source, but anybody can tell me how to write a demo or where can get a demo?
I found some code like this:

Code: Select all

			ConfigOptionMap options = mRoot->getRenderSystem()->getConfigOptions();
			String mode = options.find( "Video Mode" )->second.currentValue;
			std::vector<String> tab = StringUtil::split(mode," x@");
			int w,h;
			w = StringConverter::parseInt(tab[0]);
			h = StringConverter::parseInt(tab[1]);

			NameValuePairList miscParams;
			miscParams["vsync"] = options.find( "Video Mode" )->second.currentValue;

			mRoot->initialise(false); // init ogre but do not create windows

			miscParams["top"] = StringConverter::toString((int)0);
			miscParams["left"] = StringConverter::toString((int)0);
			mWindow = mRoot->createRenderWindow("Left window", w, h, true, &miscParams);
			miscParams["top"] = StringConverter::toString((int)0);
			miscParams["left"] = StringConverter::toString((int)1280);
			mWindow2 = mRoot->createRenderWindow("Right window", w, h, true, &miscParams);

			// tells the listener to change the focus of the second window when the focus
			// of the first windows has changed
			mFocusListener.setTargetWindow(mWindow2);
			WindowEventUtilities::addWindowEventListener(mWindow,&mFocusListener);
			// gives the focus to the second window because when created, only the first window has the focus
			mFocusListener.windowFocusChange(mWindow); 

but some codes i don't know what it means.

Code: Select all

			mFocusListener.setTargetWindow(mWindow2);
			WindowEventUtilities::addWindowEventListener(mWindow,&mFocusListener);
			// gives the focus to the second window because when created, only the first window has the focus
			mFocusListener.windowFocusChange(mWindow); 

I need to rewrite the focus event?
User avatar
Thieum
Gnome
Posts: 342
Joined: Wed Apr 26, 2006 5:13 pm
Location: Bordeaux, France
x 2

Re: Stereo vision manager [now as a plugin]

Post by Thieum »

the focus listener is defined in the demo (look for MultiheadListener)
If you do not add these lines of code, the second window will only display garbage because ogre does not update the windows when they don't have the focus.
And when you create two fullscreen windows, only the one windows has the focus, and the second will no normally get updated.
The MultiheadListener will tell the second window to be updated when the first one has the focus.

you can also replace the code by this :

Code: Select all

mWindow->setDeactivateOnFocusChange(false);
mWindow2->setDeactivateOnFocusChange(false);
This time, the two windows will continue to be updated even when then don't have the focus.
I think I will replace the code in the demo by that because it is easier to understand (I think)
lygyue
Greenskin
Posts: 122
Joined: Wed Nov 29, 2006 4:07 pm

Re: Stereo vision manager [now as a plugin]

Post by lygyue »

Thanks, Thieum. I had rebuilt the demo and it runs well. :D :D :D
murderv
Greenskin
Posts: 105
Joined: Tue Jun 26, 2007 12:20 pm

Re: Stereo vision manager [now as a plugin]

Post by murderv »

i have tried the 1.6.3 patch and the fresnel example..

it renders ok seems to run in fullscreen when the app starts.. but when pressing 'U' to change modes it just crashes..

should i do anything else?

i've downloaded ogre 1.6.3, applied the last patch on this thread and compiled the ogre source, then compiled example..

anything else ?
thanks in advance
murderv
Greenskin
Posts: 105
Joined: Tue Jun 26, 2007 12:20 pm

Re: Stereo vision manager [now as a plugin]

Post by murderv »

Hi Thieum,

i am also working on an application for an HMD, i have prepared your example to use DUALOUTPUT and i have called mStereoManager.setFocalLengthInfinite( true ); just inside createScene().

i believe this should give me a paralell frustum, but both views that i see in each screen seem exactly the same, with no eye spacing.

when showing stereo debug screen the +/- keys can move a grid of triangles but the image itself do not seperate.

my question is what exactly is happening or should happen when in parallell frustum (infinite focal) mode ?

thanks in advance,
User avatar
Thieum
Gnome
Posts: 342
Joined: Wed Apr 26, 2006 5:13 pm
Location: Bordeaux, France
x 2

Re: Stereo vision manager [now as a plugin]

Post by Thieum »

I could not reproduce the crash but I just corrected a few bugs in the demo and in the manager, mostly about the infinite focal length.
you should download the new version and tell me if it is better.
If it still crashes, could you tell me what is callstack when the demo crashes ?

When the focal length is infinite, the camera is just moved to the left and to the right. The frustums for the left and right view are not deformed, they stay parallel. The separation is nearly unnoticeable for the objects that not close to the camera.
With a finite focal length, the separation is not visible at the position of the focal plane, but very visible for the objects far and near the camera.
Try to augment the value eye separation or move nearer objects.
But I never had access to an HMD and I never could try the infinite frustum mode in real conditions
murderv
Greenskin
Posts: 105
Joined: Tue Jun 26, 2007 12:20 pm

Re: Stereo vision manager [now as a plugin]

Post by murderv »

hi, it seems better. now i can notice the image does seperate when changing the eye-spacing. as for the crash, im getting it in the end of the application with MULTIHEAD is on.
apart from that i get a crash when i change between stereo modes. i have MULTIHEAD on, it creates both windows, and it seems ok with infinite distance, but if i try to change mode it crashes.
i think it might crash because the multihead is on? every other method is based on one single window right? maybe some problem there ?

the callstack below is the crash i get when i exit the application with multihead on:


> OgreMain_d.dll!nedalloc::threadcache_free(malloc_chunk * p=0x022c0258, nedalloc::threadcache_t * tc=0x022c01f0, int mymspace=0, void * mem=0x022c0260, unsigned int size=512) Line 483 + 0x8 bytes C++
OgreMain_d.dll!nedalloc::nedpfree(nedalloc::nedpool_t * p=0x11ae5ff8, void * mem=0x022c0260) Line 852 + 0x19 bytes C++
OgreMain_d.dll!nedalloc::nedfree(void * mem=0x022c0260) Line 155 + 0x29 bytes C++
OgreMain_d.dll!Ogre::NedAllocImpl::deallocBytes(void * ptr=0x022c0260) Line 66 + 0x9 bytes C++
OgreMain_d.dll!Ogre::NedAllocPolicy::deallocateBytes(void * ptr=0x022c0260) Line 69 + 0x9 bytes C++
OgreMain_d.dll!Ogre::AllocatedObject<Ogre::CategorisedAllocPolicy<0> >::operator delete(void * ptr=0x022c0260) Line 91 + 0x9 bytes C++
Demo_Fresnel_stereo_d.exe!Ogre::Root::`scalar deleting destructor'() + 0x49 bytes C++
Demo_Fresnel_stereo_d.exe!ExampleApplication::~ExampleApplication() Line 83 + 0x2e bytes C++
Demo_Fresnel_stereo_d.exe!FresnelApplication::~FresnelApplication() Line 308 + 0x38 bytes C++
Demo_Fresnel_stereo_d.exe!WinMain(HINSTANCE__ * hInst=0x00400000, HINSTANCE__ * __formal=0x00000000, char * strCmdLine=0x00222494, HINSTANCE__ * __formal=0x00000000) Line 588 + 0x1c bytes C++
Demo_Fresnel_stereo_d.exe!__tmainCRTStartup() Line 578 + 0x35 bytes C
Demo_Fresnel_stereo_d.exe!WinMainCRTStartup() Line 403 C
kernel32.dll!7d4e7d2a()
[Frames below may be incorrect and/or missing, no symbols loaded for kernel32.dll]
User avatar
Thieum
Gnome
Posts: 342
Joined: Wed Apr 26, 2006 5:13 pm
Location: Bordeaux, France
x 2

Re: Stereo vision manager [now as a plugin]

Post by Thieum »

This is strange. If you run the other ogre demos, do you have a crash ?

If you open the sources of one of the demos and you add this

Code: Select all

	RenderWindow *window = Root::getSingleton().getAutoCreatedWindow();
	Viewport *viewport = window->getViewport(0);
	NameValuePairList miscParams;
	miscParams["monitorIndex"] = "1";

	RenderWindow *window2 = Root::getSingleton().createRenderWindow("second window", 
		window->getWidth(), window->getHeight(), window->isFullScreen(), &miscParams);
	window2->addViewport(viewport->getCamera());
at the beginning of createScene, do you have a crash when you exit the application ?

And for the two crashes, (you have two diffeernt crashes, if I understand), do you see some errors in the log ?
murderv
Greenskin
Posts: 105
Joined: Tue Jun 26, 2007 12:20 pm

Re: Stereo vision manager [now as a plugin]

Post by murderv »

i've copied the code to the beginning of the createScene in the normal Fresnel demo, and it does not crash. only the stereo version demo does crash when we exit the application.

as for the other crash, no, it doesnt log anything to the logfile. I found out a new crash. When i execute the application and Ogre option's dialog box shows, if i click "cancel" it crashes aswell. I believe in the same crash as when the app exits.

here's the error window information for when i use the 'U' key to change stereo modes (this is the second error i mentioned)

---------------------------
Microsoft Visual C++ Debug Library
---------------------------
Debug Error!

Program: ...ork\C++\Ratio\stereoscopy\bin\Debug\Demo_Fresnel_stereo_d.exe
Module: ...ork\C++\Ratio\stereoscopy\bin\Debug\Demo_Fresnel_stereo_d.exe
File:


Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is usually a result of calling a function declared with one calling convention with a function pointer declared with a different calling convention.


(Press Retry to debug the application)
---------------------------
Abort Retry Ignore
---------------------------
User avatar
Thieum
Gnome
Posts: 342
Joined: Wed Apr 26, 2006 5:13 pm
Location: Bordeaux, France
x 2

Re: Stereo vision manager [now as a plugin]

Post by Thieum »

I you have a stack corruption I think you should rebuild everything (even Ogre). maybe some code that needed to be recompiled or relinked after you applied the patch were missed by the compiler
murderv
Greenskin
Posts: 105
Joined: Tue Jun 26, 2007 12:20 pm

Re: Stereo vision manager [now as a plugin]

Post by murderv »

hmm its weird. well i can do that again.

i got a fresh download of ogre source, i've applied the patch, compiled everything and i'm using the compiled libs and dll's. anyway, thanks for the help. ill clean it all up and rebuild everything again and see if it happens..

thanks for the updates on the stereo manager too, it's been a great help and headache saviour =)

my regards.
User avatar
Thieum
Gnome
Posts: 342
Joined: Wed Apr 26, 2006 5:13 pm
Location: Bordeaux, France
x 2

Re: Stereo vision manager [now as a plugin]

Post by Thieum »

you're welcome!

please also tell me if the parallel frustum mode works well with a HMD
murderv
Greenskin
Posts: 105
Joined: Tue Jun 26, 2007 12:20 pm

Re: Stereo vision manager [now as a plugin]

Post by murderv »

hi thieum,

i still haven't tested the app with the HMD because i'm having trouble setting up the app to run in fullscreen.

here's the error: "OGRE EXCEPTION(2:InvalidParametersException): Cannot create secondary windows when the primary is full screen in D3D9RenderSystem::_createRenderWindow at ..\src\OgreD3D9RenderSystem.cpp (line 647)"



here is the code i use to setup both windows when choosing the stereo mode. the app starts, i see one display going fullscreen (the first one), and then after some time, seems like he tries to create the second window, but it crashes, since the first one is already in fullscreen. it works just fine in windowed mode though..
( it DOESNT work in the fresnel example demo aswell. i'm running in release mode.. seems to work fine in debug, and not in release mode)

do you have any ideas??


//
// STEREO RENDERING
//
else
{
Ogre::LogManager::getSingleton().logMessage( "---------------------------- ENTERING STEREO MODE" );

root->initialise( false );

Ogre::ConfigOptionMap options = root->getRenderSystem()->getConfigOptions();
Ogre::String mode = options.find( "Video Mode" )->second.currentValue;

std::vector<Ogre::String> tab = Ogre::StringUtil::split(mode," x@");
_width = Ogre::StringConverter::parseInt( tab[0] );
_height = Ogre::StringConverter::parseInt( tab[1] );
_invWidth = 1.0f / (float)_width;
_invHeight = 1.0f / (float)_height;
logger->logMessage( Ogre::StringConverter::toString(_width) + " -- " + Ogre::StringConverter::toString(_height) );

bool fullscreen = StringConverter::parseBool( options.find( "Full Screen" )->second.currentValue );

NameValuePairList miscParams;
miscParams["vsync"] = options.find( "VSync" )->second.currentValue;

miscParams["monitorIndex"] = "0";
renderWindow = root->createRenderWindow( appName+": (STEREO) Left window", _width, _height, fullscreen, &miscParams );

miscParams["monitorIndex"] = "1";
renderWindow2 = root->createRenderWindow( appName+": (STEREO) Right window", _width, _height, fullscreen, &miscParams );

if( renderWindow2 )
{
// When there are two windows, only the first one has the focus. Ogre Disables the rendering
// on the unfocused window by default.
// these lines will tell the two windows to render event when unfocused
renderWindow->setDeactivateOnFocusChange( false );
renderWindow2->setDeactivateOnFocusChange( false );
}
User avatar
Thieum
Gnome
Posts: 342
Joined: Wed Apr 26, 2006 5:13 pm
Location: Bordeaux, France
x 2

Re: Stereo vision manager [now as a plugin]

Post by Thieum »

This is strange that you get this error if you applied the patch.

maybe there is an error with the monitor index. try 1 and 2 instead of 0 and 1
I never knew if the index was 1 based or 0 based :D
murderv
Greenskin
Posts: 105
Joined: Tue Jun 26, 2007 12:20 pm

Re: Stereo vision manager [now as a plugin]

Post by murderv »

did it work for you in release mode and using fullscreen, by using the 0 based indices ??
User avatar
Thieum
Gnome
Posts: 342
Joined: Wed Apr 26, 2006 5:13 pm
Location: Bordeaux, France
x 2

Re: Stereo vision manager [now as a plugin]

Post by Thieum »

It works with 0 1 and 1 2

When I use wrong settings, I get this exception :
10:18:24: OGRE EXCEPTION(3:RenderingAPIException): Unable to get the swap chain in D3D9RenderWindow::acquireRenderWindowResources at D:\dev\okatra\ogre1.6.3_MH_MT\RenderSystems\Direct3D9\src\OgreD3D9Device.cpp (line 1026)

In fact I checked the sources, and I am pretty sure that your Ogre is not patched correctly. The error message "Cannot create secondary windows when the primary is full screen" is removed by the patch and is no longer present into the sources
murderv
Greenskin
Posts: 105
Joined: Tue Jun 26, 2007 12:20 pm

Re: Stereo vision manager [now as a plugin]

Post by murderv »

hmm i have applied the last patch found in the thread.

patch -p0 -i MultipleRenderWindows_1.6.3_Source_release_v4.0.patch

it worked fine. do i have to apply any other patch ?

thanks in advance
User avatar
Thieum
Gnome
Posts: 342
Joined: Wed Apr 26, 2006 5:13 pm
Location: Bordeaux, France
x 2

Re: Stereo vision manager [now as a plugin]

Post by Thieum »

your project is still using an unpatched version of Ogre. have you checked the directory configuration of your project to be sure it points to the right version ?
Do not forget to change the OGRE_SRC environement variable because Demo_Fresnel_stereo and _Plugin_Stereomanager use to find Ogre
murderv
Greenskin
Posts: 105
Joined: Tue Jun 26, 2007 12:20 pm

Re: Stereo vision manager [now as a plugin]

Post by murderv »

hello thieum.

i have re-compiled ogre, and yes there was something wrong with my dll files, it now works fine with release mode.

i also have run it with my HMD, but i did not notice any real stereoscopy effect.

my HMD is a VR1280 from virtual research. i find this helmet to suck alot, so i can't really say if the plugin works fine or not.

i have to thank you for such plugin. really appreciate it
marc_
Halfling
Posts: 48
Joined: Wed May 21, 2008 7:03 pm
Location: México, CVA

Re: Stereo vision manager [now as a plugin]

Post by marc_ »

thieum,
i got a question, we have an ATI fireGL 7350 video card with 2dvi output and a 3d sync output, the stereomanager uses this 3ds sync output to use active stereo?, if i use the 2 DVi output of the card i don't need to use the vsync? .... is there a way to use only one window ??

thank you in adavnce thieum.
User avatar
Thieum
Gnome
Posts: 342
Joined: Wed Apr 26, 2006 5:13 pm
Location: Bordeaux, France
x 2

Re: Stereo vision manager [now as a plugin]

Post by Thieum »

Hi!

The Stereo manager doesn't use the 3d sync output, it doesn't use any hardware specific stereoscopic feature. It does only one rendering per eye.
If you use the dual output mode with the stereo plugin, it will use your two dvi output with two windows. This mode will only work if ogre sees two monitors
(with Windows and nvidia drivers, it's when you use the the "dualview" mode in your stereo drivers, not the "horizontal span" mode. The names may be different with your setup)
The plugin doesn't support the horizontal span mode yet.

But you can use the stereo manager class directly (see Demo_Fresnel_Stereo), and you will be able to do everything you want
marc_
Halfling
Posts: 48
Joined: Wed May 21, 2008 7:03 pm
Location: México, CVA

Re: Stereo vision manager [now as a plugin]

Post by marc_ »

hi thieum, another question, i have only one camera inmy scene named "camera01", with that camera ogre creates the viewport and so. I'm creating by my own a second renderwindow and a second viewport using "camera01" and then passing this second viewport to the init function, my douct is about the camera is it correct to use only one camera?.. the stereo manager automatically is doing the panning of the "camera01" for the rightEye and then returns the camera to its original position?.. is there a way to sync this swapping to the monitors refresh rate?..

thank you thieum..
User avatar
Thieum
Gnome
Posts: 342
Joined: Wed Apr 26, 2006 5:13 pm
Location: Bordeaux, France
x 2

Re: Stereo vision manager [now as a plugin]

Post by Thieum »

Yes, you have to assign the same camera to the two viewports, the manager will move it automatically for each eye.
About the vsync, in my tests when you activate it, there is a lot of flickering. Thus I leave it off. I don't know if it is possible to "sync the vsync" of the two monitors.