Skip to content

Commit 228fda5

Browse files
authored
Merge pull request #349 from AsoboStudio/update_to_blender_4_5
Update to blender 4 5
2 parents a4286f3 + bd6890e commit 228fda5

File tree

12 files changed

+260
-128
lines changed

12 files changed

+260
-128
lines changed

README.md

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,21 @@
44

55
This repository contains the current version of the official Microsoft Flight Simulator 2020 Blender Import/Export plugin. The flight sim community has already developed and forked the original project many times, and Asobo's intention is to fully support Blender with the help and contributions of all the developers that have already implemented features in the different unofficial Blender plugins.
66

7-
>Asobo would especially like to thank the following people: <br>
8-
>Vitus of [Wing42](https://wing42.com/), [tml1024](https://github.com/tml1024), [ronh991](https://github.com/ronh991), [pepperoni505](https://github.com/pepperoni505) of [FlyByWire](https://flybywiresim.com/)
7+
> Asobo would especially like to thank the following people: <br>
8+
> Vitus of [Wing42](https://wing42.com/), [tml1024](https://github.com/tml1024), [ronh991](https://github.com/ronh991), [pepperoni505](https://github.com/pepperoni505) of [FlyByWire](https://flybywiresim.com/)
99
10-
:warning: This plugin cannot import glTF files that have been built into a Microsoft Flight Simulator 2020 package through the Sim's Package Builder.
11-
<br>
12-
13-
:warning: This plugin is NOT compatible with the legacy exporter developed for FSX and P3D. Remove these plugin (Prefered) or disabled these plugins.
14-
<br>
10+
> [!WARNING]
11+
>- This addon cannot import glTF files that have been built into a Microsoft Flight Simulator 2020 package through the Sim's Package Builder.
12+
>- This addon is **NOT compatible** with the legacy exporter developed for FSX and P3D. Remove these plugin (Prefered) or disabled these plugins.
13+
>- This addon need to have the `Import-Export: gltf 2.0 format` addon (gltf2 Khronos Blender IO) **enabled** to work. Do not remove it or disable it !
1514
16-
:warning: The latest version of this addon is compatible with Blender **3.3.x LTS**, **3.6.x LTS** and **4.2.x LTS** only. We can't guarantee not having bugs with other unstable versions
15+
> [!IMPORTANT]
16+
> Supported blender versions of the latest version of the addon (We can't guarantee not having bugs with other unstable versions):
17+
> - **3.3.x LTS**
18+
> - **3.6.x LTS**
19+
> - **4.2.x LTS**
20+
> - **4.5.x LTS**
1721
18-
:warning: This addon need to have the `Import-Export: gltf 2.0 format` addon (gltf2 Khronos IO) **enabled** to work. Do not remove it or disable it !
1922

2023
*******
2124

addons/io_scene_gltf2_msfs_2020/__init__.py

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424
"author": "Asobo Studio",
2525
"description": "This toolkit prepares your 3D assets to be used for Microsoft Flight Simulator 2020",
2626
"blender": (3, 3, 0),
27-
"version": (2, 3, 2),
27+
"version": (3, 3, 0),
2828
"location": "File > Import-Export",
2929
"category": "Import-Export",
3030
"tracker_url": "https://github.com/AsoboStudio/glTF-Blender-IO-MSFS-2020",
@@ -243,6 +243,12 @@ def register():
243243
bpy.types.Scene.msfs_exporter_settings = bpy.props.PointerProperty(
244244
type=MSFS2020_ExporterProperties
245245
)
246+
247+
if bpy.app.version >= (4, 5, 0):
248+
# This is used to add a panel in the Khronos export view
249+
# Use the following 2 lines to register the UI for this hook
250+
from io_scene_gltf2 import exporter_extension_layout_draw
251+
exporter_extension_layout_draw['Example glTF Extension'] = draw_export
246252

247253
def unregister():
248254
try:
@@ -265,7 +271,12 @@ def unregister():
265271
for module in modules:
266272
if hasattr(module, "unregister"):
267273
module.unregister()
268-
274+
275+
if bpy.app.version >= (4, 5, 0):
276+
# Use the following 2 lines to unregister the UI for this hook
277+
from io_scene_gltf2 import exporter_extension_layout_draw
278+
del exporter_extension_layout_draw['Example glTF Extension']
279+
269280
extension_panels = []
270281
if bpy.app.version < (4, 2, 0):
271282
extension_panels = [
@@ -310,8 +321,8 @@ def unregister_panel():
310321

311322

312323
class glTF2ImportUserExtension(Import):
313-
def __init__(self):
314-
super().__init__()
324+
def __init__(self, *args, **kwargs):
325+
super().__init__(*args, **kwargs)
315326

316327

317328
# endregion
@@ -322,8 +333,8 @@ def __init__(self):
322333

323334

324335
class glTF2ExportUserExtension(Export):
325-
def __init__(self):
326-
super().__init__()
336+
def __init__(self, *args, **kwargs):
337+
super().__init__(*args, **kwargs)
327338

328339

329340
# endregion

addons/io_scene_gltf2_msfs_2020/blender/gizmo.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,8 +95,8 @@ class MSFS2020CollisionGizmo(bpy.types.Gizmo):
9595
"custom_shape_edges",
9696
)
9797

98-
def __init__(self):
99-
super().__init__()
98+
def __init__(self, *args):
99+
super().__init__(*args)
100100
self.custom_shape_edges = None
101101
self.custom_shape = None
102102

addons/io_scene_gltf2_msfs_2020/blender/msfs_material_panel.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ class MSFS2020_OT_MigrateMaterialData(bpy.types.Operator):
6161
"msfs_anisotropic_direction_texture": "msfs_extra_slot1_texture",
6262
"msfs_clearcoat_texture": "msfs_dirt_texture",
6363
"msfs_behind_glass_texture": "msfs_detail_color_texture",
64+
"msfs_comp_texture": "msfs_occlusion_metallic_roughness_texture",
6465
}
6566

6667
@staticmethod

addons/io_scene_gltf2_msfs_2020/blender/msfs_material_prop_update.py

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -204,43 +204,64 @@ def reset_material_prop_object(self):
204204
@staticmethod
205205
def update_base_color_texture(self, context):
206206
material = MSFS2020_Material_Property_Update.getMaterial(self)
207-
if material is not None and type(material) is not MSFS2020_Invisible:
207+
if (
208+
material is not None
209+
and type(material) not in (MSFS2020_Invisible, MSFS2020_Environment_Occluder)
210+
):
208211
material.setBaseColorTex(self.msfs_base_color_texture)
209212

210213
@staticmethod
211214
def update_comp_texture(self, context):
212215
material = MSFS2020_Material_Property_Update.getMaterial(self)
213-
if material is not None and type(material) is not MSFS2020_Invisible:
216+
if (
217+
material is not None
218+
and type(material) not in (MSFS2020_Invisible, MSFS2020_Environment_Occluder)
219+
):
214220
material.setCompTex(self.msfs_occlusion_metallic_roughness_texture)
215221

216222
@staticmethod
217223
def update_normal_texture(self, context):
218224
material = MSFS2020_Material_Property_Update.getMaterial(self)
219-
if material is not None and type(material) is not MSFS2020_Invisible:
225+
if (
226+
material is not None
227+
and type(material) not in (MSFS2020_Invisible, MSFS2020_Environment_Occluder)
228+
):
220229
material.setNormalTex(self.msfs_normal_texture)
221230

222231
@staticmethod
223232
def update_emissive_texture(self, context):
224233
material = MSFS2020_Material_Property_Update.getMaterial(self)
225-
if material is not None and type(material) is not MSFS2020_Invisible:
234+
if (
235+
material is not None
236+
and type(material) not in (MSFS2020_Invisible, MSFS2020_Environment_Occluder)
237+
):
226238
material.setEmissiveTexture(self.msfs_emissive_texture)
227239

228240
@staticmethod
229241
def update_detail_color_texture(self, context):
230242
material = MSFS2020_Material_Property_Update.getMaterial(self)
231-
if material is not None and type(material) is not MSFS2020_Invisible:
243+
if (
244+
material is not None
245+
and type(material) not in (MSFS2020_Invisible, MSFS2020_Environment_Occluder)
246+
):
232247
material.setDetailColorTex(self.msfs_detail_color_texture)
233248

234249
@staticmethod
235250
def update_detail_comp_texture(self, context):
236251
material = MSFS2020_Material_Property_Update.getMaterial(self)
237-
if material is not None and type(material) is not MSFS2020_Invisible:
252+
if (
253+
material is not None
254+
and type(material) not in (MSFS2020_Invisible, MSFS2020_Environment_Occluder)
255+
):
238256
material.setDetailCompTex(self.msfs_detail_occlusion_metallic_roughness_texture)
239257

240258
@staticmethod
241259
def update_detail_normal_texture(self, context):
242260
material = MSFS2020_Material_Property_Update.getMaterial(self)
243-
if material is not None and type(material) is not MSFS2020_Invisible:
261+
if (
262+
material is not None
263+
and type(material) not in (MSFS2020_Invisible, MSFS2020_Environment_Occluder)
264+
):
244265
material.setDetailNormalTex(self.msfs_detail_normal_texture)
245266

246267
@staticmethod

addons/io_scene_gltf2_msfs_2020/com/msfs_material_props.py

Lines changed: 59 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,68 +1068,72 @@ def to_extension(blender_material, gltf2_material, export_settings):
10681068
hasTexture = False
10691069
result = {}
10701070
if (
1071-
blender_material.msfs_material_type not in (
1071+
blender_material.msfs_material_type in (
10721072
"NONE",
10731073
"msfs_parallax",
10741074
"msfs_invisible",
10751075
"msfs_environment_occluder",
1076+
"msfs_sss",
1077+
"msfs_hair",
1078+
"msfs_fresnel_fade",
10761079
)
10771080
):
1081+
return
10781082

1079-
if blender_material.msfs_detail_color_texture is not None:
1080-
result["detailColorTexture"] = MSFS2020_Material_IO.export_image(
1081-
blender_material,
1082-
blender_material.msfs_detail_color_texture,
1083-
"DEFAULT",
1084-
export_settings,
1085-
)
1086-
hasTexture = True
1087-
1088-
if blender_material.msfs_detail_normal_texture is not None:
1089-
result["detailNormalTexture"] = MSFS2020_Material_IO.export_image(
1090-
blender_material,
1091-
blender_material.msfs_detail_normal_texture,
1092-
"NORMAL",
1093-
export_settings,
1094-
)
1095-
hasTexture = True
1096-
result["detailNormalTexture"].scale = blender_material.msfs_detail_normal_scale
1097-
1098-
if blender_material.msfs_detail_occlusion_metallic_roughness_texture is not None:
1099-
result["detailMetalRoughAOTexture"] = MSFS2020_Material_IO.export_image(
1100-
blender_material,
1101-
blender_material.msfs_detail_occlusion_metallic_roughness_texture,
1102-
"DEFAULT",
1103-
export_settings,
1104-
)
1105-
hasTexture = True
1106-
1107-
if blender_material.msfs_blend_mask_texture is not None:
1108-
result["blendMaskTexture"] = MSFS2020_Material_IO.export_image(
1109-
blender_material,
1110-
blender_material.msfs_blend_mask_texture,
1111-
"DEFAULT",
1112-
export_settings,
1113-
)
1114-
hasTexture = True
1115-
1116-
if hasTexture:
1117-
if blender_material.msfs_detail_uv_scale != AsoboMaterialDetail.Defaults.UVScale:
1118-
result["UVScale"] = blender_material.msfs_detail_uv_scale
1119-
if blender_material.msfs_detail_blend_threshold != AsoboMaterialDetail.Defaults.blendThreshold:
1120-
result["blendThreshold"] = blender_material.msfs_detail_blend_threshold
1121-
if (
1122-
blender_material.msfs_detail_uv_offset_u != AsoboMaterialDetail.Defaults.UVOffset[0]
1123-
or blender_material.msfs_detail_uv_offset_v != AsoboMaterialDetail.Defaults.UVOffset[1]
1124-
):
1125-
result["UVOffset"] = (blender_material.msfs_detail_uv_offset_u, blender_material.msfs_detail_uv_offset_v)
1126-
1127-
if result:
1128-
gltf2_material.extensions[AsoboMaterialDetail.SerializedName] = Extension(
1129-
name=AsoboMaterialDetail.SerializedName,
1130-
extension=result,
1131-
required=False,
1132-
)
1083+
if blender_material.msfs_detail_color_texture is not None:
1084+
result["detailColorTexture"] = MSFS2020_Material_IO.export_image(
1085+
blender_material,
1086+
blender_material.msfs_detail_color_texture,
1087+
"DEFAULT",
1088+
export_settings,
1089+
)
1090+
hasTexture = True
1091+
1092+
if blender_material.msfs_detail_normal_texture is not None:
1093+
result["detailNormalTexture"] = MSFS2020_Material_IO.export_image(
1094+
blender_material,
1095+
blender_material.msfs_detail_normal_texture,
1096+
"NORMAL",
1097+
export_settings,
1098+
)
1099+
hasTexture = True
1100+
result["detailNormalTexture"].scale = blender_material.msfs_detail_normal_scale
1101+
1102+
if blender_material.msfs_detail_occlusion_metallic_roughness_texture is not None:
1103+
result["detailMetalRoughAOTexture"] = MSFS2020_Material_IO.export_image(
1104+
blender_material,
1105+
blender_material.msfs_detail_occlusion_metallic_roughness_texture,
1106+
"DEFAULT",
1107+
export_settings,
1108+
)
1109+
hasTexture = True
1110+
1111+
if blender_material.msfs_blend_mask_texture is not None:
1112+
result["blendMaskTexture"] = MSFS2020_Material_IO.export_image(
1113+
blender_material,
1114+
blender_material.msfs_blend_mask_texture,
1115+
"DEFAULT",
1116+
export_settings,
1117+
)
1118+
hasTexture = True
1119+
1120+
if hasTexture:
1121+
if blender_material.msfs_detail_uv_scale != AsoboMaterialDetail.Defaults.UVScale:
1122+
result["UVScale"] = blender_material.msfs_detail_uv_scale
1123+
if blender_material.msfs_detail_blend_threshold != AsoboMaterialDetail.Defaults.blendThreshold:
1124+
result["blendThreshold"] = blender_material.msfs_detail_blend_threshold
1125+
if (
1126+
blender_material.msfs_detail_uv_offset_u != AsoboMaterialDetail.Defaults.UVOffset[0]
1127+
or blender_material.msfs_detail_uv_offset_v != AsoboMaterialDetail.Defaults.UVOffset[1]
1128+
):
1129+
result["UVOffset"] = (blender_material.msfs_detail_uv_offset_u, blender_material.msfs_detail_uv_offset_v)
1130+
1131+
if result:
1132+
gltf2_material.extensions[AsoboMaterialDetail.SerializedName] = Extension(
1133+
name=AsoboMaterialDetail.SerializedName,
1134+
extension=result,
1135+
required=False,
1136+
)
11331137

11341138

11351139
class AsoboMaterialFakeTerrain:

addons/io_scene_gltf2_msfs_2020/io/msfs_export.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,3 +135,6 @@ def gather_material_hook(
135135

136136
if "KHR_materials_clearcoat" in gltf2_material.extensions:
137137
gltf2_material.extensions.pop("KHR_materials_clearcoat", None)
138+
139+
if "KHR_materials_anisotropy" in gltf2_material.extensions:
140+
gltf2_material.extensions.pop("KHR_materials_anisotropy", None)

addons/io_scene_gltf2_msfs_2020/io/msfs_material.py

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,33 @@
1515
import bpy
1616
import os
1717

18-
if bpy.app.version >= (4, 2, 0):
19-
from io_scene_gltf2.blender.exp.material.gltf2_blender_search_node_tree import (
18+
if bpy.app.version >= (4, 5, 0):
19+
from io_scene_gltf2.blender.imp.image import BlenderImage
20+
from io_scene_gltf2.blender.exp.material.search_node_tree import (
2021
NodeSocket
2122
)
22-
23-
if bpy.app.version >= (3, 6, 0):
24-
from io_scene_gltf2.blender.exp.material.gltf2_blender_gather_texture_info import (
23+
from io_scene_gltf2.blender.exp.material.texture_info import (
2524
gather_material_normal_texture_info_class,
2625
gather_texture_info
2726
)
2827
else:
29-
from io_scene_gltf2.blender.exp.gltf2_blender_gather_texture_info import (
30-
gather_material_normal_texture_info_class,
31-
gather_texture_info
32-
)
28+
from io_scene_gltf2.blender.imp.gltf2_blender_image import BlenderImage
3329

34-
from io_scene_gltf2.blender.imp.gltf2_blender_image import BlenderImage
30+
if bpy.app.version >= (4, 2, 0):
31+
from io_scene_gltf2.blender.exp.material.gltf2_blender_search_node_tree import (
32+
NodeSocket
33+
)
34+
35+
if bpy.app.version >= (3, 6, 0):
36+
from io_scene_gltf2.blender.exp.material.gltf2_blender_gather_texture_info import (
37+
gather_material_normal_texture_info_class,
38+
gather_texture_info
39+
)
40+
else:
41+
from io_scene_gltf2.blender.exp.gltf2_blender_gather_texture_info import (
42+
gather_material_normal_texture_info_class,
43+
gather_texture_info
44+
)
3545

3646
from ..com import msfs_material_props as MSFS2020_MaterialExtensions
3747

0 commit comments

Comments
 (0)