1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
|
import struct
class Node:
pass
BaseNode = Node()
BaseNode.mtx = [1.0,0.0,0.0,0.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0]
BaseNode.brres_key = '3D00'
BaseNode.model_name = 'GoldwoodBase'
BaseNode.lm_type = 0
TreeNode = Node()
TreeNode.mtx = [1.0,0.0,0.0,60.0,0.0,1.0,0.0,0.0,0.0,0.0,1.0,0.0]
TreeNode.brres_key = '3D00'
TreeNode.model_name = 'RedTree'
TreeNode.lm_type = 1
nodes = {}
nodes['Base'] = BaseNode
nodes['Tr00'] = TreeNode
header = struct.pack('>4sI', b'MScn', len(nodes))
entrydata = b''
stringtable = b''
currentoffset = 8 + (0x40 * len(nodes))
for key,node in nodes.items():
#nodekey, brreskey, lmtype, nameoffset, matrix
entrydata += struct.pack('>4s4sII', key.encode('Shift-JIS'), node.brres_key.encode('Shift-JIS'), node.lm_type, currentoffset)
for f in node.mtx:
entrydata += struct.pack('>f', f)
stringtable += node.model_name.encode('Shift-JIS')
stringtable += b'\0'
currentoffset += len(node.model_name) + 1
open('scenedata.bin', 'wb').write(header + entrydata + stringtable)
|