Re: [osg-users] [osgPlugins] osgDB OBJ Plugin
Alright, some more details. I'm converting some constructive geometry models from BRL-CAD into faceted models in OBJ format. I'm converting them region by region in a constructive geometry sense. Each region becomes a group in an OBJ file sense. Now, each region has a material value associated with it, typically an integer value that could represent things like: concrete, glass, tile, etc... to me it's just an integer. The important thing is that this material value be maintained as part of the usemtl label for the converted group. A list of these material values in maintained in a material .mtl file. The process I'm using (that unfortunately I can't change) dumps out a material file and obj file for each region converted. That part is just peachy the material file looks right, the obj file looks right as far as the mtllib and usemtl labels go they match the .mtl file. Great. Now the goal is to merge all these .obj files together into ONE .obj file and maintain the respective usemtl labels because in the analysis tool I've built (in Delta3D using OSG) I have the ability to change the color scheme or shading of the input OBJ model based on these usemtl or material values. I.e. the converted model might be a car and I might want to shade all the glass components black or all the plastic components brown etc I've already got the ability to do all of this as long as the OBJ file has proper usemtl labels (i.e. I edit the converted OBJ file by hand). So my question is there a way to merge these .obj files and maintain the group names, usemtl labels? I hoped to avoid writing my own OBJ parser just to accomplish this, but if I have no choice I'll guess I'll have to. I want to be able to take that correctly merged .obj file and use it in other analysis tools that read in this .obj file and the tool knows, based on the usemtl statements what kinds of materials this model is made of and then does some calculations that are not important to this issue... I'm mainly wondering are there other, specific arguments to readNode or writeNode (osgDB for the OBJ Plugin) that allow the maintaining of these labels? Like I said before the resultant, merged obj file had the correctly defined vertices and facets but the group names, usemtl labels are all auto generated, I think based on the input file name. Please let me know if you need any more information. Thanks in advance! Rob -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=12104#12104 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [osgPlugins] osgDB OBJ Plugin
Robert, At the moment the OBJ loader builds a material to stateset map, which is indexed by the material name. However when the stateset is applied to a geometry, the material name is effectively lost. Also the OBJ loader reads the group name (i.e. g groupname in the .obj) and any object name (i.e. o objectname in the .obj). For any g field in the OBJ file, it creates a new geode under the toplevel group, with a name as in the form groupname:objectname You should be able to see this visually by converting models into .osg and reading the results. However, the OBJ writer outputs everything as o objectname, and doesn't preserve groups at all. Unfortunately, I think that what you want is not possible with the OBJ loader coded as it is. I think you (or someone) might need to dive in and: 1) Attach a loaded material name to a stateset on loading 2) Output things as g geodename rather than o geodename. Probably ditch the writing (and reading?) of object completely. 3) The code for actually outputting material names seems to still be there. IMplementing (1) would not break any body elses code. Implementing (2), however, might. Does anybody actually use o objectname in their modelling pipeling? From the spec, Wavefront claims to ignore this anyway... Regards, David ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [osgPlugins] osgDB OBJ Plugin
Hi, For reasons that aren't relevant I'm trying to merge multiple .obj files into one. Each .obj file fairly small and includes the typical mtllib, usemtl statements then is followed by the g group name then the list of vertices v then a list of facets, f. All very normal, I can load and view the files no problem. So maybe this isn't the best way to do this but to merge I'm doing: osgDB.writeNodeFile(osgDB.readNodeFiles(objFileList,mergedObjFileName) where, objFileList is a list of the file paths to each of the .obj files to merge, mergedObjFileName is the output .obj file name. This does, technically, work. However, in the final, merged, .obj file I've lost what I specified for mtllib, usemtl and the group g names It looks like all those have been auto generated? Am I missing something? I know there is the ability for osgDB.readNodeFiles and osgDB.writeNodeFiles to take other command line parameters? So should I be specifying some? Help! Any guidance would be appreciated! Is there a better way to handle the merge? Thank you! Cheers, Robert -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=12039#12039 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] [osgPlugins] osgDB OBJ Plugin
Robert Youngren wrote: This does, technically, work. However, in the final, merged, .obj file I've lost what I specified for mtllib, usemtl and the group g names It looks like all those have been auto generated? Am I missing something? I know there is the ability for osgDB.readNodeFiles and osgDB.writeNodeFiles to take other command line parameters? So should I be specifying some? Help! Any guidance would be appreciated! AFAIK, OSG doesn't need those names and structure for rendering, so they are discarded during load. Maybe if you explain what your goal is in merging them, we can offer a better suggestion. Thank you! Cheers, Robert -- Chris 'Xenon' Hanson, omo sanza lettere Xenon AlphaPixel.com PixelSense Landsat processing now available! http://www.alphapixel.com/demos/ 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