[osg-users] [Newbie]: Can`t update Ortho2D camera after resize
Hello, I am trying to find the right way to update my 2D camera after a window resize. I check all the mailing list but I can't find the trick. Maybe somebody can help. I try the followings 1. Setting up the camera: ... camera2d = new osg::Camera; camera2d-setReferenceFrame(osg::Transform::ABSOLUTE_RF); osgViewer::Viewer::Windows windows; viewerWindow-getWindows(windows); if (windows.empty()) return; camera2d-setGraphicsContext(windows[0]); camera2d-setProjectionMatrixAsOrtho2D(0, viewerWindow-width(), 0, viewerWindow-height()); camera2d-setViewport(new osg::Viewport(*(viewerWindow-getCamera()-getViewport(; ... 2. The resizeGL method from my Qt OSG adapter class void QtOsgWidget::resizeGL(int width, int height) { _gw-getEventQueue()-windowResize(0, 0, width, height); _gw-resized(0, 0, width, height); // Seems not working _gw-resizedImplementation(0, 0, width, height); // a manual update will work, but I think this // is not the elegant way to do it osg::GraphicsContext::Cameras cameras = _gw-getCameras(); osg::Camera * camera = cameras.back(); // My Ortho2D Camera // This will work! camera-setProjectionMatrixAsOrtho2D(0, width, 0, height); } Many thanks for a tip. Karl ... ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] [Newbie]: Best way to load huge amount of models
Hello, I am just experimenting to load huge amount of models. I have a set of ~50.000+ single models (parts) stored on disk in a folder structure in .osg or .ive format, converted from a cad system format. To each of the models I have a transformation matrix to position the model in the scene. Each model has the size similar to the cessna example. At the end the scene represent a complete mechanical car, aeroplane truck etc. I would like to have best performance when loading the scene in the viewer and inspecting them (zoom, pan, etc.). My newbie questions are: - Should I use simply osgDB::readNodeFile in a loop for all parts? I guess this will be slow when reading. - Can I prepared something before reading? creating an archive etc.? - Can osgDB::DatabasePager be a solution? Is there any Newbie documentation available for osgDB::DatabasePager? Examples or code sniplets? Many thanks for some tips. Karl ... ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] [Newbie]: Cannot build OpenVRML; regex.a is missing
Hello, I am following http://www.openscenegraph.org/projects/osg/wiki/Support/PlatformSpecifics/Linux to build VRML plugin Normally I am using Eclipse CDT4 - MingW environment on my Windows PC. But for this task I have installed cygwin with all needed packages to build the three needed libs: - libopenvrml.a - libantlr.a - regex.a There are no problems (error messages etc.) during ./configure .., make and make install But as result I get only: openvrml-0.14.3\lib\antlr\src\.libs\antlr.a openvrml-0.14.3\lib\libopenvrml.a - Where is my regex.a lib? - I am on the right track to build the VRML plugin? - All tips to build the VRML plugin for Eclipse CDT4 - MingW environment are welcomed. I am dealing with this topic now for over two weekends, so any help is really appreciated. Many thanks. Karl ... ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [Newbie]: PolytopeIntersector in WINDOW CoordinateFrame is not working as expected
Hello Jean-Sébastien, it no big deal for me, coding around OpenSceneGraph is my hobby ... ... to keep a bit on track and good for my brain. A made some other code to select geometry objects within a box. The scenario is that I place 1.000 cows.osg (transform + scale) in a world cube of 200,200,200. Then I do an intersection for each cow with a given SelectionBoundingBox (max: 200,200,200). For each node I do ... nodeBoundingBox.intersects(selectionBoundingBox); ... This is very, very fast, 1sec for 1.000 cows. But some nodes could be outside the selectionBoundingBox, because the box of the node has an intersection with the SelectionBoundingBox and not the node itself. To be more accurate I made another try, using PolytopeIntersector For each node I do ... osg::Polytope polytope; polytope.setToBoundingBox(selectionBoundingBox); PolytopeIntersectorRef boxContent = new osgUtil::PolytopeIntersector(polytope); GroupRef group = new osg::Group; getWorldGroup(group.get()); // own func. to get the node with the transforms to the world position IntersectionVisitorRef intersectionVisitor = new osgUtil::IntersectionVisitor(boxContent..get()); group-accept(*intersectionVisitor); osgUtil::PolytopeIntersector::Intersections intersection = boxContent-getIntersections(); if (intersections.size()) { ... This example computes me the exactly the nodes inside the box but it's slower. I takes about 6-7minutes for the 1000 cows. - Any idea to speed up this procedure? - How can I use setDimensionMask(DimZero)? Is this faster? How put I then the points of the nodes into the intersection algo? Many thanks for any kind of help. Karl ... = -- Forwarded message -- From: Jean-Sébastien Guay [EMAIL PROTECTED] Date: 18 Nov., 22:44 Subject: [Newbie]: PolytopeIntersector in WINDOW CoordinateFrame is not working as expected To: OpenSceneGraph Users Hi Karl, hey, you are a hero ... It's working, fine. Glad I could help. Seems we're doing similar things... :-) Do you have any experience in terms of performance when expanding a rect (dragging like a rubberband) over a huge number of models (ex. hundreds or thousands of cow.osg) and computing the intersection in a EventHandler depending on mouse positions? That's exactly what I'm doing, and it's pretty slow. Even compared to a single LineSegmentIntersection without kd-trees, a relatively complex geometric object takes a few seconds to be selected if I make a box-selection that contains it all. If I make a smaller box it's faster of course. I'll be looking into using the kd-tree to do PolytopeIntersections in the near future, to speed this up. Although, I've been having weird results profiling this... It seems like STL operations (additions/removals from STL containers) are taking a sizable amount of time, even in release mode. Anyways, that will wait until the basic functionality is in place, which won't happen until I get this graphics context deadlock fixed... (another thread) J-S -- __ Jean-Sebastien Guay[EMAIL PROTECTED] http://www.cm-labs.com/ http://whitestar02.webhop.org/ ___ osg-users mailing list [EMAIL PROTECTED]://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph... ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [Newbie]: PolytopeIntersector in WINDOW CoordinateFrame is not working as expected
Hello Peter, Combine your two approaches: First check the planes of your Polytope against the bounding volumes of your nodes. Do not use intersect but check if the volume is properly on the inner side of the plane. If this test passes for all planes you don't need to generate all the results. If the bounding volume of the node is on the outer side of any plane, there are no intersections. If the bounding volume of the node intersects one of the planes itself, use the polytope intersector for that node to check for proper intersections. I did it and it works. Now computation time is 1sec - 1min, depending on the node to compute by polytope intersector and always accurate results, fine! It's more then ok for me. Thanks again. Karl ... ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] [Newbie]: PolytopeIntersector in WINDOW CoordinateFrame is not working as expected
Hello, I am following the osgkeyboardmouse example and would like to implement a selection by a rect (like rubberbanding). I thought PolytopeIntersector in CoordinateFrame WINDOW is the right choice for it. Hmm, but my problem is that I will get always intersection when a model is loaded around origin (0,0,0) independently from the pan (zoom) of the model. Even when the model is far away or not visible in the window. In osgkeyboardmouse example it works correctly and intersection will be found only when a model is under the given window coordinates. I am using the Qt environment with AdapterWidget. The only difference I see is that osgkeyboardmouse has a definition of a osg::GraphicsContext::Traits ?! - Any idea what`s wrong in my case? - Where to investigate further? - Any other hints or suggestions about selection with a rect (rubberband) are welcome. - Any information regarding performance and PolytopeIntersector as well. Many thanks for a help. Karl ... ... PolytopeIntersectorRef boxContent = new osgUtil::PolytopeIntersector(osgUtil::Intersector::WINDOW, 0.0f, 0.0f, 10.0f, 10.0f); IntersectionVisitorRef intersectionVisitor = new osgUtil::IntersectionVisitor(boxContent.get()); topNode-accept(*(intersectionVisitor.get())); osgUtil::PolytopeIntersector::Intersections allIntersections = boxContent-getIntersections(); std::cout no of intersections= allIntersections.size() std::endl; ... ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [Newbie]: PolytopeIntersector in WINDOW CoordinateFrame is not working as expected
Hello Jean-Sébastien, hey, you are a hero ... It's working, fine. Do you have any experience in terms of performance when expanding a rect (dragging like a rubberband) over a huge number of models (ex. hundreds or thousands of cow.osg) and computing the intersection in a EventHandler depending on mouse positions? In first test I saw that PolytopeIntersector will find thousends of intersection. So I ask my self it is the right way for selection of models (nodes) by a dynamic rect in WINDOW by using mouse position. Thanks for any tips. Karl ... == -- Forwarded message -- From: Jean-Sébastien Guay [EMAIL PROTECTED] Date: 18 Nov., 20:34 Subject: [Newbie]: PolytopeIntersector in WINDOW CoordinateFrame is not working as expected To: OpenSceneGraph Users Hello Karl, but my problem is that I will get always intersection when a model is loaded around origin (0,0,0) independently from the pan (zoom) of the model. Even when the model is far away or not visible in the window. In osgkeyboardmouse example it works correctly and intersection will be found only when a model is under the given window coordinates. It seems you're starting the intersection from the root node of your scene graph. You need to start it from your camera. So for example, instead of: topNode-accept(*(intersectionVisitor.get())); (which is overly verbose btw, you can just do *intersectionVisitor instead of *(intersectionVisitor.get()) ) you should do: viewer-getCamera()-accept(*intersectionVisitor); It's logical after all, your problem was that the intersection didn't take into account the camera's position... It looked like it was intersecting in world space Well that's exactly what you were asking it to do :-) BTW, if you're in an event handler when you want to do the intersection, you can do osgViewer::View* view = dynamic_castosgViewer::View*(aa); view-getCamera()-... Or if you're in a CompositeViewer, you'll probably need to get your viewer, then get the right view with viewer-getViewWithFocus(). Hope this helps, J-S -- __ Jean-Sebastien Guay[EMAIL PROTECTED] http://www.cm-labs.com/ http://whitestar02.webhop.org/ ___ osg-users mailing list [EMAIL PROTECTED]://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph... ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Picking (Intersection) inside a ClipNodeBox, HowTo?
Hello, I am experimenting around a ClipNodeBox and selection by picking of Nodes inside this box. Is there a elegant way to limit the computeIntersections(ea.getX(), ea.getY(), intersections, 0x) method to take my ClipNodeBox into account? I try to do it by my own by using boundingBox.contains(intersectionPoint). But here I have the problem that the BoundingBox has always it's initial values after a modification by using a TabBoxDragger. I suppose it's somewhere hidden in a TransformMatrix. So my questions are: 1. Can I limit computeIntersections(ea.getX(), ea.getY(), intersections, 0x) to a given ClipNodeBox? 2. If not, where can I get the modified values from the TabBoxDragger after interactively use it? Here are my code for the setup of the Draggers. Many thanks for a help. Karl ... // clipBoxGeode created with a Box and BoundingBox before ... // Draggers // First a BoxDragger, as the Parent Dragger boxDragger = new osgManipulator::TabBoxDragger(); boxDragger-setupDefaultGeometry(); osg::Vec3d scaleVec = osg::Vec3d(bb.xMax() - bb.xMin(), bb.yMax() - bb.yMin(), bb.zMax() - bb.zMin()); scaleVec.normalize(); scaleVec *= clipBoxGeode-getBound().radius() * 2.01; boxDragger-setMatrix(osg::Matrix::scale(scaleVec.x(), scaleVec.y(), scaleVec.z()) * osg::Matrix::translate(clipBoxGeode-getBound().center())); boxDragger-setNodeMask(0x); // dragger invisible at start // Then an AxisDragger, as a Child of BoxDragger axisDragger = new osgManipulator::TranslateAxisDragger(); axisDragger-setupDefaultGeometry(); axisDragger-setMatrix(osg::Matrix::scale(3, 3, 3) * osg::Matrix::translate(osg::Vec3f( clipBoxGeode-getBound().center().x(), clipBoxGeode-getBound().center().y(), clipBoxGeode-getBound().center().z() + (bb.zMax() - bb.zMin())/2))); axisDragger-setNodeMask(0x); // dragger invisible at start // Set in relation, box- and axisDragger boxDragger-addDragger(axisDragger); axisDragger-setParentDragger(boxDragger); // The set of elements to drag osgManipulator::Selection * selection = new osgManipulator::Selection; selection-addChild(clipBoxGeode); selection-addChild(clipNode); selection-addChild(axisDragger); // A container for the two main elements osg::Group * group = new osg::Group; group-addChild(boxDragger); group-addChild(selection); // Connect both with the commandManager cmdMgr-connect(*boxDragger, *selection); osg::ref_ptrosg::MatrixTransform transform = new osg::MatrixTransform; // Integration into the osg tree transform.get()-addChild(group); clipNodeContainer-addChild(transform.get()); // ... ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org