diff options
author | Treeki <treeki@gmail.com> | 2011-03-16 05:15:57 +0100 |
---|---|---|
committer | Treeki <treeki@gmail.com> | 2011-03-16 05:15:57 +0100 |
commit | 938dee99403d750c97452b20831a6c549bbac649 (patch) | |
tree | 95825fc4c44af6960fa17f8c545dd1dacd549201 | |
parent | 562543f0c7658f11595f37c886861efaf76b5d5a (diff) | |
download | kamek-938dee99403d750c97452b20831a6c549bbac649.tar.gz kamek-938dee99403d750c97452b20831a6c549bbac649.zip |
yawn. some work on content, including an embarassingly crappy GW scenegen
-rw-r--r-- | MMFullWorld.fileset | bin | 0 -> 103 bytes | |||
-rw-r--r-- | scenedata.bin | bin | 157 -> 82 bytes | |||
-rw-r--r-- | scenegen.py | 119 | ||||
-rw-r--r-- | scenegen_.py | 48 | ||||
-rw-r--r-- | setgen.py | 21 | ||||
-rw-r--r-- | src/world_camera.cpp | 24 | ||||
-rw-r--r-- | src/worldmap.cpp | 2 |
7 files changed, 184 insertions, 30 deletions
diff --git a/MMFullWorld.fileset b/MMFullWorld.fileset Binary files differnew file mode 100644 index 0000000..4fde7e6 --- /dev/null +++ b/MMFullWorld.fileset diff --git a/scenedata.bin b/scenedata.bin Binary files differindex 534b7b6..ea87a2d 100644 --- a/scenedata.bin +++ b/scenedata.bin diff --git a/scenegen.py b/scenegen.py index 84fccc9..86f4006 100644 --- a/scenegen.py +++ b/scenegen.py @@ -1,41 +1,130 @@ import struct +from collections import OrderedDict + +from gameobjects.matrix44 import * +from gameobjects.vector3 import * + + class Node: pass +nodes = OrderedDict() + 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.mtx = Matrix44() +#BaseNode.mtx *= Matrix44.rotation_about_axis((0,1,0), radians(180)) BaseNode.brres_key = '3D00' BaseNode.model_name = 'GoldwoodBase' BaseNode.lm_type = 0 +nodes['Base'] = BaseNode -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 +trees = [] +trees.append([(-432.6419,491.4498,36.07888)]) +trees.append([(-528.9393,465.0258,54.24921),(0,0,1,-205),(1.5,1.5,1.5)]) +trees.append([(-620.4692,390.3275,67.48116),(0,0,-1,-84.99999),(2,2,2)]) +trees.append([(-560.6774,261.2726,36.07889),(0,0,-1,-115)]) +trees.append([(-335.7342,473.2928,58.58809),(0,0,1,-195),(2,2,2)]) +trees.append([(-600.3536,168.692,54.24921),(0,0,-1,-30),(1.5,1.5,1.5)]) +trees.append([(-504.1465,157.0091,34.27255),(0,0,-1,-15)]) +trees.append([(-473.3172,-230.0073,-47.6824),(0,0,-1,-30),(1.5,1.5,1.5)]) +trees.append([(-309.3281,-345.4817,-66.51208),(0,0,-1,-105)]) +trees.append([(-200.273,417.9867,58.58809),(0,0,1,-160),(2,2,2)]) +trees.append([(-428.3652,220.8884,53.48188),(0,0,1,-144.3318),(1.5,1.5,1.5)]) +trees.append([(202.4636,423.0312,58.58809),(0,0,1,-190),(1.5,1.5,1.5)]) +trees.append([(104.0971,448.0217,37.58566),(0,0,1,-90.00001)]) +trees.append([(558.988,200.4099,134.7052),(0,0,1,-195),(2,2,2)]) +trees.append([(-496.7122,52.15556,65.01857),(0,0,-1,-114.4882),(2,2,2)]) +trees.append([(-625.6561,-14.46614,69.94374),(0,0,1,-160),(2,2,2)]) +trees.append([(-451.8466,374.4697,54.24921),(0,0,1,-205),(1.5,1.5,1.5)]) +trees.append([(-498.7201,302.163,36.07889),(0,0,1,-228.8284)]) +trees.append([(-502.41,-357.0221,-66.51208),(0,0,1,-57.69051)]) +trees.append([(-563.8763,-117.5426,32.63081),(0,0,-1,-15)]) +trees.append([(-164.7518,28.56541,37.55599),(0,0,-1,-15)]) +trees.append([(69.34688,-370.9233,54.24921),(0,0,1,-23.78404),(1.5,1.5,1.5)]) +trees.append([(-381.2546,-27.60487,54.24921),(0,0,1,-143.3339),(1.5,1.5,1.5)]) +trees.append([(517.5121,-118.4075,54.24921),(0,0,1,-143.3339),(1.5,1.5,1.5)]) +trees.append([(636.0891,-20.87392,65.01857),(0,0,-1,-114.4882),(2,2,2)]) +trees.append([(595.799,-261.0563,65.01857),(0,0,-1,-2.230904),(2,2,2)]) +trees.append([(442.6156,-445.4103,35.47948),(0,0,1,-33.01907)]) +trees.append([(601.3714,-369.1882,33.41096),(0,0,-1,-101.3162)]) +trees.append([(135.2478,-410.5703,30.18969),(0,0,-1,-101.3162)]) +trees.append([(375.7895,-410.6814,33.71223),(0,0,1,-122.8022)]) +trees.append([(381.3143,312.5172,132.5149),(0,0,-1,-2.230904),(2,2,2)]) +trees.append([(492.7756,314.4396,113.5759),(0,0,1,-143.3339),(1.5,1.5,1.5)]) +trees.append([(123.7032,317.5327,65.01857),(0,0,-1,-76.25513),(2,2,2)]) +trees.append([(224.8819,-211.3689,54.24921),(0,0,-1,-85.55461),(1.5,1.5,1.5)]) +trees.append([(322.8776,-90.80885,65.01857),(0,0,1,-62.79728),(2,2,2)]) +trees.append([(38.92174,-16.14143,37.55599),(0,0,1,-140.1519)]) +trees.append([(123.4013,-39.51448,54.24921),(0,0,1,-226.3537),(1.5,1.5,1.5)]) +trees.append([(-257.9183,-36.27791,46.23754),(0,0,1,-226.3537),(1.367996,1.367996,1.367996)]) +trees.append([(-129.6952,-311.2891,30.18969),(0,0,-1,-92.79686)]) +trees.append([(-212.5955,250.4542,60.27821),(0,0,1,-205),(1.645125,1.645125,1.645125)]) +trees.append([(46.9944,279.5399,37.58566),(0,0,1,-216.0257)]) +trees.append([(292.9048,-450.7896,54.24921),(0,0,1,-69.19887),(1.5,1.5,1.5)]) +trees.append([(518.238,-452.9915,54.24921),(0,0,-1,-22.77429),(1.5,1.5,1.5)]) +trees.append([(78.49855,-208.7774,30.18969),(0,0,1,-59.14187)]) +trees.append([(-438.4393,-129.7501,34.27255),(0,0,1,-123.4304)]) +trees.append([(-220.1394,-355.7235,65.01857),(0,0,-1,-114.4882),(2,2,2)]) +trees.append([(4.708786,-273.2903,30.18969),(0,0,-1,-96.09806)]) +trees.append([(-52.38176,-376.2185,54.24921),(0,0,1,-23.78404),(1.5,1.5,1.5)]) +trees.append([(-233.0447,-430.365,-61.64869),(0,0,1,-195),(1.125775,1.125775,1.125775)]) +trees.append([(-433.6412,-411.0383,-66.51208),(0,0,-1,-80)]) +trees.append([(203.4264,-84.41426,37.55599),(0,0,1,-140.1519)]) +trees.append([(78.68404,42.78148,37.55599),(0,0,1,-140.1519)]) +trees.append([(-518.1977,-62.53108,54.24921),(0,0,1,-143.3339),(1.5,1.5,1.5)]) +trees.append([(566.8211,-142.5897,35.47948),(0,0,1,-33.01907)]) +trees.append([(-19.99593,36.96886,37.55599),(0,0,1,-20.15192)]) +tree_idx = 0 +for tree in trees: + TreeNode = Node() + TreeNode.mtx = Matrix44() + # todo: matrix creation + # todo: specifying which type each transformation is + tf_idx = 0 + for tf in tree: + if tf_idx == 0: + #translate -- swap Y,Z! also, Z is negative for some reason... + TreeNode.mtx *= Matrix44.translation(tf[0]+7.44,tf[2]-37,-tf[1]) + elif tf_idx == 1: + #rotate + TreeNode.mtx *= Matrix44.rotation_about_axis((tf[0],tf[2],tf[1]), radians(tf[3])) + elif tf_idx == 2: + #scale + TreeNode.mtx *= Matrix44.scale(tf[0]*0.5, tf[1]*0.5, tf[2]*0.5) + tf_idx += 1 + TreeNode.brres_key = '3D00' + TreeNode.model_name = 'BrownTree' if tree_idx == 24 else 'RedTree' + TreeNode.lm_type = 1 + nodes['Tr%02d' % tree_idx] = TreeNode + tree_idx += 1 -nodes = {} -nodes['Base'] = BaseNode -nodes['Tr00'] = TreeNode + + +# 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 - 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) + nameoffs = stringoffsets[enc_name] - stringtable += node.model_name.encode('Shift-JIS') - stringtable += b'\0' - currentoffset += len(node.model_name) + 1 + + 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) 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) + @@ -1,9 +1,20 @@ import struct -names = {} -names['PATH'] = '/Maps/forest/pathdata.bin' -names['SCN0'] = '/Maps/forest/mainscene.bin' -names['3D00'] = '/Maps/forest/base.brres' +def Goldwood(): + names = {} + names['PATH'] = '/Maps/forest/pathdata.bin' + names['SCN0'] = '/Maps/forest/mainscene.bin' + names['3D00'] = '/Maps/forest/base.brres' + return ('SMGoldwood.fileset', names) + +def World(): + names = {} + names['PATH'] = '/Maps/main/pathdata.bin' + names['SCN0'] = '/Maps/main/mainscene.bin' + names['3D00'] = '/Maps/main/base.brres' + return ('MMFullWorld.fileset', names) + +filename, names = World() header = struct.pack('>4sI', b'MSet', len(names)) entrydata = b'' @@ -19,5 +30,5 @@ for key,path in names.items(): currentoffset += len(encpath) + 1 -open('SMGoldwood.fileset', 'wb').write(header + entrydata + stringtable) +open(filename, 'wb').write(header + entrydata + stringtable) diff --git a/src/world_camera.cpp b/src/world_camera.cpp index 1fc3a5a..3e1cc6b 100644 --- a/src/world_camera.cpp +++ b/src/world_camera.cpp @@ -18,8 +18,15 @@ dWorldCamera_c *dWorldCamera_c::build() { int dWorldCamera_c::onCreate() { - this->camPos = (Point3d){0.0f, 400.0f, 400.0f}; - this->camRotate = (Point3d){-40.0f, 0.0f, 0.0f}; // ZXY order + this->camPos = (Point3d){58.8f, 1163.7f, 2106.2f}; + this->camRotate = (Point3d){-60.0f, 0.0f, 0.0f}; // ZXY order + //this->camRotate = (Point3d){-40.0f, 0.0f, 0.0f}; // ZXY order + + this->camPos = (Point3d){0.0f, 0.0f, 1000.0f}; + this->camRotate = (Point3d){0.0f, 0.0f, 0.0f}; // ZXY order + + this->camPos = (Point3d){0.0f, -2000.0f, 0.0f}; + this->camRotate = (Point3d){-90.0f, 0.0f, 0.0f}; // ZXY order return true; } @@ -71,23 +78,22 @@ int dWorldCamera_c::onDraw() { cam3d.SetViewportJitter(VIGetNextField()); cam3d.SetPerspective(45, (f32)rmode->viWidth / (f32)rmode->viHeight, 0.1f, 2400.0f); + //cam3d.SetOrtho(rmode->efbHeight, 0.0f, 0.0f, rmode->fbWidth * (IsWideScreen() ? 1.3333334f : 1.0f), -100000.0f, 100000.0f); - nw4r::g3d::Camera::PostureInfo posture; + /*nw4r::g3d::Camera::PostureInfo posture; posture.tp = nw4r::g3d::Camera::POSTURE_ROTATE; posture.cameraRotate = this->camRotate; cam3d.SetPosition(this->camPos); - cam3d.SetPosture(posture); + cam3d.SetPosture(posture);*/ - /*nw4r::g3d::Camera::PostureInfo posture; + nw4r::g3d::Camera::PostureInfo posture; posture.tp = nw4r::g3d::Camera::POSTURE_LOOKAT; posture.cameraUp = (Point3d){0,1,0}; posture.cameraTarget = (Point3d){0,0,0}; - cam3d.SetPosition((Point3d){-3,2,3}); - cam3d.SetPosture(posture);*/ - - //cam3d.GetCameraMtx(&T3D::Camera.view_matrix); + cam3d.SetPosition((Point3d){0,400,1000}); + cam3d.SetPosture(posture); return true; } diff --git a/src/worldmap.cpp b/src/worldmap.cpp index dd027f0..12c3486 100644 --- a/src/worldmap.cpp +++ b/src/worldmap.cpp @@ -121,7 +121,7 @@ bool WMInit_EndLoading(void *ptr) { bool WMInit_LoadResources(void *ptr) {
dScNewerWorldMap_c *wm = (dScNewerWorldMap_c*)ptr;
- return wm->resMng.loadSet("SMGoldwood");
+ return wm->resMng.loadSet("MMFullWorld");
}
bool WMInit_SetupWait(void *ptr) {
|