Skip to content

Commit

Permalink
plugin - fix some more pc ms2 stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
HENDRIX-ZT2 committed Dec 15, 2023
1 parent 73c33b9 commit cc172ac
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 19 deletions.
18 changes: 15 additions & 3 deletions generated/formats/ms2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -345,11 +345,22 @@ def update_buffer_2_bytes(self):
for wrapper in model.meshes:
wrapper.mesh.assign_buffer_info(self.buffer_infos)
wrapper.mesh.write_data()
if is_pc(self.context):
for wrapper in model.meshes:
wrapper.mesh.write_verts()
for wrapper in model.meshes:
wrapper.mesh.write_weights()
for wrapper in model.meshes:
wrapper.mesh.write_tris()
for wrapper in model.meshes:
wrapper.mesh.write_uvs()
# update LodInfo
logging.debug(f"Updating lod vertex counts")
for lod in model.lods:
lod.vertex_count = sum(ob.mesh.vertex_count for ob in lod.objects)
lod.tri_index_count = sum(ob.mesh.tri_index_count for ob in lod.objects)
if is_pc(self.context):
lod.tri_index_count -= 4
# only used by PC
vertex_offset_within_lod = 0
for ob in lod.objects:
Expand Down Expand Up @@ -466,10 +477,11 @@ def clear(self):
# m.load("C:/Users/arnfi/Desktop/Coding/Frontier/PC OVLs/walker_export/Content0/Environment/Scenery/Themes/FT_FairyTale/FT_Topiary/FT_Topiary/models.ms2", read_editable=True)
# m.load("C:/Users/arnfi/Desktop/Coding/Frontier/PC OVLs/walker_export/Content0/Environment/Scenery/Themes/PR_Pirate/PR_Redcoat/PR_Redcoat/models.ms2", read_editable=True)
# m.load("C:/Users/arnfi/Desktop/Coding/Frontier/PC OVLs/walker_export/Content0/Rides/FlatRides/Chair-O-Plane/FR_COP/models.ms2", read_editable=True)
m.load("C:/Users/arnfi/Desktop/models.ms2", read_editable=True)
m.load("C:/Users/arnfi/Desktop/dino_.ms2", read_editable=True)
# m.load("C:/Users/arnfi/Desktop/models.ms2", read_editable=True)
print(m)
# m.save("C:/Users/arnfi/Desktop/dino_save.ms2")
m.load("C:/Users/arnfi/Desktop/models_polyp.ms2", read_editable=True)
m.save("C:/Users/arnfi/Desktop/dino_save.ms2")
# m.load("C:/Users/arnfi/Desktop/models_polyp.ms2", read_editable=True)
print(m)

# m.load("C:/Users/arnfi/Desktop/Coding/Frontier/PC OVLs/walker_export/Content0/Rides/FlatRides/360_Power/FR_360PWR/models.ms2", read_editable=True)
Expand Down
19 changes: 13 additions & 6 deletions generated/formats/ms2/compounds/PcMeshData.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,21 +212,28 @@ def read_tris(self):
index_count = self.tri_index_count // self.shell_count
self.tri_indices = self.read_pc_array(np.uint16, self.tri_offset, index_count)

def write_data(self):
# write to the buffer_info that has been assigned to mesh
def write_verts(self):
self.vertex_count = len(self.verts_data)
self.tri_index_count = self.tri_index_count_a = len(self.tri_indices) * self.shell_count
# write vertices
self.vertex_offset = self.write_pc_array(self.verts_data)
self.uv_offset = self.write_pc_array(self.uv_data)

def write_weights(self):
if self.use_weights:
self.weights_offset = self.write_pc_array(self.weights_data)
else:
self.weights_offset = 0
# write tris

def write_tris(self):
self.tri_index_count = self.tri_index_count_a = len(self.tri_indices) * self.shell_count
self.tri_offset = self.write_pc_array(self.tri_indices)
# todo shells?
# extend tri array according to shell count
# for shell in range(self.shell_count-1):
# self.write_pc_array(self.tri_indices)

def write_uvs(self):
self.uv_offset = self.write_pc_array(self.uv_data)

def write_data(self):
# order separately: verts, weights, tris, uvs
pass

