Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
143 commits
Select commit Hold shift + click to select a range
814fd8c
Added extra warning for too many bones per partition and move warning…
Candoran2 Jan 5, 2022
a68aee7
Fixed issue #496 by allowing for multiple triangles with the same ver…
Candoran2 Jan 5, 2022
1b57dd2
Merge pull request #497 from Candoran2/develop
neomonkeus Jan 13, 2022
0aa5ba3
Import animation by default
HENDRIX-ZT2 Mar 28, 2022
6c43b75
Merge pull request #505 from HENDRIX-ZT2/develop
neomonkeus Mar 28, 2022
3dbe8a7
Add timing debug for keys
HENDRIX-ZT2 Mar 28, 2022
ebb59e7
Speed up keys import
HENDRIX-ZT2 Mar 28, 2022
35b1b79
Speed up keys import
HENDRIX-ZT2 Mar 28, 2022
62472b7
Merge branch 'niftools:develop' into develop
HENDRIX-ZT2 Mar 28, 2022
9997f62
Refactor keys import
HENDRIX-ZT2 Mar 30, 2022
14daae8
Remove removed attribute for blender 3.1
HENDRIX-ZT2 Mar 30, 2022
d67e66b
Fix anim import
HENDRIX-ZT2 Mar 30, 2022
1671410
Fix anim import
HENDRIX-ZT2 Mar 30, 2022
fd08980
Improve comments
HENDRIX-ZT2 Mar 30, 2022
56d208d
Improve parameters
HENDRIX-ZT2 Mar 30, 2022
5508e6e
Refactor and join code paths for keys import
HENDRIX-ZT2 Mar 30, 2022
c696772
Add todo for permeability
HENDRIX-ZT2 Mar 30, 2022
936f780
Cleanup
HENDRIX-ZT2 Mar 30, 2022
d00f471
Move key lut, share data type constants
HENDRIX-ZT2 Mar 30, 2022
b5d02a8
Refactor + fix import_visibility
HENDRIX-ZT2 Mar 30, 2022
d057831
Refactor morph + vis ctrl import
HENDRIX-ZT2 Mar 30, 2022
fd9eadf
Refactor mat anim import
HENDRIX-ZT2 Mar 30, 2022
dcc661c
Upgrade UV offset import
HENDRIX-ZT2 Mar 30, 2022
b30338f
Upgrade UV offset import
HENDRIX-ZT2 Mar 30, 2022
f3bc4fe
Upgrade UV offset import
HENDRIX-ZT2 Mar 30, 2022
133a9e5
Upgrade UV offset import
HENDRIX-ZT2 Mar 30, 2022
af4a25f
Remove uv anim comments from BFB plugin
HENDRIX-ZT2 Mar 31, 2022
0f5f263
Fix decoding handling - closes #500
HENDRIX-ZT2 Mar 31, 2022
16fd32c
Fix shape keys export, add doc - closes #180
HENDRIX-ZT2 Mar 31, 2022
d20ca21
Refactor export_children()
HENDRIX-ZT2 Apr 2, 2022
425f9da
Move root node type to scene
HENDRIX-ZT2 Apr 2, 2022
33d0a35
Refactor root node
HENDRIX-ZT2 Apr 2, 2022
7e679b4
Move BS Inv marker properties and UI to scene
HENDRIX-ZT2 Apr 2, 2022
bb9c5bf
Refactor BS Inv marker
HENDRIX-ZT2 Apr 2, 2022
cff4796
Refactor import_root_collision, import_empty
HENDRIX-ZT2 Apr 2, 2022
30d4e7b
Fixed error that occured when trying to qhull without any vertices.
Candoran2 Apr 29, 2022
085b06a
Temporarily moved penetration depth from collision modifier permeabil…
Candoran2 Apr 29, 2022
5eaeb32
Merge pull request #512 from Candoran2/develop
HENDRIX-ZT2 May 21, 2022
4b32bfa
Merge branch 'develop' into develop
HENDRIX-ZT2 May 21, 2022
fbdce87
Increase generated image name range for embedded textures - closes #510
HENDRIX-ZT2 May 21, 2022
ee5ea9f
Refactor UV nodes names, add _ after TexCoordIndex
HENDRIX-ZT2 May 22, 2022
58f618b
External textures fixes - closes #510, closes #517
HENDRIX-ZT2 May 26, 2022
6a74b8d
get_controller_data more intelligently for anim import
HENDRIX-ZT2 May 26, 2022
b93a623
Cleanup embedded tex
HENDRIX-ZT2 May 26, 2022
e95efd9
Move BSInvMarker back to object
HENDRIX-ZT2 May 26, 2022
9d8b2cb
Preliminary support for texture transform import - #514
HENDRIX-ZT2 May 26, 2022
1cc75c0
Bump to next dev version
neomonkeus May 21, 2022
b228594
Use "@" instead of "*" for matrix multiplication
Allofich May 26, 2022
273b8f8
Update version number
Allofich May 26, 2022
9c7eba0
Naminc conventions for MorphAnimation as per review
HENDRIX-ZT2 May 27, 2022
e31eaa6
Fix frozen import with multiple tex transform controllers
HENDRIX-ZT2 May 27, 2022
a8d6e09
Cleanup & pull out skin partition code
HENDRIX-ZT2 May 27, 2022
519c413
Cleanup trishape export
HENDRIX-ZT2 May 27, 2022
e11ac76
Cleanup trishape export
HENDRIX-ZT2 May 27, 2022
1fd4486
Cleanup trishape export
HENDRIX-ZT2 May 27, 2022
56af76a
Cleanup add_defined_tangents
HENDRIX-ZT2 May 27, 2022
615ce6b
Merge branch 'develop' into develop
HENDRIX-ZT2 May 27, 2022
6aaae94
Revert TestTriShape
HENDRIX-ZT2 Jun 2, 2022
67e0f92
Merge pull request #506 from HENDRIX-ZT2/develop
neomonkeus Jun 2, 2022
3cef937
int cast in add_dummy_markers to comply with blender python 3.1+
TackYs Jun 13, 2022
458b4c1
Allow manually setting armature axis on import
TackYs Jun 15, 2022
2d21c72
Override armature axis orientation option on nif import
TackYs Jun 20, 2022
d8becf1
fix in get_controller_data
TackYs Jun 23, 2022
c80b1a0
Merge pull request #524 from TackYs/develop
HENDRIX-ZT2 Jun 29, 2022
66212c1
split override into it's own panel, implementing orientation_helper
TackYs Jun 29, 2022
3ba02d5
saner orientation_helper default
TackYs Jun 29, 2022
dd66c97
Merge pull request #526 from TackYs/manual_armature_axis
HENDRIX-ZT2 Jun 30, 2022
ca0c37d
Removed unecessary import from kf_import.py
Candoran2 Sep 17, 2022
7153b53
Updated kf_export.py to remove unused imports.
Candoran2 Sep 18, 2022
19e0294
Made changes necessary to export ZT2 kf.
Candoran2 Sep 18, 2022
11cb4db
Made changes for FO3 kf export.
Candoran2 Sep 18, 2022
e8b70e4
Added missed reset_field and added validation step before writing kf.
Candoran2 Sep 23, 2022
1ddbe4f
Transferred nif import to use the new library.
Candoran2 Sep 25, 2022
fa20764
Updated vertex group import for new library.
Candoran2 Sep 26, 2022
41308e5
Made changes to use new library for nif export.
Candoran2 Sep 26, 2022
9dce93a
Updated BS data flags export.
Sep 27, 2022
a7dbd75
Removed now-unnecessary .decode calls.
Sep 27, 2022
a4b804b
Made makezip.bat work with dir paths with spaces.
Sep 27, 2022
0977c88
Let n_node_type override detected one (needed for BSFadeNode as root …
Candoran2 Sep 27, 2022
6223cc6
Fix skin_partition_blocks > partitions because of xml change and shad…
Candoran2 Sep 27, 2022
57e8778
Added forgotten .classes.
Candoran2 Sep 29, 2022
0f9d234
Replaced NifFormat.classes with direct import of classes as NifClasses.
Candoran2 Sep 29, 2022
1305247
Changed game property to only allow games for supported versions.
Candoran2 Sep 30, 2022
0186864
Added initial support for static SSE nif import.
Candoran2 Oct 3, 2022
8637f4a
Couple small fixes, and #521 - partially.
Candoran2 Oct 3, 2022
1b5f91e
Finished adjustment to partition/body party import to directly use pa…
Candoran2 Oct 3, 2022
a897ebe
Added changes to import skinned BSTriShape, and corrected error in ma…
Candoran2 Oct 5, 2022
ed32f48
Normalization of ByteVector3 no longer necessary in addon code - is h…
Candoran2 Oct 6, 2022
d3dbf40
Replaced uses of Enum._name_ with Enum.name (_name_ is writeable, nam…
Candoran2 Oct 6, 2022
88c1c91
Replaced Enum._value_ with Enum.value, since the latter is read-only.
Candoran2 Oct 6, 2022
f3b7fa9
Followed f-string suggestions, as well as enum access and itertools.c…
Candoran2 Oct 7, 2022
e574d05
Removed modulo % 256 from texture clamp mode because it's no longer n…
Candoran2 Oct 7, 2022
9166bb0
Simplified havok material import due to xml changes and fixed BSEffec…
Candoran2 Oct 7, 2022
3934ff8
Removed KFFile class and used NifFile instead for KF import since cod…
Candoran2 Oct 7, 2022
56ab2c3
Removed uses of safe_decode and moved it to generated code.
Candoran2 Oct 9, 2022
70203cb
Did small fixes for codegen and migrated updated save_as_dds function…
Candoran2 Oct 11, 2022
0e280a4
Changed BSEffectShaderProperty import/export to reflect xml changes.
Candoran2 Oct 15, 2022
432f845
Updated (some) collision import and export for xml.
Candoran2 Oct 16, 2022
46e5628
Updated constraint import to reflect newer xml.
Candoran2 Nov 4, 2022
a782929
Made the file glob for nifs dependent on the extensions in pyffi.
Candoran2 Nov 6, 2022
b05a3b3
Added support for (Epic Mickey 2) NiMesh geometry import.
Candoran2 Nov 8, 2022
0a1986a
Merge pull request #535 from Candoran2/pyffi_overhaul
Candoran2 Nov 10, 2022
cf15c16
Updated some of collision export to prevent errors - still need to be…
Candoran2 Nov 10, 2022
4c70a11
Added support for BSDynamicTriShape import and made nif_import.py les…
Candoran2 Nov 10, 2022
2dd20f5
Small fix for extra_name setting, added small comment about loops vs …
Candoran2 Nov 11, 2022
1ebafea
Added bone import for Epic Mickey NiMesh.
Candoran2 Nov 11, 2022
7db2a2c
Reused get_skin_bind function for NiMesh bones and adapted store_bind…
Candoran2 Nov 14, 2022
1c25400
Removed flag setting from bhkBlendCollisionObject - already happens b…
Candoran2 Nov 15, 2022
8275b85
Removed setting of unused values and updated other parts of collision…
Candoran2 Nov 15, 2022
ec0ce8b
Re-enabled materials for collision objects. With the updated pyffi, t…
Candoran2 Nov 15, 2022
e238e42
Fixed shader property flag errors and incorrect formatting due to upd…
Candoran2 Nov 15, 2022
55cb20d
Fixed error caused by treating Enum class as dictionary.
Candoran2 Nov 15, 2022
d1797fb
Updated import of NiMesh for non-EM instances.
Candoran2 Nov 17, 2022
c8279a8
Updated Object properties UI to only show certain properties when rel…
Candoran2 Nov 18, 2022
2de8d98
Fixed small misspelling.
Candoran2 Nov 19, 2022
d4dfe6f
Renamed NONE game to UNKNOWN to agree with codegen and added case for…
Candoran2 Nov 22, 2022
e020c99
Added explicit error when encountering NiMesh with DisplayList.
Candoran2 Nov 25, 2022
f3898fe
Re-added exception handling for nodetype determination (bones don't h…
Candoran2 Nov 25, 2022
4a0fdf2
Use "Color" type for "InvertY" group
enpinion Dec 5, 2022
f5211a9
Merge pull request #543 from enpinion/develop
Candoran2 Dec 9, 2022
45971e3
Fixed import error for bhkRigidBodyT. Fixed spelling error. Added imp…
Candoran2 Dec 18, 2022
c02a50b
Potential fix for #545. None properties were added to the properties …
Candoran2 Dec 18, 2022
cc40128
Fix for #547 - fixed by also allowing Oblivion KF to use Oblivion col…
Candoran2 Dec 19, 2022
4db4e94
Partial fix for #550 (but will result in wrong value).
Candoran2 Dec 23, 2022
074489a
Change how Prn values are handled. Now any value will work and make t…
Candoran2 Dec 23, 2022
7fd1cdb
Fix for #553 (combined with fixes in libraries)
Candoran2 Jan 1, 2023
8b17c3b
Merge pull request #541 from Candoran2/pyffi_overhaul
HENDRIX-ZT2 Mar 13, 2023
c952d8c
Fixed BSInvMarker rotation export (should always be set to int, not f…
Candoran2 Apr 10, 2023
4f7da48
Changed condition for bs_data_flags to correspond with xml, solving i…
Candoran2 Apr 26, 2023
332afea
Fixed wrong transform application on packed collision vertices.
Candoran2 Apr 28, 2023
39a3fe0
Use conditional argument in StringProperty that was only introduced i…
Candoran2 May 5, 2023
68dfa54
Fix for the "'bhkMalleableConstraint' object has no attribute 'ragdol…
Candoran2 May 5, 2023
f620ab0
Changed NiMesh import to use new sep_datastreams argument, removing n…
Candoran2 May 6, 2023
d0a1328
Add processing of regions to bone import.
Candoran2 May 18, 2023
0024c0a
Basic displaylist import.
Candoran2 May 27, 2023
7acb953
Merge pull request #572 from Candoran2/pyffi_overhaul
Candoran2 Jun 14, 2023
40d3f64
Preparations for release, including adding copying of generated folde…
Candoran2 Jun 16, 2023
162cbf1
Update to changelog for the release prep PR.
Candoran2 Jun 16, 2023
b7e4909
Merge pull request #576 from Candoran2/pyffi_overhaul
Candoran2 Jun 17, 2023
4ce5f09
Update VERSION.txt
Candoran2 Jun 19, 2023
179c8af
Merge pull request #577 from niftools/Version-correction
HENDRIX-ZT2 Jun 20, 2023
d95b3da
Update CHANGELOG.rst for missed PR and correction on issue number
Candoran2 Jun 20, 2023
09dae59
Merge pull request #579 from niftools/Added-missed-PR
HENDRIX-ZT2 Jun 20, 2023
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
2 changes: 1 addition & 1 deletion .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,14 @@ Contributors
------------

* Aaron1178
* Allofich
* Alphax
* Arcimaestro
* Arthmoor
* Artorp

* Deedes
* Eli2
* enpinion
* Entim
* Eugenius-v
* Fritz_fretz
Expand All @@ -37,11 +38,13 @@ Contributors
* mgm101
* opusGlass
* Pacificmorrowind
* paulgreenG
* Pentinen
* @reddraconi
* shon
* @SubhadeepG
* @TagnumElite
* TackYs
* Tamira
* Thedaywalker
* Tijer
Expand Down
33 changes: 33 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,36 @@
Version v0.1.00
===============

- #576 Updates to documentation, changelog and makezip.bat (copies over generated folder from cobra-tools).
- #572 Extra development of NiMesh import and some fixes
- Fix to BSInvMarker rotation export.
- Fix for bs_data_flags setting in export - now also applied to other games where applicable, not just Skyrim.
- Fix to transform on packed collision vertices export.
- Adjust StringProperty arguments to prevent crash in Blender 3.2 or lower.
- Fix to mistake in BhkMalleableConstraint info import.
- Added processing of regions to NiMesh bone import.
- Basic DisplayList import (NiMesh with a specific type of datastream, which encodes the geometry). Bone weights for this type of nif are still unimplemented.
- #543 Use "Color" type for "InvertY" group
- #541 NiMesh import and updates for newer xml
- Nif file glob now partially dependent on xml.
- Support for NiMesh import (except those using DisplayList).
- Support for BSDynamicTriShape import.
- Update to Object properties ui (now only show relevant properties)
- Closes #533 "Unknown block type BSDynamicTriShape".
- Closes #421 "Can't import catherine classic .nif files."
- #535 Pyffi overhaul
- Change kf and nif import to make use of the new statically generated nif reading/writing library.
- Added support for SSE mesh import.
- Closes #521.
- #526 Allow setting armature axis manually
- #524 int cast in add_dummy_markers to comply with blender 3.1+'s python and check for interpolator attribute on controller before accessing it.
- #506 Speedup anim import & various other fixes
- Closes #180
- Closes #495
- Closes #500
- Closes #510
- Closes #517

Version v0.0.14
===============

Expand Down
12 changes: 12 additions & 0 deletions docs/user/features/geometry/geometry.rst
Original file line number Diff line number Diff line change
Expand Up @@ -94,3 +94,15 @@ Vertex Color & Alpha
* `This image should clarify per-face vertex colouring
<http://i211.photobucket.com/albums/bb189/NifTools/Blender/documentation/per_face_vertex_color.jpg>`_
* On export, the scripts will create extra vertices for different vertex colors per face.


.. _geometry-shapekeys:

Shape Key Animations
--------------------

**Example:**

#. :ref:`Create a mesh-object <geometry-mesh>`.
#. Add relative shape keys to your mesh.
#. Keyframe each shape key's value so that the key influences the shape of the mesh at the desired time.
4 changes: 2 additions & 2 deletions docs/user/features/object/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ First, we complete the object panel:
#. Set your **BSX Flags**.
#. Select a **Consistency Flag** from the drop-down box. See `this comment
<https://github.com/niftools/nifskope/issues/69#issuecomment-61427385>`_ for discussion of what they might do.
#. The **Object Flag** is ???????. Set it to an appropriate number.
#. The **Nif Long Name** is ???????. Set it to an appropriate string.
#. The **Object Flag** corresponds to the flags field on NiAVObjects. The exact meaning will differ based on the block type. Set it to an appropriate number. If left to 0, will use a default value.
#. The **Nif Long Name** is the actual name used for the corresponding block in the nif. You can either set it to an appropriate string, or leave it empty. In the latter case, the nif name will be determined based on the blender name of the object.
#. The **Skeleton Root** determines the root bone used in this mesh's SkinInstance. Can usually be ignored / left empty, falls back to the armature object = root node.

.. Extra Data and InvMarkers I have no idea how to fill them in. Help?
Expand Down
19 changes: 17 additions & 2 deletions install/makezip.bat
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,26 @@ mkdir "%DEPS%"

python -m pip install "PyFFI==%PYFFI_VERSION%" --target="%DEPS%"

xcopy "%GENERATED_FOLDER%" "%DEPS%\generated" /s /q /i

xcopy "%ROOT%"\AUTHORS.rst io_scene_niftools
xcopy "%ROOT%"\CHANGELOG.rst io_scene_niftools
xcopy "%ROOT%"\LICENSE.rst io_scene_niftools
xcopy "%ROOT%"\README.rst io_scene_niftools

:: remove all __pycache__ folders
for /d /r %%x in (*) do if "%%~nx" == "__pycache__" rd %%x /s /q

popd

powershell -executionpolicy bypass -Command "%DIR%\zip.ps1" -source "%DIR%\temp\io_scene_niftools" -destination "%DIR%\%ZIP_NAME%.zip"
rmdir /s /q %DIR%\temp
set "COMMAND_FILE=%DIR%\zip.ps1"
set "COMMAND_FILE=%COMMAND_FILE: =` %"

set "SOURCE_DIR=%DIR%\temp\io_scene_niftools"
set "SOURCE_DIR=%SOURCE_DIR: =` %"

set "DESTINATION_DIR=%DIR%\%ZIP_NAME%.zip"
set "DESTINATION_DIR=%DESTINATION_DIR: =` %"

powershell -executionpolicy bypass -Command "%COMMAND_FILE%" -source "%SOURCE_DIR%" -destination "%DESTINATION_DIR%"
rmdir /s /q "%DIR%\temp"
2 changes: 1 addition & 1 deletion io_scene_niftools/VERSION.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v0.0.14
v0.1.0
6 changes: 3 additions & 3 deletions io_scene_niftools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
"description": "Import and export files in the NetImmerse/Gamebryo formats (.nif, .kf, .egm)",
"author": "Niftools team",
"blender": (2, 82, 0),
"version": (0, 0, 14), # can't read from VERSION, blender wants it hardcoded
"version": (0, 1, 0), # can't read from VERSION, blender wants it hardcoded
"api": 39257,
"location": "File > Import-Export",
"warning": "Generally stable port of the Niftool's Blender NifScripts, many improvements, still work in progress",
Expand All @@ -72,8 +72,8 @@ def locate_dependencies():

with open(os.path.join(current_dir, "VERSION.txt")) as version:
NifLog.info(f"Loading: Blender Niftools Addon: {version.read()}")
import pyffi
NifLog.info(f"Loading: PyFFi: {pyffi.__version__}")
import generated.formats.nif as NifFormat
NifLog.info(f"Loading: NifFormat: {NifFormat.__xml_version__}") # todo [generated] update this and library to have actual versioning


locate_dependencies()
Expand Down
69 changes: 0 additions & 69 deletions io_scene_niftools/file_io/kf.py

This file was deleted.

17 changes: 9 additions & 8 deletions io_scene_niftools/file_io/nif.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,9 @@
#
# ***** END LICENSE BLOCK *****

import os.path as path

from pyffi.formats.nif import NifFormat
import generated.formats.nif as NifFormat

from io_scene_niftools.utils.logging import NifLog, NifError

Expand All @@ -51,18 +52,18 @@ def load_nif(file_path):
"""Loads a nif from the given file path"""
NifLog.info(f"Importing {file_path}")

data = NifFormat.Data()
file_ext = path.splitext(file_path)[1]

# open file for binary reading
with open(file_path, "rb") as nif_stream:
# check if nif file is valid
data.inspect_version_only(nif_stream)
if data.version >= 0:
modification, (version, user_version, bs_version) = NifFormat.NifFile.inspect_version_only(nif_stream)
if version >= 0:
# it is valid, so read the file
NifLog.info(f"NIF file version: {data.version:x}")
NifLog.info("Reading file")
data.read(nif_stream)
elif data.version == -1:
NifLog.info(f"NIF file version: {version:x}")
NifLog.info(f"Reading {file_ext} file")
data = NifFormat.NifFile.from_stream(nif_stream)
elif version == -1:
raise NifError("Unsupported NIF version.")
else:
raise NifError("Not a NIF file.")
Expand Down
8 changes: 3 additions & 5 deletions io_scene_niftools/kf_export.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@
import os
import bpy

import pyffi.spells.nif.fix

from io_scene_niftools.file_io.kf import KFFile
from io_scene_niftools.modules.nif_export import armature
from io_scene_niftools.modules.nif_export.animation.transform import TransformAnimation
from io_scene_niftools.nif_common import NifCommon
from io_scene_niftools.utils import math
Expand All @@ -69,7 +65,7 @@ def execute(self):
directory = os.path.dirname(NifOp.props.filepath)
filebase, fileext = os.path.splitext(os.path.basename(NifOp.props.filepath))

if bpy.context.scene.niftools_scene.game == 'NONE':
if bpy.context.scene.niftools_scene.game == 'UNKNOWN':
raise NifError("You have not selected a game. Please select a game in the scene tab.")

prefix = "x" if bpy.context.scene.niftools_scene.game in ('MORROWIND',) else ""
Expand All @@ -95,6 +91,8 @@ def execute(self):
# scale correction for the skeleton
self.apply_scale(data, round(1 / NifOp.props.scale_correction))

data.validate()

kffile = os.path.join(directory, prefix + filebase + ext)
with open(kffile, "wb") as stream:
data.write(stream)
Expand Down
7 changes: 2 additions & 5 deletions io_scene_niftools/kf_import.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,7 @@

import os

import pyffi.spells.nif.fix

from io_scene_niftools.file_io.kf import KFFile
from io_scene_niftools.modules.nif_export import armature
from io_scene_niftools.file_io.nif import NifFile as KFFile
from io_scene_niftools.modules.nif_import.animation.transform import TransformAnimation
from io_scene_niftools.nif_common import NifCommon
from io_scene_niftools.utils import math
Expand Down Expand Up @@ -72,7 +69,7 @@ def execute(self):
# get nif space bind pose of armature here for all anims
self.transform_anim.get_bind_data(b_armature)
for kf_file in kf_files:
kfdata = KFFile.load_kf(kf_file)
kfdata = KFFile.load_nif(kf_file)

self.apply_scale(kfdata, NifOp.props.scale_correction)

Expand Down
24 changes: 12 additions & 12 deletions io_scene_niftools/modules/nif_export/animation/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
from abc import ABC

import bpy
from pyffi.formats.nif import NifFormat
from generated.formats.nif import classes as NifClasses

from io_scene_niftools.modules.nif_export.block_registry import block_store
from io_scene_niftools.utils.singleton import NifOp, NifData
Expand Down Expand Up @@ -93,14 +93,14 @@ def get_controllers(nodes):
"""find all nodes and relevant controllers"""
node_kfctrls = {}
for node in nodes:
if not isinstance(node, NifFormat.NiAVObject):
if not isinstance(node, NifClasses.NiAVObject):
continue
# get list of all controllers for this node
ctrls = node.get_controllers()
for ctrl in ctrls:
if bpy.context.scene.niftools_scene.game == 'MORROWIND':
# morrowind: only keyframe controllers
if not isinstance(ctrl, NifFormat.NiKeyframeController):
if not isinstance(ctrl, NifClasses.NiKeyframeController):
continue
if node not in node_kfctrls:
node_kfctrls[node] = []
Expand Down Expand Up @@ -132,14 +132,14 @@ def create_controller(self, parent_block, target_name, priority=0):
# link interpolator from the controller
n_kfc.interpolator = n_kfi
# if parent is a node, attach controller to that node
if isinstance(parent_block, NifFormat.NiNode):
if isinstance(parent_block, NifClasses.NiNode):
parent_block.add_controller(n_kfc)
if n_kfi:
# set interpolator default data
n_kfi.scale, n_kfi.rotation, n_kfi.translation = parent_block.get_transform().get_scale_quat_translation()

# else ControllerSequence, so create a link
elif isinstance(parent_block, NifFormat.NiControllerSequence):
elif isinstance(parent_block, NifClasses.NiControllerSequence):
controlled_block = parent_block.add_controlled_block()
controlled_block.priority = priority
# todo - pyffi adds the names to the NiStringPalette, but it creates one per controller link...
Expand All @@ -159,15 +159,15 @@ def create_controller(self, parent_block, target_name, priority=0):
controlled_block.controller_type = "NiTransformController"
# get the parent's string palette
if not parent_block.string_palette:
parent_block.string_palette = NifFormat.NiStringPalette()
parent_block.string_palette = NifClasses.NiStringPalette(NifData.data)
# assign string palette to controller
controlled_block.string_palette = parent_block.string_palette
# add the strings and store their offsets
palette = controlled_block.string_palette.palette
controlled_block.node_name_offset = palette.add_string(controlled_block.node_name)
controlled_block.controller_type_offset = palette.add_string(controlled_block.controller_type)
# morrowind style
elif isinstance(parent_block, NifFormat.NiSequenceStreamHelper):
elif isinstance(parent_block, NifClasses.NiSequenceStreamHelper):
# create node reference by name
nodename_extra = block_store.create_block("NiStringExtraData")
nodename_extra.bytes_remaining = len(target_name) + 4
Expand All @@ -184,14 +184,14 @@ def create_controller(self, parent_block, target_name, priority=0):
@staticmethod
def get_n_interp_from_b_interp(b_ipol):
if b_ipol == "LINEAR":
return NifFormat.KeyType.LINEAR_KEY
return NifClasses.KeyType.LINEAR_KEY
elif b_ipol == "BEZIER":
return NifFormat.KeyType.QUADRATIC_KEY
return NifClasses.KeyType.QUADRATIC_KEY
elif b_ipol == "CONSTANT":
return NifFormat.KeyType.CONST_KEY
return NifClasses.KeyType.CONST_KEY

NifLog.warn(f"Unsupported interpolation mode ({b_ipol}) in blend, using quadratic/bezier.")
return NifFormat.KeyType.QUADRATIC_KEY
return NifClasses.KeyType.QUADRATIC_KEY

def add_dummy_markers(self, b_action):
# if we exported animations, but no animation groups are defined,
Expand All @@ -201,4 +201,4 @@ def add_dummy_markers(self, b_action):
NifLog.info("Defining default action pose markers.")
for frame, text in zip(b_action.frame_range, ("Idle: Start/Idle: Loop Start", "Idle: Loop Stop/Idle: Stop")):
marker = b_action.pose_markers.new(text)
marker.frame = frame
marker.frame = int(frame)
Loading