Exemplo n.º 1
0
    def _iwrite(self,file,tag,name,value,indent):
        svalue = '?enum?'
        if tag == 'enum':
            svalue = value
        elif tag == 'color':
            svalue = iUtils.del2SColor(value)
        elif tag == 'float':
            svalue = iUtils.float2str(value)
        elif tag == 'texture':
            svalue = value
        elif tag == 'int':
            svalue = iUtils.int2str(value)
        elif tag == 'bool':
            svalue = iUtils.bool2str(value)

        out = indent + '<%s name="%s" value="%s"/>\n' % (tag,name,svalue)
        file.write(out)  
Exemplo n.º 2
0
    def _iwrite(self, file, tag, name, value):
        svalue = "?enum?"
        if tag == "enum":
            svalue = value
        elif tag == "color":
            svalue = iUtils.del2SColor(value)
        elif tag == "float":
            svalue = iUtils.float2str(value)
        elif tag == "texture":
            svalue = value
        elif tag == "int":
            svalue = iUtils.int2str(value)
        elif tag == "bool":
            svalue = iUtils.bool2str(value)

        out = '         <%s name="%s" value="%s"/>\n' % (tag, name, svalue)
        file.write(out)
Exemplo n.º 3
0
def writeUserData(file,i1,i2,bObject,writeClose=True):

    props = bObject.properties

    if type(props) != Blender.Types.IDGroupType:
        return

    file.write(i1 + '<userData>\n')
    file.write(i2 + '<attributes>\n')
    i3 = i2 + '   '

    # extract from irrb:userAttributes namespace
    if 'irrb' in props and 'userAttributes' in props['irrb']:
        userAttributes = props['irrb']['userAttributes']
        keys = userAttributes.keys()
        keys.sort()
        for name in keys:
            data = userAttributes[name]
            dtype = type(data)
            stype = None
            if dtype == int:
                stype = 'int'
                svalue = str(data)
            elif dtype == str:
                stype = 'string'
                svalue = data
            elif dtype == float:
                stype = 'float'
                svalue = iUtils.float2str(data)
                
            if name.lower().find('color') >= 0:
                stype = 'colorf'

            if stype != None:
                pout = '<%s name="%s" value="%s"/>\n' % (stype,name,svalue)
                file.write(i3 + pout)

    #
    # write game properties
    #
    try:
        gprops = bObject.getAllProperties()
        for p in gprops:
            dtype = p.getType()
            name = p.getName()
            data = p.getData()

            stype = None
            svalue = ''
            if dtype == 'STRING':
                stype = 'string'
                svalue = data
            elif dtype == 'INT':
                stype = 'int'
                svalue = str(data)
            elif dtype == 'BOOL':
                stype = 'bool'
                svalue = 'false'
                if data == True:
                    svalue = 'true'
            elif dtype == 'FLOAT':
                stype = 'float'
                svalue = iUtils.float2str(data)
            if stype != None:
                pout = '<%s name="%s" value="%s"/>\n' % (stype,name,svalue)
                file.write(i3 + pout)
    except:
        pass

    if writeClose:
        file.write(i2 + '</attributes>\n')
        file.write(i1 + '</userData>\n')