niftools / blender_niftools_addon

The Blender Niftools Addon is a Blender add-on to enable import and export of NetImmese File Formats including .nif, .kf, .egm.
http://www.niftools.org
Other
379 stars 103 forks source link

Can't export .kf file AttributeError: 'NoneType' object has no attribute 'pose_markers' #634

Open Estrangeling opened 3 months ago

Estrangeling commented 3 months ago

I know this may come across as arrogant but I need to demonstrate my knowledge so that I have a better chance of being taken seriously.

I am extremely well-versed in computers, I am a Windows power user, I know about many Windows registry tweaks and I know how to reinstall operating systems and I know how to change router/modem settings to make bypassing the Great Firewall of China easier, I have to, otherwise I cannot access Google, YouTube, Wikipedia...

And I know a lot about programming, I started by learning PowerShell and I am most experienced in Python, I have been coding in Python for well over 3 years now, I have coded hundreds of working scripts for many purposes, and I am not good with words because I don't have any friends, I never had, I have no one to talk to so my communications skills are extremely poor, but that made me channel myself through programming, and I will let you see my Stack Exchange profiles to see what I am capable of. My Stack Overflow profile, my Super User profile, my Code Review profile.

Please, do take a look at my profiles. So that you can see my past accomplishments and know that I am no fool. That is all I ask. I hate not being taken seriously.

Now, the problem. I have installed Blender 4.0.2 x64, I am currently using Windows 10 21H1 x64 Pro, and I installed blender niftools addon v.0.1.1, the latest version.

I have installed TES4 Oblivion and I don't like the ugly player motion animations, more specifically the camera orientation is tied to player orientation and vice versa, the player character always faces the same direction as the camera, and if you move left the player faces the same direction as the camera instead of looking left, and moves sideways like a crab with its back facing you!

I have tried to find a mod to make the camera work like Bioware games, more specifically Mass Effect, in which camera orientation isn't tied to player facing, you can freely rotate the camera around your character and the character stays still when you rotate the camera. And when you move the character left for example, by pressing A, the character moves in relation to the camera, the character moves to the left parallel to the screen, and faces the left side of the screen...

I don't know what this is called, vanity camera? Orbiting camera? Free camera? The terms are inconsistent, and trying to Google search a mod that enables this behavior for Oblivion is futile. I have tried the aforementioned terms as keywords, as well as 360 movement (because I have installed a mod for New Vegas with that name that does exactly what I am looking for here, I found it after many hours of futile Google searching, but it works, and New Vegas and Oblivion use the same Gambryo/NetImmerse engine) and diagonal movement (because there seems to be a mod for New Vegas with that name that does similar things as aforementioned mod, but I haven't tried that)...

All to no avail, the only thing relevant I have found is WalkBlessed, from the videos there it does exactly what I want, but it hasn't been updated since 2019, and I cannot get it work well enough with OBSE GOG build 1.2.0.416 from https://obse.silverlock.org/, which is from 2017! Nor can I get it work with xOBSE from last year.

More specifically, the camera is untied from the player, check, vanity mode works. Player movement is relative to the camera, instead of tank controls, check. But the animation doesn't work, the moving left forward and moving right forward animations work correctly, but the moving animations for left, right, left backward, right backward, and backward are still the janky crab like animations...

So I searched and searched, and I have found this, I have invalidated the archive invalidation and properly overridden the animations, now the walk and run animations work as I have described, but the jump animation is unchanged, there is only exactly one animation for jumps in all eight directions, in all of them the character faces forward while doing a forward jump, but instead of going forward the character moves to the intended direction like a hovering ghost.

Indeed, the jump animations aren't included in the files. I have found a few jump animation replacers on Nexusmods, some of them do seem to jump naturally sideways like I described, but all of them give exactly the same result: there is only one jump animation for all directional jumps...

So I dug deeper, and the horrors I have found: in the AnimGroups of Oblivion, there are Forward, Backward, Left and Right for walking, FastForward, FastBackward, FastLeft and FastRight for running, even DodgeForward, DodgeBackward, DodgeLeft and DodgeRight for dodging! But there is only one set of animations for jumping: JumpStart, JumpLoop and JumpLand. That is it, no JumpStartLeft or JumpLandRight...

So I am trying to add the missing animations and then use a custom mod I will create to invoke them as specialanims by call SetActorAnims actor anim...

I am no animator and I have no idea what I am doing, but I am a fast learner. And I know I don't need to create the animations myself, there are already a bunch of existing animations I have downloaded, and I can rip the animations from Oblivion - Meshes.bsa using BSArch.exe if all else fails.

The issue with the animations is that they aren't "directionally corrected", so if I can somehow rotate them to match the direction of movement then I am done.

And after hours of Google searching I have finally found this.

But it doesn't work.

First I cannot even import the .nif file! io_scene_niftools\modules\nif_import\collision__init__.py is causing the import to fail, more specifically this part:

