Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for KFA files import/export (DAOC) #558

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

DigitalBox98
Copy link

@niftools/blender-niftools-addon-reviewer

Overview

Proposal for KFA import files (DAOC anim files)

Detailed Description

Import menu now add the .kfa option

Fixes Known Issues

While KFA are NIF files there were never useable under Blender

Documentation

Testing

Two types of KFA tested and working fine (dr_rat_run.kfa & GnomeR_Run.kfa)

Manual

Automated

Additional Information

@DigitalBox98
Copy link
Author

kfa

@HENDRIX-ZT2
Copy link
Contributor

I don't think it needs to be an extra format operator. The logic can be inserted into import_kf_root from what I see

@DigitalBox98
Copy link
Author

DigitalBox98 commented Feb 2, 2023

Export has been added but is experimental for the moment. Format is recognized in game but some futures adjustments are needed.
The aim of this PR is to review how the KFA import/export can be added in the actual plugin code and is open for discussions/improvements

@DigitalBox98 DigitalBox98 changed the title Add support for KFA import files (DAOC) Add support for KFA files import/export (DAOC) Feb 2, 2023
targetname = "Scene Root"

# mapping between bones name and id
bonename_dict = { "Bip01":0, "Bip01 Pelvis":1, "Bip01 Spine":2, "Bip01 Spine1":3, "Bip01 Spine2":4, "Bip01 Spine3":5, "Bip01 Neck":6, "Bip01 Neck1":7, "Bip01 Neck2":8, "Bip01 Neck3":9, "Bip01 Neck4":10, "Bip01 Head":11, "Bip01 Ponytail1":12, "Bip01 Ponytail11":13, "Bip01 Ponytail12":14, "Bip01 Ponytail13":15, "Bip01 Ponytail14":16, "Bip01 Ponytail2":17, "Bip01 Ponytail21":18, "Bip01 Ponytail22":19, "Bip01 Ponytail23":20, "Bip01 Ponytail24":21, "Bip01 L Clavicle":22, "Bip01 L UpperArm":23, "Bip01 L Forearm":24, "Bip01 L Hand":25, "Bip01 L Finger0":26, "Bip01 L Finger01":27, "Bip01 L Finger02":28, "Bip01 L Finger1":29, "Bip01 L Finger11":30, "Bip01 L Finger12":31, "Bip01 L Finger2":32, "Bip01 L Finger21":33, "Bip01 L Finger22":34, "Bip01 R Clavicle":35, "Bip01 R UpperArm":36, "Bip01 R Forearm":37, "Bip01 R Hand":38, "Bip01 R Finger0":39, "Bip01 R Finger01":40, "Bip01 R Finger02":41, "Bip01 R Finger1":42, "Bip01 R Finger11":43, "Bip01 R Finger12":44, "Bip01 R Finger2":45, "Bip01 R Finger21":46, "Bip01 R Finger22":47, "Bip01 L Thigh":48, "Bip01 L Calf":49, "Bip01 L HorseLink":50, "Bip01 L Foot":51, "Bip01 L Toe0":52, "Bip01 L Toe01":53, "Bip01 R Thigh":54, "Bip01 R Calf":55, "Bip01 R HorseLink":56, "Bip01 R Foot":57, "Bip01 R Toe0":58, "Bip01 R Toe01":59, "Bip01 Tail":60, "Bip01 Tail1":61, "Bip01 Tail2":62, "Bip01 Tail3":63, "Bip01 Tail4":64, "Bip01 L Shield":65, "Bip01 R Shield":66, "Bip01 L Held":67, "Bip01 R Held":68, "Bip01 L Belt":69, "Bip01 R Belt":70, "Bip01 L Back":71, "Bip01 R Back":72, "Bip01 Helm":73, "Bip01 Ext01":74, "Bip01 Ext02":75, "Bip01 Ext03":76, "Bip01 Ext04":77, "Bip01 Ext05":78, "Bip01 Ext06":79, "Bip01 Ext07":80, "Bip01 Ext08":81, "Bip01 Ext09":82, "Bip01 Ext10":83, "Bip01 Ext11":84, "Bip01 Ext12":85, "Bip01 Ext13":86, "Bip01 Ext14":87, "Bip01 Ext15":88, "Bip01 Ext16":89, "Bip01 Ext17":90, "Bip01 Ext18":91, "Bip01 Ext19":92, "Bip01 Ext20":93, "Bip01 L Finger3":94, "Bip01 L Finger31":95, "Bip01 L Finger32":96, "Bip01 L Finger4":97, "Bip01 L Finger41":98, "Bip01 L Finger42":99, "Bip01 R Finger3":100, "Bip01 R Finger31":101, "Bip01 R Finger32":102, "Bip01 R Finger4":103, "Bip01 R Finger41":104, "Bip01 R Finger42":105, "Bip01 L Toe02":106, "Bip01 L Toe03":107, "Bip01 L Toe1":108, "Bip01 L Toe11":109, "Bip01 L Toe12":110, "Bip01 L Toe2":111, "Bip01 L Toe21":112, "Bip01 L Toe22":113, "Bip01 R Toe02":114, "Bip01 R Toe03":115, "Bip01 R Toe1":116, "Bip01 R Toe11":117, "Bip01 R Toe12":118, "Bip01 R Toe2":119, "Bip01 R Toe21":120, "Bip01 R Toe22":121, "Bip01 L ForeTwist":122, "Bip01 L ForeTwist1":123, "Bip01 R ForeTwist":124, "Bip01 R ForeTwist1":125, "Bip01 EyeLids":126, "Bip01 L BicepTwist":127, "Bip01 R BicepTwist":128, "Bip01 L Pauldron":129, "Bip01 R Pauldron":130, "Bip01 Beard1":131, "Bip01 Beard2":132, "Bip01 FrontRobe1":133, "Bip01 FrontRobe2":134, "Bip01 BackRobe1":135, "Bip01 BackRobe2":136, "Bip01 C Cloak01":137, "Bip01 C Cloak02":138, "Bip01 C Cloak03":139, "Bip01 C Cloak04":140, "Bip01 C Cloak05":141, "Bip01 L Cloak01":142, "Bip01 L Cloak02":143, "Bip01 L Cloak03":144, "Bip01 L Cloak04":145, "Bip01 L Cloak05":146, "Bip01 R Cloak01":147, "Bip01 R Cloak02":148, "Bip01 R Cloak03":149, "Bip01 R Cloak04":150, "Bip01 R Cloak05":151, "Bip01 C CloakIKChain":152, "Bip01 L CloakIKChain":153, "Bip01 R CloakIKChain":154, "Bip01 L ThighTwist":155, "Bip01 R ThighTwist":156, "R Cloak Control01":157, "L Cloak Control01":158, "C Cloak Control01":159, "C Cloak Control02":160, "C Cloak Control03":161, "C Cloak Control04":162, "C Cloak Control05":163, "C Cloak Control06":164, "L Cloak Control02":165, "L Cloak Control03":166, "L Cloak Control04":167, "L Cloak Control05":168, "L Cloak Control06":169, "R Cloak Control02":170, "R Cloak Control03":171, "R Cloak Control04":172, "R Cloak Control05":173, "R Cloak Control06":174 }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this just the same as the bone_names mapped to their indices in io_scene_niftools/modules/nif_import/animation/transform.py? If so, it would probably be best to store it as one object (either list or dict) and obtain the other object from there, rather than hardcoding it twice.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, a new BonesMapper class has been added to handle this

