Skip to content

Commit

Permalink
Merge pull request #52 from monkeyman192/development
Browse files Browse the repository at this point in the history
[MRG] - Update for Beyond
  • Loading branch information
monkeyman192 authored Aug 20, 2019
2 parents 6984d1d + 4c15506 commit 75aa413
Show file tree
Hide file tree
Showing 11 changed files with 32 additions and 11 deletions.
2 changes: 2 additions & 0 deletions ModelImporter/readers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions NMS/classes/Object.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand All @@ -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):
Expand Down
2 changes: 2 additions & 0 deletions NMS/classes/TkAnimationComponentData.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
14 changes: 9 additions & 5 deletions NMS/classes/TkPhysicsComponentData.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"""
1 change: 1 addition & 0 deletions NMS/classes/TkSceneNodeData.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down
2 changes: 1 addition & 1 deletion __init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
12 changes: 7 additions & 5 deletions tests/export_tests/export_animations.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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('<I', f.read(0x4))[0] == 0x6C3A12AE
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit 75aa413

Please sign in to comment.