Skip to content

Commit 033b523

Browse files
authored
Merge pull request #311 from AsoboStudio/glTF-Blender-IO-MSFS-v1.3.3
Update MSFS exporter/importer glTF Blender v1.3.3
2 parents 1ccb1fd + 5c4bac9 commit 033b523

16 files changed

+798
-311
lines changed

addons/io_scene_gltf2_msfs/__init__.py

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"author": "Luca Pierabella, Yasmine Khodja, Wing42, pepperoni505, ronh991, and others",
2525
"description": "This toolkit prepares your 3D assets to be used for Microsoft Flight Simulator",
2626
"blender": (3, 3, 0),
27-
"version": (1, 3, 2),
27+
"version": (1, 3, 3),
2828
"location": "File > Import-Export",
2929
"category": "Import-Export",
3030
"tracker_url": "https://github.com/AsoboStudio/glTF-Blender-IO-MSFS"
@@ -34,18 +34,23 @@ def get_version_string():
3434
return str(bl_info['version'][0]) + '.' + str(bl_info['version'][1]) + '.' + str(bl_info['version'][2])
3535

3636
class MSFS_ImporterProperties(bpy.types.PropertyGroup):
37-
enabled: bpy.props.BoolProperty(
37+
enable_msfs_extension: bpy.props.BoolProperty(
3838
name='Microsoft Flight Simulator Extensions',
3939
description='Enable MSFS glTF import extensions',
4040
default=True
4141
)
4242

4343
class MSFS_ExporterProperties(bpy.types.PropertyGroup):
44+
def msfs_enable_msfs_extension_update(self, context):
45+
props = bpy.context.scene.msfs_exporter_settings
46+
settings = bpy.context.scene.msfs_multi_exporter_settings
47+
settings.enable_msfs_extension = props.enable_msfs_extension
4448

45-
enabled: bpy.props.BoolProperty(
49+
enable_msfs_extension: bpy.props.BoolProperty(
4650
name='Microsoft Flight Simulator Extensions',
4751
description='Enable MSFS glTF export extensions',
4852
default=True,
53+
update=msfs_enable_msfs_extension_update
4954
)
5055

5156
use_unique_id: bpy.props.BoolProperty(
@@ -79,7 +84,7 @@ def draw(self, context):
7984
layout.use_property_split = True
8085
layout.use_property_decorate = False # No animation.
8186

82-
layout.prop(props, 'enabled', text="Enabled")
87+
layout.prop(props, 'enable_msfs_extension', text="Enabled")
8388

8489
class GLTF_PT_MSFSExporterExtensionPanel(bpy.types.Panel):
8590
bl_space_type = 'FILE_BROWSER'
@@ -96,17 +101,17 @@ def poll(cls, context):
96101

97102
def draw_header(self, context):
98103
layout = self.layout
99-
layout.label(text="MSFS Extensions", icon='TOOL_SETTINGS')
104+
layout.label(text="Microsoft Flight Simulator Extensions", icon='TOOL_SETTINGS')
100105

101106
def draw(self, context):
102-
props = bpy.context.scene.msfs_exporter_properties
107+
props = bpy.context.scene.msfs_exporter_settings
103108

104109
layout = self.layout
105110
layout.use_property_split = True
106111
layout.use_property_decorate = False # No animation.
107112

108-
layout.prop(props, 'enabled', text="Enabled")
109-
if props.enabled:
113+
layout.prop(props, 'enable_msfs_extension', text="Enabled")
114+
if props.enable_msfs_extension:
110115
layout.prop(props, 'use_unique_id', text="Enable ASOBO Unique ID extension")
111116

112117
def recursive_module_search(path, root=""):
@@ -164,7 +169,7 @@ def register():
164169
pass
165170

166171
bpy.types.Scene.msfs_importer_properties = bpy.props.PointerProperty(type=MSFS_ImporterProperties)
167-
bpy.types.Scene.msfs_exporter_properties = bpy.props.PointerProperty(type=MSFS_ExporterProperties)
172+
bpy.types.Scene.msfs_exporter_settings = bpy.props.PointerProperty(type=MSFS_ExporterProperties)
168173

169174

170175
def register_panel():
@@ -231,4 +236,4 @@ def __init__(self):
231236
# Otherwise, it may fail because the gltf2 may not be loaded yet
232237
from io_scene_gltf2.io.com.gltf2_io_extensions import Extension
233238
self.Extension = Extension
234-
self.properties = bpy.context.scene.msfs_exporter_properties
239+
self.properties = bpy.context.scene.msfs_exporter_settings

addons/io_scene_gltf2_msfs/blender/gizmo.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
import bpy
15+
from math import radians
16+
1617
import bgl
17-
import gpu
1818
import bmesh
19+
import bpy
20+
import gpu
1921
import numpy as np
20-
from mathutils import Matrix
21-
from math import radians
2222
from gpu_extras.batch import batch_for_shader
23+
from mathutils import Matrix
2324

2425

2526
class MSFSGizmoProperties():
@@ -216,8 +217,9 @@ def refresh(self, context):
216217

217218
for _, (empty, gizmo) in enumerate(self.__class__.empties.copy().items()):
218219
if empty not in found_empties:
219-
self.gizmos.remove(gizmo)
220220
del self.__class__.empties[empty]
221+
if gizmo:
222+
self.gizmos.remove(gizmo)
221223

222224
# Check if there are any new gizmo empties, and if so create new gizmo. We can't do this in the above loop due to the crash mentioned above
223225
for object in context.view_layer.objects:

addons/io_scene_gltf2_msfs/blender/material/utils/msfs_material_enum.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ class MSFS_ShaderNodesTypes(Enum):
6767
shaderNodeRGB = "ShaderNodeRGB"
6868
shaderNodeValue = "ShaderNodeValue"
6969
shaderNodeRGBCurve = "ShaderNodeRGBCurve"
70+
shaderNodeMapRange = "ShaderNodeMapRange"
7071

7172
class MSFS_FrameNodes(Enum):
7273
baseColorFrame = "Base Color Frame"
@@ -95,6 +96,9 @@ class MSFS_ShaderNodes(Enum):
9596
occlusionMul = "Occlusion Multiplier"
9697
roughnessMul = "Roughness Multiplier"
9798
metallicMul = "Metallic Multiplier"
99+
detailOMRMul = "Multiply detail OcclMetalRough"
100+
detailOMRSubtract = "Subtract detail OcclMetalRough"
101+
detailOMRClamp = "Clamp detail OcclMetalRough"
98102
emissiveTex = "Emissive Texture"
99103
emissiveColor = "Emissive RGB"
100104
emissiveScale = "Emissive Scale"
@@ -120,7 +124,7 @@ class MSFS_ShaderNodes(Enum):
120124
blendNormalMap = "Blend Normal Map"
121125
blendColorMap = "Blend Color Map"
122126
blendAlphaMap = "Blend Alpha Map"
123-
blendCompMap = "Blend Occlusion(R) Roughness(G) Metallic(B) Map"
127+
blendCompMap = "Add Occlusion(R) Roughness(G) Metallic(B)"
124128
vertexColor = "Vertex Color"
125129
albedoDetailMix = "Albedo Detail Mix"
126130
behindGlassTex = "Behind Glass"

addons/io_scene_gltf2_msfs/blender/msfs_material_function.py

Lines changed: 60 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,54 @@ def defaultShadersTree(self):
443443
color = (0.1, 0.4, 0.6)
444444
)
445445

446+
## Multiply Detail OMR
447+
# In[0] : Detail OMR texture
448+
# Out[0] : Substract Detail OMR
449+
multiplyDetailOMR = self.addNode(
450+
name = MSFS_ShaderNodes.detailOMRMul.value,
451+
typeNode = MSFS_ShaderNodesTypes.shaderNodeVectorMath.value,
452+
operation = "MULTIPLY",
453+
location = (-500.0, 200.0),
454+
width = 200.0,
455+
frame = omrFrame
456+
)
457+
multiplyDetailOMR.inputs[1].default_value = (2.0, 2.0, 2.0)
458+
459+
## Links
460+
self.link(detailCompTexNode.outputs[0], multiplyDetailOMR.inputs[0])
461+
462+
## Substract Detail OMR
463+
# In[0] : Multiply Detail OMR
464+
# Out[0] : Clamp Detail OMR
465+
subtractDetailOMR = self.addNode(
466+
name = MSFS_ShaderNodes.detailOMRSubtract.value,
467+
typeNode = MSFS_ShaderNodesTypes.shaderNodeVectorMath.value,
468+
operation = "SUBTRACT",
469+
location = (-500.0, 150.0),
470+
width = 200.0,
471+
frame = omrFrame
472+
)
473+
subtractDetailOMR.inputs[1].default_value = (1.0, 1.0, 1.0)
474+
475+
## Links
476+
self.link(multiplyDetailOMR.outputs[0], subtractDetailOMR.inputs[0])
477+
478+
## Map to clamp detail OMR
479+
# In[0] : Substract Detail OMR
480+
# Out[0] : Add Detail comp
481+
clampDetailOMR = self.addNode(
482+
name = MSFS_ShaderNodes.detailOMRClamp.value,
483+
typeNode = MSFS_ShaderNodesTypes.shaderNodeMapRange.value,
484+
location = (-500.0, 100.0),
485+
width = 200.0,
486+
frame = omrFrame
487+
)
488+
clampDetailOMR.data_type = "FLOAT_VECTOR"
489+
clampDetailOMR.interpolation_type = "LINEAR"
490+
491+
## Links
492+
self.link(subtractDetailOMR.outputs[0], clampDetailOMR.inputs[6]) ## input[6] == "Vector"
493+
446494
## Metallic scale
447495
# Out[0] : Metallic Multiplier -> In[0]
448496
# Out[0] : PrincipledBSDF -> In["Metallic"]
@@ -464,24 +512,22 @@ def defaultShadersTree(self):
464512
)
465513

466514
## Blend Detail Operations (OccMetalRough)
467-
# Detail comp operators
515+
# Add Detail comp
468516
# In[0] : Vertex Color -> Out[1]
469517
# In[1] : Comp Texture -> Out[0]
470518
# In[2] : Detail Comp Texture -> Out[0]
471519
blendCompMapNode = self.addNode(
472520
name = MSFS_ShaderNodes.blendCompMap.value,
473-
typeNode = MSFS_ShaderNodesTypes.shaderNodeMixRGB.value,
474-
blend_type = "MULTIPLY",
521+
typeNode = MSFS_ShaderNodesTypes.shaderNodeVectorMath.value,
522+
operation = "ADD",
475523
location = (-150.0, 200.0),
476524
width = 300.0,
477525
frame = omrFrame
478-
)
479-
blendCompMapNode.inputs[0].default_value = 1.0
526+
)
480527

