Users browsing this thread: 1 Guest(s)
NDS model + animation => COLLADA converter
#15
So the FBX does indeed break the armature, and sadly due to the way blender handles animations I couldn't find a way to pass them to the armature of the *.dae (the nice one) without screwing the animation itself.

So I ended writing and learning a phyton script that separates each *.dae file into several ones, each containing one of the animations in the original file, I only have to import each file individually and merge the animations into one single library, some require editing due to the extra frame they come with but that's not my fault, that's how they were, to begin with.

Anyway, here's the code for anyone interested, copy and paste it into a text file and change the extension to ".py", you'll need python2.7 for it to work

Code:
import sys
import xml.etree.ElementTree as ET
import copy

ET.register_namespace('', "http://www.collada.org/2005/11/COLLADASchema")

my_file = sys.argv[1]

tree = ET.parse(my_file)
root = tree.getroot()

ns = {'d': 'http://www.collada.org/2005/11/COLLADASchema'}

library_animation_clips = root.find('d:library_animation_clips', ns)
library_animation_clips_copy = copy.deepcopy(library_animation_clips)
library_animations = root.find('d:library_animations', ns)
library_animations_copy = copy.deepcopy(library_animations)

def libraryClear():
    for child in library_animation_clips.findall('d:animation_clip', ns):
        for child in library_animation_clips.findall('d:animation_clip', ns):
            library_animation_clips.remove(child)
        for child in library_animations.findall('d:animation', ns):
            library_animations.remove(child)
    return

libraryClear()

i = 0

for child in library_animation_clips_copy:
    
    library_animation_clips.append(child)
    
    att_id    = child.get('id')
    att_name  = child.get('name')
    file_name = att_name + ".dae"
    
    for joint in child:
        library_animations.append(library_animations_copy[i])
        i = i + 1
    
    tree.write(file_name, encoding="utf-8", xml_declaration=True)# <?xml version="1.0" encoding="utf-8"?>
    libraryClear()

I only tested it with three files, is not optimized and there is probably a better way to do this, but the thing works and is enough for me (although if you think it can be improved let me now to change what's needed).

Use the command line and pass the file as an argument

daesplitter.py <file>

or make a bat with this ("c:\Python27\python.exe" daesplitter.py %1), and drag and drop the file onto the bat.

And I was unable to make a test on Maya or 3Dmax due to the fact that 64 exclusive nowadays.
Reply
Thanked by: scurest


Messages In This Thread
RE: NDS model + animation => COLLADA converter - by Inferry - 05-20-2017, 10:32 PM

Forum Jump: