From 070077c1741f30c88baf4ffa5638162dbde43996 Mon Sep 17 00:00:00 2001 From: Treeki Date: Sun, 20 Mar 2011 05:20:22 +0100 Subject: added W2 map definition. updated worldmap_gen.rb a bit --- MMFullWorld.wm | Bin 0 -> 1192 bytes MMFullWorld.xml | 84 ++++++++++++++++++++++++++++++++++++++++++++++++ src/world_camera.cpp | 18 ++++++----- worldmap_gen.rb | 88 ++++++++++++++++++++++++++++++--------------------- 4 files changed, 146 insertions(+), 44 deletions(-) create mode 100644 MMFullWorld.wm create mode 100644 MMFullWorld.xml diff --git a/MMFullWorld.wm b/MMFullWorld.wm new file mode 100644 index 0000000..2e4e4c7 Binary files /dev/null and b/MMFullWorld.wm differ diff --git a/MMFullWorld.xml b/MMFullWorld.xml new file mode 100644 index 0000000..0a596e9 --- /dev/null +++ b/MMFullWorld.xml @@ -0,0 +1,84 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/world_camera.cpp b/src/world_camera.cpp index 3e1cc6b..5c7c903 100644 --- a/src/world_camera.cpp +++ b/src/world_camera.cpp @@ -22,11 +22,11 @@ int dWorldCamera_c::onCreate() { 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, 500.0f, 1000.0f}; + this->camRotate = (Point3d){-40.0f, -30.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 + //this->camPos = (Point3d){0.0f, -2000.0f, 0.0f}; + //this->camRotate = (Point3d){-90.0f, 0.0f, 0.0f}; // ZXY order return true; } @@ -80,20 +80,22 @@ int dWorldCamera_c::onDraw() { 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){0,400,1000}); - cam3d.SetPosture(posture); + cam3d.SetPosture(posture);*/ return true; } diff --git a/worldmap_gen.rb b/worldmap_gen.rb index c8013e3..e52eefc 100644 --- a/worldmap_gen.rb +++ b/worldmap_gen.rb @@ -1,18 +1,18 @@ require 'rexml/document' doc = nil -File::open("TestMap.xml") do |f| +File::open("#{ARGV[0]}.xml") do |f| doc = REXML::Document.new(f.read) end class Exit attr_accessor :path attr_accessor :reverse - + def initialize(element) @path = element.attribute('to').value @reverse = false - + unless element.attribute('reverse').nil? @reverse = true end @@ -25,26 +25,26 @@ class Point attr_accessor :params attr_accessor :position attr_reader :id - + def initialize(element) @exits = {} @type = '' @params = [0,0,0,0] @position = [0,0,0] - + position = element.attribute 'position' @position = position.value.split(',').collect { |v| v.to_f } - + type = element.attribute 'type' params = element.attribute 'params' - + @type = type.value unless type.nil? @params = params.value.split(',').collect { |v| v.to_i } unless params.nil? - + element.each_element 'exit' do |e| @exits[e.attribute('direction').value] = Exit.new(e) end - + @id = $point_id $point_id += 1 end @@ -59,30 +59,46 @@ class Segment attr_accessor :direction, :same_dir attr_reader :id # todo: actions - + def initialize(element) - @start_pos = element.attribute('from').value.split(',').collect { |v| v.to_f } - @end_pos = element.attribute('to').value.split(',').collect { |v| v.to_f } - + from = element.attribute('from').value + to = element.attribute('to').value + + if $points.has_key? from + @start_pos = $points[from].position + puts "From: point #{from} #{@start_pos}" + else + @start_pos = from.split(',').collect { |v| v.to_f } + puts "From: position #{from}" + end + + if $points.has_key? to + @end_pos = $points[to].position + puts "To: point #{to} #{@end_pos}" + else + @end_pos = to.split(',').collect { |v| v.to_f } + puts "To: position #{to}" + end + @speed = 4.5 speed = element.attribute 'speed' unless speed.nil? @speed = speed.value.to_f end - + @anim = 'run' @anim_speed = 2.0 - + anim = element.attribute 'animation' unless anim.nil? @anim = anim.value end - + anim_speed = element.attribute 'animation_speed' unless anim_speed.nil? @anim_speed = anim_speed.value.to_f end - + @direction = nil direction = element.attribute 'direction' unless direction.nil? @@ -111,12 +127,12 @@ class Segment @direction *= 180 / Math::PI end end - + @same_dir = !(element.attribute('same_dir').nil?) - + @id = $segment_id $segment_id += 1 - + $segments << self end end @@ -127,19 +143,19 @@ class Path attr_accessor :start_point attr_accessor :end_point attr_reader :id - + def initialize(element) @start_point = element.attribute('start').value @end_point = element.attribute('end').value - + @segments = [] @segment_ids = [] - + element.each_element 'segment' do |e| @segments << Segment.new(e) @segment_ids << @segments.last.id end - + @id = $path_id $path_id += 1 end @@ -199,49 +215,49 @@ puts "[[[ Paths done ]]]" puts "Statistics: #{$points.count} points, #{$paths.count} paths, #{$segments.count} segments" # now write the file -File::open("TestMap.wm", "w") do |f| +File::open("#{ARGV[0]}.wm", "w") do |f| f << 'NwWM' - + # calculate all this stuff header_size = 0x24 - + path_list_offs = header_size point_list_offs = path_list_offs + ($paths.count * 4) segment_list_offs = point_list_offs + ($points.count * 4) action_list_offs = segment_list_offs + ($segments.count * 4) data_offset = action_list_offs # + ($actions.count * 4) - + f << [path_list_offs, $paths.count].pack('NN') f << [point_list_offs, $points.count].pack('NN') f << [segment_list_offs, $segments.count].pack('NN') f << [action_list_offs, 0].pack('NN') - + # now work out the offsets for everything current_offset = data_offset $paths.each_value do |p| f << [current_offset].pack('N') current_offset += 0xC + (p.segments.count * 4) end - + $points.each_value do |p| f << [current_offset].pack('N') current_offset += 0x40 end - + $segments.each do |s| f << [current_offset].pack('N') current_offset += 0x2C end - + # nothing for actions yet! - + # now write the data $paths.each_value do |p| f << [$points[p.start_point].id, $points[p.end_point].id].pack('NN') f << [p.segments.count].pack('N') f << p.segment_ids.pack('N*') end - + $points.each_value do |p| ['left', 'right', 'up', 'down'].each do |direction| if p.exits.include? direction @@ -252,12 +268,12 @@ File::open("TestMap.wm", "w") do |f| f << [-1,-1].pack('NN') end end - + f << [point_types[p.type]].pack('N') f << p.params.pack('N*') f << p.position.pack('g*') end - + $segments.each do |s| f << s.start_pos.pack('g*') f << s.end_pos.pack('g*') -- cgit v1.2.3