利用者:Roger/XML

提供: wiki
移動先: 案内検索

XML in Blender

The purpose of this page is for everyone to contribute toward the creation of three things: a standard XML document specification that contains a complete blend file (and tools used to manage that specification), an importer, and an exporter. In order to make an XML file, you first need a specification for the document, called a Document Type Descriptor, or DTD document. Rather than create a new one, let's borrow from existing DTD's for Ogre and Maya. I found some links (please add yours):

http://www.ogre3d.org/wiki/index.php/Ogre_meshxml_DTD

I know Maya exports to XML, but cannot find the DTD. help? Does 3DSMax do XML?

For the mystery of the blend, I would defer to the expert: http://www.atmind.nl/blender/mystery_ot_blend.html

Goal / Example

The goal is to run the python exporter to create an XML document that looks like something a human or production supervisor/development leader/creative supervisor/customer can understand, something like this, for example:

 <File-Header>
     <identifier value="BLENDER">
     <pointer-size value="_" comment="32 bit">
     <endianness value="v" comment="little endian" 
     <version-number value="250" comment="2.50">
 </File-Header>
 <Objects count="1">
     <Object>
         <ID value=1234>
         <type value=1 comment="Mesh">
     </Object>
 </Objects>
 <Mesh name="monkey" count_Vertices="69" count_Faces="33">
    <Vertices>
        <Vertex>
            <Position x="-0.500" y="-0.000" z="0.500" /> 
            <Normal x="0.000" y="1.000" z="0.000" />
            <UV u="0" v="0" />
        </Vertex>
        and so on...
     </Vertices>
    <Faces>
        <Face>
            <Indice ID0="0" ID1="1" ID2="2" />
            <Normal x="0.000" y="1.000" z="0.000" />
        </Face>
        and so on...
    </Faces>
 </Mesh>

As you can see in the above example, we can just read what is in the file, and a patch such as ---<Mesh name="monkey... would readily identify that the monkey mesh was deleted in that SVN commit. You can also tell this file will be quite long. A point of discussion is how technical to get, namely should we have stuff like:

 <File-Blocks count=1>
     <File-Block code="DNA1" size=1024 old memory address=4 SDNA index=0 count=10>
     </File-Block>
 </File-Blocks>

that more accurately reflects the structure of the blend file?

DTD

Rather than write a DTD by hand, which wastes time and introduces errors, there are tools that enable DTD creation. Which one to use? XRay, Tiny XML? An DTD document, for example for Ogre, looks like, in part:

 <!ELEMENT mesh (sharedgeometry?, submeshes, 
                 skeletonlink?, boneassignments?, levelofdetail?, submeshnames?, poses?, animations?, extremes?)>
 <!ELEMENT sharedgeometry (vertexbuffer+)>
 <!ATTLIST sharedgeometry vertexcount CDATA #REQUIRED>

A DTD is itself an XML document, with !Element identifying elements of the document, and !Attlist provides the list of attributes for an element.

The current DTD can be found here <put link here>, and is exported as:

 <!--this is just a hand-hacked very partial. please use the wiki here to update this!-->
 <!ELEMENT File-Header (identifier, pointer-size, endianness, version-number)>
 <!ELEMENT identifier (value)>
    <!ATTLIST value CDATA #REQUIRED>
    <!ATTLIST pointer-size (value, comment)>
    <!ATTLIST endianness (value, comment)> 
    <!ATTLIST version-number (value, comment)>

Import Script

Python goes here :)

Export Script

Python goes here :)