Author Topic: Plugin for importing bones and animations to Blender from .anim (RE1MV)  (Read 778 times)

Ivan Enzhaev

  • Newbie
  • *
  • Posts: 29
Yes, positions are relative to parents. I wrote a script for Blender that set object hierarchy and set object positions:



Code: [Select]
import bpy

scale = 1

file = open("E:\\_Projects\\WebGL\\re\\re1-animaitons-webgl10-ts\\project_files\\CHAR11_01.ANI", "r")
lines = file.readlines() # get all lines

current_file_line = 0;
amount = int(lines[current_file_line]) # get an amount of bones
current_file_line += 1

# Create an array of object, scale and apply rotations
whole_object = []
for i in range(amount):
    whole_object.append(bpy.data.objects["Object_" + str(i) + ".002"])
    whole_object[i].scale = (scale, scale, scale)
    whole_object[i].select = True
    bpy.ops.object.transform_apply(location=False, rotation=True, scale=False)

# Set parents
for i in range(amount):
    line_parts = lines[current_file_line].split()
    current_file_line += 1
    bone_amount = int(line_parts[0])
    for j in range(bone_amount):
        index = int(line_parts[j+1])
        whole_object[index].parent = whole_object[i]

# Set positions
start_index = amount+1
for i in range(amount):
    coords = lines[start_index + i].split()
    x = float(coords[0])
    y = float(coords[1])
    z = float(coords[2])
    print(x, y, z)
    whole_object[i].location = (x, y, z)