481528
## Links
482-
self.link(blendCompMapNode.inputs[0], vertexColorNode.outputs[1])
483-
self.link(blendCompMapNode.inputs[1], compTexNode.outputs[0])
484-
self.link(blendCompMapNode.inputs[2], detailCompTexNode.outputs[0])
529+
self.link(compTexNode.outputs[0], blendCompMapNode.inputs[0])
530+
self.link(clampDetailOMR.outputs[1], blendCompMapNode.inputs[1])
485531

486532
## Split Occlusion Metallic Roughness
487533
# In[0] : Blend Comp Map -> Out[0]
@@ -554,7 +600,7 @@ def defaultShadersTree(self):
554600
name = MSFS_ShaderNodes.emissiveMul.value,
555601
typeNode = MSFS_ShaderNodesTypes.shaderNodeMixRGB.value,
556602
blend_type = "MULTIPLY",
557-
location = (200.0, 0.0),
603+
location = (250.0, -50.0),
558604
frame = emissiveFrame
559605
)
560606

@@ -868,11 +914,14 @@ def updateEmissiveLinks(self):
868914

869915
# emissive
870916
if nodeEmissiveTex.image:
871-
self.link(nodeEmissiveColor.outputs[0], nodeMulEmissive.inputs[0])
872-
self.link(nodeEmissiveTex.outputs[0], nodeMulEmissive.inputs[1])
917+
self.link(nodeEmissiveScale.outputs[0], nodeMulEmissive.inputs[0])
918+
self.link(nodeEmissiveColor.outputs[0], nodeMulEmissive.inputs[1])
919+
self.link(nodeEmissiveTex.outputs[0], nodeMulEmissive.inputs[2])
873920
self.link(nodeMulEmissive.outputs[0], nodePrincipledBSDF.inputs[MSFS_PrincipledBSDFInputs.emission.value])
874921
else:
875922
self.link(nodeEmissiveColor.outputs[0], nodePrincipledBSDF.inputs[MSFS_PrincipledBSDFInputs.emission.value])
923+
self.unLinkNodeInput(nodeMulEmissive, 0)
924+
self.unLinkNodeInput(nodeMulEmissive, 1)
876925

