bones
This commit is contained in:
parent
f5dfc32779
commit
2dbf87ad81
24
NinjaBone.py
24
NinjaBone.py
@ -24,6 +24,7 @@
|
||||
"""
|
||||
|
||||
import math
|
||||
import struct
|
||||
from Mat4 import Mat4
|
||||
|
||||
class NinjaBone: # {
|
||||
@ -77,3 +78,26 @@ class NinjaBone: # {
|
||||
|
||||
def apply(self, vec3):
|
||||
return self.world.apply(vec3)
|
||||
|
||||
def createDmfEntry(self, file):
|
||||
|
||||
# 0x00 Name
|
||||
name = self.name
|
||||
while len(name) < 0x20:
|
||||
name += '\0'
|
||||
bytes = name.encode()
|
||||
file.write(bytes)
|
||||
|
||||
# 0x20 Index
|
||||
file.write(struct.pack('hh', self.index, self.parentIndex))
|
||||
file.write(struct.pack('III', 0, 0, 0))
|
||||
|
||||
# 0x30 Local Matrix
|
||||
m = self.local.mtx
|
||||
file.write(struct.pack('ffff', m[0][0], m[0][1], m[0][2], m[0][3]))
|
||||
file.write(struct.pack('ffff', m[1][0], m[1][1], m[1][2], m[1][3]))
|
||||
file.write(struct.pack('ffff', m[2][0], m[2][1], m[2][2], m[2][3]))
|
||||
file.write(struct.pack('ffff', m[3][0], m[3][1], m[3][2], m[3][3]))
|
||||
return None
|
||||
|
||||
|
||||
|
@ -472,7 +472,7 @@ class NinjaModel: # {
|
||||
|
||||
for vert in self.vertex_list:
|
||||
vert.createDmfEntry(f)
|
||||
|
||||
|
||||
while f.tell() % 0x10:
|
||||
f.write(struct.pack('B', 0))
|
||||
|
||||
@ -489,6 +489,16 @@ class NinjaModel: # {
|
||||
while f.tell() % 0x10:
|
||||
f.write(struct.pack('B', 0))
|
||||
|
||||
# Write Bones
|
||||
pos = f.tell()
|
||||
count = len(self.bones)
|
||||
f.seek(0x58, 0)
|
||||
f.write(struct.pack('II', pos, count))
|
||||
f.seek(0, 2)
|
||||
|
||||
for bone in self.bones:
|
||||
bone.createDmfEntry(f)
|
||||
|
||||
f.close()
|
||||
return None
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user