Blender exporter

Hello, I'm starting a project and I expect to use either jME (3) or a self written engine. And yes, I whould prefer to use jME.



I also will use Blender as my asset creation tool and, as far as I know, there are no plug-ins to create a "j3o" in blender, and the recommended way to do it is throught "OGRE". The point is, I have some experience writting Blender plug-ins (I made an exporter last year for an old project), where can I find the format of "j3o", so I can write one?



I'm ready to read all the "you shouldn't do it, you should use OGRE format" posts, but try to be convincing 8)

You could use XMLExporter instead of BinaryExporter and see how the

xml-file looks like.

atridas said:

I'm ready to read all the "you shouldn't do it, you should use OGRE format" posts, but try to be convincing 8)


In my humble opinion...I would say...if you can do it.....you should do it!!
I think it would really ease the art workflow.
But i'm no JME3 guru...

Though, i think j3o is a binary file format, and each jme3 objects expose a read and write method, maybe you should look there first.

There's an equivalent XML format for J3O that can be used. You just export it via XMLExporter instead of BinaryExporter.

blaine has wrote a Blender3D export plugin to jME2 XML, which is syntactically the same to jME3 XML, except the objects being exported are different.

You could try to port it to jME3 if you want, here's an example jME3 XML file:

<?xml  version='1.0' encoding='UTF-8'?>
<com.jme3.scene.Geometry name='MyTeapot'>

    <transform class='com.jme3.math.Transform'>
        <translation class='com.jme3.math.Vector3f' x='1.0' y='2.0' z='3.0'/>
   <rot class='com.jme3.math.Quaternion' w='0.5' x='-0.50000006' y='0.50000006' z='0.5'/>
        <scale class='com.jme3.math.Vector3f' x='2.0' y='3.0' z='4.0'/>
    </transform>

    <lights class='com.jme3.light.LightList'>
        <lights size='0'/>
    </lights>

    <controlsList size='0'/>

    <mesh class='com.jme3.scene.Mesh' elementCount='6320' vertCount='3241'>

        <modelBound class='com.jme3.bounding.BoundingBox' xExtent='0.80425' yExtent='0.39375' zExtent='0.5'>
            <center class='com.jme3.math.Vector3f' x='0.054250002' y='0.39375'/>
        </modelBound>

        <buffers>
            <MapEntry key='0'>
                <Savable buffer_type='Position' class='com.jme3.scene.VertexBuffer' components='3' usage='Static'>
                    <dataFloat size='1' data='0.0'/>
                </Savable>
            </MapEntry>
            <MapEntry key='2'>
                <Savable buffer_type='Normal' class='com.jme3.scene.VertexBuffer' components='3' usage='Static'>
                    <dataFloat size='1'data='0.0' />
                </Savable>
            </MapEntry>
            <MapEntry key='3'>
                <Savable buffer_type='TexCoord' class='com.jme3.scene.VertexBuffer' components='2' usage='Static'>
                    <dataFloat size='1' data='0.0' />
                </Savable>
            </MapEntry>
            <MapEntry key='9'>
                <Savable buffer_type='Index' class='com.jme3.scene.VertexBuffer' components='3' format='UnsignedShort' usage='Static'>
                    <dataUnsignedShort size='1' data='0'/>
                </Savable>
            </MapEntry>
        </buffers>

    </mesh>

    <material class='com.jme3.material.Material' material_def='Common/MatDefs/Misc/ShowNormals.j3md'>
        <parameters>

             <MapEntry key='m_Color'>
                <Savable class='com.jme3.material.MatParam' name='m_Color' varType='Vector4'>
                    <value_savable class='com.jme3.math.ColorRGBA' r='0.25490198' g='0.15686275' b='0.09803922' a='1.0'/>
                </Savable>
            </MapEntry>

            <MapEntry key='m_SomeTextureVar'>
                <Savable class='com.jme3.material.Material$MatParamTexture' varType='Texture2D' name='m_SomeTextureVar' texture_unit='0' >

                    <value_savable class='com.jme3.texture.Texture2D' minificationFilter='Trilinear' name='Interface/Logo/Monkey.png' reference_ID='com.jme3.texture.Texture2D@1288118851'>
                        <key class='com.jme3.asset.TextureKey' flip_y='true' generate_mips='true' name='Interface/Logo/Monkey.png'/>
                    </value_savable>
                    <texture class='com.jme3.texture.Texture2D' ref='com.jme3.texture.Texture2D@1288118851'/>

                </Savable>
            </MapEntry>

            <MapEntry key='m_MyFloatVar'>
                <Savable class='com.jme3.material.MatParam' varType='Float' name='m_MyFloatVar' value_float='123.456'/>
            </MapEntry>

        </parameters>
    </material>

</com.jme3.scene.Geometry>

Cool! Go for it :slight_smile: Do you have experience with the new Python API already? Would be cool to have a 2.5/2.6 compatible exporter as I fear the porting of the ogrexml converter might take a while… And yes, I'd also suggest using the XML file format.



Cheers,

Normen

Yeah, well. Next year is going to be my last university year, and with any hope I'll have enought time to do A GAME, and right now I'm doing the preparations.



I haven't yet seen the new Blender API, mainlly 'cause I'm in germany this semester and I only have my laptop, with a Intel card that's just not suitable to manage "serious" things, so starting on 1rst of august I'll put my time on that (I hope the "filosophy" of the API didn't change a lot).



And yep, I watched some of the exporters and probably I will need a more seriouse xml file than that to understand it (everything makes sense but the "buffer" part. I gess you just erased part of it, so when I watch a REAL file, I'll hope I'll understand better :stuck_out_tongue: ).



So, thank you for cheering me :smiley:

atridas said:

And yep, I watched some of the exporters and probably I will need a more seriouse xml file than that to understand it (everything makes sense but the "buffer" part. I gess you just erased part of it, so when I watch a REAL file, I'll hope I'll understand better :P ).

So, thank you for cheering me :D

Hey no that's a real file. I exported the teapot! It uses buffers, transforms, and materials.. which is like, everything.

Just look into the read and write methods of the classes that extand Savable (Spatial, Material etc.) and it should be obvious how its structured.