Skip to content

Commit

Permalink
Merge pull request #378 from Candoran2/develop
Browse files Browse the repository at this point in the history
Bug fixes to zip generation, BSEffecShaderProperty export, and meshes parented to armature. Also game set on import.
  • Loading branch information
neomonkeus authored Aug 5, 2020
2 parents 38a43a5 + 408d023 commit 5fbd241
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 29 deletions.
2 changes: 1 addition & 1 deletion install/install.bat
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,6 @@ echo.Removing old installation
if exist "%BLENDER_ADDONS_DIR%\io_scene_nif" rmdir /s /q "%BLENDER_ADDONS_DIR%\io_scene_nif"

:: copy files from repository to blender addons folder
powershell -executionpolicy bypass -Command "%DIR%\unzip.ps1" -source '%DIR%\%ZIP_NAME%.zip' -destination '%BLENDER_ADDONS_DIR%\io_scene_nif'
powershell -executionpolicy bypass -Command "%DIR%\unzip.ps1" -source '%DIR%\%ZIP_NAME%.zip' -destination '%BLENDER_ADDONS_DIR%'

:end
6 changes: 0 additions & 6 deletions install/unzip.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,6 @@ param (
write ("Source : {0}" -f $source)
write ("Destination : {0}" -f $destination)

If(Test-path $destination) {
write ("Ensuring existing folder is removed {0}" -f $destination)
Remove-item $destination
write ("Success")
}

Add-Type -assembly "system.io.compression.filesystem"
[io.compression.zipFile]::ExtractToDirectory($source, $destination)

Expand Down
2 changes: 1 addition & 1 deletion install/zip.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ write ("Existing archive removed successfully")
}

Add-Type -assembly "system.io.compression.filesystem"
[io.compression.zipfile]::CreateFromDirectory($source, $destination)
[io.compression.zipfile]::CreateFromDirectory($source, $destination, 1, 1)
If(Test-path $destination) {
write("File successully written")
}
5 changes: 3 additions & 2 deletions io_scene_nif/modules/nif_export/object/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,14 +223,15 @@ def export_children(self, b_parent, n_parent):
"""Export all children of blender object b_parent as children of n_parent."""
# loop over all obj's children
for b_child in b_parent.children:
temp_parent = n_parent
# special case: objects parented to armature bones - find the nif parent bone
if b_parent.type == 'ARMATURE' and b_child.parent_bone != "":
parent_bone = b_parent.data.bones[b_child.parent_bone]
assert (parent_bone in block_store.block_to_obj.values())
for n_parent, obj in block_store.block_to_obj.items():
for temp_parent, obj in block_store.block_to_obj.items():
if obj == parent_bone:
break
self.export_node(b_child, n_parent)
self.export_node(b_child, temp_parent)

def export_collision(self, b_obj, n_parent):
"""Main function for adding collision object b_obj to a node.
Expand Down
3 changes: 2 additions & 1 deletion io_scene_nif/modules/nif_export/property/shader/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ def export_bs_effect_shader_property(self, b_mat):
bsshader.emissive_color.g = b_mat.niftools.emissive_color.g
bsshader.emissive_color.b = b_mat.niftools.emissive_color.b
bsshader.emissive_color.a = b_mat.niftools.emissive_alpha.v
bsshader.emissive_multiple = b_mat.emit
# TODO [shader] Expose a emission multiplier value
# bsshader.emissive_multiple = b_mat.emit

# Shader Flags
BSShaderProperty.export_shader_flags(b_mat, bsshader)
Expand Down
19 changes: 2 additions & 17 deletions io_scene_nif/modules/nif_export/scene/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,21 +42,6 @@
from io_scene_nif.utils.util_logging import NifLog
from pyffi.formats.nif import NifFormat

# TODO [scene] Use this as global import and export values and remove from operator
USER_VERSION = {
'OBLIVION': 11,
'FALLOUT_3': 11,
'SKYRIM': 12,
'DIVINITY_2': 131072
}

USER_VERSION_2 = {
'OBLIVION': 11,
'FALLOUT_3': 34,
'SKYRIM': 83
}


def get_version_data():
""" Returns NifFormat.Data of the correct version and user versions """
b_scene = bpy.context.scene.niftools_scene
Expand All @@ -65,7 +50,7 @@ def get_version_data():
NifLog.info("Writing NIF version 0x%08X" % version)

# get user version and user version 2 for export
user_version = b_scene.user_version if b_scene.user_version else USER_VERSION.get(game, 0)
user_version_2 = b_scene.user_version_2 if b_scene.user_version_2 else USER_VERSION_2.get(game, 0)
user_version = b_scene.user_version if b_scene.user_version else b_scene.USER_VERSION.get(game, 0)
user_version_2 = b_scene.user_version_2 if b_scene.user_version_2 else b_scene.USER_VERSION_2.get(game, 0)

return version, NifFormat.Data(version, user_version, user_version_2)
30 changes: 29 additions & 1 deletion io_scene_nif/modules/nif_import/scene/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,38 @@
# ***** END LICENSE BLOCK *****

import bpy

from pyffi.formats.nif import NifFormat
from io_scene_nif.properties.scene import _game_to_enum

def import_version_info(data):
scene = bpy.context.scene.niftools_scene
scene.nif_version = data._version_value_._value
scene.user_version = data._user_version_value_._value
scene.user_version_2 = data._user_version_2_value_._value

#filter possible games by nif version
possible_games = []
for game, versions in NifFormat.games.items():
if game != '?':
if scene.nif_version in versions:
game_enum = _game_to_enum(game)
#go to next game if user version for this game does not match defined
if game_enum in scene.USER_VERSION:
if scene.USER_VERSION[game_enum] != scene.user_version:
continue
#or user version in scene is not 0 when this game has no associated user version
elif scene.user_version != 0:
continue
#same checks for user version 2
if game_enum in scene.USER_VERSION_2:
if scene.USER_VERSION_2[game_enum] != scene.user_version:
continue
elif scene.user_version_2 != 0:
continue
#passed all checks, add to possible games list
possible_games.append(game_enum)
if len(possible_games) == 1:
scene.game = possible_games[0]
elif len(possible_games) > 1:
scene.game = possible_games[0]
NifLog.warn(f"Game set to '{possible_games[0]}', but multiple games qualified")

0 comments on commit 5fbd241

Please sign in to comment.