def convert_river(sound_shape: SoundShape) -> TerryRiver: terry_river = TerryRiver() # setting default values for now terry_river.spline_closed = False terry_river.spline_step_size = 15 terry_river.terrain_relative = True terry_river.reverse_direction = False position_x = sound_shape.river_nodes[0].vertex.x position_y = sound_shape.river_nodes[0].vertex.y position_z = sound_shape.river_nodes[0].vertex.z terry_river.ectransform = ECTransform( Point3D(position_x, position_y, position_z), Rotation3D(0, 0, 0), Scale3D(1, 1, 1)) for river_node in sound_shape.river_nodes: width = river_node.width flow_speed = river_node.flow_speed position = Point3D(river_node.vertex.x - position_x, river_node.vertex.y - position_y, river_node.vertex.z - position_z) # need to find a way how to calculate those values tangent_in = [0, 0, 0] tangent_out = [0, 0, 0] terrain_offset = 0 alpha_fade = 1 foam_amount = 0.1 spline_point = TerrySplinePoint(position, tangent_in, tangent_out, width, terrain_offset, alpha_fade, flow_speed, foam_amount) terry_river.spline.append(spline_point) return terry_river
def read_sound_shape_common(file): sound_shape = SoundShape() sound_shape.key = string(file) sound_shape.type = string(file) points = int4(file) sound_shape.points = [] for j in range(points): point = Point3D(float4(file), float4(file), float4(file)) sound_shape.points.append(point) sound_shape.inner_radius = float4(file) sound_shape.outer_radius = float4(file) sound_shape.inner_cube = Cube(float4(file), float4(file), float4(file), float4(file), float4(file), float4(file)) sound_shape.outer_cube = Cube(float4(file), float4(file), float4(file), float4(file), float4(file), float4(file)) river_nodes_amount = int4(file) sound_shape.river_nodes = [] for i in range(river_nodes_amount): river_node_version = int2(file) sound_shape.river_nodes.append( river_node_versions.get_reader(river_node_version)(file)) sound_shape.clamp_to_surface = bool1(file) sound_shape.height_mode = string(file) sound_shape.campaign_type_mask = int4(file) return sound_shape
def convert_sound_shape(sound_shape: SoundShape) -> TerrySoundShape: terry_sound_shape = TerrySoundShape() terry_sound_shape.key = sound_shape.key terry_sound_shape.type = sound_shape.type if terry_sound_shape.type != "SST_RIVER": terry_sound_shape.ectransform = ECTransform(sound_shape.points[0], Rotation3D(0, 0, 0), Scale3D(1, 1, 1)) position_x = sound_shape.points[0].x position_y = sound_shape.points[0].y position_z = sound_shape.points[0].z # subtract position from poluline points if terry_sound_shape.type == "SST_MULTI_POINT": terry_sound_shape.points_cloud = [] for i in sound_shape.points: x = i.x - sound_shape.points[0].x y = i.y - sound_shape.points[0].y z = i.z - sound_shape.points[0].z point = Point3D(x, y, z) terry_sound_shape.points_cloud.append(point) else: terry_sound_shape.points = [] for i in sound_shape.points: x = i.x - position_x y = i.z - position_z point = Point2D(x, y) terry_sound_shape.points.append(point) terry_sound_shape.radius = sound_shape.outer_radius return terry_sound_shape
def read_river_node_v1(file): river_node = RiverNode() river_node.vertex = Point3D(float4(file), float4(file), float4(file)) river_node.width = float4(file) river_node.flow_speed = float4(file) #print(river_node.vertex.__dict__) return river_node
def get_transforms(transform: Matrix): position = Point3D(*transform[3]) scale = Scale3D(*map(mod_vector, transform[0:3])) rotation_matrix = unscale(transform[0:3], scale.as_vector()) rotation = Rotation3D( *map(degrees, get_angles(transpose(rotation_matrix)))) return position, rotation, scale
def get_transforms_4_4(transformation: Matrix): position = Point3D(*transformation[3][:3]) coordinates = transformation[:3] scale = Scale3D(*map(mod_vector, coordinates)) coordinates = unscale(coordinates, scale.as_vector()) rotation = Rotation3D( *map(lambda angle: -degrees(angle), get_angles_XYZ(coordinates))) return position, rotation, scale
def convert_outline_to_polyline(outline: Outline): position_x = outline.points[0].x position_z = outline.points[0].y polyline = ECPolyline() polyline.closed = True polyline.polyline = [] for point in outline.points: polyline.polyline.append( Point2D((point.x - position_x), (point.y - position_z))) position = Point3D(position_x, 0, position_z) return polyline, position
def read_custom_material_mesh_v2(file): custom_material_mesh = CustomMaterialMesh() vertices_amount = int4(file) custom_material_mesh.vertices = [] for i in range(vertices_amount): vertex = Point3D(float4(file), float4(file), float4(file)) custom_material_mesh.vertices.append(vertex) indices_amount = int4(file) custom_material_mesh.indices = [] for i in range(indices_amount): custom_material_mesh.indices.append(int2(file)) custom_material_mesh.material = string(file) custom_material_mesh.height_mode = string(file) return custom_material_mesh
def convert_playable_area(playable_area: PlayableArea) -> TerryPlayableArea: terry_playable_area = TerryPlayableArea() terry_playable_area.width = playable_area.max_x - playable_area.min_x terry_playable_area.height = playable_area.max_y - playable_area.min_y x = playable_area.min_x + (terry_playable_area.width / 2) z = playable_area.min_y + (terry_playable_area.height / 2) terry_playable_area.ectransform = ECTransform(Point3D(x, 0, z), Rotation3D(0, 0, 0), Scale3D(1, 1, 1)) terry_playable_area.deployment_locations = [] for key, value in playable_area.flags.items(): if value: temp_string = key.replace('valid_', '').capitalize() terry_playable_area.deployment_locations.append(temp_string) return terry_playable_area
def convert_prefab_instance(prefab: PrefabInstance) -> TerryPrefabInstance: terry_prefab_instance = TerryPrefabInstance() terry_prefab_instance.ecterrainclamp = ECTerrainClamp() terry_prefab_instance.key = prefab.name.replace('prefabs/', '').replace(".bmd", '') # transform position = Point3D(*prefab.transformation[3][:3]) coordinates = prefab.transformation[:3] scale = Scale3D(*map(mod_vector, coordinates)) coordinates = unscale(coordinates, scale.as_vector()) rotation = Rotation3D( *map(lambda angle: -degrees(angle), get_angles_XYZ(coordinates))) terry_prefab_instance.ectransform = ECTransform(position, rotation, scale) return terry_prefab_instance