Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 21 additions & 14 deletions BlenderExtensions/EntityPanels.py
Original file line number Diff line number Diff line change
Expand Up @@ -567,12 +567,18 @@ class NMS_GcInteractionType_Properties(bpy.types.PropertyGroup):

class NMS_Vector4f_Properties(bpy.types.PropertyGroup):
""" Properties for Vector4f """
x: FloatProperty(name="x")
y: FloatProperty(name="y")
z: FloatProperty(name="z")
t: FloatProperty(name="t")


x: FloatProperty(name="X")
y: FloatProperty(name="Y")
z: FloatProperty(name="Z")
t: FloatProperty(name="W")
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be w so that it's consistent?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so, but I wasn't sure if it would break something somewhere else, so I left it alone.


class NMS_Vector4i_Properties(bpy.types.PropertyGroup):
""" Properties for Vector4i """
x: IntProperty(name="X")
y: IntProperty(name="Y")
z: IntProperty(name="Z")
t: IntProperty(name="W")

class NMS_TkCameraWanderData_Properties(bpy.types.PropertyGroup):
""" Properties for TkCameraWanderData """
CamWander: BoolProperty(name="CamWander")
Expand Down Expand Up @@ -1048,10 +1054,10 @@ def GcInteractionComponentData(self, layout, obj):
b2 = b1.box("Camera")
b2.row("Distance")
b3 = b2.box("Offset")
b3.row("x")
b3.row("y")
b3.row("z")
b3.row("t")
b3.row("X")
b3.row("Y")
b3.row("Z")
b3.row("W")
b2.row("Pitch")
b2.row("Rotate")
b2.row("LightPitch")
Expand Down Expand Up @@ -1120,10 +1126,10 @@ def TkModelRendererData(self, layout, obj, index=0):
b1 = r.box("Camera")
b1.row("Distance")
b2 = b1.box("Offset")
b2.row("x")
b2.row("y")
b2.row("z")
b2.row("t")
b2.row("X")
b2.row("Y")
b2.row("Z")
b2.row("W")
b1.row("Pitch")
b1.row("Rotate")
b1.row("LightPitch")
Expand Down Expand Up @@ -1366,6 +1372,7 @@ def get_index(self, obj):
NMS_GcSpaceshipComponentData_Properties,
NMS_TkCameraWanderData_Properties,
NMS_Vector4f_Properties,
NMS_Vector4i_Properties,
NMS_TkModelRendererCameraData_Properties,
NMS_GcAlienPuzzleMissionOverride_Properties,
NMS_TkModelRendererData_Properties,
Expand Down
26 changes: 13 additions & 13 deletions BlenderExtensions/NMSShaderNode.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@

FLAGS = [('_F01_DIFFUSEMAP', 'Diffuse Map', 'Diffuse Map'),
('_F03_NORMALMAP', 'Normal Map', 'Normal Map'),
('_F21_VERTEXCOLOUR', 'Vertex Colour', 'Vertex Colour'),
('_F25_ROUGHNESS_MASK', 'Roughness Mask', 'Roughness Mask')]
('_F21_VERTEXCUSTOM', 'Vertex Custom', 'Vertex Custom'),
('_F25_MASKS_MAP', 'Masks Map', 'Masks Map')]


class NMSShader(bpy.types.NodeCustomGroup):
Expand All @@ -27,8 +27,8 @@ def operators(self, context):
context.space_data.edit_tree
list = [('_F01_DIFFUSEMAP', 'Diffuse Map', 'Diffuse Map'),
('_F03_NORMALMAP', 'Normal Map', 'Normal Map'),
('_F21_VERTEXCOLOUR', 'Vertex Colour', 'Vertex Colour'),
('_F25_ROUGHNESS_MASK', 'Roughness Mask', 'Roughness Mask')]
('_F21_VERTEXCUSTOM', 'Vertex Custom', 'Vertex Custom'),
('_F25_MASKS_MAP', 'Masks Map', 'Masks Map')]
return list

