示例#1
0
 def _initialize_actuator(self, obj, actuator):
     llsd_info = get_llsd_info()["Actuators"]
     act_info = llsd_info[actuator.type]
     pre = str(actuator.id)
     for prop in act_info:
         name = list(prop.keys())[0]
         data = list(prop.values())[0]
         tmp_name = "tmp_" + pre + name
         if not tmp_name in obj:
             if 'default' in data:
                 val = data['default']
             elif data['type'] == 'integer':
                 val = 0
             elif data['type'] == 'string':
                 val = "bla"
             elif data['type'] == 'key':
                 val = "bla"
             elif data['type'] == 'float':
                 val = 0.0
             obj[tmp_name] = val
示例#2
0
文件: fsmeditor.py 项目: b2rex/b2rex
 def _initialize_actuator(self, obj, actuator):
     llsd_info = get_llsd_info()["Actuators"]
     act_info = llsd_info[actuator.type]
     pre = str(actuator.id)
     for prop in act_info:
         name = list(prop.keys())[0]
         data = list(prop.values())[0]
         tmp_name = "tmp_" + pre + name
         if not tmp_name in obj:
             if 'default' in data:
                 val = data['default']
             elif data['type'] == 'integer':
                 val = 0
             elif data['type'] == 'string':
                 val = "bla"
             elif data['type'] == 'key':
                 val = "bla"
             elif data['type'] == 'float':
                 val = 0.0
             obj[tmp_name] = val
示例#3
0
    def draw_object(self, box, editor, obj):
        """
        Draw scripting section in the object panel.
        """
        if not self.expand(box):
            return False
        mainbox = box.box()
        box = mainbox.row()
        main_row = mainbox.row()
        #box = box.box()
        box.label("State")
        props = obj.opensim.fsm
        # draw state list
        row = box.row()
        if not props.states or (props.selected_state
                                and not props.selected_state in props.states):
            row.operator('b2rex.fsm', text='',
                         icon='ZOOMIN').action = '_add_state'
        elif props.states:
            row.operator('b2rex.fsm', text='',
                         icon='ZOOMOUT').action = '_delete_state'
        row.prop_search(props, 'selected_state', props, 'states')

        # draw sensor list
        if not props.selected_state or not props.selected_state in props.states:
            return
        box = main_row.column()
        box.label("Sensors")
        currstate = props.states[props.selected_state]
        box.template_list(currstate, 'sensors', props, 'selected_sensor')
        row = box.row()
        row.operator('b2rex.fsm', text='',
                     icon='ZOOMIN').action = '_add_sensor'
        if currstate.sensors:
            row.operator('b2rex.fsm', text='',
                         icon='ZOOMOUT').action = '_delete_sensor'
        mainbox.operator('b2rex.fsm', text='Generate',
                         icon='SCRIPT').action = '_generate_llsd'
        if props.selected_sensor >= len(currstate.sensors):
            return
        #box = box.box()
        currsensor = currstate.sensors[props.selected_sensor]
        row = box.row()
        row.alignment = 'LEFT'
        row.label(text='Type:')
        row.operator_menu_enum('b2rex.fsm_sensortype',
                               'type',
                               text=currsensor.type,
                               icon='BLENDER')

        box = main_row.column()
        box.label("Actions")
        # draw current sensor controls

        if currsensor.actuators:
            box.template_list(currsensor, 'actuators', props,
                              'selected_actuator')

        row = box.row()
        row.operator('b2rex.fsm', text='',
                     icon='ZOOMIN').action = '_add_actuator'
        if currsensor.actuators:
            row.operator('b2rex.fsm', text='',
                         icon='ZOOMOUT').action = '_delete_actuator'
            if props.selected_actuator > 0:
                row.operator('b2rex.fsm', text='',
                             icon='TRIA_UP').action = '_up_actuator'
            if props.selected_actuator < len(currsensor.actuators) - 1:
                row.operator('b2rex.fsm', text='',
                             icon='TRIA_DOWN').action = '_down_actuator'

        if props.selected_actuator >= len(currsensor.actuators):
            return

        curractuator = currsensor.actuators[props.selected_actuator]
        #box.prop(curractuator, 'name')
        row = box.row()
        row.alignment = 'LEFT'
        row.label(text='Type:')
        row.operator_menu_enum('b2rex.fsm_actuatortype',
                               'type',
                               text=curractuator.type,
                               icon='BLENDER')

        llsd_info = get_llsd_info()["Actuators"]
        act_info = llsd_info[curractuator.type]
        pre = str(curractuator.id)
        for prop in act_info:
            name = list(prop.keys())[0]
            data = list(prop.values())[0]
            tmp_name = "tmp_" + pre + name
            if tmp_name in obj:
                box.prop(obj, '["' + tmp_name + '"]', text=name)
