diff --git a/ModelImporter/readers.py b/ModelImporter/readers.py index 81ccb80..252d467 100644 --- a/ModelImporter/readers.py +++ b/ModelImporter/readers.py @@ -106,6 +106,8 @@ def read_entity(fname): if struct_name == 'cTkAnimationComponentData': has_anims = True break + # Read the SubGUID but ignore it... + SubGUID = f.read(0x8) # If no animation data is found, return. if not has_anims: return anim_data diff --git a/NMS/classes/Object.py b/NMS/classes/Object.py index e1b7c02..6a485de 100644 --- a/NMS/classes/Object.py +++ b/NMS/classes/Object.py @@ -2,6 +2,8 @@ # Each object in blender will be passed into this class. Any children are added # as child objects. +from zlib import crc32 + from .TkSceneNodeData import TkSceneNodeData from .TkSceneNodeAttributeData import TkSceneNodeAttributeData from .TkTransformData import TkTransformData @@ -154,6 +156,7 @@ def construct_data(self): self.Child_Nodes = None self.NodeData = TkSceneNodeData(Name=self.Name, + NameHash=self.NameHash, Type=self._Type, Transform=self.Transform, Attributes=self.Attributes, @@ -174,6 +177,13 @@ def rebuild_entity(self): for entity in self.ExtraEntityData[entityname]: self.EntityData[entityname].append(entity) + @property + def NameHash(self): + """ Returns the nameHash value for the object. """ + byte_name = bytes(self.Name, encoding='utf-8') + # do bit operation to ensure it's always unsigned + return crc32(byte_name) & 0xFFFFFFFF + class Locator(Object): def __init__(self, Name, **kwargs): diff --git a/NMS/classes/TkAnimationComponentData.py b/NMS/classes/TkAnimationComponentData.py index 8e11044..4178f9e 100644 --- a/NMS/classes/TkAnimationComponentData.py +++ b/NMS/classes/TkAnimationComponentData.py @@ -15,4 +15,6 @@ def __init__(self, **kwargs): # This will always just be empty for now... self.data['Trees'] = kwargs.get('Trees', List()) self.data['NetSyncAnimation'] = kwargs.get('NetSyncAnimation', False) + self.data['JointLODOverrides'] = kwargs.get('JointLODOverrides', + List()) """ End of the struct contents""" diff --git a/NMS/classes/TkPhysicsComponentData.py b/NMS/classes/TkPhysicsComponentData.py index c2e0a0d..54caa00 100644 --- a/NMS/classes/TkPhysicsComponentData.py +++ b/NMS/classes/TkPhysicsComponentData.py @@ -12,17 +12,21 @@ def __init__(self, **kwargs): """ Contents of the struct """ self.data['Data'] = kwargs.get('Data', TkPhysicsData()) - self.data['RagdollData'] = kwargs.get('RagdollData', Empty(0x48)) + self.data['RagdollData'] = kwargs.get('RagdollData', Empty(0x50)) self.data['VolumeTriggerType'] = kwargs.get('VolumeTriggerType', TkVolumeTriggerType()) - self.SurfaceProperties = ["None", "Glass"] + self.SurfaceProperties = ["None", "Glass"] # Is this needed??? self.data['SurfaceProperties'] = kwargs.get('SurfaceProperties', "None") self.data['TriggerVolume'] = kwargs.get('TriggerVolume', False) self.data['Climbable'] = kwargs.get('Climbable', False) self.data['IgnoreModelOwner'] = kwargs.get('IgnoreModelOwner', False) - self.data['NoVehicleCollision'] = kwargs.get('NoVehicleCollision', - False) + self.data['NoVehicleCollide'] = kwargs.get('NoVehicleCollide', False) + self.data['NoPlayerCollide'] = kwargs.get('NoPlayerCollide', False) self.data['CameraInvisible'] = kwargs.get('CameraInvisible', False) - self.data['EndPadding'] = Empty(0x3) + self.data['InvisibleForInteraction'] = kwargs.get( + 'InvisibleForInteraction', False) + self.data['AllowTeleporter'] = kwargs.get('AllowTeleporter', False) + self.data['BlockTeleporter'] = kwargs.get('BlockTeleporter', False) + self.data['EndPadding'] = Empty(0x7) """ End of the struct contents""" diff --git a/NMS/classes/TkSceneNodeData.py b/NMS/classes/TkSceneNodeData.py index f672b5e..633df0e 100644 --- a/NMS/classes/TkSceneNodeData.py +++ b/NMS/classes/TkSceneNodeData.py @@ -12,6 +12,7 @@ def __init__(self, **kwargs): """ Contents of the struct """ self.data['Name'] = String(kwargs.get('Name', ""), 0x80) + self.data['NameHash'] = kwargs.get('NameHash', 0) self.data['Type'] = String(kwargs.get('Type', 'MODEL'), 0x10) self.data['Transform'] = kwargs.get('Transform', TkTransformData()) self.data['Attributes'] = kwargs.get('Attributes', List()) diff --git a/__init__.py b/__init__.py index 9ade090..fc78be4 100644 --- a/__init__.py +++ b/__init__.py @@ -24,7 +24,7 @@ bl_info = { "name": "No Man's Sky Development Kit", "author": "gregkwaste, monkeyman192", - "version": (0, 9, 15), + "version": (0, 9, 16), "blender": (2, 79, 0), "location": "File > Export", "description": "Create NMS scene structures and export to NMS File format", diff --git a/tests/export_tests/export_animations.py b/tests/export_tests/export_animations.py index 7231a64..f40cf10 100644 --- a/tests/export_tests/export_animations.py +++ b/tests/export_tests/export_animations.py @@ -4,11 +4,6 @@ import struct -# TODO: This script will fail at the moment due to the calling of exporting -# from the command line not being mature enough. This will come in a future -# update. - - with tempfile.TemporaryDirectory() as tempdir: res = bpy.ops.nmsdk.export_scene(output_directory=tempdir, export_directory='CUSTOMMODELS', @@ -49,3 +44,10 @@ f.seek(jump - 0x4, 1) f.seek(0x10, 1) assert f.read(0xC) == b'CUSTOMMODELS' + + # Do some checks on the scene file. + scene = op.join(export_path, 'ANIM_TEST', 'ANIM_TEST.SCENE.MBIN') + with open(scene, 'rb') as f: + f.seek(0xE0) + # Check the hash of the model name + assert struct.unpack('