[osg-users] [osgPlugins] How to read/write/access OpenFlight Surface Material Code (SMC) and Feature ID (FID) ?
Hi, I would like to include several attributes of openflight face records, namely Surface Material Code, and Feature ID into the scene graph. Essentialy I am looking at modifying the openflight plugin and the ive plugin to read/write these attributes. I want to use this information as a "cost" of movement for entities, so that a vehicle moves slower over dirt than over tarmac. Basically I need to be able to get access to the data using intersectors under the wheels. I am using OSG release 2.8.3 and I have noticed that in the source code of the openflight plugin src\osgPlugins\OpenFlight\GeometryRecords.cpp the data is skipped/discarded (lines 259,260 and lines 826,827) Code: /*int16 surface =*/ in.readInt16(); /*int16 feature =*/ in.readInt16(); My question is: where is the most logical place to store this data in the scene graph. Should I just store it as user data for the stateset or the geode or should I define a new class derived from osg::StateAttribute and add an instance of this object to the stateset of the face? What would be the caveats of these aproaches? P.S. I am fairly new to OpenSceneGraph and my knowledge of OpenGL is basic. Thank you! Cheers, Robert -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=38454#38454 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [osgPlugins] How to read/write/access OpenFlight Surface Material Code (SMC) and Feature ID (FID) ?
If it can be stored as simple text, the DescriptionList (an attribute of Node) would be the best place for it. UserData is already used by the OpenFlight loader for other things. The 2.9.x series has a new mechanism for storing such application-specifc data in the scene graph, but if you use DescriptionList instead, your change could be back-ported to the 2.8.5 release (if/when that happens). -Paul Original Message Subject: [osg-users] [osgPlugins] How to read/write/access OpenFlightSurface Material Code (SMC) and Feature ID (FID) ?From: "Robert Ioiart"Date: Wed, April 13, 2011 5:40 pmTo: osg-users@lists.openscenegraph.orgHi,I would like to include several attributes of openflight face records, namely Surface Material Code, and Feature ID into the scene graph. Essentialy I am looking at modifying the openflight plugin and the ive plugin to read/write these attributes.I want to use this information as a "cost" of movement for entities, so that a vehicle moves slower over dirt than over tarmac. Basically I need to be able to get access to the data using intersectors under the wheels.I am using OSG release 2.8.3 and I have noticed that in the source code of the openflight plugin src\osgPlugins\OpenFlight\GeometryRecords.cpp the data is skipped/discarded (lines 259,260 and lines 826,827)Code:/*int16 surface =*/ in.readInt16();/*int16 feature =*/ in.readInt16();My question is: where is the most logical place to store this data in the scene graph. Should I just store it as user data for the stateset or the geode or should I define a new class derived from osg::StateAttribute and add an instance of this object to the stateset of the face?What would be the caveats of these aproaches?P.S. I am fairly new to OpenSceneGraph and my knowledge of OpenGL is basic.Thank you!Cheers,Robert--Read this topic online here:http://forum.openscenegraph.org/viewtopic.php?p=38454#38454___osg-users mailing listosg-users@lists.openscenegraph.orghttp://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
Re: [osg-users] [osgPlugins] How to read/write/access OpenFlight Surface Material Code (SMC) and Feature ID (FID) ?
Hi, Thanks Paul for your answer. I am looking into that. But what would be wrong with storing such non-visual properties as a new type of state set attribute? Regards, Robert -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=38469#38469 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [osgPlugins] How to read/write/access OpenFlight Surface Material Code (SMC) and Feature ID (FID) ?
StateAttributes issue OpenGL commands to affect the appearance of rendered geometry. OSG uses StateAttributes to sort your geometry during cull and draw. My understanding of your FLT material codes is that they are application data that don't map directly to OpenGL commands. (Perhaps indirectly: your app would interpret the material codes and replace them with StateAttributes.) If you store your material codes as StateAttributes, OSG will sort your geometry accordingly, but for no purpose, as it would do nothing to minimize OpenGL state changes, and could in fact interfere with the process, which would handicap performance. You mentioned you are a newcomer to OSG. Can I recommend that you obtain one or both of the OpenSceneGraph intro books (if you haven't already). http://www.lulu.com/product/file-download/openscenegraph-quick-start-guide/1144915 http://www.packtpub.com/openscenegraph-3-0-beginners-guide/book -Paul Original Message Subject: Re: [osg-users] [osgPlugins] How to read/write/accessOpenFlight Surface Material Code (SMC) and Feature ID (FID) ?From: "Robert Ioiart"Date: Thu, April 14, 2011 7:23 amTo: osg-users@lists.openscenegraph.orgHi,Thanks Paul for your answer. I am looking into that.But what would be wrong with storing such non-visual properties as a new type of state set attribute? Regards,Robert--Read this topic online here:http://forum.openscenegraph.org/viewtopic.php?p=38469#38469___osg-users mailing listosg-users@lists.openscenegraph.orghttp://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
Re: [osg-users] [osgPlugins] How to read/write/access OpenFlight Surface Material Code (SMC) and Feature ID (FID) ?
Paul, Thanks again for the reply. Indeed, my main concern was the fact that storing the data as a stateset attribute could mess-up other things mainly the state sorting for rendering. On the other hand, storing these values as descriptions for geodes would mean that this data would be stored for each geode in the scene (which could add up to a lot of data right? ) The reason I was thinking of storing FID and SMC in the stateset, even if it has nothing to do with rendering, is the fact that geodes reference the state set essentially as a pointer, for instance in a sample OSG file I converted from a FLT I noticed that each state set is defined only once and then each geode has an entry referencing the state set by its unique ID. Geode { DataVariance STATIC ... Use StateSet_0 ... } Neverthelss it seems a bit out-of-place to store non visual properties in a datastrcuture designed to control rendering. I guess I'll use the DescriptionList then. :| Thank you again! Robert -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=38473#38473 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [osgPlugins] How to read/write/access OpenFlight Surface Material Code (SMC) and Feature ID (FID) ?
Hi Robert, I guess I'll use the DescriptionList then. :| You could also use the DescriptionList of the StateSet... If the SMC follows say a texture or a material, and is generally inherited from the top down like state attributes, that might be a way of doing it. It won't be an actual attribute, so it won't affect state sorting, but from a given Geode you'll be able to check statesets, going up until you find one with the SMC in its DescriptionList, and that's the SMC to use for that Geode. Just a thought. J-S -- __ Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com http://www.cm-labs.com/ http://whitestar02.dyndns-web.com/ ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [osgPlugins] How to read/write/access OpenFlight Surface Material Code (SMC) and Feature ID (FID) ?
On 4/14/2011 9:28 AM, Jean-Sébastien Guay wrote: > You could also use the DescriptionList of the StateSet... Or, even better, the DescriptionList of any node that is a parent of the Geode. -- Chris 'Xenon' Hanson, omo sanza lettere. xe...@alphapixel.com http://www.alphapixel.com/ Digital Imaging. OpenGL. Scene Graphs. GIS. GPS. Training. Consulting. Contracting. "There is no Truth. There is only Perception. To Perceive is to Exist." - Xen ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [osgPlugins] How to read/write/access OpenFlight Surface Material Code (SMC) and Feature ID (FID) ?
Hi Chris, Robert, You could also use the DescriptionList of the StateSet... Or, even better, the DescriptionList of any node that is a parent of the Geode. I was suggesting the StateSet because if the SMC naturally follows a texture or material, then it might be more natural that it be there. But whatever works for you (you being Robert Ioiart :-) ). J-S -- __ Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com http://www.cm-labs.com/ http://whitestar02.dyndns-web.com/ ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [osgPlugins] How to read/write/access OpenFlight Surface Material Code (SMC) and Feature ID (FID) ?
You could also use the DescriptionList of the StateSet... One of the default osgUtil::Optimizer flags is SHARE_DUPLICATE_STATE. So if two StateSets are otherwise identical and would be shared under this optimization, adding a different material code to the description list of the two StateSets would impair that optimization. If he really wants to share the material codes with a pointer, then I still recommend modifying the FLT loader to use the DescriptionList (per Node) as the mechanism to return this information to the app. Once the app has the loaded model, it can run a NodeVisitor to move that information out of the DescriptionList and into shared UserData. (The FLT plugin only uses UserData internally for external references, if I remember correctly, and at the root node to return geoposition information... A quick search of the code would verify this.) -Paul ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [osgPlugins] How to read/write/access OpenFlight Surface Material Code (SMC) and Feature ID (FID) ?
Hi Paul, One of the default osgUtil::Optimizer flags is SHARE_DUPLICATE_STATE. So if two StateSets are otherwise identical and would be shared under this optimization, adding a different material code to the description list of the two StateSets would impair that optimization. From what I can see, the StateSet comparison only compares Uniforms and StateAttributes (both normal and texture attributes). See Optimizer::StateVisitor::optimize() in osgUtil/Optimizer.cpp. So adding different descriptions to two StateSets that are otherwise identical will actually result in only one of the sets of descriptions "winning" once the stateset is shared. So if, as I said, the SMC is associated to a texture or a material (in the sense of an osg::Material), then that's fine, there will never be a different SMC when the textures/materials are identical. Anyways, if adding it to the nodes is fine, go with that, I was just saying that it sounded natural to me (anything textured as concrete should have the SMC of concrete, and setting the SMC in the descriptions of the stateset gives you this sharing for free) but I don't know how it actually works in the OpenFlight format, so if what I say is nonsense, then just disregard it. Then again no one has yet said that this association is not actually the case, if that had been said I would just have dropped the subject altogether :-) J-S -- __ Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com http://www.cm-labs.com/ http://whitestar02.dyndns-web.com/ ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [osgPlugins] How to read/write/access OpenFlight Surface Material Code (SMC) and Feature ID (FID) ?
Sorry I implied in my previous post that using the DescriptionList of the StateSet was a bad idea; this was an error on my part. The DescriptionList of either the StateSet, or the Node. or even the Drawable works for me. Just as long as it's used only as a mechanism for transporting this data back to the app, and doesn't interfere with rendering performance if the app simply ignores it. Note to the OP (Robert): The general philosophy behind the FLT loader is to return an unoptimized scene graph that matches the FLT model as close as possible. Optimizations can be performed by the app after loading the model. With respect to the material codes, this means your modification to the FLT loader should not worry about trying to be "smart" about sharing duplicate material codes; leave that as a post-load step to be optionally performed by the application. J-S -- Good catch on the Optimizer issue, dropping the DescriptionList of StateSets when they become shared. Seems like a possible bug. Unexpected behavior, at the least. After all, the word "DUPLICATE" is in the name of the flag. -Paul Original Message Subject: Re: [osg-users] [osgPlugins] How to read/write/accessOpenFlight Surface Material Code (SMC) and Feature ID (FID) ?From: Jean-Sébastien Guay;Date: Thu, April 14, 2011 9:19 amTo: OpenSceneGraph Users Hi Paul,> One of the default osgUtil::Optimizer flags is> SHARE_DUPLICATE_STATE. So if two StateSets are otherwise identical> and would be shared under this optimization, adding a different> material code to the description list of the two StateSets would> impair that optimization.>From what I can see, the StateSet comparison only compares Uniforms and StateAttributes (both normal and texture attributes). See Optimizer::StateVisitor::optimize() in osgUtil/Optimizer.cpp.So adding different descriptions to two StateSets that are otherwise identical will actually result in only one of the sets of descriptions "winning" once the stateset is shared. So if, as I said, the SMC is associated to a texture or a material (in the sense of an osg::Material), then that's fine, there will never be a different SMC when the textures/materials are identical.Anyways, if adding it to the nodes is fine, go with that, I was just saying that it sounded natural to me (anything textured as concrete should have the SMC of concrete, and setting the SMC in the descriptions of the stateset gives you this sharing for free) but I don't know how it actually works in the OpenFlight format, so if what I say is nonsense, then just disregard it. Then again no one has yet said that this association is not actually the case, if that had been said I would just have dropped the subject altogether :-)J-S-- __Jean-Sebastien Guay jean-sebastien.g...@cm-labs.comhttp://www.cm-labs.com/http://whitestar02.dyndns-web.com/___osg-users mailing listosg-users@lists.openscenegraph.orghttp://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
Re: [osg-users] [osgPlugins] How to read/write/access OpenFlight Surface Material Code (SMC) and Feature ID (FID) ?
Hi Paul, J-S -- Good catch on the Optimizer issue, dropping the DescriptionList of StateSets when they become shared. Seems like a possible bug. Unexpected behavior, at the least. After all, the word "DUPLICATE" is in the name of the flag. That's semantics :-) It may be argued that the Optimizer is concerned with improving rendering performance, so checking the descriptions to decide if two statesets are duplicates might not make sense. I guess that's why StateSet doesn't have an operator== which could be used for this purpose - it would be too general, and in the case of Optimizer we just want to consider certain attributes when doing the comparison. I think the current behavior is OK, but should be documented :-) J-S -- __ Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com http://www.cm-labs.com/ http://whitestar02.dyndns-web.com/ ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [osgPlugins] How to read/write/access OpenFlight Surface Material Code (SMC) and Feature ID (FID) ?
Hi, Just a small point worth mentioning... The osg::StateSet class does not have any members of type DescriptioList, at least not in OSG 2.8.3. Only osg::Node and derived classes have a DescriptionList as far as I can tell. So in this case, I can't add the data to the StateSet because there is no description for the StateSet. I'll use the aproch suggested by Paul and store the additional data in the DescriptionList of the Geode itself. > J-S -- Good catch on the Optimizer issue, dropping the DescriptionList of > StateSets when they become shared. Seems like a possible bug. Unexpected > behavior, at the least. After all, the word "DUPLICATE" is in the name of the > flag. ...so there is no bug after all :) But having started this line of thaught don't you think that one should be able to store descriptions in the state set? Thanks for the great feedback. Regards, Robert[/quote] -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=38485#38485 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [osgPlugins] How to read/write/access OpenFlight Surface Material Code (SMC) and Feature ID (FID) ?
Hi Robert, Just a small point worth mentioning... The osg::StateSet class does not have any members of type DescriptioList, at least not in OSG 2.8.3. Only osg::Node and derived classes have a DescriptionList as far as I can tell. Hah, a small point but well worth mentioning! Somehow I confused descriptions and UserData. UserData is in osg::Object, which both StateSet and Node inherit, and I assumed it was the same for descriptions. Well then, sorry for causing such a big discussion over nothing! But having started this line of thaught don't you think that one should be able to store descriptions in the state set? I think there was some discussion about turning UserData into a container for various types of metadata... Or was that the description list? :-) IIRC, this was actually rather ingenious, as it allowed storing many types of data in a type-safe way, but if there was nothing (as will be the case most of the time) didn't take any more space than the current UserData (one pointer). J-S -- __ Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com http://www.cm-labs.com/ http://whitestar02.dyndns-web.com/ ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [osgPlugins] How to read/write/access OpenFlight Surface Material Code (SMC) and Feature ID (FID) ?
Jean-Sébastien, Do you have a link to that thread? > I think there was some discussion about turning UserData into a > container for various types of metadata... Or was that the description > list? :-) > Anyway, I am inclined to think that there are many cases such as mine, when users want to store aditional data in the scene graph, data that won't be used for the visual scene. In such cases it would be nice to have descriptions as one table per scene graph, and instead of storing the actual descriptions for each Node, we could just reference the entry in the description table. Just like state sets are referenced at the moment. But I guess, something like this wouldn't be a small change to OSG... Thanks for all the replies. Regards, Robert -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=38487#38487 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [osgPlugins] How to read/write/access OpenFlight Surface Material Code (SMC) and Feature ID (FID) ?
Hi Robert, Do you have a link to that thread? It started here: http://thread.gmane.org/gmane.comp.graphics.openscenegraph.user/65022 But I don't get why gmane seems to have broken up the thread into multiple threads. There is more discussion here: http://thread.gmane.org/gmane.comp.graphics.openscenegraph.user/65115 and then here: http://thread.gmane.org/gmane.comp.graphics.openscenegraph.user/65155 and then here: http://thread.gmane.org/gmane.comp.graphics.openscenegraph.user/65274 This is all the same thread, and I think I have all of it there. You'll see that one suggestion from Paul Martz that may apply here, is that if you have a reliable way of identifying nodes, you can always store a mapping of node to any data you want in a separate structure than the scene graph. Then it doesn't interfere with the rendering process, but is still accessible easily. This may not be what you want if you want SMC to be inherited down the graph (the mapping will give you a value for that specific node, if there is none you'll have to revert to going up the graph until you find a node that has one). J-S -- __ Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com http://www.cm-labs.com/ http://whitestar02.dyndns-web.com/ ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [osgPlugins] How to read/write/access OpenFlight Surface Material Code (SMC) and Feature ID (FID) ?
Do you have a link to that thread?> I think there was some discussion about turning UserData into a> container for various types of metadata... Or was that the description> list? :-)> This was, in fact, the development on trunk I mentioned in my first reply in this thread. If you're on 2.8.x, it isn't available to you. Anyway, I am inclined to think that there are many cases such as mine, when users want to store aditional data in the scene graph, data that won't be used for the visual scene. I agee with you that many people do want this. Even i did, back when I was new to scene graph technology. But all this is covered in the thread that J-S references, so I won't re-open that box... :-) -Paul ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [osgPlugins] How to read/write/access OpenFlight Surface Material Code (SMC) and Feature ID (FID) ?
Hi all, Thanks for all the feedback. In case you are interested, I have made a patch for the OpenFlight plugin so that it reades/writes the surface material code (SMC) and feature id (FID) and stores it as a description of the geode that contains these attributes. The format of the description string is like "SF:[SMC]:[FID]" for example "SF:918:10" So you can expect to see in the .osg file something like this: Code: Geode { DataVariance STATIC ... description "SF:918:10" ... } Regards, Robert -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=38490#38490 Attachments: http://forum.openscenegraph.org//files/openflight_read_smc_fid_968.zip ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [osgPlugins] How to read/write/access OpenFlight Surface Material Code (SMC) and Feature ID (FID) ?
Hi Robert, In case you are interested, I have made a patch for the OpenFlight plugin so that it reades/writes the surface material code (SMC) and feature id (FID) and stores it as a description of the geode that contains these attributes. The format of the description string is like "SF:[SMC]:[FID]" for example "SF:918:10" Glad you were able to craft a solution that works for you. I haven't looked at your attachment, but you are aware of the submission guidelines? You should send your submission, which should consist of a zip file with the complete modified files (not a patch or diff) to osg-submissions (the forum called Submissions automatically sends to this mailing list, so posting there works too). Also, we spoke about metadata, it seems one of the actors of this subject, Sukender, wants to see this suggestion move forward, see this topic: http://forum.openscenegraph.org/viewtopic.php?t=8175 http://forum.openscenegraph.org/viewtopic.php?t=8174 J-S -- __ Jean-Sebastien Guayjean-sebastien.g...@cm-labs.com http://www.cm-labs.com/ http://whitestar02.dyndns-web.com/ ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [osgPlugins] How to read/write/access OpenFlight Surface Material Code (SMC) and Feature ID (FID) ?
Hi Robert, What you implemented (SMC to Description), is exactly what I need. But I did not found your code OSG. Did you submit your code? Were your changes rejected, or what is the state of it? Regards, WeSee rioiart wrote: > Hi all, > > Thanks for all the feedback. > In case you are interested, I have made a patch for the OpenFlight plugin so > that it reades/writes the surface material code (SMC) and feature id (FID) > and stores it as a description of the geode that contains these attributes. > The format of the description string is like "SF:[SMC]:[FID]" for example > "SF:918:10" > > So you can expect to see in the .osg file something like this: > > Code: > Geode { > DataVariance STATIC > ... > description "SF:918:10" > ... > } > > > > > Regards, > Robert -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=47177#47177 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org