summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreeki <treeki@gmail.com>2011-06-18 02:45:22 +0200
committerTreeki <treeki@gmail.com>2011-06-18 02:45:22 +0200
commit45fede365a5664dd428d4dc47b8ac2fed8119f2a (patch)
tree387a6a969c3ddf9071a574996752d5315bea6882
parent4ec93865045c4455c3a59344c09b3c43ca2e86ed (diff)
downloadkamek-45fede365a5664dd428d4dc47b8ac2fed8119f2a.tar.gz
kamek-45fede365a5664dd428d4dc47b8ac2fed8119f2a.zip
world map scenes are now handled by worldmap_gen.rb
Diffstat (limited to '')
-rw-r--r--MMFullWorld.scenebin0 -> 606 bytes
-rw-r--r--MMFullWorld.xml2
-rw-r--r--worldmap_gen.rb66
3 files changed, 67 insertions, 1 deletions
diff --git a/MMFullWorld.scene b/MMFullWorld.scene
new file mode 100644
index 0000000..e6098bc
--- /dev/null
+++ b/MMFullWorld.scene
Binary files differ
diff --git a/MMFullWorld.xml b/MMFullWorld.xml
index 99e3de6..bcc0675 100644
--- a/MMFullWorld.xml
+++ b/MMFullWorld.xml
@@ -1,4 +1,6 @@
<map>
+ <model key="Base" from="3D00" name="WorldBase" lightmap="map" />
+
<point name="drydry" position="-266.624,61.122,244.628" type="level" level="2-9">
<exit direction="up" to="drydry to columns" />
<exit direction="right" to="drydry to oasis" />
diff --git a/worldmap_gen.rb b/worldmap_gen.rb
index 6595ba2..a0f8eb3 100644
--- a/worldmap_gen.rb
+++ b/worldmap_gen.rb
@@ -1,4 +1,5 @@
require 'rexml/document'
+require 'matrix'
doc = nil
File::open("#{ARGV[0]}.xml") do |f|
@@ -58,6 +59,7 @@ class StringTable
end
def offset(str)
+ push(str) unless include?(str)
@start_offset + @offset_hash[str]
end
@@ -72,6 +74,31 @@ class StringTable
end
alias :<< :push
+ alias :[] :offset
+end
+
+class Model
+ attr_accessor :resource_key
+ attr_accessor :name
+ attr_accessor :lightmap_type
+ attr_accessor :matrix
+
+ def initialize(element=nil)
+ return if element.nil?
+
+ @resource_key = element.attribute('from').value
+ @name = element.attribute('name').value
+
+ lm = element.attribute('lightmap').value
+ @lightmap_type = case lm
+ when 'map' then 0
+ when 'mapobj' then 1
+ else 0xFFFFFFFF
+ end
+
+ # TODO; solve this glaring omission
+ @matrix = Matrix.columns([[1,0,0], [0,1,0], [0,0,1], [0,0,0]])
+ end
end
class Exit
@@ -122,6 +149,14 @@ class Point
normal_event, secret_event = 0xFFFF, 0xFFFF
@params = level + [normal_event, secret_event]
+
+ model = Model.new
+ model.resource_key = 'LV_M'
+ model.name = 'LevelMarker'
+ model.lightmap_type = 1
+ model.matrix = Matrix.columns([[1,0,0], [0,1,0], [0,0,1], @position])
+ $models['L%03d' % $point_id] = model
+ puts "created marker model for this point"
end
element.each_element 'exit' do |e|
@@ -280,6 +315,17 @@ directions = {'left' => 0, 'right' => 1, 'up' => 2, 'down' => 3}
$string_table = StringTable.new
+# initial: scene models
+$models = {}
+
+puts "[[[ Getting models ]]]"
+
+doc.each_element 'map/model' do |m|
+ puts "Reading #{m.attribute 'key'}..."
+ raise "key must be 4 characters long" unless m.attribute('key').value.length == 4
+ $models[m.attribute('key').value] = Model.new(m)
+end
+
# first, collect every point
$points = {}
$point_id = 0
@@ -313,7 +359,7 @@ puts "[[[ Paths done ]]]"
puts "Statistics: #{$points.count} points, #{$paths.count} paths, #{$segments.count} segments"
# now write the file
-File::open("#{ARGV[0]}.wm", "w") do |f|
+File::open("#{ARGV[0]}.wm", "wb") do |f|
f << 'NwWM'
# calculate all this stuff
@@ -397,3 +443,21 @@ File::open("#{ARGV[0]}.wm", "w") do |f|
f << $string_table.to_s
end
+
+File::open("#{ARGV[0]}.scene", "wb") do |f|
+ f << 'MScn'
+ f << [$models.count].pack('N')
+
+ st = StringTable.new
+ st.start_offset = 8 + (0x40 * $models.count)
+
+ $models.each_pair do |key,m|
+ f << key
+ f << m.resource_key
+ f << [m.lightmap_type, st[m.name]].pack('NN')
+ f << m.matrix.to_a.flatten.pack('g*')
+ end
+
+ f << st.to_s
+end
+