18 changes: 15 additions & 3 deletions source/formats/ms2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,11 +344,22 @@ def update_buffer_2_bytes(self):
for wrapper in model.meshes:
wrapper.mesh.assign_buffer_info(self.buffer_infos)
wrapper.mesh.write_data()
if is_pc(self.context):
for wrapper in model.meshes:
wrapper.mesh.write_verts()
for wrapper in model.meshes:
wrapper.mesh.write_weights()
for wrapper in model.meshes:
wrapper.mesh.write_tris()
for wrapper in model.meshes:
wrapper.mesh.write_uvs()
# update LodInfo
logging.debug(f"Updating lod vertex counts")
for lod in model.lods:
lod.vertex_count = sum(ob.mesh.vertex_count for ob in lod.objects)
lod.tri_index_count = sum(ob.mesh.tri_index_count for ob in lod.objects)
if is_pc(self.context):
lod.tri_index_count -= 4
# only used by PC
vertex_offset_within_lod = 0
for ob in lod.objects:
Expand Down Expand Up @@ -465,10 +476,11 @@ def clear(self):
# m.load("C:/Users/arnfi/Desktop/Coding/Frontier/PC OVLs/walker_export/Content0/Environment/Scenery/Themes/FT_FairyTale/FT_Topiary/FT_Topiary/models.ms2", read_editable=True)
# m.load("C:/Users/arnfi/Desktop/Coding/Frontier/PC OVLs/walker_export/Content0/Environment/Scenery/Themes/PR_Pirate/PR_Redcoat/PR_Redcoat/models.ms2", read_editable=True)
# m.load("C:/Users/arnfi/Desktop/Coding/Frontier/PC OVLs/walker_export/Content0/Rides/FlatRides/Chair-O-Plane/FR_COP/models.ms2", read_editable=True)
m.load("C:/Users/arnfi/Desktop/models.ms2", read_editable=True)
m.load("C:/Users/arnfi/Desktop/dino_.ms2", read_editable=True)
# m.load("C:/Users/arnfi/Desktop/models.ms2", read_editable=True)
print(m)
# m.save("C:/Users/arnfi/Desktop/dino_save.ms2")
m.load("C:/Users/arnfi/Desktop/models_polyp.ms2", read_editable=True)
m.save("C:/Users/arnfi/Desktop/dino_save.ms2")
# m.load("C:/Users/arnfi/Desktop/models_polyp.ms2", read_editable=True)
print(m)

# m.load("C:/Users/arnfi/Desktop/Coding/Frontier/PC OVLs/walker_export/Content0/Rides/FlatRides/360_Power/FR_360PWR/models.ms2", read_editable=True)
Expand Down
19 changes: 13 additions & 6 deletions source/formats/ms2/compounds/PcMeshData.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,20 +127,27 @@ def read_tris(self):
index_count = self.tri_index_count // self.shell_count
self.tri_indices = self.read_pc_array(np.uint16, self.tri_offset, index_count)

def write_data(self):
# write to the buffer_info that has been assigned to mesh
def write_verts(self):
self.vertex_count = len(self.verts_data)
self.tri_index_count = self.tri_index_count_a = len(self.tri_indices) * self.shell_count
# write vertices
self.vertex_offset = self.write_pc_array(self.verts_data)
self.uv_offset = self.write_pc_array(self.uv_data)

def write_weights(self):
if self.use_weights:
self.weights_offset = self.write_pc_array(self.weights_data)
else:
self.weights_offset = 0
# write tris

def write_tris(self):
self.tri_index_count = self.tri_index_count_a = len(self.tri_indices) * self.shell_count
self.tri_offset = self.write_pc_array(self.tri_indices)
# todo shells?
# extend tri array according to shell count
# for shell in range(self.shell_count-1):
# self.write_pc_array(self.tri_indices)

def write_uvs(self):
self.uv_offset = self.write_pc_array(self.uv_data)

def write_data(self):
# order separately: verts, weights, tris, uvs
pass
2 changes: 1 addition & 1 deletion version.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
e317e8e57 - Fri Dec 15 19:03:49 2023 +0100
73c33b9d0 - Fri Dec 15 20:25:36 2023 +0100

0 comments on commit cc172ac

Please sign in to comment.