summaryrefslogtreecommitdiff
path: root/extractor
diff options
context:
space:
mode:
authorDaniel Weipert <git@mail.dweipert.de>2024-12-30 15:15:01 +0100
committerDaniel Weipert <git@mail.dweipert.de>2024-12-30 15:15:01 +0100
commite08a29e73ea4f7e6d78e8e7f5a6e7033dbc1f542 (patch)
tree966b95a7cdad16f7658d2e10cec6e549f3b98c17 /extractor
parent6e2deea3d1b2fb4d79dac02a0d4310936c7f317c (diff)
next commit
Diffstat (limited to 'extractor')
-rw-r--r--extractor/gat_format.gd18
-rw-r--r--extractor/gnd_format.gd11
-rw-r--r--extractor/grf.gd5
-rw-r--r--extractor/rsm_format.gd87
4 files changed, 116 insertions, 5 deletions
diff --git a/extractor/gat_format.gd b/extractor/gat_format.gd
index 712657b..7192cbc 100644
--- a/extractor/gat_format.gd
+++ b/extractor/gat_format.gd
@@ -42,6 +42,14 @@ static func from_bytes(bytes: ByteStream) -> GATFormat:
return gat_format
+enum TileFlags {
+ Walkable = 0b00000001,
+ Water = 0b00000010,
+ Snipable = 0b00000100,
+ Cliff = 0b00001000,
+}
+
+
class Tile:
## Byte Type: f32 [br]
## Byte Length: 4 [br]
@@ -63,12 +71,12 @@ class Tile:
## Orignal Coordinates: (1, 1)
var top_right_altitude: int
- ## Byte Type: u32 ?[br]
- ## Byte Length: 4 ?
+ ## Byte Type: u8 [br]
+ ## Byte Length: 1
var terrain_type: int
- func get_height_map() -> Dictionary: # Dictionary[Vector2, int]
+ func get_height_map() -> Dictionary[Vector2, int]:
return {
Vector2(0, 0): top_left_altitude,
Vector2(1, 0): top_right_altitude,
@@ -84,6 +92,8 @@ class Tile:
tile.bottom_right_altitude = bytes.decode_float()
tile.top_left_altitude = bytes.decode_float()
tile.top_right_altitude = bytes.decode_float()
- tile.terrain_type = bytes.decode_u32()
+ tile.terrain_type = bytes.decode_u8()
+
+ bytes.advance(3) # unused
return tile
diff --git a/extractor/gnd_format.gd b/extractor/gnd_format.gd
index f13956e..ea8d965 100644
--- a/extractor/gnd_format.gd
+++ b/extractor/gnd_format.gd
@@ -211,7 +211,7 @@ class Surface:
var vertex_color_alpha: int
- func get_uvs() -> Dictionary: # Dictionary[Vector2, Vector2]
+ func get_uvs() -> Dictionary[Vector2, Vector2]:
return {
Vector2(0, 0): Vector2(u_top_left, v_top_left),
Vector2(1, 0): Vector2(u_top_right, v_top_right),
@@ -220,6 +220,15 @@ class Surface:
}
+ func get_vertex_color() -> Color:
+ return Color8(
+ vertex_color_red,
+ vertex_color_green,
+ vertex_color_blue,
+ vertex_color_alpha
+ )
+
+
static func from_bytes(bytes: ByteStream) -> Surface:
var surface = Surface.new()
diff --git a/extractor/grf.gd b/extractor/grf.gd
index e2a3c82..1d19046 100644
--- a/extractor/grf.gd
+++ b/extractor/grf.gd
@@ -446,6 +446,11 @@ func convert(destination: String = "res://client_data"):
scene_root.add_child(audio, true)
audio.owner = scene_root
+ var surfrace_tool := SurfaceTool.new()
+ for surface: GNDFormat.Surface in gnd.surfaces:
+ pass
+ #surfrace_tool.add_vertex()
+
scene.pack(scene_root)
ResourceSaver.save(scene, "%s/%s/%s.tscn" % [destination, base_directory_path, file_name])
diff --git a/extractor/rsm_format.gd b/extractor/rsm_format.gd
new file mode 100644
index 0000000..d3dabb0
--- /dev/null
+++ b/extractor/rsm_format.gd
@@ -0,0 +1,87 @@
+class_name RSMFormat
+
+
+## Byte Length: 4 [br]
+## GRAT
+var signature: String = "GRSM"
+
+## Byte Type: u8 [br]
+## Byte Length: 2
+var version: Version
+
+## Byte Type: u32 [br]
+## Byte Length: 4
+var animation_length: int
+
+## Byte Type: u32 [br]
+## Byte Length: 4
+var shade_type: int
+
+## Byte Type: u8 [br]
+## Byte Length: 1
+## Versions: [>=1.4]
+var alpha: int
+
+## Byte Type: u8 [br]
+## Byte Length: 16
+## Versions: [<2.2]
+var reserved: PackedByteArray
+
+## Byte Type: f32 [br]
+## Byte Length: 4
+## Versions: [>=2.2]
+var frames_per_second: float
+
+## Byte Type: u32 [br]
+## Byte Length: 4
+## Versions: [<2.3]
+var texture_count: int
+
+## Length: [member texture_count]
+## Byte Length: 40
+var texture_names: Array[String]
+
+## Byte Type: u8
+## Byte Length: 40
+var root_node_name: String
+
+## Byte Type: u32 [br]
+## Byte Length: 4
+## Versions: [>=2.2]
+var root_node_count: int
+
+## Length: [member root_node_count]
+## Byte Length: 40
+var root_node_names: Array[String]
+
+## Byte Type: u32 [br]
+## Byte Length: 4
+var node_count: int
+
+## Length: [member node_count]
+var nodes: Array[ModelNode]
+
+
+static func from_bytes(bytes: ByteStream) -> RSMFormat:
+ var rsm_format = RSMFormat.new()
+
+ bytes.advance(rsm_format.signature.length())
+
+ @warning_ignore("shadowed_variable")
+ var version = Version.new()
+ version.major = bytes.decode_u8()
+ version.minor = bytes.decode_u8()
+ rsm_format.version = version
+
+ print(inst_to_dict(rsm_format))
+ return rsm_format
+
+
+class ModelNode:
+ ## Byte Type: u8 [br]
+ ## Byte Length: 40
+ var node_name: String
+
+ ## Byte Type: u8 [br]
+ ## Byte Length: 40
+ var parent_node_name: String