示例#4
0
文件: fsmeditor.py 项目: b2rex/b2rex
    def draw_object(self, box, editor, obj):
        """
        Draw scripting section in the object panel.
        """
        if not self.expand(box):
            return False
        mainbox = box.box()
        box = mainbox.row()
        main_row = mainbox.row()
        #box = box.box()
        box.label("State")
        props = obj.opensim.fsm
        # draw state list
        row = box.row()
        if not props.states or (props.selected_state and not props.selected_state in props.states):
            row.operator('b2rex.fsm', text='', icon='ZOOMIN').action = '_add_state'
        elif props.states:
            row.operator('b2rex.fsm', text='', icon='ZOOMOUT').action = '_delete_state'
        row.prop_search(props, 'selected_state', props, 'states')

        # draw sensor list
        if not props.selected_state or not props.selected_state in props.states:
            return
        box = main_row.column()
        box.label("Sensors")
        currstate = props.states[props.selected_state]
        box.template_list(currstate,
                          'sensors',
                          props,
                          'selected_sensor')
        row = box.row()
        row.operator('b2rex.fsm', text='', icon='ZOOMIN').action = '_add_sensor'
        if currstate.sensors:
            row.operator('b2rex.fsm', text='', icon='ZOOMOUT').action = '_delete_sensor'
        mainbox.operator('b2rex.fsm', text='Generate', icon='SCRIPT').action = '_generate_llsd'
        if props.selected_sensor >= len(currstate.sensors):
            return
        #box = box.box()
        currsensor = currstate.sensors[props.selected_sensor]
        row = box.row()
        row.alignment = 'LEFT'
        row.label(text='Type:')
        row.operator_menu_enum('b2rex.fsm_sensortype',
                               'type',
                               text=currsensor.type, icon='BLENDER')

        box = main_row.column()
        box.label("Actions")
        # draw current sensor controls

        if currsensor.actuators:
            box.template_list(currsensor,
                          'actuators',
                          props,
                          'selected_actuator')

        row = box.row()
        row.operator('b2rex.fsm', text='', icon='ZOOMIN').action = '_add_actuator'
        if currsensor.actuators:
            row.operator('b2rex.fsm', text='', icon='ZOOMOUT').action = '_delete_actuator'
            if props.selected_actuator > 0:
                row.operator('b2rex.fsm', text='', icon='TRIA_UP').action = '_up_actuator'
            if props.selected_actuator < len(currsensor.actuators) -1:
                row.operator('b2rex.fsm', text='', icon='TRIA_DOWN').action = '_down_actuator'

        if props.selected_actuator >= len(currsensor.actuators):
            return

        curractuator = currsensor.actuators[props.selected_actuator]
        #box.prop(curractuator, 'name')
        row = box.row()
        row.alignment = 'LEFT'
        row.label(text='Type:')
        row.operator_menu_enum('b2rex.fsm_actuatortype',
                               'type',
                               text=curractuator.type, icon='BLENDER')

        llsd_info = get_llsd_info()["Actuators"]
        act_info = llsd_info[curractuator.type]
        pre = str(curractuator.id)
        for prop in act_info:
            name = list(prop.keys())[0]
            data = list(prop.values())[0]
            tmp_name = "tmp_" + pre + name
            if tmp_name in obj:
                box.prop(obj, '["'+tmp_name+'"]', text=name)