Re: [osg-users] [build] CMake error regarding Boost with master branch
Thanks for your help! I'll check on the CMake forum. Cheers, Andrés -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=62175#62175 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] [build] CMake error regarding Boost with master branch
Hi, I synced today my repo with the master branch in GitHub and got an error when building with CMake: Code: globbed: CMake Error at D:/PROYECTOS/SITEGI/LIBRERIAS/MSVC/2010/boost_1.50_prebuilt/share/cmake/boost/BoostConfig.cmake:15 (include): include could not find load file: C:/Projets/PCL/SuperBuild_boost_1_50/CMakeExternal/Install/Boost/share/boost-/cmake/BoostConfig.cmake Call Stack (most recent call first): C:/Program Files (x86)/CMake 2.8/share/cmake-2.8/Modules/FindBoost.cmake:177 (find_package) CMakeLists.txt:652 (FIND_PACKAGE) I tried to set up the vars BOOST_ROOT and BOOST_LIBRARY_DIRS but didn't work. About my Boost: It's version 1.51. I built it with MinGW and there is NO BoostConfig.cmake file. ... Thank you! Cheers, Andrés -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=62166#62166 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Computing the bounding box of a node. Different approach.
Hi, Still struggling with this. Any idea? ... Thanks and cheers! Andrés -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=61629#61629 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Computing the bounding box of a node. Different approach.
Hi, I've been playing around with the "Computing the world bounding box of any node" example in the Cookbook, which uses a ShapeDrawable. I've read in the Doxygen docs that: > > The implementation of ShapeDrawable is not geared to efficiency; it's better > to think of it as a convenience to render Shapes easily (perhaps for test or > debugging purposes) than as the right way to render basic shapes in some > efficiency-critical section of code. > So, I thought I would try to create a custom box shape using a Geometry: osgshapes.h Code: #ifndef OSGSHAPES_H #define OSGSHAPES_H #include "osg/PositionAttitudeTransform" namespace osg { class Geode; } class Shape: public osg::PositionAttitudeTransform { public: Shape( const bool w = true ); virtual bool create() = 0; int getScaleFactor() const { return scaleFactor; } void setScaleFactor( const int s ); bool isWireframe() const { return wire; } void setWireframe( const bool w ); protected: virtual ~Shape(); private: bool wire; int scaleFactor; }; class Box: public Shape { public: Box( const double l = 1. ); bool create(); double getLenght() const { return length; } void setLenght( const double l ); protected: ~Box(); private: double length; }; #endif osgshapes.cpp Code: namespace { namespace BoxFactory { void drawBox( osg::ref_ptr vert ) { vert->push_back( osg::Vec3d( -1.0, -1.0, 1.0 ) ); vert->push_back( osg::Vec3d( 1.0, -1.0, 1.0 ) ); vert->push_back( osg::Vec3d( 1.0, 1.0, 1.0 ) ); vert->push_back( osg::Vec3d( -1.0, 1.0, 1.0 ) ); vert->push_back( osg::Vec3d( -1.0, -1.0, -1.0 ) ); vert->push_back( osg::Vec3d( 1.0, -1.0, -1.0 ) ); vert->push_back( osg::Vec3d( 1.0, 1.0, -1.0 ) ); vert->push_back( osg::Vec3d( -1.0, 1.0, -1.0 ) ); } osg::ref_ptr getQuads() { osg::ref_ptr quads = new osg::DrawElementsUInt( GL_QUADS ) ; // FRONT quads->push_back( 0 ); quads->push_back( 1 ); quads->push_back( 2 ); quads->push_back( 3 ); // BOTTOM quads->push_back( 0 ); quads->push_back( 1 ); quads->push_back( 5 ); quads->push_back( 4 ); // LEFT quads->push_back( 0 ); quads->push_back( 4 ); quads->push_back( 7 ); quads->push_back( 3 ); // BACK quads->push_back( 4 ); quads->push_back( 5 ); quads->push_back( 6 ); quads->push_back( 7 ); // TOP quads->push_back( 3 ); quads->push_back( 2 ); quads->push_back( 6 ); quads->push_back( 7 ); // RIGHT quads->push_back( 1 ); quads->push_back( 5 ); quads->push_back( 6 ); quads->push_back( 2 ); return quads; } osg::ref_ptr buildBox() { osg::ref_ptr geode = new osg::Geode; osg::ref_ptr geom = new osg::Geometry; geode->addDrawable( geom.get() ); osg::ref_ptr vertices = new osg::Vec3Array; geom->setVertexArray( vertices ); //geom->setDataVariance( osg::Object::DYNAMIC ); //geom->setUseDisplayList( false ); //geom->setUseVertexBufferObjects( true ); drawBox( vertices ); osg::ref_ptr quads = getQuads(); geom->addPrimitiveSet( quads ); geom->getOrCreateStateSet()->setAttributeAndModes( new osg::Point( 5.0f ) ); geom->addPrimitiveSet( new osg::DrawArrays(GL_POINTS, 0, vertices->size() ) ); return geode; } } // End BoxFactory } Shape::Shape( const bool w ) : osg::PositionAttitudeTransform(), scaleFactor( 1.0 ) { setWireframe( w ); } Shape::~Shape() { } void Shape::setScaleFactor( const int s ) { if( s == scaleFactor ) { return; } scaleFactor = s; const osg::Vec3d scale = getScale() * s; setScale( scale ); } void Shape::setWireframe( const bool w ) { if( w == wire ) { return; } wire = w; osg::observer_ptr ss = getOrCreateStateSet(); ss->setMode( GL_LIGHTING, osg::StateAttribute::OFF ); osg::PolygonMode::Mode mode = ( w ) ? osg::PolygonMode::LINE : osg::PolygonMode::FILL ; osg::PolygonMode* pmode = new osg::PolygonMode( osg::PolygonMode::FRONT_AND_BACK, mode ) ; ss->setAttributeAndModes
Re: [osg-users] [3rdparty] Graph/Tree visualization
Hi, is this advice from last year still active? I tried to write a Dot file for the scene, using the Dot writer. It created a simple graph, but only for the main camera. In order to also show in the graph the geodes that are attached to the slave camera (I use masks), do I have to specifically set a mask in the Dot writer? ... Thanks and cheers! Andres. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=61242#61242 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Precise world to screen space transformation
Hi, > I (again for the screenshots) started a StackOverflow question You can upload here pics too. There's a size limit, though. ... Cheers, Andrés -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=61203#61203 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [osgPlugins] Bad Freetype font displaying
Hi, I changed the code logic in my app and got rid of the camera creation. Now the font is loaded and displayed :) As for my "various modifications" to osgtext, it's just a pointer check. I mean, the pointer shouldn't be NULL becuase without the check it is returned. But then if I write down that simple check C++ thinks the font pointer is NULL, hence my "throw" executes. I'm just curious in that last part, as I can't see the reason why the font pointer can be valid and invalid at the same time (I will cal it Schroedinger's pointer). I'm missing something, obviously, and probably is a basic thing, but right now I just don't get it. Anyway, the font displaying problem is solved. ... Thanks and cheers, Andrés. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=61164#61164 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [osgPlugins] Bad Freetype font displaying
Hi Robert! The osgtext example works fine, my app not. The difference is that I was calling: Code: osgText::readFontFile("arial.ttf"); instead of: Code: osgText::readFontFile("fonts/arial.ttf"); I added the "fonts" part but the "cubic" display persists. Now, in both situations (using "fonts/arial.ttf" or "arial.ttf"), the font smart pointer: Code: const char* font_name = "arial.ttf"; // or fonts/arial.ttf const std::string found = osgText::findFontFile( font_name ); osg::ref_ptr font = osgText::readFontFile( found ); is valid. # Another thing, if in Font::readFontFile I add this: Code: if( !font ) { throw 1; } after Code: osgText::Font* font = dynamic_cast(object); the osgtext example will crash, even tough the font was found. How can the font be both valid and invalid? --- Thanks and cheers, Andrés. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=61158#61158 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] [osgPlugins] Bad Freetype font displaying
Hello! I've updated from version 3.0.1 to version 3.2.1. I'm testing it but everything seems fine except for the Freetype plugin. I want to display text using the Arial font. OSG seems to find the font and load the freetype plugin, but the text displaying is "cubic". With version 3.0.1 the text looks fine. I've uploaded two pics to show the problem. Any help will be appreciated. -- CODE Code: const char* font_name = "arial.ttf"; const std::string found = osgText::findFontFile( font_name ); osg::ref_ptr font = osgText::readFontFile( found ); qDebug() << "FOUND:" << found.c_str(); if( !font.valid() ) { qDebug() << "WARNING! COULDN'T FIND FONT:" << font_name; font = osgText::Font::getDefaultFont(); } PS: I've checked and this time I'm not mixing debug and release libraries. Target platform: Windows 8.1 64 bit Compiler: MinGW 4.5 64 bit --- Thanks and cheers, Andrés. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=61137#61137 Attachments: http://forum.openscenegraph.org//files/osg32_430.png http://forum.openscenegraph.org//files/osg301_220.png ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [build] Problem with version 3.2.1 and Qt 4.8
Hi Tianlan (I think you've romanized the order of your name, right?), you were right! It was a rogue debug Qt library that got mixed with the release ones in CMake. Before posting the question, I checked the libs in CMake several times but missed that one!!! ... Thanks and cheers! Andrés. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=61125#61125 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] [build] Problem with version 3.2.1 and Qt 4.8
Hi, I've downloaded the new version (3.2.1) and built it with support for Qt 4.8. When I tried to use the libs in my app (which worked fine with version 3.0.1) I got two errors. First one, from QGraphicsWindowQt: Code: GraphicsWindowQt:24:21: fatal error: QGLWidget: No such file or directory I solved this changing the include QGLWidget to QtOpenGL/QGLWidget. Second one and still there, it happened when running the app: Code: QPixmap: Must construct a QApplication before a QPaintDevice In my code where I use OSG, there's no call to QPixmap. I use other things from Qt, like QPolygon and QDialog, but no explicitly call to QPixmap. And as I said, this worked fine with version 3.0.1. The app crashes when doing this call: Code: camera->setViewport(new osgQt::GraphicsWindowQt( traits.get() ) ) Any help will be appreciated. ... Thanks and cheers! Andrés[/i] -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=6#6 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Hard time with slave cameras and viewports.
Hi STTrife, thanks for your help. I'll check the info you gave me! ... Thank you! Cheers, Andrés -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=60520#60520 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Hard time with slave cameras and viewports.
Hi STTrife (), Yeah, I also thought of the POST_RENDER camera, but I wanted another opinion :D About the cull masks, I switched them off. I thought it would be more efficient using them, but that's not my main concern right now. The clear color was a just a test to see what the specified viewport was. I forgot to remove it from the posted code. Sorry. Okay, about the perspective. I think the problem is my poor understanding of the math involved. I will have to start again with the theory. Also, using an ABSOLUTE reference frame, the axis appear but with too much zoom; almost all of the viewport is filled with the red axis. And I think the callback is not working properly here, as I can see no change in the axis (with the compositeviewer example it worked, though). Changind the RF to RELATIVE, the axes appear, but very very small. I have to zoom them in to get a suitable size. But I don't want to have any events in that viewport. So, as I said before, I'll check the theory again. Besides the OpenGL Red Book, do you know of any link or book that may be useful? ... Thank you! Cheers, Andrés -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=60493#60493 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Hard time with slave cameras and viewports.
Hi, I've been able to setup a HUD via a slave camera in my app to draw a cross that would always face the user. Since I wanted that cross to be able to "move" across all the scene, I did the setup of the slave as the following: Code: osg::ref_ptr hud = new osg::Camera; hud->setCullMask( HUD_CAM ); hud->setReferenceFrame( osg::Transform::ABSOLUTE_RF ); hud->setClearMask( GL_DEPTH_BUFFER_BIT /*| GL_COLOR_BUFFER_BIT*/ ); hud->setRenderOrder( osg::Camera::POST_RENDER ); hud->setAllowEventFocus( false ); osgViewer::Viewer::Windows windows; getWindows( windows ); hud->setGraphicsContext( windows.front() ); hud->setClearColor( osg::Vec4d( 0.0, 1.0, 0.0, 1.0 ) ); hud->getOrCreateStateSet()->setMode( GL_DEPTH, osg::StateAttribute::OFF ); Please, correct me if I'm wrong: it's my understanding that if I use the same graphics context as the master camera, the slave camera's scene will be rendered in the same "window" as the main camera, whereas if I use a new graphics context, a new window will appear with the slave's scene (I tried this with the Cookbook power wall example). Now, for the projection matrix: Code: osg::observer_ptr cam = viewer.getCamera(); osg::observer_ptr vport = cam->getViewport(); hud->setViewport( vport.get() ); hud->setProjectionMatrix( osg::Matrix::ortho2D( vport->x(), vport->width(), vport->y(), vport->height() ) ); Specifying the same viewport as the master camera, I was able to move the cross all around the scene. I tried to specify a window, let's say: Code: setViewport( 0, 0, 300, 300 ) and the projection matrix: Code: setProjectionMatrix( osg::Matrix::ortho2D( 0, 300, 0, 300 ) ); This will make the cross appear only in that little window. So! I thought of adding the axes to the scene (as stated in my other post (forum.openscenegraph.org/viewtopic.php?t=14088)). I want the axes to appear in a corner of the scene and to update them when I rotate the main scene. I don't want the axes to be zoomed or panned. Code: osg::ref_ptr slave = new osg::Camera; slave->setGraphicsContext( viewer.getCamera()->getGraphicsContext() ); slave->setViewport( 0, 0, 300, 300 ); slave->setClearColor( osg::Vec4d(0.0,1.0,0.0,0.5) ); slave->setReferenceFrame( osg::Camera::ABSOLUTE_RF ); What I'm not sure is: 1) Should the slave's render mode be PRE or POST? 2) How should I specify the projection matrix for this camera? I'm having a hard time to do this for the 3D axes. 3) Playing a bit with the viewport in 2D, I realized that if I move the master camera's child near the slave's "area", once ir crosses the "border" between them, the main model will disappear. If I want that everything that is rendered by the main camera to be able to appear as well in the slave's viewport when panning, what would the cull mask in this case? NOTE: Both the master and slave cameras have their own cull mask. The nodes I add to the scene also have their node masks set accordingly to the camera that will host them. ... Thank you! Cheers, Andrés -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=60426#60426 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Key events doesn't work with function keys
Hi Robert, thanks for the info! In the example the function keys worked right! ... Thank you! Cheers, Andrés -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=60393#60393 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Questions about the axes. Is this the right way?
Hi, I'm playing with the osgcompositeviewer example in order to load and show the axes in the scene. I want that when I rotate the model in the first view, the axes get updated accordingly, but I don't want them to change position or allow the user to zoom them. So, I got this thing running (at least I think so), but I' would like to know if this is the right way to do this. In the View three I load the axes.osg file and add it as a child of a PositionAttitudeTransform node. This transform will be the scene node of the third view. Also I rotate the axes node so the Y axis will be pointing upwards and the Z axis will increase towards me. Code: // Should check the pointers... osg::ref_ptr axes = osgDB::readNodeFile("axes.osg"); axes->setName( "AXES" ); osg::ref_ptr pat = new osg::PositionAttitudeTransform; pat->setName( "PAT" ); pat->setAttitude( osg::Quat( osg::DegreesToRadians( 90.0 ), osg::X_AXIS ) ); pat->addChild( axes ); pat->addUpdateCallback( new AttitudeCallback( viewer.getView(0)->getCamera() ) ); view->setSceneData( pat.get() ); Now, for the update of the axes node I used a callback: Code: class AttitudeCallback: public osg::NodeCallback { public: AttitudeCallback( osg::Camera* c ) : NodeCallback(), cam( c ) { } virtual void operator ()( osg::Node* node, osg::NodeVisitor* vis ) { const osg::Matrixd vmat = cam->getViewMatrix(); std::cout << "CALLBACK: " << node->getName() << std::endl; osg::ref_ptr pat = dynamic_cast( node ); if( pat ) { const osg::Quat axis_rot( osg::DegreesToRadians( 90.0 ), osg::X_AXIS ); pat->setAttitude( /*axis_rot **/ vmat.getRotate() * axis_rot ); pat->setScale( osg::Vec3d( 0.5, 0.5, 0.5 ) ); } traverse( node, vis ); } private: osg::ref_ptr cam; }; I'm wondering whether instead of using a CompositeViewer, I could use the single Viewer and set a new viewport/camera to host the axes node. And, if when I create the PositionAttitudeTransform in the third view and set then the scale and remove the pat->setScale(...) line from the callback, the axes don't get scaled at all! Why is that? ... Thank you and sorry for this huge post!! Cheers, Andrés -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=60392#60392 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Key events doesn't work with function keys
Hi, I'm trying to detect the press of some keys in a custom event handler. Code: if( osgGA::GUIEventAdapter::RESIZE == ea.getEventType() ) { switch( ea.getKey() ) { case osgGA::GUIEventAdapter::KEY_L: // More things... break; case osgGA::GUIEventAdapter::KEY_F2: I'am able to do this with keys from a to z and the modifier keys. But when I try to use, say, the F2 key, and then print the Code: ea.getKey() value, I always get 0. Do I need to activate some option before to use the functions keys? ... Thank you! Cheers, Andrés -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=60307#60307 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Trouble with HUD
Hi, no need to reply. I have loaded different models and tried with the code as-is. It really draws the cross in the middle of the screen!. ... Thank you! Cheers, Andrés :D -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=60197#60197 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Trouble with HUD
Hi again, Jus a doubt with my previous code: is my way of getting the center of the screen right? Code: osg::Viewport* vport = camera->getViewport(); osg::Vec3d vc = osg::Vec3d( vport->x() + vport->width()/2, vport->y() + vport->height()/2, 0.0 ); Or is there a better way? ... Thank you! Cheers, Andrés -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=60188#60188 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Trouble with HUD
Hi Nick! You were right. I needed to specify the Z value. I also had to change the values of the vertices, as I had them wrong, but thas was my fault. ... Thank you! Cheers, Andrés -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=60187#60187 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Trouble with HUD
Hello there! I've struggling a while with the setup of a HUD camera. What I want to achieve is to show cross in the middle of the vieport. I have been able to display text, but not the cross, so I'm requesting a little help with this ... :) Here's the code for the viewer (it is based in the osgQt and osghud examples): Code: class Viewer: public QWidget, public osgViewer::Viewer { public: static const unsigned int MAIN_MASK = 0x1; static const unsigned int HUD_MASK = 0x2; virtual void paintEvent( QPaintEvent* event ) { frame(); } Viewer( osg::ref_ptr g): QWidget(), osgViewer::Viewer() { osg::ref_ptr cam = createCamera( 150, 10, 640, 800 ); QGridLayout* layout = new QGridLayout; layout->setContentsMargins( 1, 1, 1, 1 ); QWidget* widget = addViewWidget( cam.get(), g.get() ); layout->addWidget( widget ); setLayout( layout ); connect( &( this->timer_ ), SIGNAL( timeout() ), this, SLOT( update() ) ); getDatabasePager()->setDoPreCompile( true ); } void startTimer() { timer_.start(24); } ~Viewer(){} private: osg::Camera* createCamera( int x, int y, int w, int h ) { try { osg::DisplaySettings* ds = osg::DisplaySettings::instance().get(); if( !ds ) { return NULL; } osg::ref_ptr traits = new osg::GraphicsContext::Traits ; traits->windowName = "no name"; traits->windowDecoration = true; traits->x = x; traits->y = y; traits->width = w; traits->height = h; traits->doubleBuffer = true; traits->alpha = ds->getMinimumNumAlphaBits(); traits->stencil = ds->getMinimumNumStencilBits(); traits->sampleBuffers = ds->getMultiSamples(); traits->samples = 4; osgViewer::Viewer::Views views; getViews( views ); osg::ref_ptr camera = views[ 0 ]->getCamera(); camera->setGraphicsContext( new osgQt::GraphicsWindowQt( traits.get() ) ) ; camera->setClearColor( osg::Vec4( 0,0,0,1 ) ); camera->setViewport( new osg::Viewport( 0, 0, traits->width, traits->height) ) ; const double tw = static_cast( traits->width ); const double th = static_cast( traits->height ); camera->setProjectionMatrixAsPerspective( 30.0f, tw / th, 1.0f, 1.0f ) ; camera->setCullMask( MAIN_MASK ); return camera.release(); } catch( const std::bad_alloc& ) { return NULL; } } QWidget* addViewWidget( osg::Camera *camera, osg::Node *scene ) { try { addEventHandler( new osgViewer::StatsHandler ); osgGA::CameraManipulator* cameraManipulator = new osgGA::TrackballManipulator( osgGA::StandardManipulator::DEFAULT_SETTINGS ) ; setCameraManipulator( cameraManipulator ); osg::observer_ptr cm = dynamic_cast( cameraManipulator ) ; cm->setAnimationTime( -1 ); cm->setMinimumDistance( 10 ); hud = new osg::Camera; hud->setCullMask( HUD_MASK ); hud->setReferenceFrame(osg::Transform::ABSOLUTE_RF); hud->setClearMask(GL_DEPTH_BUFFER_BIT /*| GL_COLOR_BUFFER_BIT*/ ); hud->setRenderOrder(osg::Camera::POST_RENDER); hud->setAllowEventFocus(false); osgViewer::Viewer::Windows windows; getWindows( windows ); hud->setClearColor( osg::Vec4( 0.0, 1.0, 0.0, 255.0 ) ); hud->getOrCreateStateSet()->setMode(GL_DEPTH_TEST,osg::StateAttribute::OFF); hud->setGraphicsContext( windows.front() ); osg::Viewport* vport = camera->getViewport(); const osg::Matrix wmat = vport->computeWindowMatrix(); osg::Vec3d vc( vport->x() + vport->width()/2, vport->y() + vport->height()/2, 1.0 ); hud->setViewport( vc.x() - 50, vc.y() - 50, 100,100 ); hud->setProjectionMatrix( osg::Matrix::ortho2D( vc.x() - 50, vc.y() - 50, vc.x() + 50, vc.y() + 50 ) ); osg::ref_ptr geode = new osg::Geode; osg::ref_ptr color = new osg::Vec4Array; color->push_back( osg::Vec4( 1.0, 0.0, 0.0, 1.0 ) ); #if 0 osg::ref_ptr text = new osgText::Text; geode->addDrawable( text.get() );
Re: [osg-users] Change the camera rotation axis
Hi Nick, I am reading the code. Thanks for your help!!! :D ... Cheers, Andrés -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=59978#59978 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Change the camera rotation axis
Hi Trajce! Thanks for your help. I've been browsing the manipulator's source code and found something interesting: the SET_CENTER_ON_WHEEL_FORWARD_MOVEMENT flag. If I understand correctly, having this flag set will make that if zoom in the view, the camera will update its position on each scroll. Wouldn't this do the same as what you suggested, setting the home position? Now, for whatever the reason it may be, the setCenterByMousePointerIntersection function always return false. The intersection test is done with a LineSegmentIntersector, but it finds zero intersections. This has happened to me before when I was trying to achieve point picking, following the example in the Beginner's Guide. Changing the LineSegmentIntersector to a PolytopeIntersector did the trick. My camera was created using the setProjectionMatrixAsPerspective method. ... Cheers! Andrés -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=59870#59870 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Change the camera rotation axis
Hi Trajce! Yes, it is the Trackball manipulator. So changing the home position will do the trick? Nice. But doing this, it would also require changing the "wheel zoom" code, wouldn't it? I mean, if I zoom and inmediately want to rotate, the home position should already be updated. What do you think? While waiting for your answer, I'll go ahead and try it (if I can) :) ... Thank you! Cheers, Andrés -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=59834#59834 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Change the camera rotation axis
Hi, I have a viewer with several models loaded. When doing a rotation with the left mouse button, it seems as if the camera takes into account all the scene. Would it be possible to change the rotation axis? For example, if I zoom in and can only view a tree and a car, I want to rotate as if the scene only contained that tree and car; ignoring the rest until is viewed. I haven't found any like that in the camera manipulator or camera options/methods, so I suppose I'll have to play with the view matrix and so. Am I in the right direction? ... Thank you! Cheers, Andrés -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=59816#59816 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org