[osg-users] How to get the listof supported file formats
Hi, I'm using OSG & Qt to build a visualizer for my thesis. I'm completely new to OSG and almost as new to Computer Graphics Programming too, so please don't mad on me and be patient ;-) I need to know how to get the list of supported file formats in order to use QFileDialog with the proper extension filters. I'm trying this in a slot of my main window: Code: void MainWindow::loadFile() { osg::ref_ptr registry = osgDB::Registry::instance(); osgDB::Registry::ReaderWriterList readers = registry->getReaderWriterList(); osgDB::Registry::ReaderWriterList::iterator it; osgDB::ReaderWriter::FormatDescriptionMap descrMap; osgDB::ReaderWriter::FormatDescriptionMap::iterator descrMapIt; qDebug() << readers.size() << " registered ReaderWriters"; for (it = readers.begin(); it != readers.end(); it++) { descrMap = (*it)->supportedOptions(); for( descrMapIt = descrMap.begin(); descrMapIt != descrMap.end(); descrMapIt++) { //std::cout << (*descrMapIt); } } QString filename = QFileDialog::getOpenFileName( this, tr("Load a File:"), QDir::homePath(), "OpenSceneGraph (*.osg)" ); if ( !filename.isNull() ) { this->osgWidget->loadModel(filename); } } But qDebug() always says that there are no registered ReaderWriters. I'd expect to get the native osg ReaderWriter as a minimum, but I can't get that even. Thank you! Cheers, Daniel :D :D :? :( :( [/code] -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=41002#41002 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] How to get the listof supported file formats
I thought that ReaderWriters were registered at startup. If you had not told me, I'd never noticed because documentation about it's very reduced. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=41053#41053 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] How to get the listof supported file formats
Please give me one last hint. I have taken a look to to osgconv.cpp as you told me and I found this: Code: if (arguments.read("--formats") { osgDB::FileNameList plugins = osgDB::listAllAvailablePlugins(); for(osgDB::FileNameList::iterator itr = plugins.begin(); itr != plugins.end(); ++itr) { osgDB::outputPluginDetails(std::cout,*itr); } return 0; } So I guess that there must be a function or class method in the osgDB namespace which gives me a mechanism to query all plugin supported formats given the plugin file referenced by *itr. The problem is that I can't find it in the documentation at first sight. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=41056#41056 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] How to get the listof supported file formats
No, sorry. Quick Start Guide is great, but it was too dense for me given that I'm a newbie looking for a way to make progress quickly. So I preferred to look at the new OSG 3.0 book and the doxygen docs. (The doxygen docs has much classes/methods documentation missing). Anyway, thanks a lot everybody, I think I've found my way to do what I wanted. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=41072#41072 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Boundary Representations
Hi, I'd like to know if OSG has any class for handling Boundary Representations before writing one by myself. I'm working with orthogonal pseudo polyhedra. ... Thank you! Cheers, Daniel -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=41120#41120 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Fitting my world into the viewport
Hi, I'm very new to OSG and OpenGL programming in general, but right now I'm working on my thesis and my application requires to load several models on the same scene. Once every model is done loading, I must adjust the viewer's settings so that an user is able to see the entire scene. I know this can be achieved by fitting the world's bounding sphere into the viewport, the problem is that I don't know OSG Classes well enough to do so. My application is Qt-based and uses a Track Ball Manipulator. I wonder if I must use the manipulator methods, or adjust the camera's projection directly. I'd appreciate if you can give me some examples of how should I work on this. Thank you! Cheers, Daniel -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=51686#51686 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Fitting my world into the viewport
I'm not using any custom Qt manipulator, I'm using OSG ones, i.e. osgGA::TrackballManipulator. I'm using Qt only for my application GUI, and my code is based on the OSG Cookbok recipe, where I define an osgWidget class and pass a camera pointer. Besides that, my intention is not using the command line osgviewer application, but integrate it into a GUI as mentioned before, so maybe there is a bit of confusion here in what I need to do and how to do it :) -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=51692#51692 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Fitting my world into the viewport
Hi, thank you for your reply. I solved the problem by computing the world's bounding sphere and then computing the minimum distance from the eye to the near clipping plane by using a formula I found in OpenGL forums: Code: boundingSphere.radius() / sin( osg::DegreesToRadians( FIELD_OF_VIEW * .5 ) ) It resulted to be the same formula mentioned in the post you suggested above ;) Thank you! Cheers, Daniel -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=52178#52178 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Implementing a custom dragger
Hi, I need to implement a Dragger very similar to TabBoxTrackballDragger, but with the following characteristics: * It must be able to toggle its geometries, i.e. displaying the TabBoxDragger's geometry, the TrackballDragger's geometry, both geometries at the same time, or no geometries at all. * TrackballDragger's geometry must be adjusted to the radius of the bounding sphere of the model. I would like to receive some guidelines from you, since documentation on osgManipulators is very limited, and the osgmanipulator example only gave me hints to make a guess, but I was unable to understand the whole point. So, if you can provide more documentation on this topic, I would appreciate it a lot. One thing that attracted my attention was that TabBoxTrackballDragger does not scale the trackball geometry accordingly. One must scale the object by means of the TabBoxDragger first to be able to intersect and rotate the trackball on the selected axis. At least this was what I was able to appreciate directly from the osgmanipulator example. ... Thank you! Cheers, Daniel[/list] -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=52526#52526 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] osgManipulator::TrackballDragger geometry of size of bounding sphere
Hi, I have realized the osgManipulator::TrackballDragger source code creates a sphere of radius 1.0. My question is if there's any way to make the dragger's geometry scales up to the bounding sphere of the model being dragged, since to my point of view, there is no such way of doing this with the current source code. This can be appreciated even in the osgmanipulator example. Thank you! Cheers, Daniel -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=52659#52659 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] osgManipulator::TrackballDragger geometry of size of bounding sphere
Thanks for answering Robert. I understand your position but I have already taken a look to the source code. The problem is that I very new to OSG & OpenGL programming, so it is difficult to me to understand it. Nevertheless, I can see on line 127 of TrackballDragger.cpp, this line of code: Code: geode->addDrawable(createCircleGeometry(1.0f, 100)); So I think this is the line responsible for creating a fixed size sphere for the trackball. Also, I have noticed that this sphere looks immutable to other transformations, i.e., if I scale the object by using a tab box dragger, this sphere doesn't resize its radius up to the new bounding box. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=52707#52707 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Custom mouse hanlder interferes with TrackballManipulator
Hi, I'm trying to display a context menu on mouse's right button click. At the same time, I have a TrackballManipulator attached to my main camera. When I click the right button, the mouse keep triggering DRAG events, even when no button is pressed, thus scaling the scene to perform zooming. I need a hint on what I should change to fix this. I have also tried to subclass TrackballManipulator to include a boolean flag to enable it or disabled at will, but didn't work. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=52938#52938 #include "mousehandler.h" #include #include #include #include #include #include #include #include "conversionhelper.h" bool MouseHandler::handle(const osgGA::GUIEventAdapter &ea, osgGA::GUIActionAdapter &aa) { osgGA::GUIEventAdapter::EventType eventType = ea.getEventType(); int button = ea.getButton(); if( eventType == osgGA::GUIEventAdapter::DRAG ) { qDebug() << "Se ha arrastrado el raton"; switch( button ) { case osgGA::GUIEventAdapter::RIGHT_MOUSE_BUTTON: qDebug() << "Con el boton derecho"; break; case osgGA::GUIEventAdapter::LEFT_MOUSE_BUTTON: qDebug() << "Con el boton izquierdo"; break; case osgGA::GUIEventAdapter::MIDDLE_MOUSE_BUTTON: qDebug() << "Con el boton central"; break; } } // Solo tomar en cuenta clicks derechos del raton if( eventType != osgGA::GUIEventAdapter::PUSH || button != osgGA::GUIEventAdapter::RIGHT_MOUSE_BUTTON ){ return false; } qDebug() << "El usuario ha generado un evento de raton"; osgViewer::View* viewer = dynamic_cast(&aa); if ( viewer ) { osg::ref_ptr intersector = new osgUtil::LineSegmentIntersector(osgUtil::Intersector::WINDOW, ea.getX(), ea.getY()); osgUtil::IntersectionVisitor iv( intersector.get() ); viewer->getCamera()->accept( iv ); osg::Drawable *drawable = NULL; osg::ref_ptr< osg::Geometry > geometry = NULL; osgUtil::LineSegmentIntersector::Intersection i; if( intersector->containsIntersections() ) { qDebug() << "El usuario ha seleccionado objetos en la escena"; //this->clearSelectedGeometries(); this->lastIntersections = intersector->getIntersections(); i = *(this->lastIntersections.begin()); drawable = i.drawable; geometry = drawable->asGeometry(); //osgUtil::LineSegmentIntersector::Intersections::iterator k; //for(k=intersector->getIntersections().begin(); k!=intersector->getIntersections().end(); k++) //{ //qDebug() << "Intentando seleccionar geometria"; //this->selectGeometry(k->drawable->asGeometry()); this->selectGeometry(geometry); //emit( objectSelected(k->drawable->asGeometry()) ); emit( objectSelected(geometry) ); //} emit( contextMenuDisplayed(ea.getX(), ea.getY(), drawable) ); return true; } else { qDebug() << "El usuario no ha seleccionado objetos validos en la escena."; } } return false; } void MouseHandler::selectGeometry( osg::ref_ptr< osg::Geometry > geom ) { //osg::Vec4 originalColor; if( !geom ){ qDebug() << "No sean seleccionado geometrias validas"; return; } else { qDebug() << "Se han seleccionado geometrias validas"; } osg::Vec4Array *colors = dynamic_cast< osg::Vec4Array* >( geom->getColorArray() ); if( colors && !colors->empty() ) { osg::Vec4 currentColor = colors->front(); // XOR de colores con verde semi transparente osg::Vec4 hColor; hColor.r() = 0.0f, hColor.g() = 1.0f, hColor.b() = 0.0f, hColor.a() = 1.0f; osg::Vec4 newColor = this->xorColor(currentColor, hColor); newColor.a() = currentColor.a(); qDebug() << "Color actual es " << hex2str( currentColor.asRGBA() ).c_str(); qDebug() << "Nuevo color es " << hex2str( newColor.asRGBA() ).c_str(); colors->front() = newColor; colors->dirty(); } else { qDebug() << "No se encontraron colores en la geometria"; } } void MouseHandler::clearSelectedGeometries() { osgUtil::LineSegmentIntersector::Intersections::iterator it; osgUtil::LineSegmentIntersector::Intersection intersection; osg::ref_ptr< osg::Geometry > g; for( it = this->lastIntersections.begin(); it != this->lastIntersections.end(); it++ ) { intersection = *it; g = intersection.drawable->asGeometry(); this->selectGeometry(g); } this->lastIntersections.empty(); } void MouseHandler::setDrawableColor(osg::Geometry *geom, const osg::Vec4 &color) { osg::Vec4Array* colors = dynamic_cast( geom->getColorArray() ); if ( colors && colors->size()>0 ) { colors->front() = co
[osg-users] Custom Serializers
Hi, please provide more specific directions on how to build custom serializers. I have created a custom node class and its serializer, but I'm still wondering how should I debug it?, how do I know osgDB is loading my serializer right? Thank you! Cheers, Daniel -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=52939#52939 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Custom mouse hanlder interferes with TrackballManipulator
I'd really appreciate somehelp on this because I'm working on my degree thesis and this is the last thing I need to solve. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=53113#53113 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Custom mouse hanlder interferes with TrackballManipulator
I described the problem in a previous post under the same thread, maybe you are reading this through the email list system, please just locate the thread at the forums. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=53115#53115 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Custom mouse hanlder interferes with TrackballManipulator
Here is it: http://forum.openscenegraph.org/viewtopic.php?t=11874 -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=53149#53149 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org