當前位置: 首頁>>代碼示例>>Python>>正文


Python Scene.set_params方法代碼示例

本文整理匯總了Python中Scene.Scene.set_params方法的典型用法代碼示例。如果您正苦於以下問題:Python Scene.set_params方法的具體用法?Python Scene.set_params怎麽用?Python Scene.set_params使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Scene.Scene的用法示例。


在下文中一共展示了Scene.set_params方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: format

# 需要導入模塊: from Scene import Scene [as 別名]
# 或者: from Scene.Scene import set_params [as 別名]

#.........這裏部分代碼省略.........
            return int(value)
        elif var_type is np.ndarray:
            return np.array(map(float, str(value).split()))
        else: # return as string
            return value 
            
    def create_params(self, attribs):
        params = dict()
        for key in attribs.keys():
            var_type = self.__var_datatypes.get(key, str)
            params[key] = self.convert_attribute_value(attribs[key].value, var_type)
        return params
    
    def create_params_from_child(self, node, params):    
        for e in node.childNodes:
            val = self.parse(e)
            if val is not None:
                key = str(val.__class__.__name__).lower()
                if params.has_key(key):
                    print('key ' + key + ' already exists')
                    if type(params[key]) is list:
                        print('appending')
                        params[key].append(val)
                    else: #if the key already exists but is not a list
                        print('creating list and appending')
                        cval = params[key]
                        params[key] = [cval, val]
                else:        
                    params[key] = val
        return params
    
    def process_scene(self, node):
        params = self.create_params(node.attributes)
        self.scene.set_params(params)
        #self.NodeStack.append(SceneNode()) # root scene node
        
        for e in node.childNodes:
            self.parse(e)
        #self.scene.surfaces.append(self.NodeStack.pop())
        
    def process_light(self, node):
        ''' <light name="myLight" color="1 1 1" from="0 0 0 " power="1.0" type="point" /> '''
        self.scene.lights.append(Light(self.create_params(node.attributes)))
        
    def process_material(self, node):
        '''<material name="blue" diffuse="0 0 1" specular="0 0 0" hardness="0" />'''
        params = self.create_params(node.attributes)
        if params.has_key('ref'):
            if not self.Materials.has_key(params['ref']):
                print('Warning: Material ' + params['ref'] + ' not found')
            return self.Materials.get(params['ref'])
        else:
            print('adding Material ' + params['name'])
            material = Material(params)
            self.Materials[params.get('name')] = material
            return material
    
    def process_material2(self, node):
        return self.process_material(node)
        
    def process_node(self, node):
        '''Nodes can refer to other nodes '''
        print('start process_node')
        #self.scene.start_node()
        params = self.create_params(node.attributes)
        #TODO: remove this comment block (currently kept for reference)
開發者ID:danhp,項目名稱:socs,代碼行數:70,代碼來源:SceneParser.py


注:本文中的Scene.Scene.set_params方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。