# Manage the internal nodes to perform the chained operation - clear all
Expand All @@ -38,7 +38,7 @@ def __nodetree_setup__(self):

if self.F01_DIFFUSEMAP_choice:
diffuse_texture = self._add_diffuse_texture_choice()
if self.F21_VERTEXCOLOUR_choice:
if self.F21_VERTEXCUSTOM_choice:
self._add_vertex_colour_nodes()
else:
self._remove_vertex_colour_nodes()
Expand Down Expand Up @@ -111,14 +111,14 @@ def update_nodes(self, context):
description='Whether material has a normal map.',
default=False,
update=update_nodes)
F21_VERTEXCOLOUR_choice: BoolProperty(
name='Has vertex colour data',
description='Whether the material has vertex colour data.',
F21_VERTEXCUSTOM_choice: BoolProperty(
name='Has vertex custom data',
description='Whether the material has vertex custom data.',
default=False,
update=update_nodes)
F25_ROUGHNESS_MASK_choice: BoolProperty(
name='Has roughness mask',
description='Whether material has a roughness mask.',
F25_MASKS_MAP_choice: BoolProperty(
name='Has masks map',
description='Whether material has a masks map.',
default=False,
update=update_nodes)

Expand Down Expand Up @@ -150,9 +150,9 @@ def draw_buttons(self, context, layout):
row = layout.row()
row.prop(self, 'F03_NORMALMAP_choice', text='Normal Map')
row = layout.row()
row.prop(self, 'F21_VERTEXCOLOUR_choice', text='Vertex Colour')
row.prop(self, 'F21_VERTEXCUSTOM_choice', text='Vertex Custom')
row = layout.row()
row.prop(self, 'F25_ROUGHNESS_MASK_choice', text='Roughness Mask')
row.prop(self, 'F25_MASKS_MAP_choice', text='Masks Map')

# Copy
def copy(self, node):
Expand Down
66 changes: 37 additions & 29 deletions ModelExporter/addon_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@
from ModelExporter.animations import process_anims
from ModelExporter.export import Export
from ModelExporter.Descriptor import Descriptor
from NMS.classes import (TkMaterialData, TkMaterialFlags,
TkVolumeTriggerType, TkMaterialSampler,
TkMaterialUniform, TkRotationComponentData, TkPhysicsComponentData)
from NMS.classes import (TkMaterialData, TkMaterialFlags, TkVolumeTriggerType,
TkMaterialSampler, TkMaterialUniform_Float, TkMaterialUniform_UInt,
TkRotationComponentData, TkPhysicsComponentData)
from NMS.classes import TkAnimationComponentData, TkAnimationData
from NMS.classes import List, Vector4f
from NMS.classes import List, Vector4f, Vector4i
from NMS.classes import TkAttachmentData
from NMS.classes.Object import Object, Model, Mesh, Locator, Reference, Collision, Light, Joint
from NMS.LOOKUPS import MATERIALFLAGS
Expand Down Expand Up @@ -165,7 +165,7 @@ def create_sampler(image, sampler_name: str, texture_dir: str,

if op.exists(out_tex_path) and not force_overwrite:
print(f'Found existing texture at {out_tex_path}. Using this.')
return TkMaterialSampler(Name=sampler_name, Map=relpath, IsSRGB=True)
return TkMaterialSampler(Name=sampler_name, Map=relpath, IsSRGB=False)

# If the textures are packed into the blend file, unpack them.
if len(image.packed_files) > 0:
Expand All @@ -181,7 +181,7 @@ def create_sampler(image, sampler_name: str, texture_dir: str,
tex_path = image.filepath_from_user()
shutil.copy(tex_path, out_tex_path)
if op.exists(out_tex_path):
return TkMaterialSampler(Name=sampler_name, Map=relpath, IsSRGB=True)
return TkMaterialSampler(Name=sampler_name, Map=relpath, IsSRGB=False)
else:
raise FileNotFoundError(f'Texture not written to {out_tex_path}')

Expand Down Expand Up @@ -404,26 +404,36 @@ def parse_material(self, ob):
"label for the diffuse texture, etc.")

# Fetch Uniforms
matuniforms.append(TkMaterialUniform(Name="gMaterialColourVec4",
Values=Vector4f(x=1.0,
y=1.0,
z=1.0,
t=1.0)))
matuniforms.append(TkMaterialUniform(Name="gMaterialParamsVec4",
Values=Vector4f(x=1.0,
y=0.5,
z=1.0,
t=0.0)))
matuniforms.append(TkMaterialUniform(Name="gMaterialSFXVec4",
Values=Vector4f(x=0.0,
y=0.0,
z=0.0,
t=0.0)))
matuniforms.append(TkMaterialUniform(Name="gMaterialSFXColVec4",
Values=Vector4f(x=0.0,
y=0.0,
z=0.0,
t=0.0)))
matuniforms.append(TkMaterialUniform_Float(Name="gMaterialColourVec4",
Values=Vector4f(X=1.000000,
Y=1.000000,
Z=1.000000,
W=1.000000)))
matuniforms.append(TkMaterialUniform_Float(Name="gMaterialParamsVec4",
Values=Vector4f(X=1.000000,
Y=0.500000,
Z=1.000000,
W=0.000000)))
matuniforms.append(TkMaterialUniform_Float(Name="gMaterialParams2Vec4",
Values=Vector4f(X=1.000000,
Y=0.500000,
Z=1.000000,
W=0.000000)))
matuniforms.append(TkMaterialUniform_Float(Name="gMaterialSFXVec4",
Values=Vector4f(X=0.000000,
Y=0.000000,
Z=0.000000,
W=0.000000)))
matuniforms.append(TkMaterialUniform_Float(Name="gMaterialSFXColVec4",
Values=Vector4f(X=0.000000,
Y=0.000000,
Z=0.000000,
W=0.000000)))
matuniforms.append(TkMaterialUniform_UInt(Name="gDynamicFlags",
Values=Vector4i(X=3,
Y=0,
Z=0,
W=0)))

if self.settings.get('use_shared_textures'):
texture_dir = self.settings.get('shared_texture_folder')
Expand Down Expand Up @@ -451,10 +461,8 @@ def parse_material(self, ob):

# Sort out Mask
if mask_image:
# Set _F25_ROUGHNESS_MASK
# Set _F25_MASKS_MAP
add_matflags.add(24)
# Set _F39_METALLIC_MASK
add_matflags.add(38)
# Add the sampler to the list
matsamplers.append(create_sampler(
mask_image, "gMasksMap", texture_dir,
Expand Down
16 changes: 8 additions & 8 deletions ModelExporter/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -535,12 +535,12 @@ def process_nodes(self):
data['BOUNDHULLED'] = self.hull_bounds[name][1]
if mesh_obj._Type == 'MESH':
# add the AABBMIN/MAX(XYZ) values:
data['AABBMINX'] = self.mesh_bounds[name]['x'][0]
data['AABBMINY'] = self.mesh_bounds[name]['y'][0]
data['AABBMINZ'] = self.mesh_bounds[name]['z'][0]
data['AABBMAXX'] = self.mesh_bounds[name]['x'][1]
data['AABBMAXY'] = self.mesh_bounds[name]['y'][1]
data['AABBMAXZ'] = self.mesh_bounds[name]['z'][1]
data['AABBMINX'] = self.mesh_bounds[name]['X'][0]
data['AABBMINY'] = self.mesh_bounds[name]['Y'][0]
data['AABBMINZ'] = self.mesh_bounds[name]['Z'][0]
data['AABBMAXX'] = self.mesh_bounds[name]['X'][1]
data['AABBMAXY'] = self.mesh_bounds[name]['Y'][1]
data['AABBMAXZ'] = self.mesh_bounds[name]['Z'][1]
data['HASH'] = self.hashes.get(name, 0)
# we only care about entity and material data for Mesh
# Objects
Expand Down Expand Up @@ -741,8 +741,8 @@ def get_bounds(self):
self.GeometryData['MeshAABBMax'].append((x_bounds[1], y_bounds[1], z_bounds[1], 1))
if obj._Type == "MESH":
# only add the meshes to the self.mesh_bounds dict:
self.mesh_bounds[obj.Name] = {'x': x_bounds, 'y': y_bounds,
'z': z_bounds}
self.mesh_bounds[obj.Name] = {'X': x_bounds, 'Y': y_bounds,
'Z': z_bounds}

# TODO: Change this here too...
def write(self):
Expand Down
6 changes: 3 additions & 3 deletions ModelImporter/animation_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -285,9 +285,9 @@ def _create_anim_channels(self, obj, anim_name: str):
Tuple of collections.namedtuple's:
(location, rotation, scale)
"""
location = namedtuple('location', ['x', 'y', 'z'])
rotation = namedtuple('rotation', ['x', 'y', 'z', 'w'])
scale = namedtuple('scale', ['x', 'y', 'z'])
location = namedtuple('location', ['X', 'Y', 'Z'])
rotation = namedtuple('rotation', ['X', 'Y', 'Z', 'W'])
scale = namedtuple('scale', ['X', 'Y', 'Z'])
loc_x = obj.animation_data.action.fcurves.new(data_path='location',
index=0,
action_group=anim_name)
Expand Down
40 changes: 15 additions & 25 deletions NMS/LOOKUPS.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,21 @@
import numpy as np


MATERIALFLAGS = ['_F01_DIFFUSEMAP', '_F02_SKINNED', '_F03_NORMALMAP', '_F04_',
'_F05_INVERT_ALPHA', '_F06_BRIGHT_EDGE', '_F07_UNLIT',
'_F08_REFLECTIVE', '_F09_TRANSPARENT', '_F10_NORECEIVESHADOW',
'_F11_ALPHACUTOUT', '_F12_BATCHED_BILLBOARD',
'_F13_UVANIMATION', '_F14_UVSCROLL', '_F15_WIND',
'_F16_DIFFUSE2MAP', '_F17_MULTIPLYDIFFUSE2MAP',
'_F18_UVTILES', '_F19_BILLBOARD', '_F20_PARALLAXMAP',
'_F21_VERTEXCOLOUR', '_F22_TRANSPARENT_SCALAR',
'_F23_TRANSLUCENT', '_F24_AOMAP', '_F25_ROUGHNESS_MASK',
'_F26_STRETCHY_PARTICLE', '_F27_VBTANGENT', '_F28_VBSKINNED',
'_F29_VBCOLOUR', '_F30_REFRACTION', '_F31_DISPLACEMENT',
'_F32_REFRACTION_MASK', '_F33_SHELLS', '_F34_GLOW',
'_F35_GLOW_MASK', '_F36_DOUBLESIDED', '_F37_',
'_F38_NO_DEFORM', '_F39_METALLIC_MASK',
'_F40_SUBSURFACE_MASK', '_F41_DETAIL_DIFFUSE',
'_F42_DETAIL_NORMAL', '_F43_NORMAL_TILING', '_F44_IMPOSTER',
'_F45_VERTEX_BLEND', '_F46_BILLBOARD_AT',
'_F47_REFLECTION_PROBE', '_F48_WARPED_DIFFUSE_LIGHTING',
'_F49_DISABLE_AMBIENT', '_F50_DISABLE_POSTPROCESS',
'_F51_DECAL_DIFFUSE', '_F52_DECAL_NORMAL',
'_F53_COLOURISABLE', '_F54_COLOURMASK', '_F55_MULTITEXTURE',
'_F56_MATCH_GROUND', '_F57_DETAIL_OVERLAY',
'_F58_USE_CENTRAL_NORMAL', '_F59_SCREENSPACE_FADE',
'_F60_ACUTE_ANGLE_FADE', '_F61_CLAMP_AMBIENT',
'_F62_DETAIL_ALPHACUTOUT', '_F63_DISSOLVE', '_F64_']
MATERIALFLAGS = ['_F01_DIFFUSEMAP', '_F02_SKINNED', '_F03_NORMALMAP', '_F04_FEATURESMAP',
'_F05_DEPTH_EFFECT', '_F06_', '_F07_UNLIT', '_F08_', '_F09_REFLECTIVE',
'_F10_', '_F11_ALPHACUTOUT', '_F12_BATCHED_BILLBOARD', '_F13_UV_EFFECT',
'_F14_', '_F15_WIND', '_F16_DIFFUSE2MAP', '_F17_', '_F18_',
'_F19_BILLBOARD', '_F20_PARALLAX', '_F21_VERTEXCUSTOM',
'_F22_OCCLUSION_MAP', '_F23_', '_F24_', '_F25_MASKS_MAP', '_F26_', '_F27_',
'_F28_', '_F29_', '_F30_REFRACTION', '_F31_DISPLACEMENT',
'_F32_REFRACTION_MASK', '_F33_SHELLS', '_F34_', '_F35_', '_F36_DOUBLESIDED',
'_F37_EXPLICIT_MOTION_VECTORS', '_F38_', '_F39_', '_F40_', '_F41_',
'_F42_DETAIL_NORMAL', '_F43_', '_F44_IMPOSTER', '_F45_', '_F46_',
'_F47_REFLECTION_PROBE', '_F48_', '_F49_', '_F50_DISABLE_POSTPROCESS',
'_F51_', '_F52_', '_F53_COLOURISABLE', '_F54_', '_F55_MULTITEXTURE',
'_F56_MATCH_GROUND', '_F57_', '_F58_USE_CENTRAL_NORMAL',
'_F59_BIASED_REACTIVITY', '_F60_', '_F61_', '_F62_', '_F63_DISSOLVE',
'_F64_RESERVED_FLAG_FOR_EARLY_Z_PATCHING_DO_NOT_USE']

# Mesh vertex types
VERTS = 0
Expand Down
16 changes: 8 additions & 8 deletions NMS/classes/Quaternion.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ def __init__(self, **kwargs):
super(Quaternion, self).__init__()

""" Contents of the struct """
self.data['x'] = kwargs.get('x', 0.0)
self.data['y'] = kwargs.get('y', 0.0)
self.data['z'] = kwargs.get('z', 0.0)
self.data['w'] = kwargs.get('w', 0.0)
self.data['X'] = kwargs.get('X', 0.0)
self.data['Y'] = kwargs.get('Y', 0.0)
self.data['Z'] = kwargs.get('Z', 0.0)
self.data['W'] = kwargs.get('W', 0.0)
""" End of the struct contents"""

def __str__(self):
return 'Quaternion({0}, {1}, {2}, {3})'.format(self.data['x'],
self.data['y'],
self.data['z'],
self.data['w'])
return 'Quaternion({0}, {1}, {2}, {3})'.format(self.data['X'],
self.data['Y'],
self.data['Z'],
self.data['W'])

def __repr__(self):
return str(self)
6 changes: 3 additions & 3 deletions NMS/classes/TkAnimationData.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@ def __init__(self, **kwargs):
self.data['ActionFrame'] = kwargs.get('ActionFrame', -1)
self.data['ControlCreatureSize'] = kwargs.get('ControlCreatureSize',
'AllSizes')
self.data['Additive'] = kwargs.get('Additive', 'False')
self.data['Mirrored'] = kwargs.get('Mirrored', 'False')
self.data['Active'] = kwargs.get('Active', 'True')
self.data['Additive'] = kwargs.get('Additive', 'false')
self.data['Mirrored'] = kwargs.get('Mirrored', 'false')
self.data['Active'] = kwargs.get('Active', 'true')
self.data['AdditiveBaseAnim'] = kwargs.get('AdditiveBaseAnim', '')
self.data['AdditiveBaseFrame'] = kwargs.get('AdditiveBaseFrame', 0)
self.data['GameData'] = kwargs.get('GameData', TkAnimationGameData())
Expand Down
Loading
Loading