def location(self): joint_transform = get_joint_transform_from_rig(self.owner.rig, self.slot_name_hash) return sims4.math.Location(joint_transform, None, parent=self.owner, slot_hash=self.slot_name_hash)
def _event_handler_parent(self, event_data): asms = self._get_asms_from_arb_request_info() (early_out, child_object) = get_animation_object_for_event(event_data, 'parent_child_id', 'child', asms=asms) if early_out is not None: return parent_id = event_data.event_data['parent_parent_id'] if parent_id is None: parent_object = child_object.get_parenting_root() child_object.clear_parent(child_object.transform, parent_object.routing_surface) return parent_object = get_animation_object_by_id(int(parent_id)) if parent_object is None: return get_event_handler_error_for_missing_object( 'parent', parent_id) joint_name_hash = int(event_data.event_data['parent_joint_name_hash']) translation = event_data.event_data['parent_translation'] orientation = event_data.event_data['parent_orientation'] if orientation is None: joint_transform = get_joint_transform_from_rig( parent_object.rig, joint_name_hash) joint_orientation = _math.Quaternion.concatenate( parent_object.orientation, joint_transform.orientation) joint_orientation = invert_quaternion(joint_orientation) orientation = _math.Quaternion.concatenate( joint_orientation, child_object.orientation) transform = _math.Transform(translation, orientation) self.add_additional_channel(child_object.manager.id, child_object.id) try: if event_data.event_data['clip_is_mirrored']: joint_name_hash = get_mirrored_joint_name_hash( parent_object.rig, joint_name_hash) joint_name_or_hash = None slot_hash = 0 joint_name_or_hash = joint_name_hash if child_object in self._client_location_captures: location = child_object.create_parent_location( parent_object, transform, joint_name_or_hash=joint_name_or_hash, slot_hash=slot_hash) child_object.resend_location(value=location) else: child_object.set_parent(parent_object, transform, joint_name_or_hash=joint_name_or_hash, slot_hash=slot_hash) except KeyError: logger.exception( "\n ANIMATION: A clip is trying to fire a parent event with bad\n data. Either the animation actors are mistuned, or a slot\n that doesn't exist on the rig has been specified in Maya.\n \n ASMs: {}\n \n Clip: {}{} (Parent Event ID: {}),\n Parenting {} to {},\n Slot {} on {},\n Offset: {}\n ", ', '.join(set(asm.name for asm in asms)), event_data.event_data.get('clip_name', 'unknown clip'), ' (mirrored)' if event_data.event_data['clip_is_mirrored'] else '', event_data.event_id, str(child_object), str(parent_object), hex(joint_name_hash), parent_object.rig, str(transform))
def get_joint_transform_for_joint(self, joint_name): if isinstance(joint_name, str): joint_name = joint_name + str(self.subroot_index) else: joint_name = hash32(str(self.subroot_index), initial_hash=joint_name) transform = get_joint_transform_from_rig(self.rig, joint_name) transform = Transform.concatenate(transform, self.part_owner.transform) return transform
def transform(self): if self.subroot_index is None: return self.part_owner.transform if self._joint_transform is None: target_root_joint = ArbElement._BASE_ROOT_STRING + str(self.subroot_index) try: self._joint_transform = get_joint_transform_from_rig(self.rig, target_root_joint) except KeyError: raise KeyError('Unable to find joint {} on {}'.format(target_root_joint, self)) return Transform.concatenate(self._joint_transform, self.part_owner.transform)
def transform(self): if self.subroot_index is None: return self.part_owner.transform if self._joint_transform is None: target_root_joint = ArbElement._BASE_ROOT_STRING + str( self.subroot_index) try: self._joint_transform = get_joint_transform_from_rig( self.rig, target_root_joint) except KeyError: raise KeyError('Unable to find joint {} on {}'.format( target_root_joint, self)) return Transform.concatenate(self._joint_transform, self.part_owner.transform)
def get_joint_transform(self): if self._joint_transform is None: if not self.is_base_part: target_root_joint = ArbElement._BASE_SUBROOT_STRING + str( self.subroot_index) try: self._joint_transform = get_joint_transform_from_rig( self.rig, target_root_joint) except KeyError: raise KeyError('Unable to find joint {} on {}'.format( target_root_joint, self)) except ValueError: raise ValueError( 'Unable to find rig for joint {} on {}'.format( self.rig, self)) else: self._joint_transform = Transform.IDENTITY() return self._joint_transform
def _event_handler_snap(self, event_data): asms = list(self._get_asms_from_arb_request_info()) (early_out, object_to_snap) = get_animation_object_for_event( event_data, 'event_actor_id', 'object to be snapped', asms=asms) if early_out is not None: return snap_actor_namespace = event_data.event_data.get( 'snap_actor_namespace', None) if snap_actor_namespace is None: v = event_data.event_data['snap_translation'] q = event_data.event_data['snap_orientation'] snap_transform = _math.Transform(v, q) else: (early_out, snap_reference_object) = get_animation_object_for_event( event_data, 'snap_actor_id', 'snap reference object', asms=asms) if early_out is not None: return v = event_data.event_data['snap_translation'] q = event_data.event_data['snap_orientation'] suffix = event_data.event_data['snap_actor_suffix'] base_transform = snap_reference_object.transform if suffix is not None: base_joint = self._BASE_SUBROOT_STRING + suffix offset = get_joint_transform_from_rig( snap_reference_object.rig, base_joint) base_transform = _math.Transform.concatenate( offset, base_transform) snap_transform = _math.Transform(v, q) snap_transform = _math.Transform.concatenate( snap_transform, base_transform) if object_to_snap in self._client_location_captures: new_location = object_to_snap.location.clone( transform=snap_transform) object_to_snap.resend_location(value=new_location) else: object_to_snap.transform = snap_transform if object_to_snap.is_sim: object_to_snap.update_intended_position_on_active_lot()
def get_joint_transform_for_joint(self, joint_name): transform = get_joint_transform_from_rig(self.rig, joint_name) transform = Transform.concatenate(transform, self.transform) return transform
def get_slot_transform(surface, slot_name): raise RuntimeError('[bhill] This function is believed to be dead code and is scheduled for pruning. If this exception has been raised, the code is not dead and this exception should be removed.') slot_transform = get_joint_transform_from_rig(surface.rig, slot_name) slot_transform = Transform.concatenate(slot_transform, surface.transform) return slot_transform
def location(self): joint_transform = get_joint_transform_from_rig(self.owner.rig, self.slot_name_hash) return sims4.math.Location(joint_transform, None, parent=self.owner, slot_hash=self.slot_name_hash)