|
You last visited: Today at 15:24
Advertisement
[Help] how to extract Rappelz character animations
Discussion on [Help] how to extract Rappelz character animations within the Rappelz Private Server forum part of the Rappelz category.
07/10/2023, 15:57
|
#16
|
elite*gold: 0
Join Date: Mar 2013
Posts: 125
Received Thanks: 15
|
Quote:
Originally Posted by Anothers
I don't know how to explain, but I did a proper research and wrote the python NAF Reader without knowing python.
If anyone knows how to script or animate in Blender can use this code.
Like I said, this is reader only.
You will add their functionality.
What exactly do you want to know about this NAF?
NAF Reader With Python(It was made without knowing Python. Sorry if your eyes bleed.)
Code:
#Python 3.10
#Written by ZONE
file_path = "C:\\asm_cbt_attack01_c_biped.naf"
file = open(file_path, "rb") # "rb" modu ile binary dosyayı açın
BTRF = file.read(4)
print(BTRF)
header_size = file.read(4)
print(int.from_bytes(header_size, "little"), "Header Size")
major_version = file.read(2)
print(int.from_bytes(major_version, "little"), "MJ Ver")
minor_version = file.read(2)
print(int.from_bytes(minor_version, "little"), "MN Ver")
header_pos = file.read(4)
print(int.from_bytes(header_pos, "little"), "HEADER POS")
headers = int.from_bytes(header_size, "little")
header_naf_pos = headers + 8
print(header_naf_pos, "Header")
file.seek(header_naf_pos)
guid_size = file.read(4)
file.tell()
iGuidSize = int.from_bytes(guid_size, "little")
nwGuidSize = iGuidSize / 18
print(nwGuidSize)
GuidSizeList = readGuid(file, int(nwGuidSize))
print(GuidSizeList)
header_naf_pos = header_naf_pos + int(iGuidSize) + 4
file.seek(header_naf_pos)
ls = file.read(4)
pw = int.from_bytes(ls,"little")
string_count = int.from_bytes(file.read(4), "little")
print(string_count, "String Count")
stringCountArr = []
for l in range(string_count):
strings = ReadFixedString(file)
stringCountArr.append(strings)
print(stringCountArr)
header_naf_pos = header_naf_pos + int(pw) + 4
file.seek(header_naf_pos)
next_header_pos = file.read(4)
block_num = file.read(4)
blocks_num = int.from_bytes(block_num,"little")
for w in range(blocks_num):
us = file.read(3)
types = file.read(1)
block_size = file.read(4)
temp_index = file.read(2)
guidtableIndex = GuidSizeList[w]
if guidtableIndex == uuid.UUID('21e0bc81-76ad-6f34-9c7d-19885fd118b6'):
version = file.read(4)
ver = int.from_bytes(version,"little")
print(ver,"Version")
if guidtableIndex == uuid.UUID('6b29f9e8-ddb9-8040-8bc7-6c69e0aa3feb'):
bone_count = file.read(4)
bCount = int.from_bytes(bone_count,"little")
channel_count = file.read(4)
nx3_bone_ani_channel_index = file.read(2)
bone_ani_channel_index = int.from_bytes(nx3_bone_ani_channel_index,"little")
boneGUID = GuidSizeList[bone_ani_channel_index - 1]
if boneGUID == uuid.UUID('37c1b381-b8b2-b040-a3ad-d149467f5932'):
channel_name = file.read(4)
channel_flag = file.read(4)
channel_time_span = file.read(4)
channel_frame_rate = file.read(4)
bone_ani_size = file.read(4)
file.read(4)
file.read(4)
nx3_bone_ani_index = file.read(2)
bone_ani_index = int.from_bytes(nx3_bone_ani_index,"little")
BoneAniIndex = GuidSizeList[bone_ani_index - 1]
if BoneAniIndex == uuid.UUID('de4443b8-b6a1-a74a-afd6-22ca8a4b0cee'):
bone_count = file.read(4)
bCount = int.from_bytes(bone_count,"little")
print(bCount,"Bone Count")
boneArray = []
for b in range(bCount):
file.read(4)
boneSzName = file.read(4)
boneNm = int.from_bytes(boneSzName,"little")
BoneName = stringCountArr[b]
parent_id = file.read(4)
file.read(64) #BONE TM
flag = file.read(4)
pos_time_size = file.read(4)
iPsTimeSize = int.from_bytes(pos_time_size,"little")
PosTimeSize = iPsTimeSize / 4
file.read(1)
for p in range(int(PosTimeSize)):
pos_time = file.read(4)
pos_key_size = file.read(4)
iPsKeySize = int.from_bytes(pos_key_size,"little")
PosKeySize = iPsKeySize / 12
file.read(1)
for ky in range(int(PosKeySize)):
x = file.read(4)
y = file.read(4)
z = file.read(4)
xFloat = struct.unpack('f',x)
yFloat = struct.unpack('f',y)
zFloat = struct.unpack('f',z)
rot_time_size = file.read(4)
iRotTimeSize = int.from_bytes(rot_time_size,"little")
RotTimeSize = iRotTimeSize / 4
file.read(1)
for rt in range(int(RotTimeSize)):
rot_time = file.read(4)
rot_key_size = file.read(4)
iRotKeySize = int.from_bytes(rot_key_size,"little")
RotKeySize = iRotKeySize / 16
file.read(1)
for rk in range(int(RotKeySize)):
x = file.read(4)
y = file.read(4)
z = file.read(4)
w = file.read(4)
xFloat = struct.unpack('f',x)
yFloat = struct.unpack('f',y)
zFloat = struct.unpack('f',z)
wFloat = struct.unpack('f',w)
child_size = file.read(4)
iChildSize = int.from_bytes(child_size,"little")
ChildSize = iChildSize / 4
file.read(1)
for cl in range(int(ChildSize)):
child_index = file.read(4)
|
thanks, what version of blender supports python 3.10?
and what do you mean by "adding functionality?"
|
|
|
07/11/2023, 11:39
|
#17
|
elite*gold: 0
Join Date: Jul 2020
Posts: 190
Received Thanks: 85
|
Quote:
Originally Posted by hassuny
thanks, what version of blender supports python 3.10?
and what do you mean by "adding functionality?"
|
This is simply to import the data into blender, You can use this to set the keyframes yourself, What I recommend doing instead as this is probably too hard if you don't know how to program hit up someone called AOR and see if he's willing to sell some animations as I'm pretty sure he's got it figured out
|
|
|
07/11/2023, 18:26
|
#18
|
elite*gold: 0
Join Date: Mar 2013
Posts: 125
Received Thanks: 15
|
Quote:
Originally Posted by Masumichan
This is simply to import the data into blender, You can use this to set the keyframes yourself, What I recommend doing instead as this is probably too hard if you don't know how to program hit up someone called AOR and see if he's willing to sell some animations as I'm pretty sure he's got it figured out
|
thanks for replying, I know how to program but I don't know how to script with Blender. My aim is to extract models and animations and use them in unity3d.
what do you mean by "You can use this to set the keyframes yourself"?
Do you mean creating new animations? if that is so I'm not interested in creating new animations.
|
|
|
07/11/2023, 19:55
|
#19
|
elite*gold: 0
Join Date: Jul 2020
Posts: 190
Received Thanks: 85
|
Quote:
Originally Posted by hassuny
thanks for replying, I know how to program but I don't know how to script with Blender. My aim is to extract models and animations and use them in unity3d.
what do you mean by "You can use this to set the keyframes yourself"?
Do you mean creating new animations? if that is so I'm not interested in creating new animations.
|
Keyframes are points in the timeline which indicate a rotation or location changing at a certain time point
|
|
|
07/11/2023, 21:41
|
#20
|
elite*gold: 0
Join Date: Mar 2013
Posts: 125
Received Thanks: 15
|
Quote:
Originally Posted by Masumichan
Keyframes are points in the timeline which indicate a rotation or location changing at a certain time point
|
I got you.
Now I tried the script with Blender 2.78, and it did not work. do you know which version of Blender this Naf script (by Zone) works with?
|
|
|
07/12/2023, 01:30
|
#21
|
elite*gold: 0
Join Date: Aug 2013
Posts: 72
Received Thanks: 89
|
Quote:
Originally Posted by hassuny
I got you.
Now I tried the script with Blender 2.78, and it did not work. do you know which version of Blender this Naf script (by Zone) works with?
|
I have the official animations on unity and what I can tell you is that the first thing to do will be to convert the naf DIFK to naf BTRF, 90%+ of the character animations are in difk.
Please contact me for more information and to see if I can help you. I'm not often on epvp, so don't be surprised if I don't answer directly.
|
|
|
07/12/2023, 15:39
|
#22
|
elite*gold: 0
Join Date: Mar 2013
Posts: 125
Received Thanks: 15
|
Quote:
Originally Posted by omgkllz
I have the official animations on unity and what I can tell you is that the first thing to do will be to convert the naf DIFK to naf BTRF, 90%+ of the character animations are in difk.
Please contact me for more information and to see if I can help you. I'm not often on epvp, so don't be surprised if I don't answer directly.
|
thank you very much, I will send you pm.
|
|
|
07/13/2023, 14:29
|
#23
|
elite*gold: 0
Join Date: Mar 2013
Posts: 125
Received Thanks: 15
|
Quote:
Originally Posted by Anothers
I don't know how to explain, but I did a proper research and wrote the python NAF Reader without knowing python.
If anyone knows how to script or animate in Blender can use this code.
Like I said, this is reader only.
You will add their functionality.
What exactly do you want to know about this NAF?
NAF Reader With Python(It was made without knowing Python. Sorry if your eyes bleed.)
Code:
#Python 3.10
#Written by ZONE
file_path = "C:\\asm_cbt_attack01_c_biped.naf"
file = open(file_path, "rb") # "rb" modu ile binary dosyayı açın
BTRF = file.read(4)
print(BTRF)
header_size = file.read(4)
print(int.from_bytes(header_size, "little"), "Header Size")
major_version = file.read(2)
print(int.from_bytes(major_version, "little"), "MJ Ver")
minor_version = file.read(2)
print(int.from_bytes(minor_version, "little"), "MN Ver")
header_pos = file.read(4)
print(int.from_bytes(header_pos, "little"), "HEADER POS")
headers = int.from_bytes(header_size, "little")
header_naf_pos = headers + 8
print(header_naf_pos, "Header")
file.seek(header_naf_pos)
guid_size = file.read(4)
file.tell()
iGuidSize = int.from_bytes(guid_size, "little")
nwGuidSize = iGuidSize / 18
print(nwGuidSize)
GuidSizeList = readGuid(file, int(nwGuidSize))
print(GuidSizeList)
header_naf_pos = header_naf_pos + int(iGuidSize) + 4
file.seek(header_naf_pos)
ls = file.read(4)
pw = int.from_bytes(ls,"little")
string_count = int.from_bytes(file.read(4), "little")
print(string_count, "String Count")
stringCountArr = []
for l in range(string_count):
strings = ReadFixedString(file)
stringCountArr.append(strings)
print(stringCountArr)
header_naf_pos = header_naf_pos + int(pw) + 4
file.seek(header_naf_pos)
next_header_pos = file.read(4)
block_num = file.read(4)
blocks_num = int.from_bytes(block_num,"little")
for w in range(blocks_num):
us = file.read(3)
types = file.read(1)
block_size = file.read(4)
temp_index = file.read(2)
guidtableIndex = GuidSizeList[w]
if guidtableIndex == uuid.UUID('21e0bc81-76ad-6f34-9c7d-19885fd118b6'):
version = file.read(4)
ver = int.from_bytes(version,"little")
print(ver,"Version")
if guidtableIndex == uuid.UUID('6b29f9e8-ddb9-8040-8bc7-6c69e0aa3feb'):
bone_count = file.read(4)
bCount = int.from_bytes(bone_count,"little")
channel_count = file.read(4)
nx3_bone_ani_channel_index = file.read(2)
bone_ani_channel_index = int.from_bytes(nx3_bone_ani_channel_index,"little")
boneGUID = GuidSizeList[bone_ani_channel_index - 1]
if boneGUID == uuid.UUID('37c1b381-b8b2-b040-a3ad-d149467f5932'):
channel_name = file.read(4)
channel_flag = file.read(4)
channel_time_span = file.read(4)
channel_frame_rate = file.read(4)
bone_ani_size = file.read(4)
file.read(4)
file.read(4)
nx3_bone_ani_index = file.read(2)
bone_ani_index = int.from_bytes(nx3_bone_ani_index,"little")
BoneAniIndex = GuidSizeList[bone_ani_index - 1]
if BoneAniIndex == uuid.UUID('de4443b8-b6a1-a74a-afd6-22ca8a4b0cee'):
bone_count = file.read(4)
bCount = int.from_bytes(bone_count,"little")
print(bCount,"Bone Count")
boneArray = []
for b in range(bCount):
file.read(4)
boneSzName = file.read(4)
boneNm = int.from_bytes(boneSzName,"little")
BoneName = stringCountArr[b]
parent_id = file.read(4)
file.read(64) #BONE TM
flag = file.read(4)
pos_time_size = file.read(4)
iPsTimeSize = int.from_bytes(pos_time_size,"little")
PosTimeSize = iPsTimeSize / 4
file.read(1)
for p in range(int(PosTimeSize)):
pos_time = file.read(4)
pos_key_size = file.read(4)
iPsKeySize = int.from_bytes(pos_key_size,"little")
PosKeySize = iPsKeySize / 12
file.read(1)
for ky in range(int(PosKeySize)):
x = file.read(4)
y = file.read(4)
z = file.read(4)
xFloat = struct.unpack('f',x)
yFloat = struct.unpack('f',y)
zFloat = struct.unpack('f',z)
rot_time_size = file.read(4)
iRotTimeSize = int.from_bytes(rot_time_size,"little")
RotTimeSize = iRotTimeSize / 4
file.read(1)
for rt in range(int(RotTimeSize)):
rot_time = file.read(4)
rot_key_size = file.read(4)
iRotKeySize = int.from_bytes(rot_key_size,"little")
RotKeySize = iRotKeySize / 16
file.read(1)
for rk in range(int(RotKeySize)):
x = file.read(4)
y = file.read(4)
z = file.read(4)
w = file.read(4)
xFloat = struct.unpack('f',x)
yFloat = struct.unpack('f',y)
zFloat = struct.unpack('f',z)
wFloat = struct.unpack('f',w)
child_size = file.read(4)
iChildSize = int.from_bytes(child_size,"little")
ChildSize = iChildSize / 4
file.read(1)
for cl in range(int(ChildSize)):
child_index = file.read(4)
|
what version of blender supports python 3.10?
|
|
|
07/15/2023, 16:42
|
#24
|
elite*gold: 0
Join Date: Mar 2013
Posts: 125
Received Thanks: 15
|
up up
|
|
|
07/22/2023, 11:07
|
#25
|
elite*gold: 0
Join Date: Mar 2013
Posts: 125
Received Thanks: 15
|
Quote:
Originally Posted by Anothers
I don't know how to explain, but I did a proper research and wrote the python NAF Reader without knowing python.
If anyone knows how to script or animate in Blender can use this code.
Like I said, this is reader only.
You will add their functionality.
What exactly do you want to know about this NAF?
NAF Reader With Python(It was made without knowing Python. Sorry if your eyes bleed.)
Code:
#Python 3.10
#Written by ZONE
file_path = "C:\\asm_cbt_attack01_c_biped.naf"
file = open(file_path, "rb") # "rb" modu ile binary dosyayı açın
BTRF = file.read(4)
print(BTRF)
header_size = file.read(4)
print(int.from_bytes(header_size, "little"), "Header Size")
major_version = file.read(2)
print(int.from_bytes(major_version, "little"), "MJ Ver")
minor_version = file.read(2)
print(int.from_bytes(minor_version, "little"), "MN Ver")
header_pos = file.read(4)
print(int.from_bytes(header_pos, "little"), "HEADER POS")
headers = int.from_bytes(header_size, "little")
header_naf_pos = headers + 8
print(header_naf_pos, "Header")
file.seek(header_naf_pos)
guid_size = file.read(4)
file.tell()
iGuidSize = int.from_bytes(guid_size, "little")
nwGuidSize = iGuidSize / 18
print(nwGuidSize)
GuidSizeList = readGuid(file, int(nwGuidSize))
print(GuidSizeList)
header_naf_pos = header_naf_pos + int(iGuidSize) + 4
file.seek(header_naf_pos)
ls = file.read(4)
pw = int.from_bytes(ls,"little")
string_count = int.from_bytes(file.read(4), "little")
print(string_count, "String Count")
stringCountArr = []
for l in range(string_count):
strings = ReadFixedString(file)
stringCountArr.append(strings)
print(stringCountArr)
header_naf_pos = header_naf_pos + int(pw) + 4
file.seek(header_naf_pos)
next_header_pos = file.read(4)
block_num = file.read(4)
blocks_num = int.from_bytes(block_num,"little")
for w in range(blocks_num):
us = file.read(3)
types = file.read(1)
block_size = file.read(4)
temp_index = file.read(2)
guidtableIndex = GuidSizeList[w]
if guidtableIndex == uuid.UUID('21e0bc81-76ad-6f34-9c7d-19885fd118b6'):
version = file.read(4)
ver = int.from_bytes(version,"little")
print(ver,"Version")
if guidtableIndex == uuid.UUID('6b29f9e8-ddb9-8040-8bc7-6c69e0aa3feb'):
bone_count = file.read(4)
bCount = int.from_bytes(bone_count,"little")
channel_count = file.read(4)
nx3_bone_ani_channel_index = file.read(2)
bone_ani_channel_index = int.from_bytes(nx3_bone_ani_channel_index,"little")
boneGUID = GuidSizeList[bone_ani_channel_index - 1]
if boneGUID == uuid.UUID('37c1b381-b8b2-b040-a3ad-d149467f5932'):
channel_name = file.read(4)
channel_flag = file.read(4)
channel_time_span = file.read(4)
channel_frame_rate = file.read(4)
bone_ani_size = file.read(4)
file.read(4)
file.read(4)
nx3_bone_ani_index = file.read(2)
bone_ani_index = int.from_bytes(nx3_bone_ani_index,"little")
BoneAniIndex = GuidSizeList[bone_ani_index - 1]
if BoneAniIndex == uuid.UUID('de4443b8-b6a1-a74a-afd6-22ca8a4b0cee'):
bone_count = file.read(4)
bCount = int.from_bytes(bone_count,"little")
print(bCount,"Bone Count")
boneArray = []
for b in range(bCount):
file.read(4)
boneSzName = file.read(4)
boneNm = int.from_bytes(boneSzName,"little")
BoneName = stringCountArr[b]
parent_id = file.read(4)
file.read(64) #BONE TM
flag = file.read(4)
pos_time_size = file.read(4)
iPsTimeSize = int.from_bytes(pos_time_size,"little")
PosTimeSize = iPsTimeSize / 4
file.read(1)
for p in range(int(PosTimeSize)):
pos_time = file.read(4)
pos_key_size = file.read(4)
iPsKeySize = int.from_bytes(pos_key_size,"little")
PosKeySize = iPsKeySize / 12
file.read(1)
for ky in range(int(PosKeySize)):
x = file.read(4)
y = file.read(4)
z = file.read(4)
xFloat = struct.unpack('f',x)
yFloat = struct.unpack('f',y)
zFloat = struct.unpack('f',z)
rot_time_size = file.read(4)
iRotTimeSize = int.from_bytes(rot_time_size,"little")
RotTimeSize = iRotTimeSize / 4
file.read(1)
for rt in range(int(RotTimeSize)):
rot_time = file.read(4)
rot_key_size = file.read(4)
iRotKeySize = int.from_bytes(rot_key_size,"little")
RotKeySize = iRotKeySize / 16
file.read(1)
for rk in range(int(RotKeySize)):
x = file.read(4)
y = file.read(4)
z = file.read(4)
w = file.read(4)
xFloat = struct.unpack('f',x)
yFloat = struct.unpack('f',y)
zFloat = struct.unpack('f',z)
wFloat = struct.unpack('f',w)
child_size = file.read(4)
iChildSize = int.from_bytes(child_size,"little")
ChildSize = iChildSize / 4
file.read(1)
for cl in range(int(ChildSize)):
child_index = file.read(4)
|
when I tried the script on (btrf) animation I got this error message!
Read prefs: C:\Users\Acer\AppData\Roaming\Blender Foundation\Blender\3.0\config\userpref.blend
b'BTRF'
4 Header Size
1 MJ Ver
1 MN Ver
72 HEADER POS
12 Header
4.0
Traceback (most recent call last):
File "\Text", line 26, in <module>
NameError: name 'readGuid' is not defined
Error: Python script failed, check the message in the system console
|
|
|
07/24/2023, 22:24
|
#26
|
elite*gold: 0
Join Date: Oct 2013
Posts: 128
Received Thanks: 108
|
Quote:
Originally Posted by hassuny
when I tried the script on (btrf) animation I got this error message!
Read prefs: C:\Users\Acer\AppData\Roaming\Blender Foundation\Blender\3.0\config\userpref.blend
b'BTRF'
4 Header Size
1 MJ Ver
1 MN Ver
72 HEADER POS
12 Header
4.0
Traceback (most recent call last):
File "\Text", line 26, in <module>
NameError: name 'readGuid' is not defined
Error: Python script failed, check the message in the system console
|
You can do it with this but I'm not sure it's exactly correct.
You add functions.
Blender 3.0 NAF Reader
Code:
#Writed By ZONE
import bpy
import uuid
import struct
import mathutils
class NAF():
def __init__(self):
self.BTRF = ""
self.header_size = 0
self.major_version = 0
self.minor_version = 0
self.header_pos = 0
def ReadFixedString(file):
test = ""
while True:
c = file.read(1)
lw = int.from_bytes(c, "big")
sd = c.decode('utf-8')
if lw == 0:
break
test += str(sd)
return test
def readGuid(file, sdw):
print(sdw)
tewa = []
for x in range(sdw):
w = file.read(16)
dsw = uuid.UUID(bytes=w)
tewa.append(dsw)
return tewa
def ReadInt(file):
return struct.unpack("i",file.read(4))[0]
def ReadBTRF(file):
return struct.unpack("4s",file.read(4))[0].decode()
def ReadShort(file):
return struct.unpack("h",file.read(2))[0]
def ReadFloat(file):
return struct.unpack("f",file.read(4))[0]
def ProcessFile():
file_path = "C:\\asm_cbt_attack01_c_biped.naf"
with open(file_path,"rb") as file:
E = NAF()
E.BTRF = ReadBTRF(file)
E.header_size = ReadInt(file)
E.major_version = ReadShort(file)
E.minor_version = ReadShort(file)
E.header_pos = ReadInt(file)
header_naf_pos = E.header_size + 8
file.seek(header_naf_pos)
print(file.tell())
GUIDSIZE = ReadInt(file)
print("GUID SİZE",GUIDSIZE)
sz = int(GUIDSIZE / 18)
GuidSizeList = readGuid(file,sz)
print(GuidSizeList)
header_naf_pos = header_naf_pos + int(GUIDSIZE) + 4
file.seek(header_naf_pos)
print("Current Pos",file.tell())
ls = ReadInt(file)
stringArray = []
string_count = ReadInt(file)
for s in range(string_count):
strings = ReadFixedString(file)
stringArray.append(strings)
print(stringArray)
header_naf_pos = header_naf_pos + int(ls) + 4
file.seek(header_naf_pos)
print("Current Pos",file.tell())
next_header_pos = ReadInt(file)
block_num = ReadInt(file)
for b in range(block_num):
file.read(3)
types = file.read(1)
block_size = ReadInt(file)
temp_index = ReadShort(file)
guidTableIndex = GuidSizeList[b]
if guidTableIndex == uuid.UUID('21e0bc81-76ad-6f34-9c7d-19885fd118b6'):
version = ReadInt(file)
print("Version",version)
if guidTableIndex == uuid.UUID('6b29f9e8-ddb9-8040-8bc7-6c69e0aa3feb'):
bone_counts = ReadInt(file)
channel_count = ReadInt(file)
ani_channel_index = ReadShort(file)
Bone_GUID = GuidSizeList[ani_channel_index - 1]
if Bone_GUID == uuid.UUID('37c1b381-b8b2-b040-a3ad-d149467f5932'):
channel_name = ReadInt(file)
channel_flag = ReadInt(file)
channel_time_span = ReadInt(file)
channel_frame_rate = ReadInt(file)
bone_ani_size = ReadInt(file)
file.read(4)
file.read(4)
bone_ani_index = ReadShort(file)
Bone_Ani_GUID = GuidSizeList[bone_ani_index-1]
if Bone_Ani_GUID == uuid.UUID('de4443b8-b6a1-a74a-afd6-22ca8a4b0cee'):
bCount = ReadInt(file)
for bk in range(bCount):
file.read(4)
boneSName = ReadInt(file)
boneName = stringArray[bk]
print("Bone Name : ", boneName)
parent_id = ReadInt(file)
parentName = stringArray[parent_id]
file.read(64) #Bone TM
flag = ReadInt(file)
pos_time_size = int(ReadInt(file) / 4)
file.read(1)
posTimeArray = []
for ps in range(pos_time_size):
pos_time = ReadInt(file)
posTimeArray.append(pos_time)
print("POS Time Array ",posTimeArray)
posKeyArray = []
pos_key_size = int(ReadInt(file) / 12)
file.read(1)
for pk in range(pos_key_size):
x = ReadFloat(file)
y = ReadFloat(file)
z = ReadFloat(file)
matk = mathutils.Vector((x,y,z))
posKeyArray.append(matk)
print("Pos Key Array",posKeyArray)
rotTimeArray = []
rot_time_size = int(ReadInt(file) / 4)
file.read(1)
for rt in range(rot_time_size):
rot_time = ReadInt(file)
rotTimeArray.append(rot_time)
print("Rot Time Array",rotTimeArray)
rotKeyArray = []
rot_key_size = int(ReadInt(file) / 16)
file.read(1)
for rk in range(rot_key_size):
x = ReadFloat(file)
y = ReadFloat(file)
z = ReadFloat(file)
w = ReadFloat(file)
mats = mathutils.Quaternion([w,x,y,z])
mats.invert()
rotKeyArray.append(mats)
print("Rot Key Array",rotKeyArray)
child_size = int(ReadInt(file) / 4)
file.read(1)
for cz in range(child_size):
child_index_array = ReadInt(file)
ProcessFile()
|
|
|
07/25/2023, 20:54
|
#27
|
elite*gold: 0
Join Date: Mar 2013
Posts: 125
Received Thanks: 15
|
Quote:
Originally Posted by Anothers
You can do it with this but I'm not sure it's exactly correct.
You add functions.
Blender 3.0 NAF Reader
Code:
#Writed By ZONE
import bpy
import uuid
import struct
import mathutils
class NAF():
def __init__(self):
self.BTRF = ""
self.header_size = 0
self.major_version = 0
self.minor_version = 0
self.header_pos = 0
def ReadFixedString(file):
test = ""
while True:
c = file.read(1)
lw = int.from_bytes(c, "big")
sd = c.decode('utf-8')
if lw == 0:
break
test += str(sd)
return test
def readGuid(file, sdw):
print(sdw)
tewa = []
for x in range(sdw):
w = file.read(16)
dsw = uuid.UUID(bytes=w)
tewa.append(dsw)
return tewa
def ReadInt(file):
return struct.unpack("i",file.read(4))[0]
def ReadBTRF(file):
return struct.unpack("4s",file.read(4))[0].decode()
def ReadShort(file):
return struct.unpack("h",file.read(2))[0]
def ReadFloat(file):
return struct.unpack("f",file.read(4))[0]
def ProcessFile():
file_path = "C:\\asm_cbt_attack01_c_biped.naf"
with open(file_path,"rb") as file:
E = NAF()
E.BTRF = ReadBTRF(file)
E.header_size = ReadInt(file)
E.major_version = ReadShort(file)
E.minor_version = ReadShort(file)
E.header_pos = ReadInt(file)
header_naf_pos = E.header_size + 8
file.seek(header_naf_pos)
print(file.tell())
GUIDSIZE = ReadInt(file)
print("GUID SİZE",GUIDSIZE)
sz = int(GUIDSIZE / 18)
GuidSizeList = readGuid(file,sz)
print(GuidSizeList)
header_naf_pos = header_naf_pos + int(GUIDSIZE) + 4
file.seek(header_naf_pos)
print("Current Pos",file.tell())
ls = ReadInt(file)
stringArray = []
string_count = ReadInt(file)
for s in range(string_count):
strings = ReadFixedString(file)
stringArray.append(strings)
print(stringArray)
header_naf_pos = header_naf_pos + int(ls) + 4
file.seek(header_naf_pos)
print("Current Pos",file.tell())
next_header_pos = ReadInt(file)
block_num = ReadInt(file)
for b in range(block_num):
file.read(3)
types = file.read(1)
block_size = ReadInt(file)
temp_index = ReadShort(file)
guidTableIndex = GuidSizeList[b]
if guidTableIndex == uuid.UUID('21e0bc81-76ad-6f34-9c7d-19885fd118b6'):
version = ReadInt(file)
print("Version",version)
if guidTableIndex == uuid.UUID('6b29f9e8-ddb9-8040-8bc7-6c69e0aa3feb'):
bone_counts = ReadInt(file)
channel_count = ReadInt(file)
ani_channel_index = ReadShort(file)
Bone_GUID = GuidSizeList[ani_channel_index - 1]
if Bone_GUID == uuid.UUID('37c1b381-b8b2-b040-a3ad-d149467f5932'):
channel_name = ReadInt(file)
channel_flag = ReadInt(file)
channel_time_span = ReadInt(file)
channel_frame_rate = ReadInt(file)
bone_ani_size = ReadInt(file)
file.read(4)
file.read(4)
bone_ani_index = ReadShort(file)
Bone_Ani_GUID = GuidSizeList[bone_ani_index-1]
if Bone_Ani_GUID == uuid.UUID('de4443b8-b6a1-a74a-afd6-22ca8a4b0cee'):
bCount = ReadInt(file)
for bk in range(bCount):
file.read(4)
boneSName = ReadInt(file)
boneName = stringArray[bk]
print("Bone Name : ", boneName)
parent_id = ReadInt(file)
parentName = stringArray[parent_id]
file.read(64) #Bone TM
flag = ReadInt(file)
pos_time_size = int(ReadInt(file) / 4)
file.read(1)
posTimeArray = []
for ps in range(pos_time_size):
pos_time = ReadInt(file)
posTimeArray.append(pos_time)
print("POS Time Array ",posTimeArray)
posKeyArray = []
pos_key_size = int(ReadInt(file) / 12)
file.read(1)
for pk in range(pos_key_size):
x = ReadFloat(file)
y = ReadFloat(file)
z = ReadFloat(file)
matk = mathutils.Vector((x,y,z))
posKeyArray.append(matk)
print("Pos Key Array",posKeyArray)
rotTimeArray = []
rot_time_size = int(ReadInt(file) / 4)
file.read(1)
for rt in range(rot_time_size):
rot_time = ReadInt(file)
rotTimeArray.append(rot_time)
print("Rot Time Array",rotTimeArray)
rotKeyArray = []
rot_key_size = int(ReadInt(file) / 16)
file.read(1)
for rk in range(rot_key_size):
x = ReadFloat(file)
y = ReadFloat(file)
z = ReadFloat(file)
w = ReadFloat(file)
mats = mathutils.Quaternion([w,x,y,z])
mats.invert()
rotKeyArray.append(mats)
print("Rot Key Array",rotKeyArray)
child_size = int(ReadInt(file) / 4)
file.read(1)
for cz in range(child_size):
child_index_array = ReadInt(file)
ProcessFile()
|
thnx, It worked without problems. but I don't know how to add functions to apply the animations data to the character 
|
|
|
07/28/2023, 15:14
|
#28
|
elite*gold: 0
Join Date: Mar 2013
Posts: 125
Received Thanks: 15
|
up up
|
|
|
07/28/2023, 21:07
|
#29
|
elite*gold: 0
Join Date: Jul 2020
Posts: 190
Received Thanks: 85
|
Not to sound like a douche, But I really don't think anyone is going to give you a fully working work flow for free, Unless you're willing to put in the effort yourself I'm pretty sure you probably wont get it.
|
|
|
07/29/2023, 07:08
|
#30
|
elite*gold: 0
Join Date: Mar 2013
Posts: 125
Received Thanks: 15
|
Quote:
Originally Posted by Masumichan
Not to sound like a douche, But I really don't think anyone is going to give you a fully working work flow for free, Unless you're willing to put in the effort yourself I'm pretty sure you probably wont get it.
|
I agree with you and appreciate your advice. nevertheless, I got a lot of information from this thread.
|
|
|
Similar Threads
|
[GUIDE/ANIMATIONS] Creating run/walk animations which work properly
09/25/2012 - Metin2 PServer Guides & Strategies - 2 Replies
Good afternoon elitepvpers,
in this brief guide I will explain how to create any animation that implies a movement of the model in the world space. Many have been wondering why new run or walk animations wouldn't work properly, and today I will explain the reason. I'm sorry but I did not include any screenshot, for lack of both willingness and time.
An animations works by moving various bones, and I think this part is clear to everyone. The thing is, the Granny3D engine cannot know if the...
|
All times are GMT +1. The time now is 15:25.
|
|