horde3d / Horde3D

Horde3D is a small 3D rendering and animation engine. It is written in an effort to create an engine being as lightweight and conceptually clean as possible.
http://horde3d.org/
1.55k stars 308 forks source link

ColladaConv : `-useMaterialId` let use `id=` for `.material.xml` #194

Closed SuperUserNameMan closed 3 years ago

SuperUserNameMan commented 3 years ago

Regarding : https://github.com/horde3d/Horde3D/issues/193

Without this patch, ColladaConv will use the name attribute (if available) of each material to generate the .material.xml filenames.

The problem is that, sometimes, this material.name contains special reserved characters that will cause unexpected issues with some file-system, and renaming each material in the "DCC tool-chain" might be time consuming.

As the id attribute of each material follows the XML schema xs:ID rule, it should be safer to use it to make .material.xml filenames.

This patch adds a new -useMaterialId command line argument that tells to ColladaConv to use material.id instead of material.name.


Rationalisation :

Ok, so according to Collada Spec 1.4 page 8.54 : the id attribute of <material> is of type xs:ID.

According to xml-schema : xs:ID is derived from xs:NCName.

According to xml-schema : the xs:NCName valid pattern is [\i-[:]][\c-[:]]*.

And according to this page:

So, [\i-[:]][\c-[:]]* translates into english to :

So, if this is correct, using the id attribute of <material> to generate the .material.xml filenames is safer than using its name attribute.