[osg-users] Integration with WPF
Hi there, what is the recommended method for integrating OSG in a WPF application? The OSG viewer will be accessed from a high level API only. A context menu on top of the viewer needs to be available. Resizing of the viewer and overlay of other WPF controls (e.g. dialogs) need to work robustly. So, what would do you recommend? C++/CLI or ActiveX or ...? Any hints or comments are highly appreciated. Cheers, Jan ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] OSG Render Thread in Qt: Access to scene data from main app thread
Hi all, I still have problems with this. I modify the code of cookbook like this: Code: class RenderThread : public QThread { public: RenderThread() : QThread(), viewerPtr(0), _done(false) { } virtual ~RenderThread() { if (viewerPtr) viewerPtr-setDone(true); _done = true; wait(); } QMutex* getMutex() { return mutex; } osgViewer::Viewer* viewerPtr; bool _done; QWaitCondition condition; Qt::HANDLE id; protected: virtual void run() { id = QThread::currentThreadId(); yieldCurrentThread(); while( !_done ) { if(mutex.tryLock()){ if (viewerPtr) viewerPtr-frame(); mutex.unlock(); condition.wakeAll(); } Sleep(10); } viewerPtr-setDone(true); } QMutex mutex; }; class ViewerWidget : public QWidget { public: ViewerWidget( osg::Camera* camera, osg::Node* scene ) : QWidget() { _viewer.setCamera( camera ); _viewer.setSceneData( scene ); // _viewer.addEventHandler( new osgViewer::StatsHandler ); // _viewer.setCameraManipulator( new osgGA::TrackballManipulator ); _viewer.setThreadingModel( osgViewer::Viewer::SingleThreaded ); osgQt::GraphicsWindowQt* gw = dynamic_castosgQt::GraphicsWindowQt*( camera-getGraphicsContext() ); if ( gw ) { QVBoxLayout* layout = new QVBoxLayout; layout-addWidget( gw-getGLWidget() ); setLayout( layout ); } _thread.viewerPtr = _viewer; _thread.start(); } void stopRendering() { _thread._done = true; } bool isRendering() { return _thread.isRunning(); } osg::Matrix getCameraMatrix() { osg::Matrix mat; if( _thread.id != QThread::currentThreadId()){ QMutexLocker locker( _thread.getMutex() ); } mat = _viewer.getCamera()-getViewMatrix(); return mat; } void setCameraMatrix(osg::Matrix mat) { if( _thread.id != QThread::currentThreadId()){ QMutexLocker locker( _thread.getMutex() ); } _viewer.getCamera()-setViewMatrix(mat); } protected: osgViewer::Viewer _viewer; RenderThread _thread; }; My intention is to load an animated model (mesh with skeleton) in the scene and rotate their bones from the main thread: Code: in the constructor ... //osg layout render thread osg::Camera* camera = createCamera( 0, 0, 640, 480 ); m_qtOsgViewer = new ViewerWidget(camera, _sceneGroup); _sceneGroup-setUpdateCallback( this ); ... void MyOSGSceneManager::loadScene() { model = new AvatarE::AnimatedModel(../../../extras/data/models/hand.fbx); _sceneGroup-addChild(model-getRootGroup()); setActiveCamera(m_activeCameraID); } void MyOSGSceneManager::operator()( osg::Node * node , osg::NodeVisitor * nodeVisitor ) { //update cameras if(m_cameraController-isCamMoving()){ m_cameraController-updateCamera(); m_qtOsgViewer-setCameraMatrix(m_cameraController-getCameraMatrix()); } } All is loaded correctly and the camera is moved without problems. But when I call a bone manipulator function, Code: m_osgSceneManager-getAnimatedModel()-getAnimationManager()-manualBonesRotate( radio_dcho,osg::Matrix::rotate(osg::Quat(1.0,0.0,0.0,osg::DegreesToRadians(30.0))),proba); Nothing happens. This does not happen if the entire application works in the same thread. Any suggestions? Thank you! Cheers, Aitor -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=53073#53073 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] OSG could not find plugin to read objects from .osg file
Hi, I've compiled OSG 3.0.1 in Windows 7 64 bits in both release and debug mode with the MingW compiler. When running a little app I have written to test the installation, I got no display at all and a warning message in debug mode: *Warning: Could not find plugin to read objects from file cow.osgt* In release mode, everything goes fine. I have taken a look inside the *osgPlugins-3.0.1 *folder and the plugin names lack the final 'd', as in the release mode. The osg libraries, on the contrary, all end with a 'd', i. e. *libOpenThreadsd.dll * Here's the code I'm using: #include osgDB/ReadFile #include osgViewer/Viewer #include osgViewer/ViewerEventHandlers int main( int argc, char** argv ) { osg::ref_ptrosg::Node root = osgDB::readNodeFile(avatar.osg); osgViewer::Viewer viewer; viewer.setUpViewInWindow(50,50,640,400); viewer.addEventHandler( new osgViewer::StatsHandler ); viewer.addEventHandler( new osgViewer::WindowSizeHandler ); viewer.setSceneData( root.get() ); viewer.realize(); return viewer.run(); } Do you have any idea of what the problem could be? Thanks! ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Problem with fullscreen hiding dialog window
Hi, I run my osg program in fullscreen mode by setting traits width height to the same as desktop, x and y position to 0 and disabling window decoration. This prevents my windows file input dialog to show (it opens behind the osg window and I need to alt+tab to it). It shows at top level when running in a smaller osg window that doesn't cover the the whole desktop. Can I set the osg window options to have full screen specifications without the program going into fullscreen mode? Just having the window floating on top. I use http://msdn.microsoft.com/en-us/library/windows/desktop/bb776913%28v=vs.85%29.aspx to open the file dialog on Windows 7 x64 and OSG version 3.1.3. Maybe there are better approaches to do this? Thank you! Cheers, David -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=53075#53075 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Problem with fullscreen hiding dialog window
There should be a flag for your Dialog to set it always on top or something like this Nick On Wed, Mar 13, 2013 at 11:19 AM, David Sellin davse...@student.liu.sewrote: Hi, I run my osg program in fullscreen mode by setting traits width height to the same as desktop, x and y position to 0 and disabling window decoration. This prevents my windows file input dialog to show (it opens behind the osg window and I need to alt+tab to it). It shows at top level when running in a smaller osg window that doesn't cover the the whole desktop. Can I set the osg window options to have full screen specifications without the program going into fullscreen mode? Just having the window floating on top. I use http://msdn.microsoft.com/en-us/library/windows/desktop/bb776913%28v=vs.85%29.aspxto open the file dialog on Windows 7 x64 and OSG version 3.1.3. Maybe there are better approaches to do this? Thank you! Cheers, David -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=53075#53075 ___ 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
Re: [osg-users] Struggling trying to convert geometry coordinates in PagedLOD
Hi Oliver, On 13 March 2013 07:54, Olivier Tournaire olit...@gmail.com wrote: No one on this? I suspect you lost a lot of readers with the volume of your post, please remember that all members of the community are busy working and only have a little time to read and keep up with posts and write replies. Try distilling the issue you have down to what others might be able to easily understand and provide an answer for. Robert. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Struggling trying to convert geometry coordinates in PagedLOD
Hi Robert, So, I will try to summarize my post, without any code :) With my first post, I tried to be as complete as possible to clearly describe the issue, with all the related code. Sorry for this. Thus, I am trying to convert geometry coordinates of Drawables contained in Geodes. My Geodes are children of PagedLOD, and there is a single Geode per PagedLOD. For a given part of my terrain, I have more than 1000 files, with 9 levels of details. To convert the coordinates, I simply parse the coordinates in my original geometries, apply the transformation (code of my own and with proj4) and then use the setVertexArray method to replace the geometry coordinates in my drawables. I do this for each file. I center the coordinates around (0,0,0) because they are in 10e+06, and then add on top of my Geodes a translation MatrixTransform which value come from the barycenter of the points. If my Geode is contained in a PagedLOD, I also set the UserCenter to this value. The problem is that when I view the transformed hierarchy in osgviewer, sometimes, when I am really close from the terrain, some tiles disappear. If I move a few, they appear again. It also seems that the order of the loaded tiles is incorrect. Both problems are illustrated by this images: http://imageshack.us/photo/my-images/109/badtiles.png/ http://imageshack.us/photo/my-images/685/pagedlodsranges.jpg/ Hope you could help. Best regards, Olivier 2013/3/13 Robert Osfield robert.osfi...@gmail.com Hi Oliver, On 13 March 2013 07:54, Olivier Tournaire olit...@gmail.com wrote: No one on this? I suspect you lost a lot of readers with the volume of your post, please remember that all members of the community are busy working and only have a little time to read and keep up with posts and write replies. Try distilling the issue you have down to what others might be able to easily understand and provide an answer for. Robert. ___ 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
Re: [osg-users] Problem with fullscreen hiding dialog window
It doesn't seem to be a flag for that, not that I can see. But I don't have any experince of the windows api. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=53080#53080 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Problem with fullscreen hiding dialog window
What do you use for your Dialog code? Can you pass the code snippet of the dialog creation? On Wed, Mar 13, 2013 at 3:17 PM, David Sellin davse...@student.liu.sewrote: It doesn't seem to be a flag for that, not that I can see. But I don't have any experince of the windows api. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=53080#53080 ___ 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
[osg-users] Light lobes
Hi Community, I have done this before but it seams I forgot all of it now :-). Here is the story: I have GLSL code for pixel based lighting and my LightSource is attached to a matrixtrasnform which has updatecallback to update the position and orientation based on the camera view matrix (the pseudo code would look like this): osg::Matrixd mx = _camera-getInverseViewMatrix(); mxt (MatrixTransform is this)-setMatrix(mx) however, it doesnt follow the orientation, only the translation Any hints? Thanks a bunch Nick -- trajce nikolov nick ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Struggling trying to convert geometry coordinates in PagedLOD
Hi Olivier, I principle what you are doing sounds reasonable. The only odd bit in the description is that your data is already in OSG form before you transform it into local coords, to me this seems like a missed opportunity - as osg::Geometry stores coords with Vec3Array by default so will be using float positions so open to precision issues, subsequently moving these vertices into local coords won't fix the precision problem as it's already backed into the data. Tools like VirtualPlanetBuilder and osgEarth all convert from geographic/geocentric coords that use doubles for position to local coords with floats for the vertex data and doubles in the MatrixTransform that decorate the local coordinate frames. The problems with missing tiles/wrong tiles suggests to be an issue with LOD range or centers. I guess it could also be something like placing the transforms in the wrong place so that the LOD centers/ranges aren't in the coordinate frame you think they are in. Both VirtualPlanetBuilder and osgEarth place the MatrixTransform below the PagedLOD and directly above the geometry. Robert. On 13 March 2013 11:54, Olivier Tournaire olit...@gmail.com wrote: Hi Robert, So, I will try to summarize my post, without any code :) With my first post, I tried to be as complete as possible to clearly describe the issue, with all the related code. Sorry for this. Thus, I am trying to convert geometry coordinates of Drawables contained in Geodes. My Geodes are children of PagedLOD, and there is a single Geode per PagedLOD. For a given part of my terrain, I have more than 1000 files, with 9 levels of details. To convert the coordinates, I simply parse the coordinates in my original geometries, apply the transformation (code of my own and with proj4) and then use the setVertexArray method to replace the geometry coordinates in my drawables. I do this for each file. I center the coordinates around (0,0,0) because they are in 10e+06, and then add on top of my Geodes a translation MatrixTransform which value come from the barycenter of the points. If my Geode is contained in a PagedLOD, I also set the UserCenter to this value. The problem is that when I view the transformed hierarchy in osgviewer, sometimes, when I am really close from the terrain, some tiles disappear. If I move a few, they appear again. It also seems that the order of the loaded tiles is incorrect. Both problems are illustrated by this images: http://imageshack.us/photo/my-images/109/badtiles.png/ http://imageshack.us/photo/my-images/685/pagedlodsranges.jpg/ Hope you could help. Best regards, Olivier 2013/3/13 Robert Osfield robert.osfi...@gmail.com Hi Oliver, On 13 March 2013 07:54, Olivier Tournaire olit...@gmail.com wrote: No one on this? I suspect you lost a lot of readers with the volume of your post, please remember that all members of the community are busy working and only have a little time to read and keep up with posts and write replies. Try distilling the issue you have down to what others might be able to easily understand and provide an answer for. Robert. ___ 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 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Problem with fullscreen hiding dialog window
Here's the code which is basically the same as in the link in my initial post, slightly modified. Code: // Indices of file types #define INDEX_COLLADA 1 #define INDEX_OPENSCENEGRAPH 2 #define INDEX_KEYHOLEMARKUPLANGUAGE 3 #define INDEX_ALLFILES 4 #define FILE_TYPE_MODELS 1 #define FILE_TYPE_IMAGES 2 #define FILE_TYPE_TERRAFORM 3 class CDialogEventHandler : public IFileDialogEvents, public IFileDialogControlEvents { public: // IUnknown methods IFACEMETHODIMP QueryInterface(REFIID riid, void** ppv) { static const QITAB qit[] = { QITABENT(CDialogEventHandler, IFileDialogEvents), QITABENT(CDialogEventHandler, IFileDialogControlEvents), { 0 }, }; return QISearch(this, qit, riid, ppv); } IFACEMETHODIMP_(ULONG) AddRef() { return InterlockedIncrement(_cRef); } IFACEMETHODIMP_(ULONG) Release() { long cRef = InterlockedDecrement(_cRef); if (!cRef) delete this; return cRef; } // IFileDialogEvents methods IFACEMETHODIMP OnFileOk(IFileDialog *) { return S_OK; }; IFACEMETHODIMP OnFolderChange(IFileDialog *) { return S_OK; }; IFACEMETHODIMP OnFolderChanging(IFileDialog *, IShellItem *) { return S_OK; }; IFACEMETHODIMP OnHelp(IFileDialog *) { return S_OK; }; IFACEMETHODIMP OnSelectionChange(IFileDialog *) { return S_OK; }; IFACEMETHODIMP OnShareViolation(IFileDialog *, IShellItem *, FDE_SHAREVIOLATION_RESPONSE *) { return S_OK; }; IFACEMETHODIMP OnTypeChange(IFileDialog *pfd) { return S_OK; }; IFACEMETHODIMP OnOverwrite(IFileDialog *, IShellItem *, FDE_OVERWRITE_RESPONSE *) { return S_OK; }; // IFileDialogControlEvents methods IFACEMETHODIMP OnItemSelected(IFileDialogCustomize *pfdc, DWORD dwIDCtl, DWORD dwIDItem) { return S_OK; }; IFACEMETHODIMP OnButtonClicked(IFileDialogCustomize *, DWORD) { return S_OK; }; IFACEMETHODIMP OnCheckButtonToggled(IFileDialogCustomize *, DWORD, BOOL) { return S_OK; }; IFACEMETHODIMP OnControlActivating(IFileDialogCustomize *, DWORD) { return S_OK; }; CDialogEventHandler() : _cRef(1) { }; private: ~CDialogEventHandler() { }; long _cRef; }; // Instance creation helper HRESULT CDialogEventHandler_CreateInstance(REFIID riid, void **ppv) { *ppv = NULL; CDialogEventHandler *pDialogEventHandler = new (std::nothrow) CDialogEventHandler(); HRESULT hr = pDialogEventHandler ? S_OK : E_OUTOFMEMORY; if (SUCCEEDED(hr)) { hr = pDialogEventHandler-QueryInterface(riid, ppv); pDialogEventHandler-Release(); } return hr; } HRESULT basicFileOpen(std::wstring foundPath, int fileTypes ) { // CoCreate the File Open Dialog object. IFileDialog *pfd = NULL; HRESULT hr = CoCreateInstance(CLSID_FileOpenDialog, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(pfd)); pfd-SetTitle( LUrban Explorer - Open ); const COMDLG_FILTERSPEC modelSaveTypes[] = { {LCOLLADA (*.dae), L*.dae}, {LOpenSceneGraph (*.osg; *.osgb), L*.osg;*.osgb}, {LKeyhole Markup Language (*.kmz), L*.kmz}, {LAll Files (*.*), L*.*} }; const COMDLG_FILTERSPEC imageSaveTypes[] = { {LPNG (*.png), L*.png}, {LJPG (*.jpg), L*.jpg}, {LAll Files (*.*), L*.*} }; const COMDLG_FILTERSPEC terraformSaveTypes[] = { {LTFI (*.terraformImage), L*.terraformImage}, {LAll Files (*.*), L*.*} }; if (SUCCEEDED(hr)) { // Create an event handling object, and hook it up to the dialog. IFileDialogEvents *pfde = NULL; hr = CDialogEventHandler_CreateInstance(IID_PPV_ARGS(pfde)); if (SUCCEEDED(hr)) { // Hook up the event handler. DWORD dwCookie; hr = pfd-Advise(pfde, dwCookie); if (SUCCEEDED(hr))
Re: [osg-users] Problem with fullscreen hiding dialog window
Something like this somewhere on your code http://www.codeguru.com/cpp/w-d/dislog/article.php/c1857/Making-a-Window-Always-On-Top.htm Look for HWND_TOPMOST in MSDN On Wed, Mar 13, 2013 at 3:45 PM, David Sellin davse...@student.liu.sewrote: Here's the code which is basically the same as in the link in my initial post, slightly modified. Code: // Indices of file types #define INDEX_COLLADA 1 #define INDEX_OPENSCENEGRAPH 2 #define INDEX_KEYHOLEMARKUPLANGUAGE 3 #define INDEX_ALLFILES 4 #define FILE_TYPE_MODELS 1 #define FILE_TYPE_IMAGES 2 #define FILE_TYPE_TERRAFORM 3 class CDialogEventHandler : public IFileDialogEvents, public IFileDialogControlEvents { public: // IUnknown methods IFACEMETHODIMP QueryInterface(REFIID riid, void** ppv) { static const QITAB qit[] = { QITABENT(CDialogEventHandler, IFileDialogEvents), QITABENT(CDialogEventHandler, IFileDialogControlEvents), { 0 }, }; return QISearch(this, qit, riid, ppv); } IFACEMETHODIMP_(ULONG) AddRef() { return InterlockedIncrement(_cRef); } IFACEMETHODIMP_(ULONG) Release() { long cRef = InterlockedDecrement(_cRef); if (!cRef) delete this; return cRef; } // IFileDialogEvents methods IFACEMETHODIMP OnFileOk(IFileDialog *) { return S_OK; }; IFACEMETHODIMP OnFolderChange(IFileDialog *) { return S_OK; }; IFACEMETHODIMP OnFolderChanging(IFileDialog *, IShellItem *) { return S_OK; }; IFACEMETHODIMP OnHelp(IFileDialog *) { return S_OK; }; IFACEMETHODIMP OnSelectionChange(IFileDialog *) { return S_OK; }; IFACEMETHODIMP OnShareViolation(IFileDialog *, IShellItem *, FDE_SHAREVIOLATION_RESPONSE *) { return S_OK; }; IFACEMETHODIMP OnTypeChange(IFileDialog *pfd) { return S_OK; }; IFACEMETHODIMP OnOverwrite(IFileDialog *, IShellItem *, FDE_OVERWRITE_RESPONSE *) { return S_OK; }; // IFileDialogControlEvents methods IFACEMETHODIMP OnItemSelected(IFileDialogCustomize *pfdc, DWORD dwIDCtl, DWORD dwIDItem) { return S_OK; }; IFACEMETHODIMP OnButtonClicked(IFileDialogCustomize *, DWORD) { return S_OK; }; IFACEMETHODIMP OnCheckButtonToggled(IFileDialogCustomize *, DWORD, BOOL) { return S_OK; }; IFACEMETHODIMP OnControlActivating(IFileDialogCustomize *, DWORD) { return S_OK; }; CDialogEventHandler() : _cRef(1) { }; private: ~CDialogEventHandler() { }; long _cRef; }; // Instance creation helper HRESULT CDialogEventHandler_CreateInstance(REFIID riid, void **ppv) { *ppv = NULL; CDialogEventHandler *pDialogEventHandler = new (std::nothrow) CDialogEventHandler(); HRESULT hr = pDialogEventHandler ? S_OK : E_OUTOFMEMORY; if (SUCCEEDED(hr)) { hr = pDialogEventHandler-QueryInterface(riid, ppv); pDialogEventHandler-Release(); } return hr; } HRESULT basicFileOpen(std::wstring foundPath, int fileTypes ) { // CoCreate the File Open Dialog object. IFileDialog *pfd = NULL; HRESULT hr = CoCreateInstance(CLSID_FileOpenDialog, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(pfd)); pfd-SetTitle( LUrban Explorer - Open ); const COMDLG_FILTERSPEC modelSaveTypes[] = { {LCOLLADA (*.dae), L*.dae}, {LOpenSceneGraph (*.osg; *.osgb), L*.osg;*.osgb}, {LKeyhole Markup Language (*.kmz), L*.kmz}, {LAll Files (*.*), L*.*} }; const COMDLG_FILTERSPEC imageSaveTypes[] = { {LPNG (*.png), L*.png}, {LJPG (*.jpg), L*.jpg}, {LAll Files (*.*), L*.*} }; const COMDLG_FILTERSPEC terraformSaveTypes[] = { {LTFI (*.terraformImage), L*.terraformImage}, {LAll Files (*.*), L*.*} }; if (SUCCEEDED(hr)) { // Create an event handling object, and hook it up to the dialog. IFileDialogEvents *pfde = NULL; hr = CDialogEventHandler_CreateInstance(IID_PPV_ARGS(pfde));
Re: [osg-users] Light lobes
nevermind. I looked up in the archove (years ago :-) ...) and I find it. Ping me if you came across similar problem. I will provide hints Nick p.s. How useful is this list !!! On Wed, Mar 13, 2013 at 3:44 PM, Trajce Nikolov NICK trajce.nikolov.n...@gmail.com wrote: Hi Community, I have done this before but it seams I forgot all of it now :-). Here is the story: I have GLSL code for pixel based lighting and my LightSource is attached to a matrixtrasnform which has updatecallback to update the position and orientation based on the camera view matrix (the pseudo code would look like this): osg::Matrixd mx = _camera-getInverseViewMatrix(); mxt (MatrixTransform is this)-setMatrix(mx) however, it doesnt follow the orientation, only the translation Any hints? Thanks a bunch Nick -- trajce nikolov nick -- trajce nikolov nick ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Light lobes
just for the record. with some code samples including light lobes combination with shadow map (thanks to wojtek) https://groups.google.com/forum/?fromgroups=#!topic/osg-users/M_sGi1Ayj68 Nick On Wed, Mar 13, 2013 at 4:49 PM, Trajce Nikolov NICK trajce.nikolov.n...@gmail.com wrote: nevermind. I looked up in the archove (years ago :-) ...) and I find it. Ping me if you came across similar problem. I will provide hints Nick p.s. How useful is this list !!! On Wed, Mar 13, 2013 at 3:44 PM, Trajce Nikolov NICK trajce.nikolov.n...@gmail.com wrote: Hi Community, I have done this before but it seams I forgot all of it now :-). Here is the story: I have GLSL code for pixel based lighting and my LightSource is attached to a matrixtrasnform which has updatecallback to update the position and orientation based on the camera view matrix (the pseudo code would look like this): osg::Matrixd mx = _camera-getInverseViewMatrix(); mxt (MatrixTransform is this)-setMatrix(mx) however, it doesnt follow the orientation, only the translation Any hints? Thanks a bunch Nick -- trajce nikolov nick -- trajce nikolov nick -- trajce nikolov nick ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] [forum] Rendering backface like front face
Hi, sorry if this may be too obvious. I was wondering if there is some kind of backface mode where backfaces are rendered like the front face? We have a model here that looks normal in Rhino and SimLab Composer because they seem to be able to render that way (backface like front face) - see foot note. Looking at the model in OSG it becomes obvious, that some surfaces are inside out (e.g. black if culling is off, or invisible if backface culling is active). Instead of fixing the model, I was interested if I could teach OSG to render the backface like the front face (in terms of material and shading etc)? Thank you! Cheers, Florian e.g. for Rhino: http://docs.mcneel.com/rhino/5/help/en-us/options/view/display_mode_options.htm search for Backface settings the setting is called Use front face settings which seems to be the default -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=53088#53088 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] [osgViewer] ON_DEMAND frame updates
Hello, I have been working on switching over to ON_DEMAND frame updates while using osgViewer::Viewer and I encountered the following problems (all of these issues are specific to ON_DEMAND frame updates): 1. Some of the event handlers such as osgViewer::HelpHandler, and osgViewer::ScreenCaptureHandler (maybe others) do not request a new frame explicitly after their keyboard events are triggered. However, a number of the event handlers in the same folder do (such as the StatsHandler). Thus, the HelpHandler does nothing until something else triggers a frame update. If I add another event handler before the HelpHandler and call osgGA::GUIActionAdapter::requestRedraw() when h is pressed, then the behavior is similar to that of the StatsHandler, and the first key press does not seem to have any effect (see StatsHandler behavior below), but all subsequent key presses work as expected. 2. The StatsHandler does not show up after pressing s the first time. Every subsequent time s is pressed, the StatsHandler behaves as expected. 3. The default behavior of Viewer::checkNeedToDoFrame() makes it difficult to use with scene graphs that contain UpdateCallbacks because there is no easy way that I have found to disable or modify the getNumChildrenRequiringUpdateTraversal() check (without deriving). Some example code: osg::ref_ptr osgViewer::Viewer viewer (new osgViewer::Viewer ()); // Setup viewer camera and context here... // ... viewer-addEventHandler (new osgViewer::StatsHandler ()); viewer-setRunFrameScheme (osgViewer::ViewerBase::ON_DEMAND); viewer-run (); I did override the osgViewer::Viewer::checkNeedToDoFrame() behavior to skip the UpdateCallback check (so frames were not continuously rendered as a result) in order to address issue #3 above. Thank you, Judson ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [forum] Rendering backface like front face
Did you try turning on 2-sided lighting? On Wed, Mar 13, 2013 at 11:47 AM, Florian Kolbe florian.ko...@in-gmbh.dewrote: Hi, sorry if this may be too obvious. I was wondering if there is some kind of backface mode where backfaces are rendered like the front face? We have a model here that looks normal in Rhino and SimLab Composer because they seem to be able to render that way (backface like front face) - see foot note. Looking at the model in OSG it becomes obvious, that some surfaces are inside out (e.g. black if culling is off, or invisible if backface culling is active). Instead of fixing the model, I was interested if I could teach OSG to render the backface like the front face (in terms of material and shading etc)? Thank you! Cheers, Florian e.g. for Rhino: http://docs.mcneel.com/rhino/5/help/en-us/options/view/display_mode_options.htm search for Backface settings the setting is called Use front face settings which seems to be the default -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=53088#53088 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org -- Paul Martz Skew Matrix Software LLC ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Struggling trying to convert geometry coordinates in PagedLOD
Hi Robert, Thank you for your reply. Regarding the precision issue, I take care to do all computation in double (which works because original coordinates are in local reference frame), and, once transformed, I can safely use float without loss of precision. As VPB and osgEarth, the MatrixTransform is below the PagedLOD and directly above the Geode as you suggested. However, having a detailed look at the original data, I saw that (A PagedLOD has always a single Geode with a single Drawable): * PagedLOD center/radius is not the same as the Geode bound center/radius In the current version of my code, I set the PagedLOD center as the new center computed from the coordinate transform, and set its radius according to the Geode bound radius after conversion. I tried, to update the PagedLOD raidus keeping the initial ratio, but the problem is still there. However, this might also be related to the PagedLOD center. Do you have any idea on how to update its value, taking into account the new and old Geode centers, the old PagedLOD center? Regards, Olivier 2013/3/13 Robert Osfield robert.osfi...@gmail.com Hi Olivier, I principle what you are doing sounds reasonable. The only odd bit in the description is that your data is already in OSG form before you transform it into local coords, to me this seems like a missed opportunity - as osg::Geometry stores coords with Vec3Array by default so will be using float positions so open to precision issues, subsequently moving these vertices into local coords won't fix the precision problem as it's already backed into the data. Tools like VirtualPlanetBuilder and osgEarth all convert from geographic/geocentric coords that use doubles for position to local coords with floats for the vertex data and doubles in the MatrixTransform that decorate the local coordinate frames. The problems with missing tiles/wrong tiles suggests to be an issue with LOD range or centers. I guess it could also be something like placing the transforms in the wrong place so that the LOD centers/ranges aren't in the coordinate frame you think they are in. Both VirtualPlanetBuilder and osgEarth place the MatrixTransform below the PagedLOD and directly above the geometry. Robert. On 13 March 2013 11:54, Olivier Tournaire olit...@gmail.com wrote: Hi Robert, So, I will try to summarize my post, without any code :) With my first post, I tried to be as complete as possible to clearly describe the issue, with all the related code. Sorry for this. Thus, I am trying to convert geometry coordinates of Drawables contained in Geodes. My Geodes are children of PagedLOD, and there is a single Geode per PagedLOD. For a given part of my terrain, I have more than 1000 files, with 9 levels of details. To convert the coordinates, I simply parse the coordinates in my original geometries, apply the transformation (code of my own and with proj4) and then use the setVertexArray method to replace the geometry coordinates in my drawables. I do this for each file. I center the coordinates around (0,0,0) because they are in 10e+06, and then add on top of my Geodes a translation MatrixTransform which value come from the barycenter of the points. If my Geode is contained in a PagedLOD, I also set the UserCenter to this value. The problem is that when I view the transformed hierarchy in osgviewer, sometimes, when I am really close from the terrain, some tiles disappear. If I move a few, they appear again. It also seems that the order of the loaded tiles is incorrect. Both problems are illustrated by this images: http://imageshack.us/photo/my-images/109/badtiles.png/ http://imageshack.us/photo/my-images/685/pagedlodsranges.jpg/ Hope you could help. Best regards, Olivier 2013/3/13 Robert Osfield robert.osfi...@gmail.com Hi Oliver, On 13 March 2013 07:54, Olivier Tournaire olit...@gmail.com wrote: No one on this? I suspect you lost a lot of readers with the volume of your post, please remember that all members of the community are busy working and only have a little time to read and keep up with posts and write replies. Try distilling the issue you have down to what others might be able to easily understand and provide an answer for. Robert. ___ 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 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list
Re: [osg-users] [osgViewer] ON_DEMAND frame updates
After some additional research, I have learned that the behavior is different when the threading model is set to SingleThreaded. After setting the threading model to SingleThreaded, issues #1 and 2# are effectively gone (I still have to call requestRedraw() for #1). I can only speculate that there is a race condition somewhere that I have not tracked down. Regards, Judson On 3/13/2013 2:06 PM, Judson Weissert wrote: Hello, I have been working on switching over to ON_DEMAND frame updates while using osgViewer::Viewer and I encountered the following problems (all of these issues are specific to ON_DEMAND frame updates): 1. Some of the event handlers such as osgViewer::HelpHandler, and osgViewer::ScreenCaptureHandler (maybe others) do not request a new frame explicitly after their keyboard events are triggered. However, a number of the event handlers in the same folder do (such as the StatsHandler). Thus, the HelpHandler does nothing until something else triggers a frame update. If I add another event handler before the HelpHandler and call osgGA::GUIActionAdapter::requestRedraw() when h is pressed, then the behavior is similar to that of the StatsHandler, and the first key press does not seem to have any effect (see StatsHandler behavior below), but all subsequent key presses work as expected. 2. The StatsHandler does not show up after pressing s the first time. Every subsequent time s is pressed, the StatsHandler behaves as expected. 3. The default behavior of Viewer::checkNeedToDoFrame() makes it difficult to use with scene graphs that contain UpdateCallbacks because there is no easy way that I have found to disable or modify the getNumChildrenRequiringUpdateTraversal() check (without deriving). Some example code: osg::ref_ptr osgViewer::Viewer viewer (new osgViewer::Viewer ()); // Setup viewer camera and context here... // ... viewer-addEventHandler (new osgViewer::StatsHandler ()); viewer-setRunFrameScheme (osgViewer::ViewerBase::ON_DEMAND); viewer-run (); I did override the osgViewer::Viewer::checkNeedToDoFrame() behavior to skip the UpdateCallback check (so frames were not continuously rendered as a result) in order to address issue #3 above. Thank you, Judson ___ 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
[osg-users] Android Bug
I think we have missed a bug along the way. Yesterday a was checking the original examples and have gone totally awry crashing when Android is loading the library itself. This happens with all versions from r8a to r8d with the current thrunk. 3.0.1 instead it's still usable. Also, the latests developer releases crash in the same way that thrunk does. How it was missed? because it's something that you don't see if you don't execute the examples, and even so if you don't check twice that the project is clean you will probably end using whatever version you had already. I'll try to pinpoint the source of errors soon and i would like some feedback to changes. Thank you and please comment your thoughts. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org