Ah thats great. A good step forward. However, two minor questions: 1. Do you need the instance to the main osg window? 2. If not, how do you manage to get events from the device when you apply force on it?
I get it to read data (in my message callback) but only if a move/modify the osg window (Im using osgViewer::Viewer with just one window). /A On Thu, Nov 12, 2015 at 10:53 PM, Farshid Lashkari <fla...@gmail.com> wrote: > Hi Anders, > > You can create a separate "message-only" window to receive windows > messages from the SpaceMouse. See the following MSDN page: > > > https://msdn.microsoft.com/en-us/library/windows/desktop/ms632599(v=vs.85).aspx#message_only > > I've integrated the 3DConnexion SpaceNavigator into our application using > this method, along with other 3rd party APIs that require a window handle. > > Cheers, > Farshid > > On Thu, Nov 12, 2015 at 11:01 AM, Anders Backman <ande...@cs.umu.se> > wrote: > >> So there seem to be only a very few alternatives for integrating such a >> windows oriented toolkit as the 3DConnexion SpaceMouse... >> >> My idea of being able to create a custom implementation of a >> GraphicsWindowWin32 would really open up for a better integration, albeit >> not a portable one... >> >> Right now, using VRPN feels a bit strange in a native application (as it >> requires a server). >> >> As far as I know there is no polling API for the 3DConnexion devices, no? >> >> I see older emails about accessing it through Direct3D, and native >> USB...whereas listening to windows messages would be the "correct" way of >> integrating it. >> I would have to hack into the context classes to do this... >> >> Hm.... >> >> /Anders >> >> >> On Thu, Nov 12, 2015 at 3:54 PM, Anders Backman <ande...@cs.umu.se> >> wrote: >> >>> That is certainly an important call yes. >>> >>> I guess my problem is that these two calls are not interchangeable: >>> >>> #if 1 >>> osg::ref_ptr<osg::GraphicsContext> gc = >>> osg::GraphicsContext::createGraphicsContext(traits.get()); >>> #else >>> osg::ref_ptr<osgViewer::GraphicsWindowWin32> window = new >>> osgViewer::GraphicsWindowWin32(traits); >>> gc = window.get(); >>> #endif >>> >>> createGraphicsContext() will do a few more things which the creation of >>> a osgViewer::GraphicsWindowWin32 does not. The question is really, is it >>> possible to even consider this? >>> Is there a mechanism for creating a custom GraphicsWindowWin32 or is >>> this path doomed to fail. >>> >>> /Anders >>> >>> >>> >>> On Thu, Nov 12, 2015 at 3:31 PM, Trajce Nikolov NICK < >>> trajce.nikolov.n...@gmail.com> wrote: >>> >>>> Did you tried something like: >>>> >>>> osgViewer::Viewer viewer; >>>> viewer.getCamera()->setGraphicContext(gc); >>>> >>>> ? >>>> >>>> On Thu, Nov 12, 2015 at 2:52 PM, Anders Backman <ande...@cs.umu.se> >>>> wrote: >>>> >>>>> I notice that there is a major difference between osgViewer::Viewer >>>>> and osgViewer::CompositeViewer: >>>>> >>>>> The following code: >>>>> >>>>> osgViewer::CompositeViewer viewer; >>>>> >>>>> osg::ref_ptr<osg::GraphicsContext::Traits> traits = new >>>>> osg::GraphicsContext::Traits; >>>>> traits->x = 100; >>>>> traits->y = 100; >>>>> traits->width = 1000; >>>>> traits->height = 800; >>>>> traits->windowDecoration = true; >>>>> traits->doubleBuffer = true; >>>>> traits->sharedContext = 0; >>>>> >>>>> osg::ref_ptr<osg::GraphicsContext> gc = >>>>> osg::GraphicsContext::createGraphicsContext(traits.get()); >>>>> >>>>> osgViewer::View* view = new osgViewer::View; >>>>> view->setName("View one"); >>>>> viewer.addView(view); >>>>> >>>>> view->setSceneData(scene.get()); >>>>> view->getCamera()->setViewport(new osg::Viewport(0, 0, >>>>> traits->width / 2, traits->height / 2)); >>>>> view->getCamera()->setGraphicsContext(gc.get()); >>>>> >>>>> viewer.realize(); // Context already created. No call to >>>>> GraphicsWIndowWIn32::GraphicsWIndowWin32 will be called >>>>> >>>>> >>>>> >>>>> If I replace osgViewerCompositeViewer with a osgViewer::Viewer and >>>>> remove the creation of View, I get: >>>>> >>>>> viewer.realize(); // A new context is created. A new call to >>>>> GraphicsWIndowWIn32::GraphicsWIndowWin32 will be called >>>>> >>>>> >>>>> So it seems that osgViewer::Viewer does not respect? the previously >>>>> created GraphicsCOntext? >>>>> >>>>> /Anders >>>>> >>>>> >>>>> >>>>> On Thu, Nov 12, 2015 at 2:24 PM, Anders Backman <ande...@cs.umu.se> >>>>> wrote: >>>>> >>>>>> That is quite explicit. I was thinking about some method for >>>>>> intercepting events. >>>>>> I tried fiddling with creating a custom GraphicsWindowWin32 class, >>>>>> but it turns out that this is explicitly created internally in: >>>>>> >>>>>> osg::GraphicsContext* Win32WindowingSystem::createGraphicsContext( >>>>>> osg::GraphicsContext::Traits* traits ) >>>>>> { >>>>>> ... >>>>>> osg::ref_ptr<osgViewer::GraphicsWindowWin32> window = new >>>>>> GraphicsWindowWin32(traits); >>>>>> >>>>>> } >>>>>> >>>>>> So this does not seem to be the way to catch windows messages. >>>>>> My idea was that I could register my instance of the >>>>>> GraphicsWindowWin32 to implement the virtual method: >>>>>> >>>>>> LRESULT GraphicsWindowWin32::handleNativeWindowingEvent( HWND hwnd, >>>>>> UINT uMsg, WPARAM wParam, LPARAM lParam ) >>>>>> >>>>>> >>>>>> Where I could catch all windows events. >>>>>> >>>>>> >>>>>> Turns out that I do not have enough understanding when and where >>>>>> context etc is created. >>>>>> >>>>>> It seems that a GraphicsWindowWIn32 is first created at the call to: >>>>>> >>>>>> osg::ref_ptr<osg::GraphicsContext> gc = >>>>>> osg::GraphicsContext::createGraphicsContext(traits.get()); >>>>>> >>>>>> >>>>>> And then at the call to: >>>>>> >>>>>> viewer->realize(); >>>>>> >>>>>> will also result in a call >>>>>> to GraphicsContext::createGraphicsContext(Traits* traits), which in turn >>>>>> will create yet another GraphicsWindowWin32. >>>>>> >>>>>> So there lies my problem, my call to viewer->realize() will override >>>>>> my first call to GraphicsContext::createGraphicsContext(traits.get()); >>>>>> >>>>>> >>>>>> Not sure how to get around this though. Ideas? >>>>>> >>>>>> /Anders >>>>>> >>>>>> >>>>>> On Wed, Nov 11, 2015 at 5:05 PM, Trajce Nikolov NICK < >>>>>> trajce.nikolov.n...@gmail.com> wrote: >>>>>> >>>>>>> Hi Anders, >>>>>>> >>>>>>> here is what I do for this on Windows >>>>>>> >>>>>>> while (!viewer->done()) >>>>>>> { >>>>>>> >>>>>>> #if defined(_WIN32) >>>>>>> MSG msg; >>>>>>> if (::PeekMessage(&msg,NULL,0,0,PM_NOREMOVE)) >>>>>>> { >>>>>>> ::GetMessage(&msg, NULL, 0, 0); >>>>>>> >>>>>>> if (wins.size()) >>>>>>> { >>>>>>> osgViewer::GraphicsHandleWin32 *hdl = >>>>>>> dynamic_cast<osgViewer::GraphicsHandleWin32*>(wins.at(0)); >>>>>>> if(hdl) >>>>>>> { >>>>>>> WNDPROC fWndProc = >>>>>>> (WNDPROC)::GetWindowLongPtr(hdl->getHWND(), GWLP_WNDPROC); >>>>>>> if (fWndProc && hdl->getHWND()) >>>>>>> { >>>>>>> ::CallWindowProc(fWndProc,hdl->getHWND(),msg.message, msg.wParam, >>>>>>> msg.lParam); >>>>>>> } >>>>>>> } >>>>>>> } >>>>>>> } >>>>>>> #endif >>>>>>> >>>>>>> On Wed, Nov 11, 2015 at 4:21 PM, Anders Backman <ande...@cs.umu.se> >>>>>>> wrote: >>>>>>> >>>>>>>> Hi. >>>>>>>> >>>>>>>> Trying the 3DConnexion SpaceNavigator with OSG. However I would >>>>>>>> like to stay away from VRPN and such dependencies... >>>>>>>> >>>>>>>> I was wondering how to best intercept Windows messages from the >>>>>>>> GraphicsWindowWin32 class. >>>>>>>> >>>>>>>> This class has a virtual method handleNativeWindowingEvent which I >>>>>>>> would like to override to catch custom messages from my device. >>>>>>>> >>>>>>>> Would it be possible to implement a derived class and have that >>>>>>>> instantiated instead of the standard osgViewer::GraphicsWindowWin32 >>>>>>>> one? >>>>>>>> >>>>>>>> Or is there a different method to listen to the messages: >>>>>>>> >>>>>>>> ( HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) >>>>>>>> >>>>>>>> Thanks, >>>>>>>> Anders >>>>>>>> >>>>>>>> >>>>>>>> >>>>>>>> -- >>>>>>>> __________________________________________ >>>>>>>> Anders Backman, HPC2N >>>>>>>> 90187 Umeå University, Sweden >>>>>>>> and...@cs.umu.se http://www.hpc2n.umu.se >>>>>>>> Cell: +46-70-392 64 67 >>>>>>>> >>>>>>>> _______________________________________________ >>>>>>>> osg-users mailing list >>>>>>>> osg-users@lists.openscenegraph.org >>>>>>>> >>>>>>>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org >>>>>>>> >>>>>>>> >>>>>>> >>>>>>> >>>>>>> -- >>>>>>> trajce nikolov nick >>>>>>> >>>>>>> _______________________________________________ >>>>>>> osg-users mailing list >>>>>>> osg-users@lists.openscenegraph.org >>>>>>> >>>>>>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org >>>>>>> >>>>>>> >>>>>> >>>>>> >>>>>> -- >>>>>> __________________________________________ >>>>>> Anders Backman, HPC2N >>>>>> 90187 Umeå University, Sweden >>>>>> and...@cs.umu.se http://www.hpc2n.umu.se >>>>>> Cell: +46-70-392 64 67 >>>>>> >>>>> >>>>> >>>>> >>>>> -- >>>>> __________________________________________ >>>>> Anders Backman, HPC2N >>>>> 90187 Umeå University, Sweden >>>>> and...@cs.umu.se http://www.hpc2n.umu.se >>>>> Cell: +46-70-392 64 67 >>>>> >>>>> _______________________________________________ >>>>> osg-users mailing list >>>>> osg-users@lists.openscenegraph.org >>>>> >>>>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org >>>>> >>>>> >>>> >>>> >>>> -- >>>> trajce nikolov nick >>>> >>>> _______________________________________________ >>>> osg-users mailing list >>>> osg-users@lists.openscenegraph.org >>>> >>>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org >>>> >>>> >>> >>> >>> -- >>> __________________________________________ >>> Anders Backman, HPC2N >>> 90187 Umeå University, Sweden >>> and...@cs.umu.se http://www.hpc2n.umu.se >>> Cell: +46-70-392 64 67 >>> >> >> >> >> -- >> __________________________________________ >> Anders Backman, HPC2N >> 90187 Umeå University, Sweden >> and...@cs.umu.se http://www.hpc2n.umu.se >> Cell: +46-70-392 64 67 >> >> _______________________________________________ >> osg-users mailing list >> osg-users@lists.openscenegraph.org >> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org >> >> > > _______________________________________________ > osg-users mailing list > osg-users@lists.openscenegraph.org > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > > -- __________________________________________ Anders Backman, HPC2N 90187 Umeå University, Sweden and...@cs.umu.se http://www.hpc2n.umu.se Cell: +46-70-392 64 67
_______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org