summaryrefslogtreecommitdiff
path: root/scenegen_.py
diff options
context:
space:
mode:
authorTreeki <treeki@gmail.com>2011-03-16 05:15:57 +0100
committerTreeki <treeki@gmail.com>2011-03-16 05:15:57 +0100
commit938dee99403d750c97452b20831a6c549bbac649 (patch)
tree95825fc4c44af6960fa17f8c545dd1dacd549201 /scenegen_.py
parent562543f0c7658f11595f37c886861efaf76b5d5a (diff)
downloadkamek-938dee99403d750c97452b20831a6c549bbac649.tar.gz
kamek-938dee99403d750c97452b20831a6c549bbac649.zip
yawn. some work on content, including an embarassingly crappy GW scenegen
Diffstat (limited to '')
-rw-r--r--scenegen_.py48
1 files changed, 48 insertions, 0 deletions
diff --git a/scenegen_.py b/scenegen_.py
new file mode 100644
index 0000000..418d1b9
--- /dev/null
+++ b/scenegen_.py
@@ -0,0 +1,48 @@
+import struct
+
+from collections import OrderedDict
+
+from gameobjects.matrix44 import *
+from gameobjects.vector3 import *
+
+
+class Node:
+ pass
+
+nodes = OrderedDict()
+
+BaseNode = Node()
+BaseNode.mtx = Matrix44()
+BaseNode.brres_key = '3D00'
+BaseNode.model_name = 'WorldBase'
+BaseNode.lm_type = 0
+nodes['Base'] = BaseNode
+
+
+
+# todo: string table optimisation
+
+header = struct.pack('>4sI', b'MScn', len(nodes))
+entrydata = b''
+stringtable = b''
+stringoffsets = {}
+currentoffset = 8 + (0x40 * len(nodes))
+
+for key,node in nodes.items():
+ #nodekey, brreskey, lmtype, nameoffset, matrix
+ enc_name = node.model_name.encode('Shift-JIS')
+ if enc_name not in stringoffsets:
+ stringoffsets[enc_name] = currentoffset
+ stringtable += enc_name + b'\0'
+ currentoffset += len(enc_name) + 1
+
+ nameoffs = stringoffsets[enc_name]
+
+
+ entrydata += struct.pack('>4s4sII', key.encode('Shift-JIS'), node.brres_key.encode('Shift-JIS'), node.lm_type, stringoffsets[enc_name])
+ for f in list(node.mtx.transposed_components())[0:12]:
+ entrydata += struct.pack('>f', f)
+
+
+open('scenedata.bin', 'wb').write(header + entrydata + stringtable)
+