override = bpy.context.copy()
override['selected_objects'] = b_obj
bpy.ops.rigidbody.object_add(override)
Python: Traceback (most recent call last):
  File "C:\Users\Estranger\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\io_scene_niftools\nif_import.py", line 131, in execute
    self.import_root(root)
  File "C:\Users\Estranger\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\io_scene_niftools\nif_import.py", line 159, in import_root
    b_obj = self.import_branch(root_block)
  File "C:\Users\Estranger\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\io_scene_niftools\nif_import.py", line 234, in import_branch
    b_child = self.import_branch(n_child, b_armature=b_armature)
  File "C:\Users\Estranger\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\io_scene_niftools\nif_import.py", line 234, in import_branch
    b_child = self.import_branch(n_child, b_armature=b_armature)
  File "C:\Users\Estranger\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\io_scene_niftools\nif_import.py", line 234, in import_branch
    b_child = self.import_branch(n_child, b_armature=b_armature)
  [Previous line repeated 12 more times]
  File "C:\Users\Estranger\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\io_scene_niftools\nif_import.py", line 240, in import_branch
    b_children.extend(self.import_collision(n_block))
  File "C:\Users\Estranger\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\io_scene_niftools\nif_import.py", line 184, in import_collision
    return self.bhkhelper.import_bhk_shape(n_node.collision_object.body)
  File "C:\Users\Estranger\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\io_scene_niftools\modules\nif_import\collision\havok.py", line 90, in import_bhk_shape
    return self.process_bhk(bhk_shape)
  File "C:\Program Files\Blender Foundation\Blender 4.0\4.0\python\lib\functools.py", line 889, in wrapper
    return dispatch(args[0].__class__)(*args, **kw)
  File "C:\Users\Estranger\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\io_scene_niftools\modules\nif_import\collision\havok.py", line 176, in import_bhk_rigid_body
    collision_objs = self.import_bhk_shape(bhk_shape.shape)
  File "C:\Users\Estranger\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\io_scene_niftools\modules\nif_import\collision\havok.py", line 90, in import_bhk_shape
    return self.process_bhk(bhk_shape)
  File "C:\Program Files\Blender Foundation\Blender 4.0\4.0\python\lib\functools.py", line 889, in wrapper
    return dispatch(args[0].__class__)(*args, **kw)
  File "C:\Users\Estranger\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\io_scene_niftools\modules\nif_import\collision\havok.py", line 268, in import_bhkcapsule_shape
    self.set_b_collider(b_obj, bounds_type="CAPSULE", display_type="CAPSULE", radius=radius, n_obj=bhk_shape)
  File "C:\Users\Estranger\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\io_scene_niftools\modules\nif_import\collision\__init__.py", line 78, in set_b_collider
    bpy.ops.rigidbody.object_add(override)
  File "C:\Program Files\Blender Foundation\Blender 4.0\4.0\scripts\modules\bpy\ops.py", line 106, in __call__
    C_exec, C_undo = _BPyOpsSubModOp._parse_args(args)
  File "C:\Program Files\Blender Foundation\Blender 4.0\4.0\scripts\modules\bpy\ops.py", line 60, in _parse_args
    raise ValueError("1-2 args execution context is supported")
ValueError: 1-2 args execution context is supported

Google searching again proves futile, but I have found a fix. Right below the problematic section of code are two lines of commented code,

# bpy.context.view_layer.objects.active = b_loc_obj
# bpy.ops.rigidbody.object_add(type='PASSIVE')

So I tried to comment the problematic code and uncomment the alternative, but then again I noticed b_loc_obj is undefined and there is no any other occurrence of it, so I figured that to be a typo and changed it to b_obj and saved the file and reloaded blender.

And it worked! I can finally import nif files and kf files!

I have successfully imported Skeleton.nif and JumpLoop.kf, the animation plays, and through my own button mushing I have discovered that if I press r + x|y|z in quick succession, I can specify the rotation angle through the keyboard. And rz seems to do horizontal rotation, rz 90 seems to make the animation rotate 90 degrees counterclockwise, and that would be the left jump animation.

There might be more to this, but this seems to be a good start.

But now I can't export the keyframe file:

Python: Traceback (most recent call last):
  File "C:\Users\Estranger\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\io_scene_niftools\operators\kf_export_op.py", line 70, in execute
    return KfExport(self, context).execute()
  File "C:\Users\Estranger\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\io_scene_niftools\kf_export.py", line 82, in execute
    kf_root = self.transform_anim.export_kf_root(b_armature)
  File "C:\Users\Estranger\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\io_scene_niftools\modules\nif_export\animation\transform.py", line 106, in export_kf_root
    self.export_text_keys(b_action, anim_textextra)
  File "C:\Users\Estranger\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\io_scene_niftools\modules\nif_export\animation\transform.py", line 295, in export_text_keys
    self.add_dummy_markers(b_action)
  File "C:\Users\Estranger\AppData\Roaming\Blender Foundation\Blender\4.0\scripts\addons\io_scene_niftools\modules\nif_export\animation\__init__.py", line 203, in add_dummy_markers
    if not b_action.pose_markers:
AttributeError: 'NoneType' object has no attribute 'pose_markers'

I know what is causing the problem, but I cannot fix it without spending days reverse engineering the code to fix this problem, this bug. I can fix it and I will fix it myself if I don't get help here.

This is currently out of my ability to fix, yet.

Please, kindly tell me what needs to be done so that I can fix it myself.