Re: [osg-users] OSG 3.2.1 and Qt5 Widget integration
Hi Sebastian, I use Qt 5 and OSG 3.2.1 with no problem passing the key events from Qt to OSG. In your Qt widget subclass you'll have a method which gets the key events: void keyPressEvent(QKeyEvent* e) { const char *keyData = e-text().toLatin1().data(); gw-getEventQueue()-keyPress(osgGA::GUIEventAdapter::KeySymbol(*keyData)); } provided that gw is your osgViewer::GraphicsWindow. Note that for the meta keys (like ALT, CTRL, SHIFT), you'll have to check something like: switch(e-key()) { case Qt::Key_Shift: key = osgGA::GUIEventAdapter::KEY_Shift_L; //left key is chosen in an arbitrary way since Qt doesn't differ left or right break; case Qt::Key_Control : key = osgGA::GUIEventAdapter::KEY_Control_L; break; case Qt::Key_Alt : key = osgGA::GUIEventAdapter::KEY_Alt_L; break; } since there is no value in e-text(). And the same can be achieved for the keyReleaseEvent, mousePress/ReleaseEvent, etc. by creating a new GUIEventAdapter from the Qt event and then send it to the event queue. Hope that helps. Cheers Pierre-Jean Le 03/08/2015 17:01, Sebastian Messerschmidt a écrit : Am 03.08.2015 um 16:57 schrieb Can Olcek: Hi Sebastian, I have almost completed the example. My original implementation is a little bit complex than this. Thanks to the couple of private replies and discussion, I will post it tomorrow. But for keyboard inputs, I'm using an event filter. Okay, I know how to use EventFilters etc. The point is, that the qt4 implementation somehow passed the events to OSG, while the qt5 seems to fail to pass any keys. Cheers Sebastian Something like this: Code: class QInputFilter : public QObject { Q_OBJECT protected: bool eventFilter(QObject *obj, QEvent *event); void onKeyPress(QKeyEvent *e); void onKeyRelease(QKeyEvent *e); }; bool QInputFilter::eventFilter(QObject *obj, QEvent *event) { switch(event-type()) { case QEvent::KeyPress: onKeyPress(static_castQKeyEvent *(event)); break; case QEvent::KeyRelease: onKeyRelease(static_castQKeyEvent *(event)); break; } return QObject::eventFilter(obj, event); } void QInputFilter::onKeyPress(QKeyEvent *e) { if(e-isAutoRepeat()) { e-ignore(); return; } unsigned int key = e-key(); // add pressed keys and add changed keys for current frame // renderwidget will clear changed keys at the end of frame Input::PrivateAccess::pressedKeys().insert(key); Input::PrivateAccess::changedKeys().insert(key); e-accept(); } void QInputFilter::onKeyPress(QKeyEvent *e) { if(e-isAutoRepeat()) { e-ignore(); return; } unsigned int key = e-key(); // remove released keys and add changed keys for current frame // renderwidget will clear changed keys at the end of frame Input::PrivateAccess::pressedKeys().erase(e-key()); Input::PrivateAccess::changedKeys().insert(e-key()); e-accept(); } Add input listener to your Qt app: Code: sdt::Author::QInputFilter inputFilter; app.installEventFilter(inputFilter); I have almost fully static Input class to access keys and mouse states during each frame (paintGL()) I've actually tried to implement Unity3D like approach so inside cull or update traversal I can use Input::getButton(), Input::getKey(), Input::isKeyUp(), etc. methods. I can add full implemention of this to my full example. Cheers, Can -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=64591#64591 ___ 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] OSG 3.2.1 and Qt5 Widget integration
Hi Pierre, Hi Sebastian, I use Qt 5 and OSG 3.2.1 with no problem passing the key events from Qt to OSG. In your Qt widget subclass you'll have a method which gets the key events: void keyPressEvent(QKeyEvent* e) { const char *keyData = e-text().toLatin1().data(); gw-getEventQueue()-keyPress(osgGA::GUIEventAdapter::KeySymbol(*keyData)); } provided that gw is your osgViewer::GraphicsWindow. Note that for the meta keys (like ALT, CTRL, SHIFT), you'll have to check something like: switch(e-key()) { case Qt::Key_Shift: key = osgGA::GUIEventAdapter::KEY_Shift_L; //left key is chosen in an arbitrary way since Qt doesn't differ left or right break; case Qt::Key_Control : key = osgGA::GUIEventAdapter::KEY_Control_L; break; case Qt::Key_Alt : key = osgGA::GUIEventAdapter::KEY_Alt_L; break; } since there is no value in e-text(). And the same can be achieved for the keyReleaseEvent, mousePress/ReleaseEvent, etc. by creating a new GUIEventAdapter from the Qt event and then send it to the event queue. Okay, I have implemented this almost like this. The only thing I don't understand is why it was working out of the box (having a qwidget holding the osg::Viewer::GraphicsWindow) without manually pushing the events. Thanks for documenting ;-) Cheers Sebastian Hope that helps. Cheers Pierre-Jean Le 03/08/2015 17:01, Sebastian Messerschmidt a écrit : Am 03.08.2015 um 16:57 schrieb Can Olcek: Hi Sebastian, I have almost completed the example. My original implementation is a little bit complex than this. Thanks to the couple of private replies and discussion, I will post it tomorrow. But for keyboard inputs, I'm using an event filter. Okay, I know how to use EventFilters etc. The point is, that the qt4 implementation somehow passed the events to OSG, while the qt5 seems to fail to pass any keys. Cheers Sebastian Something like this: Code: class QInputFilter : public QObject { Q_OBJECT protected: bool eventFilter(QObject *obj, QEvent *event); void onKeyPress(QKeyEvent *e); void onKeyRelease(QKeyEvent *e); }; bool QInputFilter::eventFilter(QObject *obj, QEvent *event) { switch(event-type()) { case QEvent::KeyPress: onKeyPress(static_castQKeyEvent *(event)); break; case QEvent::KeyRelease: onKeyRelease(static_castQKeyEvent *(event)); break; } return QObject::eventFilter(obj, event); } void QInputFilter::onKeyPress(QKeyEvent *e) { if(e-isAutoRepeat()) { e-ignore(); return; } unsigned int key = e-key(); // add pressed keys and add changed keys for current frame // renderwidget will clear changed keys at the end of frame Input::PrivateAccess::pressedKeys().insert(key); Input::PrivateAccess::changedKeys().insert(key); e-accept(); } void QInputFilter::onKeyPress(QKeyEvent *e) { if(e-isAutoRepeat()) { e-ignore(); return; } unsigned int key = e-key(); // remove released keys and add changed keys for current frame // renderwidget will clear changed keys at the end of frame Input::PrivateAccess::pressedKeys().erase(e-key()); Input::PrivateAccess::changedKeys().insert(e-key()); e-accept(); } Add input listener to your Qt app: Code: sdt::Author::QInputFilter inputFilter; app.installEventFilter(inputFilter); I have almost fully static Input class to access keys and mouse states during each frame (paintGL()) I've actually tried to implement Unity3D like approach so inside cull or update traversal I can use Input::getButton(), Input::getKey(), Input::isKeyUp(), etc. methods. I can add full implemention of this to my full example. Cheers, Can -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=64591#64591 ___ 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 osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] OSG 3.2.1 and Qt5 Widget integration
Hi Sebastian, I am not using Qt but faced the same problem. So here is a 'hack' for Windows if it helps: osgViewer::CompositeViewer::Windows wins; viewer-getWindows(wins); 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_castosgViewer::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 Mon, Aug 3, 2015 at 3:43 PM, Sebastian Messerschmidt sebastian.messerschm...@gmx.de wrote: Hi Can, Have you created a full code example yet? My problem right now is the lack of keyboard events being passed through to OSG. Any hints on this? Cheers Sebastian Hi, I have been working Qt5 integration for my current rendering application implementing deferred rendering and came up with couple of solutions. I want to share it with the people struggling Qt5 integration while waiting official stable release :) Since the current stable release is OSG 3.2.1, this will be based on that version. For Qt5 version, I recommend using = 5.4, because in earlier versions you have to do a lot by yourself. In 5.4, at least you have QOpenGLWidget. Even though I will give solution for widget, this can be applied to QWindow solution as well. The codes will be bits and pieces, unfortunately cannot share full working code. Firstly, create a new widget rendering class subclassing QOpenGLWidget. This one is almost same as the QGLWidget version of it. Code: class RenderWidget : public [b]QOpenGLWidget[/b] { Q_OBJECT public: RenderWidget(QWidget* parent = 0, Qt::WindowFlags f = 0); ~RenderWidget(); protected: virtual void initializeGL(); virtual void paintGL(); virtual void resizeGL(int width, int height); osg::ref_ptrosgViewer::GraphicsWindow gw; osg::ref_ptrosgViewer::Viewer viewer; private: QTimer heartbeat; }; RenderWidget::RenderWidget(QWidget* parent, Qt::WindowFlags f) { // instead of osgViewer::setUpViewerAsEmbeddedInWindow, we are going to // inject our osg::State subclass gw = new GraphicsWindowEx(0, 0, width(), height()); viewer = new osgViewer::Viewer(); viewer-setThreadingModel(osgViewer::Viewer::SingleThreaded); // setup viewer's camera etc. // In my case, I don't want the base camera to clear anything // I have a lot of other cameras queued as FBO rendering viewer-getCamera()-setViewport(0, 0, width(), height()) viewer-getCamera()-setGraphicsContext(gw); viewer-getCamera()-setClearMask(0); //... connect(heartbeat, SIGNAL(timeout()), this, SLOT(update()), Qt::QueuedConnection); hearbeat.start(10); } void RenderWidget::initializeGL() { viewer-realize(); } void RenderWidget::paintGL() { static_castStateEx *(state)-setDefaultFbo(defaultFramebufferObject()); viewer-frame(); // OR if you want to mix OSG with Qt 2D API QPainter painter(this); painter.beginNativePainting(); viewer-frame(); painter.endNativePainting(); // calculate fps... painter.setPen(Qt::white); painter.drawText(width() - 100, 10, 50, 25, Qt::AlignLeft, QString::number(fps)); painter.end(); } void RenderWidget::resizeGL(int width, int height) { gw-getEventQueue()-windowResize(0, 0, width, height); gw-resized(0, 0, width, height); //... } The difference between old QGLWidget and QOpenGLWidget is how they handle the rendering in the background. QOpenGLWidget is using QOffscreenSurface and QFrameBufferObject to render its content. The main problem of the current OSG integration is that it does not expect a superior FBO as main framebuffer. Like in my case, if you are using a lot of FBOs, some point OSG unbinds them and returns to direct drawing or leaves the last FBO bound after drawing. However, it should return(bind) to our superior FBO used by QOpenGLWidget. Let me explain it with the source code of OSG. Code: void RenderStage::drawInner(osg::RenderInfo renderInfo, osgUtil::RenderLeaf* previous, bool doCopyTexture) { //... osg::State state = *renderInfo.getState(); osg::FBOExtensions* fbo_ext = _fbo.valid() ? osg::FBOExtensions::instance(state.getContextID(),true) : 0; bool fbo_supported = fbo_ext fbo_ext-isSupported(); bool using_multiple_render_targets = fbo_supported _fbo-hasMultipleRenderingTargets(); if (!using_multiple_render_targets) {
Re: [osg-users] Oculus+OSG
Hi, Great work on the OSG oculus support! It built and ran beautifully, for the most part. The OculusViewerSDK example continuously gives the following error message while running. There are no observable graphics issues though - the sample runs fine it appears. Warning: detected OpenGL error 'invalid operation' after applying attribute Viewport 00ABF10CF6F0 I've been building osgoculusviewer-master against the Oculus SDK 5.0.1 on Windows 8.1 64bit. The underlying OSG version is 3.2.1 I am using an nVidia GTX 970 card with the most recent WHQL drivers. My Rift Display Mode is set to Direct HMD access Is there any known cause to this error, or a possible workaround? Christian ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Threadsafe IntersectionVisitor and LineSegmentIntersector?
Hi Sebastian, the sample code is called asynchronously from several compute threads. When I make sure that only one thread at a time calls accept() everything is rock solid (millions of calls). But it's running slowly and doesn't scale well with the number of cores. Without the lock the calls to accept() are asynchronous too and I get wrong results every few hundred calls. The compute threads themselves run independetly from the main thread with the viewer. In fact this even happens in batch mode too without any visual representation at all. Thank you! Cheers, Matthias -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=64596#64596 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Threadsafe IntersectionVisitor and LineSegmentIntersector?
Hi Matthias, Hi Sebastian, the sample code is called asynchronously from several compute threads. When I make sure that only one thread at a time calls accept() everything is rock solid (millions of calls). But it's running slowly and doesn't scale well with the number of cores. Without the lock the calls to accept() are asynchronous too and I get wrong results every few hundred calls. If the scenegraph isn't static I'd expect data races or even crashes if elements are added/removed. You can traverse the graph after update/traversal safely. Take a look at osg::Operation. You can use it to add threaded operations to the update phase and synchronize against the frame only instead of interlocking your intersection traversal. I'm using it to populate the scene with instanced vegetation by querying the terrain height/color etc. and it is working fine. I don't think the problem is asynchronously call accept on the visitor but calling it when draw/update of the scenegraph are running. You could grep the intersection code for non-reentrant code (use of static objects for instance) to be sure. Cheers Sebastian The compute threads themselves run independetly from the main thread with the viewer. In fact this even happens in batch mode too without any visual representation at all. Thank you! Cheers, Matthias -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=64596#64596 ___ 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] fixed size texture
I tryed NVIDIA Quadro 600 - no results too -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=64602#64602 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [ANN] View-dependent progressive meshes on OpenSceneGraph
OK,Got it,Now all is OK! This is a great work! In following days can help you clean bugs and improve many things. Thanks zhuwan 08,03,2015 -原始邮件- 发件人: Jim Tan kctan...@hotmail.com 发送时间: 2015-8-3 17:52:37 收件人: osg-users@lists.openscenegraph.org 抄送: 主题: Re: [osg-users] [ANN] View-dependent progressive meshes on OpenSceneGraph Sorry, lost one file CMakeLists.txt on the root directory. Please update and try again. Jim webmaster wrote: Hi Jim, Infact i used to try this method,because i already found the E:/vdpm-master20150728/project/* can be used for refrence,and also tried the name E:/vdpm-master20150728/build/vdpmslim and E:/vdpm-master20150728/build/test etc,before get your hints,but still get the same errors,and even open some cmakelist.txt to check the things related. and even tried in several computers,the error is still. --- CMake Error: The source directory E:/vdpm-master20150728 does not appear to contain CMakeLists.txt. Specify --help for usage, or press the help button on the CMake GUI. --- very confused. thanks zhuwan 08,03,2015some cmakelist.txt to check the things related. 0 -- Post generated by Mail2Forum -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=64576#64576 ___ 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] fixed size texture
robertosfield wrote: My best guess is that the hardware is rounding down the tex coords when sampling the texture so that it's not always picking out the right hand set of pixels due to numerical precision issues. Try setting the Border of the osg::Texture2D::setBorderColor(Vec4(r,g,b,a)); and set the wrap mode to CLAMP_TO_BORDER. Unfortunately, no effect. Now I trying to use specific vertex shader for correct tex coord rounding. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=64579#64579 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] BTG to blender with textures?
Hi, I'm trying to convert flightgear BTG files to a format which I can open in the most recent blender. The most success I've had is with 3ds format, but there are no textures shown. Here is the code (most of it shamelessly 'robbed' from flightgear's fgviewer): Code: // // Copyright (C) 2009 - 2012 Mathias Froehlich // // This program is free software; you can redistribute it and/or // modify it under the terms of the GNU General Public License as // published by the Free Software Foundation; either version 2 of the // License, or (at your option) any later version. // // This program is distributed in the hope that it will be useful, but // WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU // General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #ifdef HAVE_CONFIG_H #include config.h #endif #include osg/ArgumentParser #include osgDB/ReadFile #include osgDB/WriteFile #include simgear/props/props.hxx #include simgear/props/props_io.hxx #include simgear/scene/material/matlib.hxx #include simgear/scene/util/SGReaderWriterOptions.hxx #include simgear/scene/util/SGSceneFeatures.hxx #include simgear/scene/tgdb/userdata.hxx #include simgear/scene/model/ModelRegistry.hxx #include simgear/misc/ResourceManager.hxx int main(int argc, char** argv) { /// Read arguments and environment variables. // use an ArgumentParser object to manage the program arguments. // FIXME implement a flightgear similar argument parser into simgear and use this one osg::ArgumentParser arguments(argc, argv); sglog().set_log_classes(SG_ALL); sglog().set_log_priority(SG_ALERT); std::string fg_root; if (arguments.read(--fg-root, fg_root)) { } else if (const char *fg_root_env = std::getenv(FG_ROOT)) { fg_root = fg_root_env; } else { SG_LOG(SG_GENERAL, SG_ALERT, No --fg-root option set.); return -1; } std::string fg_scenery; if (arguments.read(--fg-scenery, fg_scenery)) { } else if (const char *fg_scenery_env = std::getenv(FG_SCENERY)) { fg_scenery = fg_scenery_env; } else { SG_LOG(SG_GENERAL, SG_ALERT, No --fg-scenery option set.); return -1; } SGSharedPtrSGPropertyNode props = new SGPropertyNode; try { SGPath preferencesFile = fg_root; preferencesFile.append(preferences.xml); readProperties(preferencesFile.str(), props); } catch (...) { // In case of an error, at least make summer :) props-getNode(sim/startup/season, true)-setStringValue(summer); SG_LOG(SG_GENERAL, SG_ALERT, Problems loading FlightGear preferences.\n Probably FG_ROOT is not properly set.); } std::string config; while (arguments.read(--config, config)) { try { readProperties(config, props); } catch (...) { SG_LOG(SG_GENERAL, SG_ALERT, Problems loading config file \ config \ given on the command line.); } } std::string prop, value; while (arguments.read(--prop, prop, value)) { props-setStringValue(prop, value); } std::string renderer; while (arguments.read(--renderer, renderer)); std::string federation; if (arguments.read(--federation, federation)) { props-setStringValue(hla/federate/federation, federation); } /// now set up the simgears required model stuff simgear::ResourceManager::instance()-addBasePath(fg_root, simgear::ResourceManager::PRIORITY_DEFAULT); // Just reference simgears reader writer stuff so that the globals get // pulled in by the linker ... // FIXME: make that more explicit clear and call an initialization function simgear::ModelRegistry::instance(); // FIXME Ok, replace this by querying the root of the property tree sgUserDataInit(props.get()); SGSceneFeatures::instance()-setTextureCompression(SGSceneFeatures::DoNotUseCompression); SGMaterialLibPtr ml = new SGMaterialLib; SGPath mpath(fg_root); mpath.append(Materials/default/materials.xml); try { ml-load(fg_root, mpath.str(), props); } catch (...) { SG_LOG(SG_GENERAL, SG_ALERT, Problems loading FlightGear materials.\n Probably FG_ROOT is not properly set.); } simgear::SGModelLib::init(fg_root, props); // Set up the reader/writer options osg::ref_ptrsimgear::SGReaderWriterOptions options; if (osgDB::Options* ropt = osgDB::Registry::instance()-getOptions()) options = new simgear::SGReaderWriterOptions(*ropt); else options = new simgear::SGReaderWriterOptions; osgDB::convertStringPathIntoFilePathList(fg_scenery,
Re: [osg-users] fixed size texture
Try changing the Texure type to Texture2D and the tex coordinates to 0 to 1.0. On 3 August 2015 at 09:49, Vitaliy Polyakov poljak...@yandex.ru wrote: robertosfield wrote: My guess there is a numerical precision issue on the texture coordinates. Try setting the Texture wrap mode to CLAMP_TO_EDGE, via: texture-setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE); texture-setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE); It is a good idea! But setting the Texture wrap mode to CLAMP_TO_EDGE doesn't help... Nothing changed. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=64572#64572 ___ 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] fixed size texture
My best guess is that the hardware is rounding down the tex coords when sampling the texture so that it's not always picking out the right hand set of pixels due to numerical precision issues. Try setting the Border of the osg::Texture2D::setBorderColor(Vec4(r,g,b,a)); and set the wrap mode to CLAMP_TO_BORDER. On 3 August 2015 at 10:39, Vitaliy Polyakov poljak...@yandex.ru wrote: robertosfield wrote: Try changing the Texure type to Texture2D and the tex coordinates to 0 to 1.0. New code, but old behaviour.. Code: osg::ref_ptrosg::Node createFixedSizeTexture() { osg::ref_ptrosg::Image image = osgDB::readImageFile(8x8.png); float width = image-s(); float height = image-t(); osg::Vec3Array* verts = new osg::Vec3Array(4); (*verts)[0] = osg::Vec3(-width/2.0f, -height/2.0, 0.0f); (*verts)[1] = osg::Vec3(width/2.0f, -height/2.0, 0.0f); (*verts)[2] = osg::Vec3(width/2.0f, height/2.0, 0.0f); (*verts)[3] = osg::Vec3(-width/2.0f,height/2.0, 0.0f); osg::Geometry* geometry = new osg::Geometry; geometry-setVertexArray( verts ); osg::Vec2Array* texcoords = new osg::Vec2Array(4); (*texcoords)[0].set(0.0f , 0.0f); (*texcoords)[1].set(1.0f , 0.0f); (*texcoords)[2].set(1.0f , 1.0f); (*texcoords)[3].set(0.0f , 1.0f); geometry-setTexCoordArray(0, texcoords); osg::Vec4Array* colors = new osg::Vec4Array(1); (*colors)[0].set(1, 1, 1, 1); geometry-setColorArray( colors ); geometry-setColorBinding( osg::Geometry::BIND_OVERALL ); geometry-addPrimitiveSet( new osg::DrawArrays(GL_QUADS, 0, 4)); osg::StateSet* stateSet = geometry-getOrCreateStateSet(); osg::Texture2D* texture = new osg::Texture2D( image ); texture-setFilter(osg::Texture::MIN_FILTER, osg::Texture::NEAREST); texture-setFilter(osg::Texture::MAG_FILTER, osg::Texture::NEAREST); texture-setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE); texture-setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE); stateSet-setTextureAttributeAndModes(0, texture, osg::StateAttribute::ON); stateSet-setRenderingHint(osg::StateSet::TRANSPARENT_BIN); stateSet-setAttributeAndModes( new osg::Depth(osg::Depth::ALWAYS,false), 1 ); osg::Geode* geode = new osg::Geode; geode-addDrawable( geometry ); osg::AutoTransform *at = new osg::AutoTransform; at-setAutoScaleToScreen(true); at-setAutoRotateMode( osg::AutoTransform::ROTATE_TO_SCREEN ); at-addChild( geode ); return at; } -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=64574#64574 ___ 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] fixed size texture
It may be worth trying different hardware. On 3 August 2015 at 11:48, Vitaliy Polyakov poljak...@yandex.ru wrote: robertosfield wrote: My best guess is that the hardware is rounding down the tex coords when sampling the texture so that it's not always picking out the right hand set of pixels due to numerical precision issues. Try setting the Border of the osg::Texture2D::setBorderColor(Vec4(r,g,b,a)); and set the wrap mode to CLAMP_TO_BORDER. Unfortunately, no effect. Now I trying to use specific vertex shader for correct tex coord rounding. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=64579#64579 ___ 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] Moving object in a trajectory
Hi, I have created a circle using opengl and made an osg::Node object out of it. Now I want to move it in a fixed trajectory. How to do that. Also it has to be at a distance of say 250m ahead with respect to viewer. If viewer is out of the trajectory, the object has to stop moving. Once the viewer is aligned to the trajectory, the circle object should start moving again 250m ahead. If any part of my question is not clear, I'm ready to give any details. Please reply Thank you! Cheers, Vijeesh -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=64580#64580 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [ANN] View-dependent progressive meshes on OpenSceneGraph
Hi Jim, Infact i used to try this method,because i already found the E:/vdpm-master20150728/project/* can be used for refrence,and also tried the name E:/vdpm-master20150728/build/vdpmslim and E:/vdpm-master20150728/build/test etc,before get your hints,but still get the same errors,and even open some cmakelist.txt to check the things related. and even tried in several computers,the error is still. --- CMake Error: The source directory E:/vdpm-master20150728 does not appear to contain CMakeLists.txt. Specify --help for usage, or press the help button on the CMake GUI. --- very confused. thanks zhuwan 08,03,2015 -原始邮件- 发件人: Jim Tan kctan...@hotmail.com 发送时间: 2015-8-3 16:41:05 收件人: osg-users@lists.openscenegraph.org 抄送: 主题: Re: [osg-users] [ANN] View-dependent progressive meshes on OpenSceneGraph Where to build the binaries: -- [E:/vdpm-master20150728/build] should be E:/vdpm-master20150728/build/[program name], like E:/vdpm-master20150728/build/vdpmslim E:/vdpm-master20150728/build/vdpmview ... see E:/vdpm-master20150728/project/* -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=64571#64571 ___ 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] fixed size texture
robertosfield wrote: Try changing the Texure type to Texture2D and the tex coordinates to 0 to 1.0. New code, but old behaviour.. Code: osg::ref_ptrosg::Node createFixedSizeTexture() { osg::ref_ptrosg::Image image = osgDB::readImageFile(8x8.png); float width = image-s(); float height = image-t(); osg::Vec3Array* verts = new osg::Vec3Array(4); (*verts)[0] = osg::Vec3(-width/2.0f, -height/2.0, 0.0f); (*verts)[1] = osg::Vec3(width/2.0f, -height/2.0, 0.0f); (*verts)[2] = osg::Vec3(width/2.0f, height/2.0, 0.0f); (*verts)[3] = osg::Vec3(-width/2.0f,height/2.0, 0.0f); osg::Geometry* geometry = new osg::Geometry; geometry-setVertexArray( verts ); osg::Vec2Array* texcoords = new osg::Vec2Array(4); (*texcoords)[0].set(0.0f , 0.0f); (*texcoords)[1].set(1.0f , 0.0f); (*texcoords)[2].set(1.0f , 1.0f); (*texcoords)[3].set(0.0f , 1.0f); geometry-setTexCoordArray(0, texcoords); osg::Vec4Array* colors = new osg::Vec4Array(1); (*colors)[0].set(1, 1, 1, 1); geometry-setColorArray( colors ); geometry-setColorBinding( osg::Geometry::BIND_OVERALL ); geometry-addPrimitiveSet( new osg::DrawArrays(GL_QUADS, 0, 4)); osg::StateSet* stateSet = geometry-getOrCreateStateSet(); osg::Texture2D* texture = new osg::Texture2D( image ); texture-setFilter(osg::Texture::MIN_FILTER, osg::Texture::NEAREST); texture-setFilter(osg::Texture::MAG_FILTER, osg::Texture::NEAREST); texture-setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE); texture-setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE); stateSet-setTextureAttributeAndModes(0, texture, osg::StateAttribute::ON); stateSet-setRenderingHint(osg::StateSet::TRANSPARENT_BIN); stateSet-setAttributeAndModes( new osg::Depth(osg::Depth::ALWAYS,false), 1 ); osg::Geode* geode = new osg::Geode; geode-addDrawable( geometry ); osg::AutoTransform *at = new osg::AutoTransform; at-setAutoScaleToScreen(true); at-setAutoRotateMode( osg::AutoTransform::ROTATE_TO_SCREEN ); at-addChild( geode ); return at; } -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=64574#64574 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [ANN] View-dependent progressive meshes on OpenSceneGraph
Sorry, lost one file CMakeLists.txt on the root directory. Please update and try again. Jim webmaster wrote: Hi Jim, Infact i used to try this method,because i already found the E:/vdpm-master20150728/project/* can be used for refrence,and also tried the name E:/vdpm-master20150728/build/vdpmslim and E:/vdpm-master20150728/build/test etc,before get your hints,but still get the same errors,and even open some cmakelist.txt to check the things related. and even tried in several computers,the error is still. --- CMake Error: The source directory E:/vdpm-master20150728 does not appear to contain CMakeLists.txt. Specify --help for usage, or press the help button on the CMake GUI. --- very confused. thanks zhuwan 08,03,2015some cmakelist.txt to check the things related. 0 -- Post generated by Mail2Forum -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=64576#64576 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [ANN] View-dependent progressive meshes on OpenSceneGraph
Where to build the binaries: -- [E:/vdpm-master20150728/build] should be E:/vdpm-master20150728/build/[program name], like E:/vdpm-master20150728/build/vdpmslim E:/vdpm-master20150728/build/vdpmview ... see E:/vdpm-master20150728/project/* -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=64571#64571 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] fixed size texture
robertosfield wrote: My guess there is a numerical precision issue on the texture coordinates. Try setting the Texture wrap mode to CLAMP_TO_EDGE, via: texture-setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE); texture-setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE); It is a good idea! But setting the Texture wrap mode to CLAMP_TO_EDGE doesn't help... Nothing changed. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=64572#64572 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [ANN] View-dependent progressive meshes on OpenSceneGraph
hi Jim, When get your answer,i tried the following steps: 1.make a dir named build now the dir struct is below: maindir[E:\vdpm-master20150728] subdir[E:\vdpm-master20150728\archive] subdir[E:\vdpm-master20150728\config] subdir[E:\vdpm-master20150728\data] subdir[E:\vdpm-master20150728\project] subdir[E:\vdpm-master20150728\share] subdir[E:\vdpm-master20150728\build] the build dir is just made. Where is the source code: -- [E:/vdpm-master20150728/] Where to build the binaries: -- [E:/vdpm-master20150728/build] -- then cmake error dialog: Error Error in configuration process,... -- CMake Error: The source directory E:/vdpm-master20150728 does not appear to contain CMakeLists.txt. Specify --help for usage, or press the help button on the CMake GUI. --- infact i tried other build dir made in different dir,but none of the methods generate the correct .sln project. --- and i also downloaded your compiled [MT].exe demo files and data from your bolog and run them display is correct,but always generate opengl errors in dos window,then i check your code find this is caused by the opengl state change conflict with the osg,because vdpm drawable use it's own direct opengl draw method,if i can build the source code to .exe,can help you to fix this bug. cheers zhuwan 08,03,2015 -原始邮件- 发件人: Jim Tan kctan...@hotmail.com 发送时间: 2015-8-3 12:51:49 收件人: osg-users@lists.openscenegraph.org 抄送: 主题: Re: [osg-users] [ANN] View-dependent progressive meshes on OpenSceneGraph Sorry, github not show this line: Where to build the binaries: -- [Root directory of this project]/build/[program name] I've fixed it as follow: How to build: Install Visual Studio Install CMake mkdir /build In CMake GUI: Where is the source code: -- [Root directory of this project] Where to build the binaries: -- [Root directory of this project]/build/[program name] Press [Configure] [Generate], the solution files will be generated at [Root directory of this project]/build/[program name] Jim webmaster wrote: Hi Jim, Tested the vdpm's github version following your compile steps: How to build: 1.Install Visual Studio 2010 or 2008 (this two versions is all tested) 2.Install CMake 2.810.1 or 3.2 (this two versions is all tested) 3.mkdir /build 4.In CMake GUI: Where is the source code: -- Where to build the binaries: -- /build/ Press [Configure] [Generate], the solution files will be generated at /build/ --- The cmake setting: Where is the source code:E:/vdpm-master20150728/vdpm-master/share Where to build the binaries:E:/vdpm-master20150728/vdpm-master/build the all main files is in this dir:E:/vdpm-master20150728/vdpm-master --- and get the following cmake warning: CMake Warning (dev) in CMakeLists.txt: No cmake_minimum_required command is present. A line of code such as cmake_minimum_required(VERSION 2.8) should be added at the top of the file. The version specified may be lower if you wish to support older CMake versions for this project. For more information run cmake --help-policy CMP. This warning is for project developers. Use -Wno-dev to suppress it. then edit the file E:/vdpm-master20150728/vdpm-master/share/CMakeLists.txt add the line cmake_minimum_required(VERSION 2.8) the warning disappeared. but the generated .sln project contained none vdpm related projects. what's wrong with the operation??? cheers zhuwan 08,03,2015 -原始邮件- 发件人: Jim Tan 发送时间: 2015-7-28 12:34:08 收件人: 抄送: 主题: Re: [ANN] View-dependent progressive meshes on OpenSceneGraph I've built and tested on windows platform only. Suppose it should be supported on other platform which OSG supported. kornerr wrote: Good to see it open source. Is it Windows only? 2015-07-28 5:11 GMT+07:00 webmaster (): -- Post generated by Mail2Forum -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=64500#64500 ___ osg-users mailing list
Re: [osg-users] fixed size texture
robertosfield wrote: Hi Vitaliy, Is the border part of the 8x8.png image? Does the current behaviour have the icon displayed at the correct size? Yes, border is part of image. When the application started the image has correct view and size. But if I changed position of the icon by mouse dragging, on side of the border can disappear. Also, the visual size of icon can be changed. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=64568#64568 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] fixed size texture
Just after program started [Image: http://i57.tinypic.com/2wevw5s.png ] After camera moved [Image: http://i62.tinypic.com/2j1vthw.png ] -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=64569#64569 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] fixed size texture
Hi Vitaliy, My guess there is a numerical precision issue on the texture coordinates. Try setting the Texture wrap mode to CLAMP_TO_EDGE, via: texture-setWrap(osg::Texture::WRAP_S, osg::Texture::CLAMP_TO_EDGE); texture-setWrap(osg::Texture::WRAP_T, osg::Texture::CLAMP_TO_EDGE); Robert. On 3 August 2015 at 09:19, Vitaliy Polyakov poljak...@yandex.ru wrote: Just after program started [Image: http://i57.tinypic.com/2wevw5s.png ] After camera moved [Image: http://i62.tinypic.com/2j1vthw.png ] -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=64569#64569 ___ 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] Threadsafe IntersectionVisitor and LineSegmentIntersector?
Hi folks, should the IntersectionVisitor and LineSegmentIntersector be threadsafe? With the multithreaded pseudocode below everything works fine with the ScopedLock. If I disable the ScopedLock I get wrong results. Thank you! Cheers, Matthias Code: osg::Vec3d dummy; osg::ref_ptrosgUtil::LineSegmentIntersector lineSegmentIntersector = new osgUtil::LineSegmentIntersector(dummy, dummy); osg::ref_ptrosgUtil::IntersectionVisitor visitor = new osgUtil::IntersectionVisitor(lineSegmentIntersector); ... osg::Vec3d P1, P2; lineSegmentIntersector-setStart(P1); lineSegmentIntersector-setEnd(P2); ... osg::Node* searchroot; OpenThreads::Mutex mutex; ... { OpenThreads::ScopedLockOpenThreads::Mutex lock(mutex); // Works when enabled. Doesn't work when disabled! lineSegmentIntersector-reset(); searchroot-accept(*visitor); } if (lineSegmentIntersector-containsIntersections()) { ... -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=64590#64590 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] OSG 3.2.1 and Qt5 Widget integration
Hi Sebastian, I have almost completed the example. My original implementation is a little bit complex than this. Thanks to the couple of private replies and discussion, I will post it tomorrow. But for keyboard inputs, I'm using an event filter. Something like this: Code: class QInputFilter : public QObject { Q_OBJECT protected: bool eventFilter(QObject *obj, QEvent *event); void onKeyPress(QKeyEvent *e); void onKeyRelease(QKeyEvent *e); }; bool QInputFilter::eventFilter(QObject *obj, QEvent *event) { switch(event-type()) { case QEvent::KeyPress: onKeyPress(static_castQKeyEvent *(event)); break; case QEvent::KeyRelease: onKeyRelease(static_castQKeyEvent *(event)); break; } return QObject::eventFilter(obj, event); } void QInputFilter::onKeyPress(QKeyEvent *e) { if(e-isAutoRepeat()) { e-ignore(); return; } unsigned int key = e-key(); // add pressed keys and add changed keys for current frame // renderwidget will clear changed keys at the end of frame Input::PrivateAccess::pressedKeys().insert(key); Input::PrivateAccess::changedKeys().insert(key); e-accept(); } void QInputFilter::onKeyPress(QKeyEvent *e) { if(e-isAutoRepeat()) { e-ignore(); return; } unsigned int key = e-key(); // remove released keys and add changed keys for current frame // renderwidget will clear changed keys at the end of frame Input::PrivateAccess::pressedKeys().erase(e-key()); Input::PrivateAccess::changedKeys().insert(e-key()); e-accept(); } Add input listener to your Qt app: Code: sdt::Author::QInputFilter inputFilter; app.installEventFilter(inputFilter); I have almost fully static Input class to access keys and mouse states during each frame (paintGL()) I've actually tried to implement Unity3D like approach so inside cull or update traversal I can use Input::getButton(), Input::getKey(), Input::isKeyUp(), etc. methods. I can add full implemention of this to my full example. Cheers, Can -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=64591#64591 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] OSG 3.2.1 and Qt5 Widget integration
Am 03.08.2015 um 16:57 schrieb Can Olcek: Hi Sebastian, I have almost completed the example. My original implementation is a little bit complex than this. Thanks to the couple of private replies and discussion, I will post it tomorrow. But for keyboard inputs, I'm using an event filter. Okay, I know how to use EventFilters etc. The point is, that the qt4 implementation somehow passed the events to OSG, while the qt5 seems to fail to pass any keys. Cheers Sebastian Something like this: Code: class QInputFilter : public QObject { Q_OBJECT protected: bool eventFilter(QObject *obj, QEvent *event); void onKeyPress(QKeyEvent *e); void onKeyRelease(QKeyEvent *e); }; bool QInputFilter::eventFilter(QObject *obj, QEvent *event) { switch(event-type()) { case QEvent::KeyPress: onKeyPress(static_castQKeyEvent *(event)); break; case QEvent::KeyRelease: onKeyRelease(static_castQKeyEvent *(event)); break; } return QObject::eventFilter(obj, event); } void QInputFilter::onKeyPress(QKeyEvent *e) { if(e-isAutoRepeat()) { e-ignore(); return; } unsigned int key = e-key(); // add pressed keys and add changed keys for current frame // renderwidget will clear changed keys at the end of frame Input::PrivateAccess::pressedKeys().insert(key); Input::PrivateAccess::changedKeys().insert(key); e-accept(); } void QInputFilter::onKeyPress(QKeyEvent *e) { if(e-isAutoRepeat()) { e-ignore(); return; } unsigned int key = e-key(); // remove released keys and add changed keys for current frame // renderwidget will clear changed keys at the end of frame Input::PrivateAccess::pressedKeys().erase(e-key()); Input::PrivateAccess::changedKeys().insert(e-key()); e-accept(); } Add input listener to your Qt app: Code: sdt::Author::QInputFilter inputFilter; app.installEventFilter(inputFilter); I have almost fully static Input class to access keys and mouse states during each frame (paintGL()) I've actually tried to implement Unity3D like approach so inside cull or update traversal I can use Input::getButton(), Input::getKey(), Input::isKeyUp(), etc. methods. I can add full implemention of this to my full example. Cheers, Can -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=64591#64591 ___ 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] Threadsafe IntersectionVisitor and LineSegmentIntersector?
Hello Matthias, What do you mean by threadsafe in this context? By locking the mutex you achive nothing but subtle changes in timings, if you don't lock it somewhere else. Are you maybe refering to multiple threaded intersectors? Indeed the intersection should be safe if done after the viewers event traversal. At least this is working fine for me. Cheers Sebastian Hi folks, should the IntersectionVisitor and LineSegmentIntersector be threadsafe? With the multithreaded pseudocode below everything works fine with the ScopedLock. If I disable the ScopedLock I get wrong results. Thank you! Cheers, Matthias Code: osg::Vec3d dummy; osg::ref_ptrosgUtil::LineSegmentIntersector lineSegmentIntersector = new osgUtil::LineSegmentIntersector(dummy, dummy); osg::ref_ptrosgUtil::IntersectionVisitor visitor = new osgUtil::IntersectionVisitor(lineSegmentIntersector); ... osg::Vec3d P1, P2; lineSegmentIntersector-setStart(P1); lineSegmentIntersector-setEnd(P2); ... osg::Node* searchroot; OpenThreads::Mutex mutex; ... { OpenThreads::ScopedLockOpenThreads::Mutex lock(mutex); // Works when enabled. Doesn't work when disabled! lineSegmentIntersector-reset(); searchroot-accept(*visitor); } if (lineSegmentIntersector-containsIntersections()) { ... -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=64590#64590 ___ 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] Oculus DK2 and intersections
Hi Maxim, On 3 August 2015 at 15:02, Maxim Kuzmin maxri...@mail.ru wrote: For the first time, I would like to use mouse. It will be represented as it is - as cursor. When you using a mouse the mouse coordinates need to mapped from the distortion correction coordinates back into eye coordinates and then into world coordinates to be able to the intersection. In the svn/trunk and OSG-3.4 branch of the OSG there is support in osgViewer for remapping coordinates when the viewer has slave Camera's that do distortion correction via texture coordinates, however, if the shader is doing the distortion correction or if the distortion correction Camera is placed in the scene graph this remapping can't be done, so you'll have to come up with a mechanism yourself. Robert. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] fixed size texture
robertosfield wrote: It may be worth trying different hardware. OK, I will try after work. Thank you! -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=64583#64583 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Oculus DK2 and intersections
For the first time, I would like to use mouse. It will be represented as it is - as cursor. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=64587#64587 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] OSG 3.2.1 and Qt5 Widget integration
Hi Can, Have you created a full code example yet? My problem right now is the lack of keyboard events being passed through to OSG. Any hints on this? Cheers Sebastian Hi, I have been working Qt5 integration for my current rendering application implementing deferred rendering and came up with couple of solutions. I want to share it with the people struggling Qt5 integration while waiting official stable release :) Since the current stable release is OSG 3.2.1, this will be based on that version. For Qt5 version, I recommend using = 5.4, because in earlier versions you have to do a lot by yourself. In 5.4, at least you have QOpenGLWidget. Even though I will give solution for widget, this can be applied to QWindow solution as well. The codes will be bits and pieces, unfortunately cannot share full working code. Firstly, create a new widget rendering class subclassing QOpenGLWidget. This one is almost same as the QGLWidget version of it. Code: class RenderWidget : public [b]QOpenGLWidget[/b] { Q_OBJECT public: RenderWidget(QWidget* parent = 0, Qt::WindowFlags f = 0); ~RenderWidget(); protected: virtual void initializeGL(); virtual void paintGL(); virtual void resizeGL(int width, int height); osg::ref_ptrosgViewer::GraphicsWindow gw; osg::ref_ptrosgViewer::Viewer viewer; private: QTimer heartbeat; }; RenderWidget::RenderWidget(QWidget* parent, Qt::WindowFlags f) { // instead of osgViewer::setUpViewerAsEmbeddedInWindow, we are going to // inject our osg::State subclass gw = new GraphicsWindowEx(0, 0, width(), height()); viewer = new osgViewer::Viewer(); viewer-setThreadingModel(osgViewer::Viewer::SingleThreaded); // setup viewer's camera etc. // In my case, I don't want the base camera to clear anything // I have a lot of other cameras queued as FBO rendering viewer-getCamera()-setViewport(0, 0, width(), height()) viewer-getCamera()-setGraphicsContext(gw); viewer-getCamera()-setClearMask(0); //... connect(heartbeat, SIGNAL(timeout()), this, SLOT(update()), Qt::QueuedConnection); hearbeat.start(10); } void RenderWidget::initializeGL() { viewer-realize(); } void RenderWidget::paintGL() { static_castStateEx *(state)-setDefaultFbo(defaultFramebufferObject()); viewer-frame(); // OR if you want to mix OSG with Qt 2D API QPainter painter(this); painter.beginNativePainting(); viewer-frame(); painter.endNativePainting(); // calculate fps... painter.setPen(Qt::white); painter.drawText(width() - 100, 10, 50, 25, Qt::AlignLeft, QString::number(fps)); painter.end(); } void RenderWidget::resizeGL(int width, int height) { gw-getEventQueue()-windowResize(0, 0, width, height); gw-resized(0, 0, width, height); //... } The difference between old QGLWidget and QOpenGLWidget is how they handle the rendering in the background. QOpenGLWidget is using QOffscreenSurface and QFrameBufferObject to render its content. The main problem of the current OSG integration is that it does not expect a superior FBO as main framebuffer. Like in my case, if you are using a lot of FBOs, some point OSG unbinds them and returns to direct drawing or leaves the last FBO bound after drawing. However, it should return(bind) to our superior FBO used by QOpenGLWidget. Let me explain it with the source code of OSG. Code: void RenderStage::drawInner(osg::RenderInfo renderInfo, osgUtil::RenderLeaf* previous, bool doCopyTexture) { //... osg::State state = *renderInfo.getState(); osg::FBOExtensions* fbo_ext = _fbo.valid() ? osg::FBOExtensions::instance(state.getContextID(),true) : 0; bool fbo_supported = fbo_ext fbo_ext-isSupported(); bool using_multiple_render_targets = fbo_supported _fbo-hasMultipleRenderingTargets(); if (!using_multiple_render_targets) { #if !defined(OSG_GLES1_AVAILABLE) !defined(OSG_GLES2_AVAILABLE) if( getDrawBufferApplyMask() ) glDrawBuffer(_drawBuffer); if( getReadBufferApplyMask() ) glReadBuffer(_readBuffer); #endif } if (fbo_supported) { _fbo-apply(state); } RenderBin::draw(renderInfo,previous); //... } As you can see, _fbo-apply(state); is the only point where FBO of the camera (which comes from our osg::Camera and RenderStage::runCameraSetUp) is bound before drawing our geometry etc. However, there is no line to handle returning back to FBO of QOpenGLWidget. Even we put a empty FBO as a last camera, it will executes following line: Code: void FrameBufferObject::apply(State state, BindTarget target) const { //... if (_attachments.empty()) { ext-glBindFramebuffer(target, 0); return; } //... } So basicly, it
Re: [osg-users] NodeVisitor finds the named Node, but NodeCallback doesn't rotate it
Hi, scrawl! Im not sure that i understand what do you mean by saying detached graph. I have now: Root-Group-MatrixTransform-Node. //Here is Node ref_ptrNode nodeEngineCW = osgDB::readNodeFile(pathToACModels + engineCW.ac); //Here is MatrixTransform ref_ptrMatrixTransform setupForwardEngine = new MatrixTransform; setupForwardEngine-addChild( nodeEngineCW.get() ); //Here is Group ref_ptrGroup groupAircraft =new Group; groupAircraft-addChild( setupForwardEngine.get() ); //Here is Root ref_ptrGroup rootnode = new Group; rootnode-addChild( groupAircraft.get() ); Everything seems fine in this sense. Thank you! Cheers, Elias -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=64586#64586 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] NodeVisitor finds the named Node, but NodeCallback doesn't rotate it
Am 01.08.2015 um 08:59 schrieb Elias Tarasov: Hi! I have .ac models. One is a quadrocopter and two others are it's engines. Each engine has propeller, which i want to animate by rotation. To do it, i have to find propeler's node for the start. What i was able to find that two ways are exist. First is to find a node by it's name. Second is to find a node by it's unique characteristics. Here is models: https://drive.google.com/file/d/0ByDDImhSolf6cnVIN3JIMzJQTGs/view?usp=sharing So the 1st question: How to determine, the name of the node or it's other characteristics, to be able to find it? Using NodeVisitors is the way to go with scenegraphs. I developed simple program that searches a node by it's name. Something, that looks like a node's name i found when open .ac file using notepad and search for the name tag. But im not sure. Here is code: https://drive.google.com/file/d/0ByDDImhSolf6U3BmTXpjeE1mRDg/view?usp=sharing The problem: NodeVisitor finds a node( though im not sure this node is a propeller), but NodeCallback doesn't rotate it. So the 2nd question: Why the element, identified by it's name, does not rotate? The reason, why im sure that these models should be able to rotate anyway, is that i took them from another app, based on OSG and it works well. Your sample code isn't what I would consider minimal, so it is hard to spot an obvious error. But I don't see how the MatrixTransform is related to your scene graph. You need to do something like this inside your callback for (p : node-getParents()) { p-removeChild(node); p-addChild(matrixTrans); } matrixTrans-addChild(node) Your code simply adds a new parent, so the propeller is most likely drawn twice the time you would expect. Btw. If your visitor is looking for the node-name only you don't have to implement anything else but the apply(Node) as even the osg::Geode/osg::Drawables and are osg::Node-derived since version 3.3.0. Cheers Sebastian Thank you! Cheers, Elias -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=64557#64557 ___ 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] OpenSceneGraph-3.4.0-rc9 tagged
Hi All, I believe we must be pretty close to stable 3.4.0 release as I had only one submission to merge since rc8 that I tagged at the end of last week! The revision was to make osgViewer's X11 PixelBuffer query for the SGIX extensions at runtime rather than use them directly at compile time. This change is intended to make it possible to run the OSG on X11 systems that don't provide support for the SGIX extensions. - Zip file containing source code : OpenSceneGraph-3.4.0-rc9.zip http://www.openscenegraph.org/downloads/developer_releases/OpenSceneGraph-3.4.0-rc9.zip - Subversion tag for 3.4.0-rc8 : svn co http://svn.openscenegraph.org/osg/OpenSceneGraph/tags/OpenSceneGraph-3.4. http://svn.openscenegraph.org/osg/OpenSceneGraph/tags/OpenSceneGraph-3.4.0-rc90-rc9 OpenSceneGraph As before I'd like testing out on as many platforms as we can get, positive and negative feedback is required so I know where we are at. If there aren't any reports of problems I'll go for the 3.4.0 on Wednesday. Cheers. Robert. -- ChangeLog since rc8 2015-08-03 19:14 robert * include/osgViewer/api/X11/PixelBufferX11, src/osgViewer/PixelBufferX11.cpp: From Andy Skinner, Someone was using our code on a system that does not seem to have the SGIX symbols used in osgViewer.cpp. I used osgSetGLExtensionsFuncPtr to remove the symbols. I don't know how to test this path, but it did remove the symbols from libosgViewer.so. I have also not been able yet to see if that was sufficient for our customer. I did this by looking at other cases, and I tried to follow some of the same practices in PixelBufferX11, like using _useSGIX in a similar way to the previous _useGLX1_3. ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org