summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreeki <treeki@gmail.com>2011-03-20 05:20:22 +0100
committerTreeki <treeki@gmail.com>2011-03-20 05:20:22 +0100
commit070077c1741f30c88baf4ffa5638162dbde43996 (patch)
tree4b979b2689a5be1ae8022287b05e272f2f123c97
parent938dee99403d750c97452b20831a6c549bbac649 (diff)
downloadkamek-070077c1741f30c88baf4ffa5638162dbde43996.tar.gz
kamek-070077c1741f30c88baf4ffa5638162dbde43996.zip
added W2 map definition. updated worldmap_gen.rb a bit
-rw-r--r--MMFullWorld.wmbin0 -> 1192 bytes
-rw-r--r--MMFullWorld.xml84
-rw-r--r--src/world_camera.cpp18
-rw-r--r--worldmap_gen.rb88
4 files changed, 146 insertions, 44 deletions
diff --git a/MMFullWorld.wm b/MMFullWorld.wm
new file mode 100644
index 0000000..2e4e4c7
--- /dev/null
+++ b/MMFullWorld.wm
Binary files 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 @@
+<map>
+ <point name="generic" position="-266.624,61.122,244.628" type="level" params="1,17,0,0">
+ <exit direction="up" to="generic to columns" />
+ <exit direction="right" to="generic to oasis" />
+ <exit direction="down" to="generic to toadhouse" />
+ </point>
+
+ <point name="toadhouse" position="-320.172,41.155,344.66" type="level" params="1,2,0,0">
+ <exit direction="up" to="generic to toadhouse" reverse="yes" />
+ <exit direction="right" to="toadhouse to plumbing" />
+ <exit direction="down" to="toadhouse to plumbing" />
+ </point>
+
+ <point name="plumbing" position="-95.274,-35.167,385.463" type="level" params="1,2,0,0">
+ <exit direction="left" to="toadhouse to plumbing" reverse="yes" />
+ <exit direction="down" to="toadhouse to plumbing" reverse="yes" />
+ <exit direction="up" to="plumbing to castle" />
+ </point>
+
+ <point name="columns" position="-168.286,61.122,165.593" type="level" params="1,18,0,0">
+ <exit direction="down" to="generic to columns" reverse="yes" />
+ <exit direction="right" to="columns to sinkysand" />
+ </point>
+
+ <point name="sinkysand" position="-78.644,35.327,205.595" type="level" params="2,1,0,0">
+ <exit direction="left" to="columns to sinkysand" reverse="yes" />
+ <exit direction="right" to="sinkysand to castle" />
+ </point>
+
+ <point name="deserted" position="-76.596,61.122,379.174" type="level" params="2,2,0,0">
+ <exit direction="left" to="oasis to deserted" reverse="yes" />
+ <exit direction="up" to="deserted to castle" />
+ </point>
+
+ <point name="oasis" position="-154.073,52.178,322.023" type="level" params="1,19,0,0">
+ <exit direction="left" to="generic to oasis" reverse="yes" />
+ <exit direction="right" to="oasis to deserted" />
+ </point>
+
+ <point name="castle" position="-58.448,62.185,293.062" type="level" params="2,3,0,0">
+ <exit direction="up" to="sinkysand to castle" reverse="yes" />
+ <exit direction="left" to="plumbing to castle" reverse="yes" />
+ <exit direction="down" to="deserted to castle" reverse="yes" />
+ <!--exit direction="right" to="castle to airship" /-->
+ </point>
+
+
+ <path name="generic to columns" start="generic" end="columns">
+ <segment from="generic" to="columns" />
+ </path>
+
+ <path name="columns to sinkysand" start="columns" end="sinkysand">
+ <segment from="columns" to="sinkysand" />
+ </path>
+
+ <path name="sinkysand to castle" start="sinkysand" end="castle">
+ <segment from="sinkysand" to="castle" />
+ </path>
+
+ <path name="generic to oasis" start="generic" end="oasis">
+ <segment from="generic" to="oasis" />
+ </path>
+
+ <path name="oasis to deserted" start="oasis" end="deserted">
+ <segment from="oasis" to="deserted" />
+ </path>
+
+ <path name="deserted to castle" start="deserted" end="castle">
+ <segment from="deserted" to="castle" />
+ </path>
+
+ <path name="generic to toadhouse" start="generic" end="toadhouse">
+ <segment from="generic" to="toadhouse" />
+ </path>
+
+ <path name="toadhouse to plumbing" start="toadhouse" end="plumbing">
+ <segment from="toadhouse" to="plumbing" />
+ </path>
+
+ <path name="plumbing to castle" start="plumbing" end="castle">
+ <segment from="plumbing" to="castle" />
+ </path>
+</map>
+
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*')