877926
self.link(nodeEmissiveScale.outputs[0], nodePrincipledBSDF.inputs[MSFS_PrincipledBSDFInputs.emissionStrength.value])
878927

@@ -888,11 +937,6 @@ def updateCompLinks(self):
888937
nodeGltfSettings = self.getNodeByName(MSFS_ShaderNodes.glTFSettings.value)
889938
nodePrincipledBSDF = self.getNodeByName(MSFS_ShaderNodes.principledBSDF.value)
890939

891-
# blend comp
892-
# !!!! input orders matters for the exporter here
893-
self.link(nodeCompTex.outputs[0], nodeBlendCompMap.inputs[1])
894-
self.link(nodeDetailCompTex.outputs[0], nodeBlendCompMap.inputs[2])
895-
896940
# occlMetalRough
897941
self.link(nodeBlendCompMap.outputs[0], nodeSeparateComp.inputs[0])
898942
self.link(nodeMetallicScale.outputs[0], nodeMulMetallic.inputs[0])
@@ -910,13 +954,6 @@ def updateCompLinks(self):
910954
self.link(nodeMulRoughness.outputs[0], nodePrincipledBSDF.inputs[MSFS_PrincipledBSDFInputs.roughness.value])
911955
self.link(nodeMulMetallic.outputs[0], nodePrincipledBSDF.inputs[MSFS_PrincipledBSDFInputs.metallic.value])
912956

