def _initialize_component(self, obj, component): """ Initialize component operator. """ coms_info = rexio.get_component_info() com_info = coms_info[component.type] pre = str(component.id) for prop in com_info: name = list(prop.keys())[0] data = list(prop.values())[0] tmp_name = "com_" + 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'] == 'jsscript': val = "" elif data['type'] == 'boolean': val = True elif data['type'] == 'key': val = "bla" elif data['type'] == 'float': val = 0.0 obj[tmp_name] = val
def draw_object(self, box, editor, obj): """ Component editor. """ if not self.expand(box): return False mainbox = box.box() box = mainbox.row() main_row = mainbox.row() #box = box.box() box.label("Components") props = obj.opensim # draw state list row = box.row() if not props.component_data or (props.selected_component and not props.selected_component in props.component_data): row.operator('b2rex.entity', text='', icon='ZOOMIN').action = '_add_component' elif props.component_data: row.operator('b2rex.entity', text='', icon='ZOOMOUT').action = '_delete_component' row.prop_search(props, 'selected_component', props, 'component_data') # draw sensor list if not props.selected_component or not props.selected_component in props.component_data: return box = main_row.column() box.label("Current component") component = props.component_data[props.selected_component] #box.prop(curractuator, 'name') row = box.row() row.alignment = 'LEFT' row.label(text='Type:') row.operator_menu_enum('b2rex.component_type', 'type', text=component.type, icon='BLENDER') coms_info = rexio.get_component_info() com_info = coms_info[component.type] pre = str(component.id) for prop in com_info: name = list(prop.keys())[0] data = list(prop.values())[0] if data['type'] == 'hardcoded': continue tmp_name = "com_" + pre + name if tmp_name in obj: if data['type'] == 'jsscript': row = box.row() row.prop(obj, '["'+tmp_name+'"]', text=name) try: comp = library.get_component('jsscript', obj[tmp_name]) row.label('', icon='FILE_TICK') except KeyError: pass elif data['type'] == 'boolean': box.prop(obj, '["'+tmp_name+'"]', text=name, toggle=True) else: box.prop(obj, '["'+tmp_name+'"]', text=name)
def find_components(self, obj): """ Return components in the given object. """ # base components components = [NameComponent(obj), PlaceableComponent(obj), MeshComponent(obj)] # user defined components coms_info = rexio.get_component_info() for bcomp in obj.opensim.component_data: metadata = coms_info[bcomp.type] component = GenericComponent(obj, bcomp, metadata) components.append(component) return components
def find_components(self, obj): """ Return components in the given object. """ # base components components = [ NameComponent(obj), PlaceableComponent(obj), MeshComponent(obj) ] # user defined components coms_info = rexio.get_component_info() for bcomp in obj.opensim.component_data: metadata = coms_info[bcomp.type] component = GenericComponent(obj, bcomp, metadata) components.append(component) return components
def draw_object(self, box, editor, obj): """ Component editor. """ if not self.expand(box): return False mainbox = box.box() box = mainbox.row() main_row = mainbox.row() #box = box.box() box.label("Components") props = obj.opensim # draw state list row = box.row() if not props.component_data or ( props.selected_component and not props.selected_component in props.component_data): row.operator('b2rex.entity', text='', icon='ZOOMIN').action = '_add_component' elif props.component_data: row.operator('b2rex.entity', text='', icon='ZOOMOUT').action = '_delete_component' row.prop_search(props, 'selected_component', props, 'component_data') # draw sensor list if not props.selected_component or not props.selected_component in props.component_data: return box = main_row.column() box.label("Current component") component = props.component_data[props.selected_component] #box.prop(curractuator, 'name') row = box.row() row.alignment = 'LEFT' row.label(text='Type:') row.operator_menu_enum('b2rex.component_type', 'type', text=component.type, icon='BLENDER') coms_info = rexio.get_component_info() com_info = coms_info[component.type] pre = str(component.id) for prop in com_info: name = list(prop.keys())[0] data = list(prop.values())[0] if data['type'] == 'hardcoded': continue tmp_name = "com_" + pre + name if tmp_name in obj: if data['type'] == 'jsscript': row = box.row() row.prop(obj, '["' + tmp_name + '"]', text=name) try: comp = library.get_component('jsscript', obj[tmp_name]) row.label('', icon='FILE_TICK') except KeyError: pass elif data['type'] == 'boolean': box.prop(obj, '["' + tmp_name + '"]', text=name, toggle=True) else: box.prop(obj, '["' + tmp_name + '"]', text=name)