def calc_internal_data(self): HekTag.calc_internal_data(self) full_class_name = self.data.blam_header.tag_class.enum_name self.ext = '.' + full_class_name self.filepath = os.path.splitext(str(self.filepath))[0] + self.ext shader_type = self.data.tagdata.shdr_attrs.shader_type if full_class_name == "shader": shader_type.data = -1 elif full_class_name == "shader_environment": shader_type.data = 3 elif full_class_name == "shader_model": shader_type.data = 4 elif full_class_name == "shader_transparent_generic": shader_type.data = 5 elif full_class_name == "shader_transparent_chicago": shader_type.data = 6 elif full_class_name == "shader_transparent_chicago_extended": shader_type.data = 7 elif full_class_name == "shader_transparent_water": shader_type.data = 8 elif full_class_name == "shader_transparent_glass": shader_type.data = 9 elif full_class_name == "shader_transparent_meter": shader_type.data = 10 elif full_class_name == "shader_transparent_plasma": shader_type.data = 11 else: raise ValueError("Unknown shader type '%s'" % full_class_name)
def calc_internal_data(self): HekTag.calc_internal_data(self) perception = self.data.tagdata.perception looking = self.data.tagdata.looking perception.inv_combat_perception_time = 0 perception.inv_guard_perception_time = 0 perception.inv_non_combat_perception_time = 0 if perception.combat_perception_time: perception.inv_combat_perception_time = 1 / perception.combat_perception_time if perception.guard_perception_time: perception.inv_guard_perception_time = 1 / perception.guard_perception_time if perception.non_combat_perception_time: perception.inv_non_combat_perception_time = 1 / perception.non_combat_perception_time perception.inv_combat_perception_time /= 30 perception.inv_guard_perception_time /= 30 perception.inv_non_combat_perception_time /= 30 for i in range(2): looking.cosine_maximum_aiming_deviation[i] = cos( looking.maximum_aiming_deviation[i]) looking.cosine_maximum_looking_deviation[i] = cos( looking.maximum_looking_deviation[i])
def calc_internal_data(self): HekTag.calc_internal_data(self) devi_attrs = self.data.tagdata.devi_attrs devi_attrs.inv_power_acceleration_time = 0 devi_attrs.inv_power_transition_time = 0 devi_attrs.inv_position_acceleration_time = 0 devi_attrs.inv_position_transition_time = 0 devi_attrs.inv_depowered_acceleration_time = 0 devi_attrs.inv_depowered_transition_time = 0 if devi_attrs.power_acceleration_time: devi_attrs.inv_power_acceleration_time = 1 / ( 30 * devi_attrs.power_acceleration_time) if devi_attrs.power_transition_time: devi_attrs.inv_power_transition_time = 1 / ( 30 * devi_attrs.power_transition_time) if devi_attrs.depowered_position_acceleration_time: devi_attrs.inv_depowered_acceleration_time = 1 / ( 30 * devi_attrs.depowered_position_acceleration_time) if devi_attrs.depowered_position_transition_time: devi_attrs.inv_depowered_transition_time = 1 / ( 30 * devi_attrs.depowered_position_transition_time) if devi_attrs.position_acceleration_time: devi_attrs.inv_position_acceleration_time = 1 / ( 30 * devi_attrs.position_acceleration_time) if devi_attrs.position_transition_time: devi_attrs.inv_position_transition_time = 1 / ( 30 * devi_attrs.position_transition_time)
def calc_internal_data(self): HekTag.calc_internal_data(self) shape = self.data.tagdata.shape shape.cosine_falloff_angle = cos(shape.falloff_angle) shape.cosine_cutoff_angle = cos(shape.cutoff_angle) shape.sine_cutoff_angle = sin(shape.cutoff_angle)
def calc_internal_data(self): HekTag.calc_internal_data(self) tagdata = self.data.tagdata tagdata.crosshair_types.data = 0 for crosshair in tagdata.crosshairs.STEPTREE: tagdata.crosshair_types.data |= 1 << crosshair.crosshair_type.data
def calc_internal_data(self): HekTag.calc_internal_data(self) strings = self.data.tagdata.strings.STEPTREE for i in range(len(strings)): # Replace all newlines with \r\n. strings[i].data = convert_newlines_to_windows(strings[i].data)
def calc_internal_data(self): HekTag.calc_internal_data(self) for pitch_range in self.data.tagdata.pitch_ranges.STEPTREE: pitch_range.playback_rate = 1 if pitch_range.natural_pitch: pitch_range.playback_rate = 1 / pitch_range.natural_pitch
def calc_internal_data(self): HekTag.calc_internal_data(self) for event in self.data.tagdata.events.STEPTREE: for particle in event.particles.STEPTREE: particle.relative_direction_vector[:] = euler_2d_to_vector_3d( *particle.relative_direction )
def calc_internal_data(self): HekTag.calc_internal_data(self) shield = self.data.tagdata.shield shield.shield_recharge_rate = 0 if shield.recharge_time: shield.shield_recharge_rate = 1 / shield.recharge_time shield.shield_recharge_rate /= 30
def calc_internal_data(self): HekTag.calc_internal_data(self) strings = self.data.tagdata.strings.STEPTREE for i in range(len(strings)): # replace all instances of \r and \n with \r\n split_strings = [] for s in strings[i].data.split("\r\n"): for sub_s in s.split('\r'): split_strings.extend(sub_s.split('\n')) strings[i].data = "\r\n".join(split_strings)
def calc_internal_data(self): HekTag.calc_internal_data(self) tagdata = self.data.tagdata tagdata.length = 0 for vertex in tagdata.vertices.STEPTREE: sin_y = sin(vertex.angles.y) sin_p = sin(vertex.angles.p) cos_y = cos(vertex.angles.y) cos_p = cos(vertex.angles.p) vertex.offset.x = vertex.length * sin_p * cos_y vertex.offset.y = vertex.length * sin_y * sin_p vertex.offset.z = vertex.length * cos_p tagdata.length += vertex.length
def calc_internal_data(self): HekTag.calc_internal_data(self) tagdata = self.data.tagdata d = tagdata.density tagdata.scaled_density = d * 355840 / 3 try: tagdata.water_gravity_scale = -((d - 1) / (d + 1)) except ZeroDivisionError: tagdata.water_gravity_scale = float("-inf") # 0.0011 is the density of air relative to water try: tagdata.air_gravity_scale = -((d / 0.0011 - 1) / (d / 0.0011 + 1)) except ZeroDivisionError: tagdata.air_gravity_scale = float("-inf")
def calc_internal_data(self): HekTag.calc_internal_data(self) never_cull = False for event in self.data.tagdata.events.STEPTREE: for part in event.parts.STEPTREE: if part.type.tag_class.enum_name == 'light': never_cull = True part.effect_class = part.type.tag_class #TODO: There is no good way to do this right now #object_types = valid_objects('b').desc[0]['NAME_MAP'].keys() #if part.effect_class.enum_name in object_types: # part.effect_class.enum_name = 'object' for particle in event.particles.STEPTREE: particle.relative_direction_vector[:] = euler_2d_to_vector_3d( *particle.relative_direction ) self.data.tagdata.flags.never_cull = never_cull
def calc_internal_data(self): HekTag.calc_internal_data(self) full_class_name = self.data.blam_header.tag_class.enum_name self.ext = '.' + full_class_name self.filepath = os.path.splitext(self.filepath)[0] + self.ext object_type = self.data.tagdata.obje_attrs.object_type if full_class_name == "object": object_type.data = -1 elif full_class_name == "biped": object_type.data = 0 elif full_class_name == "vehicle": object_type.data = 1 elif full_class_name == "weapon": object_type.data = 2 elif full_class_name == "equipment": object_type.data = 3 elif full_class_name == "garbage": object_type.data = 4 elif full_class_name == "projectile": object_type.data = 5 elif full_class_name == "scenery": object_type.data = 6 elif full_class_name == "device_machine": object_type.data = 7 elif full_class_name == "device_control": object_type.data = 8 elif full_class_name == "device_light_fixture": object_type.data = 9 elif full_class_name == "placeholder": object_type.data = 10 elif full_class_name == "sound_scenery": object_type.data = 11 else: raise ValueError("Unknown object type '%s'" % full_class_name)
def calc_internal_data(self): ''' For each node, this method recalculates the rotation matrix from the quaternion, and the translation to the root bone. ''' HekTag.calc_internal_data(self) nodes = self.data.tagdata.nodes.STEPTREE for node in nodes: rotation = quaternion_to_matrix(*node.rotation) trans = Matrix([node.translation]) * -1 parent = None # add the parents translation to this ones if node.parent_node > -1: trans += Matrix([nodes[node.parent_node].translation_to_root]) # rotate the trans_to_root by this node's rotation trans *= rotation # combine this nodes rotation with its parents rotation if parent is not None: this_trans = node.translation node.distance_from_parent = sqrt(this_trans.x**2 + this_trans.y**2 + this_trans.z**2) parent_rot = Matrix( [parent.rot_jj_kk, parent.rot_kk_ii, parent.rot_ii_jj]) rotation *= parent_rot # apply the changes to the node node.translation_to_root[:] = trans[0][:] node.rot_jj_kk[:] = rotation[0] node.rot_kk_ii[:] = rotation[1] node.rot_ii_jj[:] = rotation[2]
def calc_internal_data(self): HekTag.calc_internal_data(self) tagdata = self.data.tagdata tagdata.cosine_falloff_angle = cos(tagdata.falloff_angle) tagdata.cosine_cutoff_angle = cos(tagdata.cutoff_angle)
def calc_internal_data(self): HekTag.calc_internal_data(self) self.calc_masses() self.calc_densities() self.calc_intertia_matrices()