Skip to content

Commit

Permalink
Change references to mxml and fix issue with loading files produced b…
Browse files Browse the repository at this point in the history
…y hgpaktool
  • Loading branch information
monkeyman192 committed Feb 4, 2025
1 parent 762a695 commit 9c02238
Show file tree
Hide file tree
Showing 19 changed files with 70 additions and 70 deletions.
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ textures/*
# vscode files
.vscode/

# We only want to store .mbin files, any exml files generated during testing should be ignored...
*.EXML
# We only want to store .mbin files, any mxml files generated during testing should be ignored...
*.MXML

# pytest cache files
.pytest_cache/
Expand Down
12 changes: 6 additions & 6 deletions ModelExporter/Descriptor.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ def __str__(self):
def __len__(self):
return len(self.children)

def to_exml(self):
def to_mxml(self):
main_data = List()
for child in self.children:
main_data.append(child.to_exml())
main_data.append(child.to_mxml())
return TkModelDescriptorList(List=main_data)


Expand All @@ -62,11 +62,11 @@ def __str__(self):
out += str(child)
return out

def to_exml(self):
def to_mxml(self):
# converts this to a TkResourceDescriptorList object
descriptors = List()
for child in self.children:
descriptors.append(child.to_exml())
descriptors.append(child.to_mxml())
return TkResourceDescriptorList(TypeId=self.TypeId,
Descriptors=descriptors)

Expand Down Expand Up @@ -96,7 +96,7 @@ def __str__(self):
out += str(child)
return out

def to_exml(self):
def to_mxml(self):
# first, we need to do some processing on the name.
# if the name starts with the prefix, then we need to sort it out so
# that it is correct
Expand Down Expand Up @@ -132,7 +132,7 @@ def not_proc(ob):
refs = List()
children = List()
for child in self.children:
children.append(child.to_exml())
children.append(child.to_mxml())
# Check how many children there are so we aren't making empty
# TkModelDescriptorList's for nothing.
if len(children) == 0:
Expand Down
2 changes: 1 addition & 1 deletion ModelExporter/addon_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ def __init__(self, output_directory, export_directory='CUSTOMMODELS',
entitydata = ParseNodes()
entity = TkAttachmentData(Components=List(entitydata))
entity.make_elements(main=True)
entity.tree.write('{}.ENTITY.exml'.format(
entity.tree.write('{}.ENTITY.mxml'.format(
op.join(self.output_directory, self.export_dir, group_name,
scene_name)))
self.state = {'FINISHED'}
Expand Down
26 changes: 13 additions & 13 deletions ModelExporter/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"""Process the 3d model data and create required files for NMS.
This function will take all the data provided by the blender script and create
a number of .exml files that contain all the data required by the game to view
a number of .mxml files that contain all the data required by the game to view
the 3d model created.
"""

Expand Down Expand Up @@ -553,7 +553,7 @@ def process_nodes(self):
# also write the entity file now too as we don't
# need to do anything else to it
AttachmentData.tree.write(
"{}.ENTITY.exml".format(
"{}.ENTITY.mxml".format(
os.path.join(self.export_directory,
ent_path)))
else:
Expand Down Expand Up @@ -591,7 +591,7 @@ def process_nodes(self):
# also write the entity file now too as we don't
# need to do anything else to it
AttachmentData.tree.write(
"{}.ENTITY.exml".format(
"{}.ENTITY.mxml".format(
os.path.join(self.export_directory,
ent_path)))
else:
Expand Down Expand Up @@ -812,16 +812,16 @@ def write(self):
hdr.write(f)
self.TkSceneNodeData.write(f)
print(f'Scene written to {scene_path}')
# Build all the descriptor exml data
# Build all the descriptor mxml data
if self.descriptor is not None:
descriptor = self.descriptor.to_exml()
descriptor = self.descriptor.to_mxml()
descriptor.make_elements(main=True)
descriptor.tree.write(
"{}.DESCRIPTOR.exml".format(self.abs_name_path))
"{}.DESCRIPTOR.mxml".format(self.abs_name_path))
for material in self.materials:
if not isinstance(material, str):
material.tree.write(
"{0}.MATERIAL.exml".format(os.path.join(
"{0}.MATERIAL.mxml".format(os.path.join(
self.abs_name_path, str(material['Name']).upper())))
# Write the animation files
idle_anim = bpy.context.scene.nmsdk_anim_data.idle_anim
Expand All @@ -832,24 +832,24 @@ def write(self):
'one of the animations that exists...')
# get the value and output it
self.anim_data[idle_anim].tree.write(
"{}.ANIM.exml".format(self.abs_name_path))
"{}.ANIM.mxml".format(self.abs_name_path))
else:
for name in list(self.anim_data.keys()):
if name != idle_anim:
self.anim_data[name].tree.write(
os.path.join(self.anims_path,
"{}.ANIM.exml".format(name.upper())))
"{}.ANIM.mxml".format(name.upper())))
else:
self.anim_data[idle_anim].tree.write(
"{}.ANIM.exml".format(self.abs_name_path))
"{}.ANIM.mxml".format(self.abs_name_path))

def convert_to_mbin(self):
""" Convert all .exml file to .mbin files. """
print('Converting .exml files to .mbin. Please wait.')
""" Convert all .mxml file to .mbin files. """
print('Converting .mxml files to .mbin. Please wait.')
for directory, _, files in os.walk(self.basepath):
for file in files:
location = os.path.join(directory, file)
if os.path.splitext(location)[1].lower() == '.exml':
if os.path.splitext(location)[1].lower() == '.mxml':
# Force MBINCompiler to overwrite existing files and
# ignore errors.
mbincompiler_path = bpy.context.scene.nmsdk_default_settings.MBINCompiler_path # noqa
Expand Down
12 changes: 6 additions & 6 deletions ModelImporter/import_scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,12 @@ def __init__(self, fpath, parent_obj=None, ref_scenes=dict(),
# determine the PCBANKS directory
self.PCBANKS_dir = get_NMS_dir(self.local_directory)

# Determine the type of file provided and get the exml and mbin file
# Determine the type of file provided and get the mxml and mbin file
# paths for that file.
if ftype.lower() == '.exml':
if ftype.lower() == '.mxml':
mbin_fpath = (op.join(self.local_directory, self.scene_basename) +
'.MBIN')
exml_fpath = fpath
mxml_fpath = fpath
elif ftype.lower() == '.mbin':
mbin_fpath = fpath
else:
Expand Down Expand Up @@ -598,9 +598,9 @@ def _add_empty_to_scene(self, scene_node: SceneNodeData,
print(f'Now trying to find a descriptor at: {descriptor_path}')
if op.exists(descriptor_path + '.MBIN'):
empty_obj.NMSReference_props.is_proc = True
# Also convert the .mbin to exml for parsing if the exml
# Also convert the .mbin to mxml for parsing if the mxml
# doesn't already exist.
if not op.exists(descriptor_path + '.EXML'):
if not op.exists(descriptor_path + '.MXML'):
retcode = subprocess.call(
[self.scn.nmsdk_default_settings.MBINCompiler_path,
"-q", "-Q", descriptor_path + '.MBIN'])
Expand All @@ -609,7 +609,7 @@ def _add_empty_to_scene(self, scene_node: SceneNodeData,
' registered on the path.')
print('Import failed')
return
self.descriptor_data = read_descriptor(descriptor_path + '.EXML')
self.descriptor_data = read_descriptor(descriptor_path + '.MXML')
else:
print("No descriptor found... Scene is not proc-gen")
self.local_objects[self.scene_basename] = empty_obj
Expand Down
4 changes: 2 additions & 2 deletions ModelImporter/readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
bytes_to_quat, read_bool, read_uint32,
returned_read)
from serialization.list_header import ListHeader # noqa pylint: disable=relative-beyond-top-level
from utils.utils import exml_to_dict # noqa pylint: disable=relative-beyond-top-level
from utils.utils import mxml_to_dict # noqa pylint: disable=relative-beyond-top-level

from serialization.NMS_Structures import TkMaterialData, MBINHeader, NAMEHASH_MAPPING, TkAnimMetadata

Expand Down Expand Up @@ -226,6 +226,6 @@ def read_descriptor(fname: str) -> dict:
"""
with open(fname) as f:
# The top level is always a list, let's just extract it immediately.
data = exml_to_dict(f)['List']
data = mxml_to_dict(f)['List']
data = read_TkModelDescriptorList(data)
return data
2 changes: 1 addition & 1 deletion NMS/classes/Struct.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ def __getitem__(self, key):
def __setitem__(self, key, value):
# assigns the value 'value' to self.data[key]
# currently no checking so be careful! Incorrect use could lead to
# incorrect exml files!!!
# incorrect mxml files!!!
self.data[key] = value

def __str__(self):
Expand Down
12 changes: 6 additions & 6 deletions NMSDK.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,8 @@ class ExportSceneOperator(Operator):
name="Don't convert files with MBINCompiler",
description="Ticking this will mean MBINCompiler will not be run on "
"the produced files. This will leave a mix of .mbin and "
".exml files. This is generally not recommended unless "
"you are trying to quickly test something as the .exml "
".mxml files. This is generally not recommended unless "
"you are trying to quickly test something as the .mxml "
"files will be not formatted nicely.",
default=False,
)
Expand Down Expand Up @@ -714,8 +714,8 @@ class NMS_Export_Operator(Operator, ExportHelper):
name="Don't convert files with MBINCompiler",
description="Ticking this will mean MBINCompiler will not be run on "
"the produced files. This will leave a mix of .mbin and "
".exml files. This is generally not recommended unless "
"you are trying to quickly test something as the .exml "
".mxml files. This is generally not recommended unless "
"you are trying to quickly test something as the .mxml "
"files will be not formatted nicely.",
default=False,
)
Expand Down Expand Up @@ -833,9 +833,9 @@ class NMS_Import_Operator(Operator, ImportHelper):
bl_label = "Import from SCENE file"

# ImportHelper mixin class uses this
filename_ext = ".EXML"
filename_ext = ".MXML"
filter_glob: StringProperty(
default="*.scene.exml;*.SCENE.EXML;*.scene.mbin;*.SCENE.MBIN",
default="*.scene.mxml;*.SCENE.MXML;*.scene.mbin;*.SCENE.MBIN",
options={"HIDDEN"})

clear_scene: BoolProperty(
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Installing NMSDK is very easy. Head to the [NMSDK Release page](https://github.c
Open Blender and open the user settings (Ctrl + Alt + U) (or `File` > `User Preferences...`), and select `Install Add-on from File...` (it is at the bottom left of the window).
Select the `.zip` file you just downloaded and blender should install it without any errors.

To make exporting easier, NMSDK will automatically convert all produced `.exml` files to `.mbin` files. For this to work, [MBINCompiler](https://github.com/monkeyman192/MBINCompiler) is required. See below for instructions on downloading and installing the latest version.
To make exporting easier, NMSDK will automatically convert all produced `.mxml` files to `.mbin` files. For this to work, [MBINCompiler](https://github.com/monkeyman192/MBINCompiler) is required. See below for instructions on downloading and installing the latest version.

### Prerequisites

Expand Down
14 changes: 7 additions & 7 deletions Tools/proc_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ def create_list(self):
contains_scene = False
scene_names = []
for file in self.dir_list:
if "SCENE" in file and "EXML" not in file.upper():
if "SCENE" in file and "MXML" not in file.upper():
# in this case we have option 2.
# add the name of the scene file to the list of files
contains_scene = True
Expand All @@ -118,7 +118,7 @@ def create_list(self):
# if we make it to this line option 1. is what has happened.
# Search through
for file in subfolders:
if "SCENE" in file and "EXML" not in file.upper():
if "SCENE" in file and "MXML" not in file.upper():
contains_scene = True
path = self.get_scene_path(os.path.join(self.path_name,
folder, file))
Expand Down Expand Up @@ -253,23 +253,23 @@ def write(self):
if not os.path.exists(self.path):
os.makedirs(self.path)
self.TkModelDescriptorList.tree.write(
"{}.DESCRIPTOR.exml".format(
"{}.DESCRIPTOR.mxml".format(
os.path.join(self.path, self.name.upper())))
self.TkGeometryData.tree.write(
"{}.GEOMETRY.exml".format(
"{}.GEOMETRY.mxml".format(
os.path.join(self.path, self.name.upper())))
self.TkSceneNodeData.tree.write(
"{}.SCENE.exml".format(
"{}.SCENE.mxml".format(
os.path.join(self.path, self.name.upper())))

def convert_to_mbin(self):
# passes all the files produced by
print('Converting all .exml files to .mbin. Please wait while this '
print('Converting all .mxml files to .mbin. Please wait while this '
'finishes.')
for directory, _, files in os.walk(self.path):
for file in files:
location = os.path.join(directory, file)
if os.path.splitext(location)[1] == '.exml':
if os.path.splitext(location)[1] == '.mxml':
subprocess.call(["MBINCompiler.exe", location])
os.remove(location)

Expand Down
2 changes: 1 addition & 1 deletion Tools/utilities/bh_converter.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def getSubValues(element, func=lambda x: x):


if __name__ == '__main__':
with open("COLTEST.GEOMETRY.MBIN.EXML") as f:
with open("COLTEST.GEOMETRY.MBIN.MXML") as f:
file = tree.parse(source=f)
bhStarts = getSubValues(findTag(file, "BoundHullVertSt"), int)
bhEnds = getSubValues(findTag(file, "BoundHullVertEd"), int)
Expand Down
2 changes: 1 addition & 1 deletion Tools/utilities/prettify.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def createWidgets(self):
button_frame.pack()

def process(self):
path_name = filedialog.askopenfilename(title="Specify exml file")
path_name = filedialog.askopenfilename(title="Specify mxml file")
prettyPrintXml(path_name)

def quit(self):
Expand Down
4 changes: 2 additions & 2 deletions docs/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ Import a complete NMS scene into blender.

**Parameters**:
*path* : string
> The complete file path to a `SCENE.MBIN` or `SCENE.EXML` file to be loaded into blender.
> The complete file path to a `SCENE.MBIN` or `SCENE.MXML` file to be loaded into blender.
**Notes**:
The entire scene will be loaded into the active scene in blender.
Expand All @@ -86,7 +86,7 @@ Import part of a scene specified by the id of a mesh node in the scene file.

**Parameters**:
*path* : string
> The complete file path to a `SCENE.MBIN` or `SCENE.EXML` file to be loaded into blender.
> The complete file path to a `SCENE.MBIN` or `SCENE.MXML` file to be loaded into blender.
*mesh_id* : string
> The `Name` of the `TkSceneNodeData` in the Scene being loaded.
Expand Down
2 changes: 1 addition & 1 deletion docs/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Removing the old version is particularly important if you had a very old version
Open Blender and open the preferences window (`Edit` > `Preferences...`), and select `Install...` (it is at the top right of the window).
Select the `.zip` file you just downloaded and blender should install it without any errors.

To make exporting easier, NMSDK will automatically convert all produced `.exml` files to `.mbin` files. For this to work, *MBINCompiler* is required. See below for instructions on downloading and installing the latest version.
To make exporting easier, NMSDK will automatically convert all produced `.mxml` files to `.mbin` files. For this to work, *MBINCompiler* is required. See below for instructions on downloading and installing the latest version.

### Prerequisites

Expand Down
2 changes: 1 addition & 1 deletion old_docs/Adding Model to Mod Guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,4 @@ These two lines dictate how regularly the object will get spawned. Higher values

You can now copy the entire GcObjectSpawnData.xml Property into the other file in this folder in the same place.

Recompile both exml files back into an mbin and create your mod as usual.
Recompile both mxml files back into an mbin and create your mod as usual.
16 changes: 8 additions & 8 deletions tests/import_export_tests/import_export_asteroid.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
if nmsdk_dir not in sys.path:
sys.path.append(nmsdk_dir)

from utils.utils import exml_to_dict # noqa pylint: E402
from utils.utils import mxml_to_dict # noqa pylint: E402
from utils.io import convert_file # noqa pylint: E402


Expand Down Expand Up @@ -60,9 +60,9 @@
assert op.exists(out_path)
# Now, let's have a look at the scene and check that it matches the
# original one (other than where modified)
# First we need to convert it to an exml file...
new_exml_scene = convert_file(out_path)
new_scene = exml_to_dict(new_exml_scene)
# First we need to convert it to an mxml file...
new_mxml_scene = convert_file(out_path)
new_scene = mxml_to_dict(new_mxml_scene)
# Let's check to see if the new LOD values are there
assert float(new_scene['Attributes'][1]['Value']) == 750.25
assert float(new_scene['Attributes'][2]['Value']) == 1250
Expand All @@ -76,8 +76,8 @@
# And then remove it from the comparison
del new_scene['Children'][0]['Transform']['ScaleY']
# Then convert the original scene file...
orig_exml_scene = convert_file(ASTEROID_PATH)
orig_scene = exml_to_dict(orig_exml_scene)
orig_mxml_scene = convert_file(ASTEROID_PATH)
orig_scene = mxml_to_dict(orig_mxml_scene)
# Delete the modified values from this scene too.
del orig_scene['Attributes'][1:4]
del orig_scene['Children'][0]['Transform']['ScaleY']
Expand All @@ -88,8 +88,8 @@
orig_descriptor = op.join(TEST_DATA_PATH,
ASTEROID_BASE_PATH,
'ASTEROIDXL.DESCRIPTOR.MBIN')
orig_descriptor = exml_to_dict(convert_file(orig_descriptor))
orig_descriptor = mxml_to_dict(convert_file(orig_descriptor))
new_descriptor = op.join(tempdir, ASTEROID_BASE_PATH,
'ASTEROIDXL.DESCRIPTOR.MBIN')
new_descriptor = exml_to_dict(convert_file(new_descriptor))
new_descriptor = mxml_to_dict(convert_file(new_descriptor))
assert orig_descriptor == new_descriptor
Loading

0 comments on commit 9c02238

Please sign in to comment.