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
12 changes: 12 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
# Version History

## v0.7.4

* adapt to API changes in Blender 5.2
* the add-on can now be installed as an extension (Blender 4.2+), the release archive works for both
the extension and the legacy add-on install
* replaced deprecated API usage: `Material.blend_method` -> `Material.surface_render_method`,
`Material.show_transparent_back` -> `Material.use_transparency_overlap`, `Material.use_nodes`,
`Mesh.vertex_colors` -> `Mesh.color_attributes` and `MeshUVLoopLayer.data` -> `MeshUVLoopLayer.uv`
* transparency of imported materials is applied again in EEVEE Next (Blender 4.2+)
* Bugfix: import no longer fails on Blender 4.1 (`Mesh.use_auto_smooth` was removed there, not in 4.2)
* Bugfix: do not rely on the deprecated truth value of xml elements when writing w3x files

## v0.7.3

* adapt to API changes in Blender 5.1+
Expand Down
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ format used in Command & Conquer™: Generals and other RTS titles from Westwood

Please see [Installing the plugin](https://github.com/OpenSAGE/OpenSAGE.BlenderPlugin/wiki/Installing-the-Plugin)

Supported Blender versions are 2.93 up to 5.2. On Blender 4.2 and newer the released `io_mesh_w3d.zip`
can be dropped into Blender to install it as an extension, older versions install it as a legacy add-on
via *Edit > Preferences > Add-ons > Install*.

## Setting up for development

Please see [Setting up for development](https://github.com/OpenSAGE/OpenSAGE.BlenderPlugin/wiki/Development-Setup)
Expand Down
66 changes: 44 additions & 22 deletions io_mesh_w3d/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,25 @@
import bpy
from bpy.types import Panel
from bpy_extras.io_utils import ImportHelper, ExportHelper
from io_mesh_w3d.utils import ReportHelper
from io_mesh_w3d.export_utils import save_data
from io_mesh_w3d.custom_properties import *
from io_mesh_w3d.geometry_export import *
from io_mesh_w3d.bone_volume_export import *
from .utils import ReportHelper
from .export_utils import save_data
from .custom_properties import *
from .geometry_export import *
from .bone_volume_export import *

from io_mesh_w3d.blender_addon_updater import addon_updater_ops
from .blender_addon_updater import addon_updater_ops

VERSION = (0, 7, 3)
VERSION = (0, 7, 4)

# add-ons installed through the extension system (Blender 4.2+) live in the
# 'bl_ext' package and are kept up to date by Blender itself
IS_EXTENSION = (__package__ or '').startswith('bl_ext.')

# 'bl_info' is only used for legacy installs, extensions are described by 'blender_manifest.toml'
bl_info = {
'name': 'Import/Export Westwood W3D Format (.w3d/.w3x)',
'author': 'OpenSage Developers',
'version': (0, 7, 3),
'version': (0, 7, 4),
"blender": (2, 90, 0),
'location': 'File > Import/Export > Westwood W3D (.w3d/.w3x)',
'description': 'Import or Export the Westwood W3D-Format (.w3d/.w3x)',
Expand Down Expand Up @@ -298,7 +303,11 @@ def draw(self, context):
col = layout.column()
col.prop(mat, 'surface_type')
col = layout.column()
col.prop(mat, 'blend_method')
# 'blend_method' is deprecated since Blender 4.2, EEVEE Next uses 'surface_render_method'
if bpy.app.version < (4, 2, 0):
col.prop(mat, 'blend_method')
else:
col.prop(mat, 'surface_render_method')
col = layout.column()
col.prop(mat, 'ambient')

Expand Down Expand Up @@ -509,35 +518,48 @@ def draw(self, context):
MATERIAL_PROPERTIES_PANEL_PT_w3d,
ExportGeometryData,
ExportBoneVolumeData,
TOOLS_PANEL_PT_w3d,
TOOLS_PANEL_PT_w3d
)

# the bundled updater would overwrite the add-on behind Blender's back,
# extensions are updated through their repository instead
UPDATER_CLASSES = (
DemoPreferences,
OBJECT_PT_DemoUpdaterPanel
)


def register():
addon_updater_ops._package = 'io_mesh_w3d'
addon_updater_ops.updater.addon = 'io_mesh_w3d'
addon_updater_ops.updater.user = "OpenSAGE"
addon_updater_ops.updater.repo = "OpenSAGE.BlenderPlugin"
addon_updater_ops.updater.website = "https://github.com/OpenSAGE/OpenSAGE.BlenderPlugin"
addon_updater_ops.updater.subfolder_path = "io_mesh_w3d"
addon_updater_ops.updater.include_branch_list = ['master']
addon_updater_ops.updater.verbose = False

addon_updater_ops.register(bl_info)

for class_ in CLASSES:
bpy.utils.register_class(class_)

if not IS_EXTENSION:
addon_updater_ops._package = 'io_mesh_w3d'
addon_updater_ops.updater.addon = 'io_mesh_w3d'
addon_updater_ops.updater.user = "OpenSAGE"
addon_updater_ops.updater.repo = "OpenSAGE.BlenderPlugin"
addon_updater_ops.updater.website = "https://github.com/OpenSAGE/OpenSAGE.BlenderPlugin"
addon_updater_ops.updater.subfolder_path = "io_mesh_w3d"
addon_updater_ops.updater.include_branch_list = ['master']
addon_updater_ops.updater.verbose = False

addon_updater_ops.register(bl_info)

for class_ in UPDATER_CLASSES:
bpy.utils.register_class(class_)

Material.shader = PointerProperty(type=ShaderProperties)

bpy.types.TOPBAR_MT_file_import.append(menu_func_import)
bpy.types.TOPBAR_MT_file_export.append(menu_func_export)


def unregister():
addon_updater_ops.unregister()
if not IS_EXTENSION:
addon_updater_ops.unregister()

for class_ in reversed(UPDATER_CLASSES):
bpy.utils.unregister_class(class_)

for class_ in reversed(CLASSES):
bpy.utils.unregister_class(class_)
Expand Down
36 changes: 36 additions & 0 deletions io_mesh_w3d/blender_manifest.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
schema_version = "1.0.0"

id = "io_mesh_w3d"
version = "0.7.4"
name = "Import/Export Westwood W3D Format (.w3d/.w3x)"
tagline = "Import or export the Westwood W3D format used by SAGE games"
maintainer = "OpenSage Developers <https://github.com/OpenSAGE>"
type = "add-on"

website = "https://github.com/OpenSAGE/OpenSAGE.BlenderPlugin"

tags = ["Import-Export"]

# The extension system was introduced in Blender 4.2, older versions install
# this add-on through the legacy 'bl_info' path instead.
blender_version_min = "4.2.0"

license = [
"SPDX:LGPL-3.0-or-later",
]

[permissions]
files = "Import and export W3D/W3X models, animations and textures"
network = "Check github for new releases of this add-on"

[build]
paths_exclude_pattern = [
"__pycache__/",
"/.git/",
"/*.zip",
"/blender_addon_updater/.git/",
"/blender_addon_updater/tests/",
"/blender_addon_updater/images/",
"*_updater_status.json",
"/blender_addon_updater/io_mesh_w3d.blender_addon_updater_updater/",
]
6 changes: 3 additions & 3 deletions io_mesh_w3d/bone_volume_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
# Written by Stephan Vedder and Michael Schnabel

import bpy
from io_mesh_w3d.utils import ReportHelper
from .utils import ReportHelper
from bpy_extras.io_utils import ExportHelper
from io_mesh_w3d.w3x.io_xml import *
from io_mesh_w3d.common.utils.helpers import *
from .w3x.io_xml import *
from .common.utils.helpers import *


def format_str(value):
Expand Down
6 changes: 3 additions & 3 deletions io_mesh_w3d/common/structs/animation.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# <pep8 compliant>
# Written by Stephan Vedder and Michael Schnabel

from io_mesh_w3d.w3d.structs.version import Version
from io_mesh_w3d.w3d.utils.helpers import *
from io_mesh_w3d.w3x.io_xml import *
from ...w3d.structs.version import Version
from ...w3d.utils.helpers import *
from ...w3x.io_xml import *

W3D_CHUNK_ANIMATION_HEADER = 0x00000201

Expand Down
8 changes: 4 additions & 4 deletions io_mesh_w3d/common/structs/collision_box.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
# Written by Stephan Vedder and Michael Schnabel

from mathutils import Vector
from io_mesh_w3d.common.structs.rgba import RGBA
from io_mesh_w3d.w3d.utils.helpers import *
from io_mesh_w3d.w3d.structs.version import Version
from io_mesh_w3d.w3x.io_xml import *
from ...common.structs.rgba import RGBA
from ...w3d.utils.helpers import *
from ...w3d.structs.version import Version
from ...w3x.io_xml import *

W3D_CHUNK_BOX = 0x00000740
ATTRIBUTE_MASK = 0xF
Expand Down
6 changes: 3 additions & 3 deletions io_mesh_w3d/common/structs/hierarchy.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
# Written by Stephan Vedder and Michael Schnabel

from mathutils import Vector, Quaternion, Matrix
from io_mesh_w3d.w3d.structs.version import Version
from io_mesh_w3d.w3d.utils.helpers import *
from io_mesh_w3d.w3x.io_xml import *
from ...w3d.structs.version import Version
from ...w3d.utils.helpers import *
from ...w3x.io_xml import *

W3D_CHUNK_HIERARCHY_HEADER = 0x00000101

Expand Down
6 changes: 3 additions & 3 deletions io_mesh_w3d/common/structs/hlod.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
# <pep8 compliant>
# Written by Stephan Vedder and Michael Schnabel

from io_mesh_w3d.w3d.structs.version import Version
from io_mesh_w3d.w3d.utils.helpers import *
from io_mesh_w3d.w3x.io_xml import *
from ...w3d.structs.version import Version
from ...w3d.utils.helpers import *
from ...w3x.io_xml import *

W3D_CHUNK_HLOD_HEADER = 0x00000701

Expand Down
16 changes: 8 additions & 8 deletions io_mesh_w3d/common/structs/mesh.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
# Written by Stephan Vedder and Michael Schnabel

from mathutils import Vector
from io_mesh_w3d.common.structs.mesh_structs.aabbtree import *
from io_mesh_w3d.common.structs.mesh_structs.shader_material import *
from io_mesh_w3d.common.structs.mesh_structs.triangle import *
from io_mesh_w3d.common.structs.mesh_structs.vertex_influence import *
from io_mesh_w3d.w3d.structs.mesh_structs.prelit import *
from io_mesh_w3d.w3d.structs.version import Version
from io_mesh_w3d.w3x.structs.mesh_structs.bounding_box import *
from io_mesh_w3d.w3x.structs.mesh_structs.bounding_sphere import *
from ...common.structs.mesh_structs.aabbtree import *
from ...common.structs.mesh_structs.shader_material import *
from ...common.structs.mesh_structs.triangle import *
from ...common.structs.mesh_structs.vertex_influence import *
from ...w3d.structs.mesh_structs.prelit import *
from ...w3d.structs.version import Version
from ...w3x.structs.mesh_structs.bounding_box import *
from ...w3x.structs.mesh_structs.bounding_sphere import *

W3D_CHUNK_MESH_HEADER = 0x0000001F

Expand Down
6 changes: 3 additions & 3 deletions io_mesh_w3d/common/structs/mesh_structs/aabbtree.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
# Written by Stephan Vedder and Michael Schnabel

from mathutils import Vector
from io_mesh_w3d.w3d.utils.helpers import *
from io_mesh_w3d.w3d.io_binary import *
from io_mesh_w3d.w3x.io_xml import *
from ....w3d.utils.helpers import *
from ....w3d.io_binary import *
from ....w3x.io_xml import *

W3D_CHUNK_AABBTREE_HEADER = 0x00000091

Expand Down
4 changes: 2 additions & 2 deletions io_mesh_w3d/common/structs/mesh_structs/shader_material.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# Written by Stephan Vedder and Michael Schnabel

from mathutils import Vector
from io_mesh_w3d.w3d.utils.helpers import *
from io_mesh_w3d.w3x.io_xml import *
from ....w3d.utils.helpers import *
from ....w3x.io_xml import *

W3D_CHUNK_SHADER_MATERIAL_HEADER = 0x52

Expand Down
4 changes: 2 additions & 2 deletions io_mesh_w3d/common/structs/mesh_structs/texture.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# <pep8 compliant>
# Written by Stephan Vedder and Michael Schnabel

from io_mesh_w3d.w3d.utils.helpers import *
from io_mesh_w3d.w3x.io_xml import *
from ....w3d.utils.helpers import *
from ....w3x.io_xml import *

W3D_CHUNK_TEXTURES = 0x00000030
W3D_CHUNK_TEXTURE_INFO = 0x00000033
Expand Down
4 changes: 2 additions & 2 deletions io_mesh_w3d/common/structs/mesh_structs/triangle.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# Written by Stephan Vedder and Michael Schnabel

from mathutils import Vector
from io_mesh_w3d.w3d.io_binary import *
from io_mesh_w3d.w3x.io_xml import *
from ....w3d.io_binary import *
from ....w3x.io_xml import *


surface_types = [
Expand Down
4 changes: 2 additions & 2 deletions io_mesh_w3d/common/structs/mesh_structs/vertex_influence.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# <pep8 compliant>
# Written by Stephan Vedder and Michael Schnabel

from io_mesh_w3d.w3d.io_binary import *
from io_mesh_w3d.w3x.io_xml import *
from ....w3d.io_binary import *
from ....w3x.io_xml import *


class VertexInfluence:
Expand Down
4 changes: 2 additions & 2 deletions io_mesh_w3d/common/structs/rgba.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# <pep8 compliant>
# Written by Stephan Vedder and Michael Schnabel

from io_mesh_w3d.w3d.io_binary import *
from io_mesh_w3d.w3x.io_xml import *
from ...w3d.io_binary import *
from ...w3x.io_xml import *


class RGBA:
Expand Down
6 changes: 3 additions & 3 deletions io_mesh_w3d/common/utils/animation_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@

import bpy
from mathutils import Quaternion
from io_mesh_w3d.common.utils.helpers import *
from io_mesh_w3d.common.structs.animation import *
from io_mesh_w3d.w3d.structs.compressed_animation import *
from ...common.utils.helpers import *
from ...common.structs.animation import *
from ...w3d.structs.compressed_animation import *


def is_translation(channel_type):
Expand Down
6 changes: 3 additions & 3 deletions io_mesh_w3d/common/utils/animation_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
# Written by Stephan Vedder and Michael Schnabel

import bpy
from io_mesh_w3d.w3d.adaptive_delta import decode
from io_mesh_w3d.common.structs.animation import *
from io_mesh_w3d.w3d.structs.compressed_animation import *
from ...w3d.adaptive_delta import decode
from ...common.structs.animation import *
from ...w3d.structs.compressed_animation import *


def is_roottransform(channel):
Expand Down
4 changes: 2 additions & 2 deletions io_mesh_w3d/common/utils/box_export.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# <pep8 compliant>
# Written by Stephan Vedder and Michael Schnabel

from io_mesh_w3d.common.utils.helpers import *
from io_mesh_w3d.common.structs.collision_box import *
from ...common.utils.helpers import *
from ...common.structs.collision_box import *


def retrieve_boxes(container_name):
Expand Down
4 changes: 2 additions & 2 deletions io_mesh_w3d/common/utils/box_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# Written by Stephan Vedder and Michael Schnabel

import bpy
from io_mesh_w3d.common.utils.helpers import *
from io_mesh_w3d.common.structs.collision_box import *
from ...common.utils.helpers import *
from ...common.structs.collision_box import *


def create_box(box, coll):
Expand Down
Loading
Loading