def unparent_wheels(self): """ Make the wheels orphans, but keep the transformation applied to the parent robot """ # Force Blender to update the transformation matrices of objects bpymorse.get_context_scene().update() wheels = [child for child in self._bpy_object.children if "wheel" in child.name.lower()] wnames = ["None"] * 5 keys = ["WheelFLName", "WheelFRName", "WheelRLName", "WheelRRName", "CasterWheelName"] properties = bpymorse.get_properties(self._bpy_object) for i in range(5): key = keys[i] expected_wheel = properties.get(key, None) if expected_wheel: for wheel in wheels: if wheel.name.startswith(expected_wheel): wnames[i] = wheel.name self.properties( WheelFLName=wnames[0], WheelFRName=wnames[1], WheelRLName=wnames[2], WheelRRName=wnames[3], CasterWheelName=wnames[4], ) for wheel in wheels: # Make a copy of the current transformation matrix transformation = wheel.matrix_world.copy() wheel.parent = None wheel.matrix_world = transformation
def unparent_wheels(self): """ Make the wheels orphans, but keep the transformation applied to the parent robot """ # Force Blender to update the transformation matrices of objects bpymorse.get_context_scene().update() wheels = [child for child in self._bpy_object.children if \ "wheel" in child.name.lower()] wnames = ['None'] * 5 keys = [ 'WheelFLName', 'WheelFRName', 'WheelRLName', 'WheelRRName', 'CasterWheelName' ] properties = bpymorse.get_properties(self._bpy_object) for i in range(5): key = keys[i] expected_wheel = properties.get(key, None) if expected_wheel: for wheel in wheels: if wheel.name.startswith(expected_wheel): wnames[i] = wheel.name self.properties(WheelFLName=wnames[0], WheelFRName=wnames[1], WheelRLName=wnames[2], WheelRRName=wnames[3], CasterWheelName=wnames[4]) for wheel in wheels: # Make a copy of the current transformation matrix transformation = wheel.matrix_world.copy() wheel.parent = None wheel.matrix_world = transformation
def unparent_wheels(self): """ Make the wheels orphans, but keep the transformation applied to the parent robot """ # Force Blender to update the transformation matrices of objects bpymorse.get_context_scene().update() keys = ['WheelFLName', 'WheelFRName', 'WheelRLName', 'WheelRRName', 'CasterWheelName'] properties = bpymorse.get_properties(self._bpy_object) for key in keys: expected_wheel = properties.get(key, None) if expected_wheel: wheel = self.get_child(expected_wheel) if wheel: # Make a copy of the current transformation matrix transformation = wheel.matrix_world.copy() wheel.parent = None wheel.matrix_world = transformation else: logger.error('Wheel %s is required but not found' % expected_wheel)
def profile(self): """ Watch the average time used during the simulation. Display the profile of the component on the viewport in percent. As Blender would for framerate and other debug-properties. """ if self._category is not "sensors": logger.warning("profile currently supports only sensors (%s)" % self) for key in ["profile", "profile_action", "profile_modifiers", "profile_datastreams"]: prop = bpymorse._property_new(self._bpy_object, key, "0") prop.show_debug = True bpymorse.get_context_scene().game_settings.show_debug_properties = True
def profile(self): """ Watch the average time used during the simulation, in percent. """ if self._category is not 'sensors': logger.warning("profile currently supports only sensors") prop = self._property_new("profile", "0 %") prop.show_debug = True prop = self._property_new("profile::action", "0 %") prop.show_debug = True prop = self._property_new("profile::modifiers", "0 %") prop.show_debug = True prop = self._property_new("profile::datastreams", "0 %") prop.show_debug = True bpymorse.get_context_scene().game_settings.show_debug_properties = True
def profile(self): """ Watch the average time used during the simulation. Display the profile of the component on the viewport in percent. As Blender would for framerate and other debug-properties. """ if self._category is not 'sensors': logger.warning("profile currently supports only sensors (%s)"%self) for key in ["profile", "profile_action", "profile_modifiers", "profile_datastreams"]: prop = self._property_new(key, "0") prop.show_debug = True bpymorse.get_context_scene().game_settings.show_debug_properties = True
def unparent_wheels(self): """ Make the wheels orphans, but keep the transformation applied to the parent robot """ # Force Blender to update the transformation matrices of objects bpymorse.get_context_scene().update() keys = [ 'WheelFLName', 'WheelFRName', 'WheelRLName', 'WheelRRName', 'CasterWheelName' ] properties = bpymorse.get_properties(self._bpy_object) for key in keys: expected_wheel = properties.get(key, None) if expected_wheel: wheel = self.get_child(expected_wheel) if wheel: # Make a copy of the current transformation matrix transformation = wheel.matrix_world.copy() wheel.parent = None wheel.matrix_world = transformation else: logger.error('Wheel %s is required but not found' % expected_wheel)
def unparent_objects(self, objs): """ Unparent child objects of the current object Remove the objects in the list of object given as an argument as children of the current object. This method is generally used to allow objects which are assembled from multiple objects using physics constraints to be added to the scene as one object and then split apart before starting the game engine. The method maintains the current location and orientation of the child objects. """ # Force Blender to update the transformation matrices of objects bpymorse.get_context_scene().update() import mathutils for obj in objs: # Make a copy of the current transformation matrix transformation = mathutils.Matrix(obj.matrix_world) obj.parent = None obj.matrix_world = transformation # This method should be easier, but does not seem to work # because of an incorrect context error bpymorse.clear_parent_keep_transform()