913-
if nodeCompTex.image and nodeDetailCompTex.image:
914-
nodeBlendCompMap.blend_type = "MULTIPLY"
915-
else: # we have only one of the two images
916-
nodeBlendCompMap.blend_type = "ADD"
917-
918-
919-
920957
def setBlendMode(self, blendMode):
921958
if blendMode == "BLEND":
922959
self.makeAlphaBlend()
@@ -930,17 +967,14 @@ def setBlendMode(self, blendMode):
930967
def toggleVertexBlendMapMask(self, useVertex=True):
931968
nodeVertexColor = self.getNodeByName(MSFS_ShaderNodes.vertexColor.value)
932969
nodeBlendColorMap = self.getNodeByName(MSFS_ShaderNodes.blendColorMap.value)
933-
nodeBlendCompMap = self.getNodeByName(MSFS_ShaderNodes.blendCompMap.value)
934970
nodeBlendNormalMap = self.getNodeByName(MSFS_ShaderNodes.blendNormalMap.value)
935971
nodeBlendMaskTex = self.getNodeByName(MSFS_ShaderNodes.blendMaskTex.value)
936972
# vertexcolor mask
937973
if useVertex:
938974
self.link(nodeVertexColor.outputs[1], nodeBlendColorMap.inputs[0])
939-
self.link(nodeVertexColor.outputs[1], nodeBlendCompMap.inputs[0])
940975
self.link(nodeVertexColor.outputs[1], nodeBlendNormalMap.inputs[0])
941976
else:
942977
self.link(nodeBlendMaskTex.outputs[0], nodeBlendColorMap.inputs[0])
943-
self.link(nodeBlendMaskTex.outputs[0], nodeBlendCompMap.inputs[0])
944978
self.link(nodeBlendMaskTex.outputs[0], nodeBlendNormalMap.inputs[0])
945979

946980
def makeOpaque(self):