bone_names = ["Bip01","Bip01 Pelvis","Bip01 Spine","Bip01 Spine1","Bip01 Spine2","Bip01 Spine3","Bip01 Neck","Bip01 Neck1","Bip01 Neck2","Bip01 Neck3","Bip01 Neck4","Bip01 Head","Bip01 Ponytail1","Bip01 Ponytail11","Bip01 Ponytail12","Bip01 Ponytail13","Bip01 Ponytail14","Bip01 Ponytail2","Bip01 Ponytail21","Bip01 Ponytail22","Bip01 Ponytail23","Bip01 Ponytail24","Bip01 L Clavicle","Bip01 L UpperArm","Bip01 L Forearm","Bip01 L Hand","Bip01 L Finger0","Bip01 L Finger01","Bip01 L Finger02","Bip01 L Finger1","Bip01 L Finger11","Bip01 L Finger12","Bip01 L Finger2","Bip01 L Finger21","Bip01 L Finger22","Bip01 R Clavicle","Bip01 R UpperArm","Bip01 R Forearm","Bip01 R Hand","Bip01 R Finger0","Bip01 R Finger01","Bip01 R Finger02","Bip01 R Finger1","Bip01 R Finger11","Bip01 R Finger12","Bip01 R Finger2","Bip01 R Finger21","Bip01 R Finger22","Bip01 L Thigh","Bip01 L Calf","Bip01 L HorseLink","Bip01 L Foot","Bip01 L Toe0","Bip01 L Toe01","Bip01 R Thigh","Bip01 R Calf","Bip01 R HorseLink","Bip01 R Foot","Bip01 R Toe0","Bip01 R Toe01","Bip01 Tail","Bip01 Tail1","Bip01 Tail2","Bip01 Tail3","Bip01 Tail4","Bip01 L Shield","Bip01 R Shield","Bip01 L Held","Bip01 R Held","Bip01 L Belt","Bip01 R Belt","Bip01 L Back","Bip01 R Back","Bip01 Helm","Bip01 Ext01","Bip01 Ext02","Bip01 Ext03","Bip01 Ext04","Bip01 Ext05","Bip01 Ext06","Bip01 Ext07","Bip01 Ext08","Bip01 Ext09","Bip01 Ext10","Bip01 Ext11","Bip01 Ext12","Bip01 Ext13","Bip01 Ext14","Bip01 Ext15","Bip01 Ext16","Bip01 Ext17","Bip01 Ext18","Bip01 Ext19","Bip01 Ext20","Bip01 L Finger3","Bip01 L Finger31","Bip01 L Finger32","Bip01 L Finger4","Bip01 L Finger41","Bip01 L Finger42","Bip01 R Finger3","Bip01 R Finger31","Bip01 R Finger32","Bip01 R Finger4","Bip01 R Finger41","Bip01 R Finger42","Bip01 L Toe02","Bip01 L Toe03","Bip01 L Toe1","Bip01 L Toe11","Bip01 L Toe12","Bip01 L Toe2","Bip01 L Toe21","Bip01 L Toe22","Bip01 R Toe02","Bip01 R Toe03","Bip01 R Toe1","Bip01 R Toe11","Bip01 R Toe12","Bip01 R Toe2","Bip01 R Toe21","Bip01 R Toe22","Bip01 L ForeTwist","Bip01 L ForeTwist1","Bip01 R ForeTwist","Bip01 R ForeTwist1","Bip01 EyeLids","Bip01 L BicepTwist","Bip01 R BicepTwist","Bip01 L Pauldron","Bip01 R Pauldron","Bip01 Beard1","Bip01 Beard2","Bip01 FrontRobe1","Bip01 FrontRobe2","Bip01 BackRobe1","Bip01 BackRobe2","Bip01 C Cloak01","Bip01 C Cloak02","Bip01 C Cloak03","Bip01 C Cloak04","Bip01 C Cloak05","Bip01 L Cloak01","Bip01 L Cloak02","Bip01 L Cloak03","Bip01 L Cloak04","Bip01 L Cloak05","Bip01 R Cloak01","Bip01 R Cloak02","Bip01 R Cloak03","Bip01 R Cloak04","Bip01 R Cloak05","Bip01 C CloakIKChain","Bip01 L CloakIKChain","Bip01 R CloakIKChain","Bip01 L ThighTwist","Bip01 R ThighTwist","R Cloak Control01","L Cloak Control01","C Cloak Control01","C Cloak Control02","C Cloak Control03","C Cloak Control04","C Cloak Control05","C Cloak Control06","L Cloak Control02","L Cloak Control03","L Cloak Control04","L Cloak Control05","L Cloak Control06","R Cloak Control02","R Cloak Control03","R Cloak Control04","R Cloak Control05","R Cloak Control06"]

# Dictionnary to map bones names to id
bonename_dict = defaultdict(int)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this a defaultdict instead of a standard python dict?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No specific reason, it's now a dict :)

bonename_dict = defaultdict(int)
id = 0
for x in bone_names:
if not bonename_dict[x]:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you expecting some bone names to be duplicated in the bone_names list? If not, it is probably not necessary to have this check, and you could use enumerate for the id.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No indeed, the enumerate do the job and it's now the case, thanks

@DigitalBox98
Copy link
Author

The archive attached is for testing purpose (import NIF and then import KFA in Blender)

dr_rat.zip

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants