[osg-users] Unique colors on a shared Geode
I'm using a shared Geode/Billboard multiparented to several transforms and want to attach a unique color and transparency to each of these. (Also they will have unique positions, rotations and scalings, but those I already got using PositionAttitudeTransform). What would be the best way to set and change color and transparency? (If possible, I'd stay with the PositionAttitudeTransform rather than calculating the MatrixTransform myself) Right now I can set a unique color to each PAT, but it's just a constant color and I need a 3D-Effect. I'm not really firm with all those Blend-Enums and could need a hint how to set source and destination, if this is the solution. Best regards Hartmut // - osg::ref_ptrosg::Group myGroup = new osg::Group; osg::ref_ptrosg::PositionAttitudeTransform myPat1 = new osg::PositionAttitudeTransform, myPat2 = new osg::PositionAttitudeTransform; osg::ref_ptrosg::Geode myGeode = new osg::Geode; osg::ref_ptrosg::Geometry myGeom = CloneNode3D(); // this is the shared geometry myGeode-addDrawable(myGeom.get()); // - const osg::StateAttribute::GLModeValue modeValue = osg::StateAttribute::ON | osg::StateAttribute::OVERRIDE; osg::ref_ptrosg::BlendFunc myBF1 = new osg::BlendFunc(), myBF2 = new osg::BlendFunc; osg::ref_ptrosg::BlendColor myBC1 = new osg::BlendColor, myBC2 = new osg::BlendColor; myBF1-setSource(osg::BlendFunc::SRC_ALPHA); myBF1-setDestination(osg::BlendFunc::ONE_MINUS_SRC_ALPHA); myPat1-getOrCreateStateSet()-setAttributeAndModes(myBF1,osg::StateAttribute::ON); myPat1-getOrCreateStateSet()-setAttributeAndModes(myBC1,osg::StateAttribute::ON); myBC1-setConstantColor(osg::Vec4(0,0,1,0.1)); myBC2-setConstantColor(osg::Vec4(0,1,0,1)); osg::ref_ptrosg::StateSet state1 = new osg::StateSet, state2 = new osg::StateSet; state1-setAttributeAndModes( myBC1, modeValue ); state2-setAttributeAndModes( myBC2, modeValue ); //osg::BlendFunc* bf = new osg::BlendFunc( osg::BlendFunc::CONSTANT_ALPHA,osg::BlendFunc::ONE_MINUS_CONSTANT_ALPHA ); // - myPat1-setScale(osg::Vec3(2,2,2)); myPat1-setPosition(osg::Vec3(4,4,4)); myPat1-setStateSet(state1.get()); myPat1-addChild(myGeode); m_PAT_to_Id[myPat1] = 1; myPat2-setScale(osg::Vec3(1,1,1)); myPat2-setPosition(osg::Vec3(0,-2,0)); myPat2-setStateSet(state2.get()); myPat2-addChild(myGeode); m_PAT_to_Id[myPat2] = 2; // - myGroup-addChild(myPat1); myGroup-addChild(myPat2); loadedModel-addChild(myGroup); -- frag nicht - du könntest eine antwort erhalten NEU: FreePhone 3-fach-Flat mit kostenlosem Smartphone! Jetzt informieren: http://mobile.1und1.de/?ac=OM.PW.PW003K20328T7073a ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Unique colors on a shared Geode
after trying a different approach using osg::Material, I found the (surprisingly simple) solution (see below) You just need to create a unique osg::Material for each PAT, add the wanted color and transparence. Also you should set the rendering hints to TRANSPARENT_BIN for correct transparence calculation. (I think that's it) Best regards Hartmut osg::ref_ptrosg::Geometry geom; ... geom-getOrCreateStateSet()-setRenderingHint(osg::StateSet::TRANSPARENT_BIN); ... osg::ref_ptrosg::Material myMat1 = new osg::Material; myMat1-setDiffuse(osg::Material::FRONT,osg::Vec4(1,0,0,0.3)); myPat1-getOrCreateStateSet()-setAttribute(myMat1.get()); -- frag nicht - du könntest eine antwort erhalten Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Scene as Texture
Hi, thanks for the quick answer. Chris Hanson wrote on Tue, 28 Feb 2012 08:55:37 -0700: The osgprerender example shows how to setup a scene to render to a texture for use on a quad. I will look into this. Hartmut -- NEU: FreePhone 3-fach-Flat mit kostenlosem Smartphone! Jetzt informieren: http://mobile.1und1.de/?ac=OM.PW.PW003K20328T7073a ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Performance question: Switch / NodeMask / WriteToFile
Hello everyone, I'm experiencing performance problems with my osg scene. I have many (up to 100k) geometries to display a tree. I'm building my whole scene graph at the beginning. To view it only partially I inserted root - group - PositionAttitudeTransform - Switch - (a/b) (a) LOD - Geode - Geometry or LOD - BillBoard - Geometry (b) Geode - Geometry Now when the scene is only partially visible (using osg::Switch), it's laggy nonetheless. If I wanted to load and save my scene on demand, what would be the best possibility (in regards of performance) 1) write unneeded subgraphs to a file 2) cache unneeded subgraphs (how would I do this?) 3) use NodeMask on osg::Group (would this also black out the respective subgraph?) Looking forward for input. Thanks in advance. Hartmut -- frag nicht - du könntest eine antwort erhalten Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Scene as Texture
Hello Osg-Users, I want, at a specific time, capture the screen (of my osgViewer) and use it as a texture for a quad. What would be the best way to achieve this? Is there already an example for this? Thanks for the advice in advance. Hartmut -- frag nicht - du könntest eine antwort erhalten Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Transparence/Geometry issues with PAT
Hey all of you, I have a problem with the coloring of my objects (osg::Geometry). When I resize any of them (using PositionAttitudeTransform) and the scaling factor is 1 the opacity of the respective geometry nodes is scaled accordingly. So *my question* is: How can I protect the transparence/opacity of a geometry against scaling? (some further questions below) Little description of what I'm doing: I have lots of similar objects to represent graphs and for each type of object (node, edge) I create a prototype to copy from. This is an osg::Geometry with TriangleStrips and TriangleFans. I keep it in memory as osg::ref_ptrosg::Geometry When building the structure I create a geometry for each object and copy (member by member) all the PrimitiveSets, Vertices, etc. as well as the ColorArray and color-binding (which is BIND_OVERALL) from the prototype to the new clone (- 2nd question). I then insert this geometry into a osg::Geode node (-3rd question), which I add to a osg::PositionAttitudeTransform node (to scale, move and rotate) and finally to the respective osg::Group. Optionally I insert a osg::LOD to get higher performance. I'm also not using the osg::ShapeDrawables but my own objects for said performance (I got up to 10^5 objects to display atm, but very possibly even more to come) Right now I'm hiding the scaled transparence by creating the prototypes about the size the objects will be at the end, but they all will have different sizes so there's still a difference in opacity. *2nd question*: How can I more easily create a osg::ref_ptrosg::Geometry copied from another osg::ref_ptrosg::Geometry (cloning all the PrimitiveSets, vertices, normals, colors, states and so on) *3rd question*: Can I add a geometry more directly to a PAT than Geometry-Geode-PAT? *4th question*: Does anybody have any further suggestions to improve my osg structures, mainly in means of performance? -- Hartmut Leister hartmut.leis...@s2005.tu-chemnitz.de Hofer Straße 58a, 04317 Leipzig 0175/8491877 http://www-user.tu-chemnitz.de/~harl -- E-Mails richtig schreiben: http://www-user.tu-chemnitz.de/~harl/email_nettiquette.php http://www-user.tu-chemnitz.de/~harl/gpg.php ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Change for need to redraw scene
Hi Filip, Am 02.12.2011 12:39, schrieb Filip Arlet: If you want redraw on demand exactly. Code: if( viewer-checkNeedToDoFrame() ) { viewer-frame(); } I will try this and keep you updated. Btw. comparing two matrices of doubles has to be done with epsilon delta of course, how could I forget...should have known this. Thank you Hartmut -- Hartmut Leister haleis...@gmx.de 04317 Leipzig ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Change for need to redraw scene
Hello OSG-Users, (I'm writing a display application, using osgviewerQt) I'm looking for a way to check, whether I need to redraw the scene to skip a redraw, if would be the same as the previous (fixed image). Or is this already done by osg-library? I figured, I only need a redraw, if a) Camera changes (position, field of view) b) scene changes (geometry changes, color changes) Unfortunately my first guesses and web searches were not successful, e.g. I saved the cameras ViewMatrix ( getCamera()-getViewMatrix() ) after a call of frame() to compare it to the current before the next call of frame(). Oddly the seem to change every time, even though the Viewer showed a fixed image. Can anyone point me to a direction and offer hints, to how I can achieve this? Am I carrying coals to Newcastle, since OSG would already be doing this and/or I only forgot to set a flag? Thanks in advance and sunny greetings Hartmut -- frag nicht - du könntest eine antwort erhalten NEU: FreePhone - 0ct/min Handyspartarif mit Geld-zurück-Garantie! Jetzt informieren: http://www.gmx.net/de/go/freephone ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Lighting problem
Hello OSG users, I'm having a lighting problem in my osgviewerQt (derived from [1]) application with a self created drawable object. All my spheres are basically looking like this [2], with this weird spot on top of all spheres. Has anybody an idea, a) what could be causing this or (more important) b) how to stop it? Has anyone stumbled upon this himself before? Grateful for any advise Hartmut [1] http://www.openscenegraph.org/projects/osg/browser/OpenSceneGraph/trunk/examples/osgviewerQT?rev=7995 [2] http://www-user.tu-chemnitz.de/~harl/mail_halde/osg/Sphere_dots.png -- frag nicht - du könntest eine antwort erhalten Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Problems with computeIntersections
Thanks Chris, inverting the y-coordinate did the trick! Picking is now super easy and correct. And I suppose you're right with the twice listed objects. Thanks again Hartmut Here's the new Code for anyone with the same problem: void ViewerQT::mouseReleaseEvent( QMouseEvent* event ) { // default mouse control AdapterWidget::mouseReleaseEvent(event); // continue with picking osgUtil::LineSegmentIntersector::Intersections intersections; float x = event-x() * 1.0; float y = height() - event-y(); if (computeIntersections(x,y,intersections)) { for(osgUtil::LineSegmentIntersector::Intersections::iterator hitr = intersections.begin(); hitr != intersections.end(); ++hitr) { if (!hitr-nodePath.empty() !(hitr-nodePath.back()-getName().empty())) { // the geodes are identified by name. std::cout Object \ hitr-nodePath.back()-getName() \ std::endl; } else if (hitr-drawable.valid()) { std::cout Object \ hitr-drawable-getName() \ std::endl; } } } } -- frag nicht - du könntest eine antwort erhalten Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Problems with computeIntersections
Hello all, I got a problem with osgUtil::computeIntersections(). I wanted to include it in my application (which is nested into the osgviewerQT example). I took the code for picking from the osgpick example. However, when I click on my view, there's the following possibilities - the picked node/drawable is correct, but listed twice - no intersection is computed, although I clicked on a drawable - an intersection is computed, although i clicked into empty space I can't explain, what I could be doing wrong. Perhaps it's that event comes from QMouseEvent and has another coordinate system than osgviewer? Any hints where to go from here? Best wishes Hartmut Code: void ViewerQT::mouseReleaseEvent( QMouseEvent* event ) { // default mouse control AdapterWidget::mouseReleaseEvent(event); // continue with picking osgUtil::LineSegmentIntersector::Intersections intersections; float x = event-x(); float y = event-y(); std::cout ( x , y ); std::cout std::endl; if (computeIntersections(x,y,intersections)) { for(osgUtil::LineSegmentIntersector::Intersections::iterator hitr = intersections.begin(); hitr != intersections.end(); ++hitr) { if (!hitr-nodePath.empty() !(hitr-nodePath.back()-getName().empty())) { // the geodes are identified by name. std::cout Object \ hitr-nodePath.back()-getName() \ std::endl; } else if (hitr-drawable.valid()) { std::cout Object \ hitr-drawable-getName() \ std::endl; } } } -- frag nicht - du könntest eine antwort erhalten NEU: FreePhone - 0ct/min Handyspartarif mit Geld-zurück-Garantie! Jetzt informieren: http://www.gmx.net/de/go/freephone ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Picking ShapeDrawables in osg
Hello, (since I couldn't find this problem searching the www, I'm trying here) I'm quite new to osg and want to pick a ShapeDrawable in my scene. I got 2 issues: (1) How can i get a pointer to a picked ShapeDrawable? (2) I'm not sure whether the intersection I started from the standard osgviewerQT example and I'm using only ShapeDrawables from osg, since I'm drawing tree layouts (spheres and cylinders). All the ShapeDrawables are added to 1 geode (only 1 for performance reasons), which is added to 1 group, which is loaded into a model to draw. I then overwrote AdapterWidget::mouseReleaseEvent to insert the picking functionality from osgpick.cpp, but I only get the drawable list (in intersections). And the returned drawable list looks weird too - when I select some empty space, I get 0 or more hits and when I select a point with only 1 ShapeDrawable underneath, I also get 0 or more hits. But perhaps this is just a result of a wrong implementation. Best wishes Hartmut -- frag nicht - du könntest eine antwort erhalten Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org