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
4 changes: 2 additions & 2 deletions BlenderExtensions/ContextMenu.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ def execute(self, context):
# Create a new sphere for collisions
mesh = bpy.data.meshes.new('sphere')
bm = bmesh.new()
bmesh.ops.create_icosphere(bm, subdivisions=4, radius=0.5)
bmesh.ops.create_icosphere(bm, subdivisions=4, radius=1)
bm.to_mesh(mesh)
bm.free()
sphere = bpy.data.objects.new('sphere', mesh)
Expand Down Expand Up @@ -163,7 +163,7 @@ def execute(self, context):
mesh = bpy.data.meshes.new('cylinder')
bm = bmesh.new()
bmesh.ops.create_cone(bm, cap_ends=True, cap_tris=True,
radius1=0.5, radius2=0.5, depth=1.0,
radius1=1, radius2=1, depth=1.0,
segments=20, matrix=CONE_ROTATION_MAT)
bm.to_mesh(mesh)
bm.free()
Expand Down
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")

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
68 changes: 38 additions & 30 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 Expand Up @@ -686,7 +694,7 @@ def mesh_parser(self, ob, is_coll_mesh: bool = False):
uv = uv_layer_data[li].uv
uvs[vi] = (uv[0], 1 - uv[1], 0, 1)
else:
# Calculate the ev value to write then compare it to what
# Calculate the uv value to write then compare it to what
# we have already to see if we need to split the vert.
uv = uv_layer_data[li].uv
uv = (uv[0], 1 - uv[1], 0, 1)
Expand Down
Loading