Working on a Blender serialization script

(elander) #1

I’m working a Blender script that serializes Blender data structures to a xml file. Here’s an example of the scripts output:


<?xml version="1.0" encoding="UTF-8"?>
<Blender>
    <Globals>
        <Pro Get="Blender.Get">
            <Args>
                <Val Type="String">curframe</Val>
            </Args>
            <Val Type="Int">1</Val>
        </Pro>
        <Pro Get="Blender.Get">
            <Args>
                <Val Type="String">curtime</Val>
            </Args>
            <Val Type="Float">1.0</Val>
        </Pro>
        <Pro Get="Blender.Get">
            <Args>
                <Val Type="String">staframe</Val>
            </Args>
            <Val Type="Int">1</Val>
        </Pro>
        <Pro Get="Blender.Get">
            <Args>
                <Val Type="String">endframe</Val>
            </Args>
            <Val Type="Int">250</Val>
        </Pro>
        <Pro Get="Blender.Get">
            <Args>
                <Val Type="String">version</Val>
            </Args>
            <Val Type="Int">244</Val>
        </Pro>
        <Pro Get="Blender.Get">
            <Args>
                <Val Type="String">filename</Val>
            </Args>
            <Res URI="D:\User\Projects\Python\CGDataBlenderExporter\MyObj.blend" />
        </Pro>
        <Pro Get="Blender.Scene.GetCurrent">
            <Ref Type="Scene" Name="MyScene" />
        </Pro>
    </Globals>
    <Scenes>
        <Scene Name="MyScene">
            <Pro Key="cursor">
                <Vec Type="Float">0.0, 0.0, 0.0</Vec>
            </Pro>
            <Pro Key="layers">
                <Vec Type="Int">1</Vec>
            </Pro>
            <Pro Key="objects">
                    <Ref Type="Mesh" Name="MyObj" />
                    <Ref Type="Lamp" Name="MyLamp" />
                    <Ref Type="Camera" Name="MyCam" />
            </Pro>
            <Pro Key="world">
                <Ref Type="World" Name="MyWorld" />
            </Pro>
        </Scene>
    </Scenes>
</Blender>

I’m only planning to support serialization of properties from: Blender, Scene, World, Object (Mesh, Lamp, Camera), Material, Texture, Image.

What do you think of the output?

This format was made for a game engine that will parse this xml file and extract the relevant data with a xml parser into it’s internal structures.

0 Likes