Re: [osg-users] export DAE file, how to change names?

2009-11-03 Thread Roger James




lucas Grijander wrote:

  Hi
all!
  
  
  I am using the collada plugin to export my geometries in .dae
format. I would like to know if there is an option of specifying the
name of Ids, such as shapes, primitives, materials, etc... It's
important to better differenciate in another application I have between
different objects.
  
  
  thanks!
  
  
  Jaime.

Hi Lucas/Jaime,

The DAE exporter gets most of its names from the names of nodes in the
OSG scene graph hierarchy you are exporting.

However, you can change anything in the DAE export by the following
procedure:-

Get hold of the DAE exporter

                    osg::ref_ptrosgDB::ReaderWriter
pReaderWriter =
osgDB::Registry::instance()-getReaderWriterForExtension("dae");
                    if (!pReaderWriter.valid())
                        throw _("Unable to load dae writer plugin");
                    wxString FileName = FileDialog.GetPath();

Set up the file name in URI format - this is very important.

                    FileName.Prepend(wxT("file:///"));            

Set up some objects to receive information about the DOM objects created

                    pDae = new DAE; // Use a new object here because
VC8.1 debugger barfs if it tries to show an on stack one in the autos
or watch window !!
                    if (NULL == pDae)
                        throw _("Failed to allocate DAE object");
                    osg::ref_ptrosgDB::ReaderWriter::Options
pOptions = new osgDB::ReaderWriter::Options;
                    std::string DocURI;
                    pOptions-setPluginData("DAE", (void*)pDae);
                    pOptions-setPluginData("DAE-DocumentURI",
(void*)DocURI);

Write the model to a file. This causes the DOM to be built. (On of
these data I might get round to putting a option in the exporter to
just create the DOM and not write the file.)

                    if (pReaderWriter-writeNode(*pGroup, (const
char *)FileName.mb_str(wxConvUTF8), pOptions.get()).status() !=
osgDB::ReaderWriter::WriteResult::FILE_SAVED)
                        throw _("Failed to save model");

Retrieve the DOM

                    domCOLLADA *pDomCollada =
pDae-getDom(DocURI.c_str());
                    if (NULL == pDomCollada)
                        throw _("Cannot get DomCollada");

You can now play around with any of the elements in the DAE hierarchy.
For exmaple:-

                    domAssetRef pAsset = pDomCollada-getAsset();
                    if (NULL == (domAsset*)pAsset)
                        throw _("Cannot get domAsset");
                    domAsset::domUp_axisRef pAxis =
pAsset-getUp_axis();
                    if (NULL == (domAsset::domUp_axis*)pAxis)
                    {
                        // Create a new up axis element
                        pAxis =
(domAsset::domUp_axis*)pAsset-createAndPlace(COLLADA_ELEMENT_UP_AXIS);
                        if (NULL == (domAsset::domUp_axis*)pAxis)
                            throw _("Cannot create up_axis element");
                    }
                    pAxis-setValue(UPAXISTYPE_Y_UP);

Write the file out again to save any changes you have just made.

                    if (DAE_OK !=  pDae-save((daeUInt)0))
                        throw _("Failed to save modified dae file");


If you want to ask questions about the DOM DAE API then you need to
post them on the Collada forums https://collada.org/public_forum/

Cheers,

Roger




___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org


Re: [osg-users] export DAE file, how to change names?

2009-11-02 Thread Jan Ciger
Hi Lucas,

lucas Grijander dev_crisa...@hotmail.com wrote:
 Hi all!
 I am using the collada plugin to export my geometries in .dae format. I
  would like to know if there is an option of specifying the name of Ids,
  such as shapes, primitives, materials, etc... It's important to better
  differenciate in another application I have between different objects.
  thanks!
 Jaime.

I think this is an odd question for OSG list - normally you specify the names 
using the tools you use to create those objects (e.g. Blender, 3DS Max ...). 
OSG doesn't touch them, nor can you export stuff from OSG in COLLADA format. 
Could you be a bit more specific about what you mean?

Regards,

Jan


signature.asc
Description: This is a digitally signed message part.
___
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org