addons/io_scene_gltf2_msfs/blender/msfs_material_prop_update.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def update_msfs_material_type(self, context):
136136
def reset_material_prop_object(self):
137137
self.msfs_alpha_cutoff = 0.5
138138
self.msfs_base_color_blend_factor = 1.0
139-
self.msfs_base_color_factor = [0.8, 0.8, 0.8, 1.0]
139+
self.msfs_base_color_factor = [1.0, 1.0, 1.0, 1.0]
140140
self.msfs_base_color_texture = None
141141
self.msfs_blend_mask_texture = None
142142
self.msfs_clamp_uv_x = False
@@ -188,7 +188,7 @@ def reset_material_prop_object(self):
188188
self.msfs_road_collision_material = False
189189
self.msfs_roughness_blend_factor = 1.0
190190
self.msfs_roughness_factor = 1.0
191-
self.msfs_sss_color = [0.8, 0.8, 0.8, 1.0]
191+
self.msfs_sss_color = [1.0, 1.0, 1.0, 1.0]
192192
self.msfs_use_pearl = False
193193
self.msfs_uv_offset_u = 0.0
194194
self.msfs_uv_offset_v = 0.0
@@ -199,6 +199,7 @@ def reset_material_prop_object(self):
199199
self.msfs_wiper_2_state = 0.0
200200
self.msfs_wiper_3_state = 0.0
201201
self.msfs_wiper_4_state = 0.0
202+
self.msfs_alpha_mode = "OPAQUE"
202203
return
203204

204205
@staticmethod

addons/io_scene_gltf2_msfs/blender/ui_properties.py

Lines changed: 1 addition & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,6 @@
1414

1515
import bpy
1616

17-
# from .func_properties import *
18-
19-
# class MSFS_UL_ObjectBehaviorListItem(bpy.types.UIList):
20-
# bl_idname = "MSFS_UL_object_behaviorListItem"
21-
# def draw_item(self, context, layout, data, item, icon, active_data, active_propname):
22-
# split = layout.split(factor=0.65)
23-
# split.label(text=item.name)
24-
# split.label(text="(kf:%i-%i)"%(item.kf_start,item.kf_end))
2517

2618
class MSFS_PT_BoneProperties(bpy.types.Panel):
2719
bl_label = "MSFS Properties"
@@ -91,32 +83,10 @@ def draw(self, context):
9183
elif active_object.type == 'EMPTY':
9284
box = layout.box()
9385
box.label(text="MSFS Collision Parameters", icon='SHADING_BBOX')
94-
box.prop(active_object, "msfs_gizmo_type") # TODO: change to msfs_msfs_gizmo_type
86+
box.prop(active_object, "msfs_gizmo_type")
9587
if active_object.msfs_gizmo_type != "NONE":
9688
box.prop(active_object, "msfs_collision_is_road_collider")
9789

98-
99-
100-
101-
#if bpy.context.active_object.type == 'ARMATURE':
102-
# box=layout.box()
103-
# box.label(text = "Behavior tags are stored in individual bones.", icon = 'ANIM')
104-
#else:
105-
# box=layout.box()
106-
# box.label(text = "Behavior list", icon = 'ANIM')
107-
# box.template_list('OBJECTBEHAVIOR_UL_listItem', "", context.object, 'msfs_behavior', context.object, 'msfs_active_behavior')
108-
109-
# if len(context.object.msfs_behavior) > context.object.msfs_active_behavior:
110-
# behavior = context.object.msfs_behavior[context.object.msfs_active_behavior]
111-
112-
# subbox=box.box()
113-
# subbox.label(text=behavior.name,icon='OUTLINER_DATA_GP_LAYER')
114-
# if behavior.source_file != "":
115-
# subbox.label(text="XML: %s"%behavior.source_filename,icon='FILE')
116-
# split=subbox.split(factor=0.75)
117-
# split.label(text="Keyframes start: %i"%behavior.kf_start,icon='DECORATE_KEYFRAME')
118-
# split.label(text="end: %i"%behavior.kf_end)
119-
# subbox.operator('msfs.behavior_remove_selected_from_object',text="Remove selected behavior",icon='TRASH')
12090

12191

12292

0 commit comments

Comments
 (0)