Re: [osg-users] any help would be appreciated - updating a groupofcameras (UNCLASSIFIED)
Classification: UNCLASSIFIED Caveats: NONE So from helpful comments, I believe I know what I'm doing wrong. I am creating a group and adding cameras to the group. in the cameras I have various drawables that I'd like to update with my program. i can't get the camera's children to update and can't find an example that works. for an example of what i'm trying to do, i took the osghud example and created a few geometries on it. i added a callback that should change a scale factor for the triangles that i'm adding and update the text in one of the screens. i tried to versions. one that had the callback on the camera and one that has the callback on one of the geodes. I appreciate any help anyone might be able to give. Danny -Original Message- From: osg-users-boun...@lists.openscenegraph.org [mailto:osg-users- boun...@lists.openscenegraph.org] On Behalf Of Paul Martz Sent: Tuesday, April 14, 2009 12:30 PM To: 'OpenSceneGraph Users' Subject: Re: [osg-users] any help would be appreciated - updating a groupofcameras (UNCLASSIFIED) Hi Danny -- There really isn't much info to go on here. You don't describe the mechanism that is doing the drawing. Cameras don't draw, they only set the matrices. Assuming you are changing a Drawable in your scene graph... One thing to check would be to make sure that you have setUseDisplayLists( false ). You don't want to use display lists for dynamic geometry. If your code is too large to debug, then write a small piece of code to reproduce the problem outside of your larger app, making it as small and simple as possible. This will increase the odds that someone on the list will take the time to look at it. Paul Martz Skew Matrix Software LLC http://www.skew-matrix.com +1 303 859 9466 -Original Message- From: osg-users-boun...@lists.openscenegraph.org [mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of Konkle, Daniel T AMRDEC/Dynetics Sent: Tuesday, April 14, 2009 9:32 AM To: OpenSceneGraph Users Subject: [osg-users] any help would be appreciated - updating a group ofcameras (UNCLASSIFIED) Classification: UNCLASSIFIED Caveats: NONE I am new to OSG and I am stuck and need help/insight. I'm created a Heads up display by extending the group class. My Hud is an osg::Group and has several cameras in it. The Hud displays fine. The Hud class has several variables that control how information is displayed such as the heading. I've written a callback and attached it to my Hud. After attaching my Hud to my scene, I want to the callback for the Hud to change its variables but the cameras in my Hud don't use the updated variables to redraw themselves. I've used osg::notify to show that the callback is getting executed and to print out the value of the heading variable I am changing. I realize I'm not showing any code only because there is so much of it. Can anyone give me an idea of where to look to figure out why all the children in my HUD class aren't updating? My HUD (an osg::Group) class constructor creates several cameras that draw a variety of elements on the screen. I've looked through most of the examples but I'm not sure what I'm looking for. Any help would be greatly appreciated. Danny Konkle Classification: UNCLASSIFIED Caveats: NONE ___ 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 Classification: UNCLASSIFIED Caveats: NONE osghud.cpp Description: osghud.cpp ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] any help would be appreciated - updating a groupofcameras (UNCLASSIFIED)
Hello Danny, Sending your message twice will not get you help faster. Good etiquette would be to wait a little, and if you don't get any response after a few days then you can send a reminder, like no one has any idea what I'm doing wrong? or something like that. We all have day jobs and sending the same message multiple times makes it look like you expect us to stop everything we're doing to help you... i can't get the camera's children to update and can't find an example that works. Your callbacks weren't actually doing anything to the text or the geometry. I've modified it to show you one example of what you can do. Basically, just changing the variable with which you calculated the vertices and which was in the text (factor) will not change them. You need to update the text in your callback (using text-setText(string) ) and you need to update your osg::Geometry objects in the other callback (creating new vertex arrays, or perhaps looping through the existing vertices and modifying those you need to). In my modifications, I used std::stringstream instead of boost::format because I don't have boost on this machine. When you send example code, it's preferable to send code that has no dependencies other than OSG (and its own dependencies). It makes it more likely that others will be able to help. Note also that you had a memory leak in your code: osg::Geometry* geom = new osg::Geometry; geom = drawLines(...); since drawLines creates a new osg::Geometry and returns it, the original one was never freed. You could change that in two ways to remove the leak: // still wasteful, but at least there's no leak osg::ref_ptrosg::Geometry geom = new osg::Geometry; geom = drawLines(...); or simply osg::Geometry* geom = drawLines(...); Also, I've set the geometry and text objects to DYNAMIC data variance. If you're modifying drawables (osg::Geometry and osgText::Text are in this category) or statesets in update callbacks, you need to set them to DYNAMIC or else you'll get crashes in multithreaded mode. Do a diff between the file you sent and the one that's attached to this message to see the changes. Now that I've shown you how to update text and geometry in the callbacks, it's up to you to make changes to get the result you want. Style comment: it works, but I think you'd be able to understand yourself more if your code was cleaner and better indented. Hope this helps, J-S -- __ Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com http://www.cm-labs.com/ http://whitestar02.webhop.org/ /* OpenSceneGraph example, osghud. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the Software), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * THE SOFTWARE IS PROVIDED AS IS, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ //#include boost/format.hpp #include sstream #include osgUtil/Optimizer #include osgDB/ReadFile #include osgViewer/Viewer #include osgViewer/CompositeViewer #include osgGA/TrackballManipulator #include osg/Material #include osg/Geode #include osg/BlendFunc #include osg/Depth #include osg/PolygonOffset #include osg/MatrixTransform #include osg/Camera #include osg/RenderInfo #include osgDB/WriteFile #include osgText/Text osg::Vec4 colorVec[] = { osg::Vec4(0.0f, 0.99f, 0.0f, 1.0f), osg::Vec4(0.85f, 0.00f, 0.0f, 1.0f), osg::Vec4(0.0f, 0.00f, 0.0f, 1.0f), osg::Vec4(1.0f, 1.00f, 1.0f, 1.0f), osg::Vec4(0.0f, 0.00f, 1.0f, 1.0f), osg::Vec4(0.3f, 0.30f, 0.3f, 1.0f), osg::Vec4(0.9f, 0.90f, 0.0f, 1.0f) }; // create LINES osg::Geometry * drawLines(osg::Vec3Array * vertices, int colorIndex, osg::PrimitiveSet::Mode lineType) { // create Geometry object to store all the vertices and lines primitive. osg::Geometry* linesGeom = new osg::Geometry(); // Set dynamic data variance since the geometry will be updated in a callback. linesGeom-setDataVariance(osg::Object::DYNAMIC); // Use vertex buffers so display lists won't need to be updated. linesGeom-setUseDisplayList(false); // pass the created vertex array to the points geometry object. linesGeom-setVertexArray(vertices); //
Re: [osg-users] any help would be appreciated - updating a groupofcameras (UNCLASSIFIED)
Classification: UNCLASSIFIED Caveats: NONE i didn't send it twice because i wanted more help or faster help. i sent it twice because i was having problem with email and i didn't think the message went out. i check the list server and it wasn't there. i was obviously mistaken and i apologize. -Original Message- From: osg-users-boun...@lists.openscenegraph.org [mailto:osg-users- boun...@lists.openscenegraph.org] On Behalf Of Jean-Sébastien Guay Sent: Wednesday, April 15, 2009 9:48 AM To: OpenSceneGraph Users Subject: Re: [osg-users] any help would be appreciated - updating a groupofcameras (UNCLASSIFIED) Hello Danny, Sending your message twice will not get you help faster. Good etiquette would be to wait a little, and if you don't get any response after a few days then you can send a reminder, like no one has any idea what I'm doing wrong? or something like that. We all have day jobs and sending the same message multiple times makes it look like you expect us to stop everything we're doing to help you... i can't get the camera's children to update and can't find an example that works. Your callbacks weren't actually doing anything to the text or the geometry. I've modified it to show you one example of what you can do. Basically, just changing the variable with which you calculated the vertices and which was in the text (factor) will not change them. You need to update the text in your callback (using text-setText(string) ) and you need to update your osg::Geometry objects in the other callback (creating new vertex arrays, or perhaps looping through the existing vertices and modifying those you need to). In my modifications, I used std::stringstream instead of boost::format because I don't have boost on this machine. When you send example code, it's preferable to send code that has no dependencies other than OSG (and its own dependencies). It makes it more likely that others will be able to help. Note also that you had a memory leak in your code: osg::Geometry* geom = new osg::Geometry; geom = drawLines(...); since drawLines creates a new osg::Geometry and returns it, the original one was never freed. You could change that in two ways to remove the leak: // still wasteful, but at least there's no leak osg::ref_ptrosg::Geometry geom = new osg::Geometry; geom = drawLines(...); or simply osg::Geometry* geom = drawLines(...); Also, I've set the geometry and text objects to DYNAMIC data variance. If you're modifying drawables (osg::Geometry and osgText::Text are in this category) or statesets in update callbacks, you need to set them to DYNAMIC or else you'll get crashes in multithreaded mode. Do a diff between the file you sent and the one that's attached to this message to see the changes. Now that I've shown you how to update text and geometry in the callbacks, it's up to you to make changes to get the result you want. Style comment: it works, but I think you'd be able to understand yourself more if your code was cleaner and better indented. Hope this helps, J-S -- __ Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com http://www.cm-labs.com/ http://whitestar02.webhop.org/ Classification: UNCLASSIFIED Caveats: NONE ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] any help would be appreciated - updating a groupofcameras (UNCLASSIFIED)
Hello Danny, i didn't send it twice because i wanted more help or faster help. i sent it twice because i was having problem with email and i didn't think the message went out. i check the list server and it wasn't there. i was obviously mistaken and i apologize. OK, apology accepted, but look below and check my message, I attached a fixed example that should help you out and gave a few explanatory comments. (I have the habit of placing quotes inline with my reply) J-S -- __ Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com http://www.cm-labs.com/ http://whitestar02.webhop.org/ ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] any help would be appreciated - updating a groupofcameras (UNCLASSIFIED)
Classification: UNCLASSIFIED Caveats: NONE Hello Danny, i didn't send it twice because i wanted more help or faster help. i sent it twice because i was having problem with email and i didn't think the message went out. i check the list server and it wasn't there. i was obviously mistaken and i apologize. OK, apology accepted, but look below and check my message, I attached a fixed example that should help you out and gave a few explanatory comments. (I have the habit of placing quotes inline with my reply) Hello Jean-Sebastien, thanks for the insight into OSG. i'm looking through the fixed example now. thanks for the help. Danny Classification: UNCLASSIFIED Caveats: NONE ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] any help would be appreciated - updating a groupofcameras (UNCLASSIFIED)
Hello Danny, thanks for the insight into OSG. i'm looking through the fixed example now. thanks for the help. My pleasure. J-S -- __ Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com http://www.cm-labs.com/ http://whitestar02.webhop.org/ ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] any help would be appreciated - updating a groupofcameras (UNCLASSIFIED)
Classification: UNCLASSIFIED Caveats: NONE thanks. that helps. so if my camera in my group have drawables attached to them how would i get them to be updated? i'm taking your approach and trying to make a useful example that is small. -Original Message- From: osg-users-boun...@lists.openscenegraph.org [mailto:osg-users- boun...@lists.openscenegraph.org] On Behalf Of Paul Martz Sent: Tuesday, April 14, 2009 12:30 PM To: 'OpenSceneGraph Users' Subject: Re: [osg-users] any help would be appreciated - updating a groupofcameras (UNCLASSIFIED) Hi Danny -- There really isn't much info to go on here. You don't describe the mechanism that is doing the drawing. Cameras don't draw, they only set the matrices. Assuming you are changing a Drawable in your scene graph... One thing to check would be to make sure that you have setUseDisplayLists( false ). You don't want to use display lists for dynamic geometry. If your code is too large to debug, then write a small piece of code to reproduce the problem outside of your larger app, making it as small and simple as possible. This will increase the odds that someone on the list will take the time to look at it. Paul Martz Skew Matrix Software LLC http://www.skew-matrix.com +1 303 859 9466 -Original Message- From: osg-users-boun...@lists.openscenegraph.org [mailto:osg-users-boun...@lists.openscenegraph.org] On Behalf Of Konkle, Daniel T AMRDEC/Dynetics Sent: Tuesday, April 14, 2009 9:32 AM To: OpenSceneGraph Users Subject: [osg-users] any help would be appreciated - updating a group ofcameras (UNCLASSIFIED) Classification: UNCLASSIFIED Caveats: NONE I am new to OSG and I am stuck and need help/insight. I'm created a Heads up display by extending the group class. My Hud is an osg::Group and has several cameras in it. The Hud displays fine. The Hud class has several variables that control how information is displayed such as the heading. I've written a callback and attached it to my Hud. After attaching my Hud to my scene, I want to the callback for the Hud to change its variables but the cameras in my Hud don't use the updated variables to redraw themselves. I've used osg::notify to show that the callback is getting executed and to print out the value of the heading variable I am changing. I realize I'm not showing any code only because there is so much of it. Can anyone give me an idea of where to look to figure out why all the children in my HUD class aren't updating? My HUD (an osg::Group) class constructor creates several cameras that draw a variety of elements on the screen. I've looked through most of the examples but I'm not sure what I'm looking for. Any help would be greatly appreciated. Danny Konkle Classification: UNCLASSIFIED Caveats: NONE ___ 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 Classification: UNCLASSIFIED Caveats: NONE ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org