diff options
Diffstat (limited to 'extractor/rsw_format.gd')
-rw-r--r-- | extractor/rsw_format.gd | 93 |
1 files changed, 87 insertions, 6 deletions
diff --git a/extractor/rsw_format.gd b/extractor/rsw_format.gd index 831a1cb..e38dad9 100644 --- a/extractor/rsw_format.gd +++ b/extractor/rsw_format.gd @@ -117,7 +117,43 @@ func convert(name: String, data_path: String) -> Node3D: node.set_script(load("res://extractor/map.gd")) for resource in map_resources: - if resource is RSWFormat.SpatialAudioSource: + if resource is Animated3DModel: + var model_file_path := "%s/data/model/%s" % [data_path, resource.model_file] + if not FileAccess.file_exists(model_file_path): + continue + + var rsm := RSMFormat.from_bytes(ByteStream.from_bytes(FileAccess.get_file_as_bytes(model_file_path))) + + var model_root := Node3D.new() + model_root.name = resource.name + model_root.position = resource.get_position() * Vector3(-1, 1, 1) + model_root.rotate_x(resource.get_rotation().x) + model_root.rotate_y(resource.get_rotation().y) + model_root.rotate_z(resource.get_rotation().z) + model_root.scale = resource.get_scale() + + node.add_child(model_root) + model_root.owner = node + + var model := rsm.convert(data_path) + model_root.add_child(model) + model.owner = node + for child in model.get_children(): + child.owner = node + + elif resource is DynamicLightSource: + continue + var light := OmniLight3D.new() + light.name = resource.name + light.position = resource.get_position() + light.light_color = resource.get_diffuse_color() + light.omni_range = resource.light_range + + node.add_child(light) + light.owner = node + + elif resource is SpatialAudioSource: + continue var audio_file_path := "%s/data/wav/%s" % [data_path, resource.audio_file] if not FileAccess.file_exists(audio_file_path): continue @@ -128,13 +164,58 @@ func convert(name: String, data_path: String) -> Node3D: audio.position = resource.get_position() audio.volume_linear = resource.volume_gain audio.max_distance = resource.audio_range + node.add_child(audio, true) audio.owner = node - - var surface_tool := SurfaceTool.new() - for surface: GNDFormat.Surface in gnd.surfaces: - pass - #surface_tool.add_vertex() + + elif resource is ParticleEffectEmitter: + continue + var particles := CPUParticles3D.new() + particles.name = resource.name + particles.position = resource.get_position() + + node.add_child(particles, true) + particles.owner = node + + #var ground := MeshInstance3D.new() + #var mesh := ArrayMesh.new() + #var surface_tool := SurfaceTool.new() + #surface_tool.begin(Mesh.PRIMITIVE_TRIANGLES) + #for surface_idx in gnd.surfaces.size(): + #if surface_idx < 1: + #continue + # + #var surface: GNDFormat.Surface = gnd.surfaces[surface_idx] + # + #surface_tool.add_triangle_fan( + #PackedVector3Array([Vector3(-0.5, -0.5, 0), Vector3(0.5, -0.5, 0), Vector3(-0.5, -0.5, -0.5)]), + #PackedVector2Array([surface.get_uvs()[Vector2(0, 0)], surface.get_uvs()[Vector2(1, 0)], surface.get_uvs()[Vector2(0, 1)]]), + #PackedColorArray([surface.get_vertex_color(),surface.get_vertex_color(),surface.get_vertex_color()]) + #) + #surface_tool.add_triangle_fan( + #PackedVector3Array([Vector3(0.5, -0.5, 0), Vector3(0.5, -0.5, -0.5), Vector3(-0.5, -0.5, -0.5)]), + #PackedVector2Array([surface.get_uvs()[Vector2(1, 0)], surface.get_uvs()[Vector2(1, 1)], surface.get_uvs()[Vector2(0, 1)]]), + #PackedColorArray([surface.get_vertex_color(),surface.get_vertex_color(),surface.get_vertex_color()]) + #) + #surface_tool.commit(mesh) + #var material := StandardMaterial3D.new() + #material.albedo_texture = load("%s/data/texture/%s" % [data_path, gnd.texture_paths[surface.texture_index]]) + #mesh.surface_set_material(0, material) + #print(surface.get_uvs()) + #break + + + #grid_map.owner = node + + #ground.mesh = mesh + # + #node.add_child(ground) + #ground.owner = node + + var grid_map := gnd.convert(data_path) + grid_map.name = gnd_file_path.get_basename() + node.add_child(grid_map) + grid_map.owner = node return node |