Example #1
0
    def write(self, file):

        file.write('<?xml version="1.0"?>\n')
        file.write('<mesh xmlns="http://irrlicht.sourceforge.net/' + 
            'IRRMESH_09_2007" version="1.0">\n')
        dateTime = (iUtils.datetime2str(time.localtime()), 
                    iUtils.getversion())
        createString = ('<!-- Created %s by irrb %s - ' + 
                '"Irrlicht/Blender Exporter" -->\n')
        file.write(createString % dateTime)

        for buffer in self.meshBuffers:
            buffer.write(file)

        file.write('</mesh>\n')
        
Example #2
0
    def writeSceneHeader(self,file,scene, physicsEnabled):

        world = Blender.World.GetCurrent()
        amb = world.getAmb()
        scolor = '%.6f, %.6f, %.6f %.6f' % (amb[0],amb[1],amb[2],1.0)

        file.write('<?xml version="1.0"?>\n')
        datetime = (iUtils.datetime2str(time.localtime()), 
                     iUtils.getversion())
        file.write(('<!-- Created %s by irrb %s - "Irrlicht/Blender ' + 
                'Exporter" -->\n') % datetime)
        file.write('<irr_scene>\n')
        file.write('   <attributes>\n')
        file.write('      <string name="Name" value="root"/>\n')
        file.write('      <int name="Id" value="-1"/>\n')
        file.write('      <vector3d name="Position" value="0.000000, ' + 
                '0.000000, 0.000000"/>\n')
        file.write('      <vector3d name="Rotation" value="0.000000, ' + 
                '0.000000, 0.000000"/>\n')
        file.write('      <vector3d name="Scale" value="1.000000, ' 
                + '1.000000, 1.000000"/>\n')
        file.write('      <colorf name="AmbientLight" value="%s"/>\n' % (scolor))
        file.write('      <bool name="AutomaticCulling" value="true"/>\n')
        file.write('      <bool name="DebugDataVisible" value="false"/>\n')
        file.write('      <bool name="IsDebugObject" value="false"/>\n')
        file.write('      <bool name="Visible" value="true"/>\n')
        
        # mist/fog enabled
        mode = world.getMode()
        if(mode & 1):
            mist = world.getMist()
            mistType = world.getMistype()
            if mistType == 0:
                sMistType = 'FogExp'
            elif mistType == 1:
                sMistType = 'FogLinear'
            else:
                sMistType = 'FogExp2'
            file.write('      <enum name="FogType" value="%s"/>\n' % (sMistType))
            file.write('      <float name="FogStart" value="%.6f"/>\n' % (mist[1]))
            file.write('      <float name="FogEnd" value="%.6f"/>\n' % (mist[2]))
            file.write('      <float name="FogHeight" value="%.6f"/>\n' % (mist[3]))
            file.write('      <float name="FogDensity" value="%.6f"/>\n' % (mist[0]))
            fcolor = world.getHor()
            scolor = '%.6f, %.6f, %.6f, %.6f' % (fcolor[0],fcolor[1],fcolor[2],1.0)
            file.write('      <colorf name="FogColor" value="%s"/>\n' % (scolor))
            file.write('      <bool name="FogPixel" value="false"/>\n')
            file.write('      <bool name="FogRange" value="false"/>\n')

        file.write('   </attributes>\n')

        if not 'irrb' in scene.properties:
            scene.properties['irrb'] = {'userAttributes': iUtils.defSceneAttributes}

        try:
            scene.properties['irrb']['userAttributes']['Gravity'] = -world.gravity
        except:
            pass

        scene.properties['irrb']['userAttributes']['Physics.Enabled'] = physicsEnabled

        writeUserData(file, '   ', 2*'   ', scene)