[Article] Informations to make a map reader (Vel) + sources

This is a sub forum dedicated to an open source map editor.
Don't post in it about another subject

Moderators: osRose dev team, ospRose dev team, osiRose dev team, Moderators

Forum rules
This is a sub forum dedicated to an open source map editor.
Don't post in it about another subject

Re: [Article] Informations to make a map reader (Vel)

Postby Maxxon on Fri Jan 16, 2009 10:07 am

i dont know where atm but there is some pseudocode for writing that quad tree stuff around here. i think in the thread of raven.
Image
an anymous comment on a program called reloader:
what if a fatal error happens, will it restart it?
User avatar
Maxxon
Hawker's pet
Hawker's pet
 
Posts: 1305
Joined: Sat Nov 10, 2007 12:42 pm

Re: [Article] Informations to make a map reader (Vel)

Postby AkramMaTT on Fri Jan 16, 2009 2:22 pm

Look here: http://pastebin.ca/1297867
You may have to modify it a bit to fit your way of storing the height values in the array.

  1.  
  2.                  BinW.Write("quad")
  3.                   ' Quadtree List 1
  4.  
  5.                   ' 16 * 16 quads
  6.                   BinW.WriteInt(256)
  7.  
  8.                   Dim Vals() As Integer
  9.                   For a As Integer = 0 To 15
  10.                      For b As Integer = 0 To 15
  11.                         Vals = GetHighLow(Heights, a * 4, b * 4, a * 4 + 4, b * 4 + 4)
  12.                         BinW.WriteSingle(Vals(0))
  13.                         BinW.WriteSingle(Vals(1))
  14.                      Next
  15.                   Next
  16.  
  17.                   ' Quadtree List 2
  18.  
  19.                   ' List of values to get the start and end index to get the high and low values in the loops.
  20.                   Dim P1()() As Integer = {New Integer() {0, 0}, New Integer() {0, 32}, New Integer() {32, 32}, New Integer() {32, 0}}
  21.                   Dim P2()() As Integer = {New Integer() {0, 0}, New Integer() {0, 16}, New Integer() {16, 16}, New Integer() {16, 0}}
  22.                   Dim P3()() As Integer = {New Integer() {0, 0}, New Integer() {0, 8}, New Integer() {8, 8}, New Integer() {8, 0}}
  23.  
  24.                   ' 1 + 4 + 16 + 64 = 85
  25.                   BinW.WriteInt(85)
  26.  
  27.                   ' Root
  28.                   Vals = GetHighLow(Heights, 0, 0, 64, 64)
  29.                   BinW.WriteSingle(Vals(0))
  30.                   BinW.WriteSingle(Vals(1))
  31.  
  32.                   ' split root in 4 -> 4 results
  33.                   ' 64, 64 splitted into 4 => block size = 32, 32
  34.  
  35.                   For i As Integer = 0 To 3
  36.                      Vals = GetHighLow(Heights, P1(i)(0), P1(i)(1), P1(i)(0) + 32, P1(i)(1) + 32)
  37.                      BinW.WriteSingle(Vals(0))
  38.                      BinW.WriteSingle(Vals(1))
  39.                   Next
  40.  
  41.                   ' split each subnode in 4 -> (4 * 4 = 16 results )
  42.                   ' 32, 32 splitted into 4 => block size = 16, 16
  43.  
  44.                   For i As Integer = 0 To 3
  45.                      For a As Integer = 0 To 3
  46.                         Vals = GetHighLow(Heights, P1(i)(0) + P2(a)(0), P1(i)(1) + P2(a)(1), P1(i)(0) + P2(a)(0) + 16, P1(i)(1) + P2(a)(1) + 16)
  47.                         BinW.WriteSingle(Vals(0))
  48.                         BinW.WriteSingle(Vals(1))
  49.                      Next
  50.                   Next
  51.  
  52.                   ' split each subsubnode  in 4 -> (4 * 4 * 4 = 64 results)
  53.                   ' 16, 16 splitted into 4 => block size = 8, 8
  54.  
  55.                   For i As Integer = 0 To 3
  56.                      For a As Integer = 0 To 3
  57.                         For b As Integer = 0 To 3
  58.                            Vals = GetHighLow(Heights, P1(i)(0) + P2(a)(0) + P3(b)(0), P1(i)(1) + P2(a)(1) + P3(b)(1), P1(i)(0) + P2(a)(0) + P3(b)(0) + 8, P1(i)(1) + P2(a)(1) + P3(b)(1) + 8)
  59.                            BinW.WriteSingle(Vals(0))
  60.                            BinW.WriteSingle(Vals(1))
  61.                         Next
  62.                      Next
  63.                   Next
  64.  
  65.  
  66.  
  67.       Function GetHighLow(ByVal Values(,) As Single, ByVal MinX As Single, ByVal MinY As Single, ByVal MaxX As Single, ByVal MaxY As Single)
  68.          Dim high As Integer
  69.          Dim low As Integer
  70.          high = -9999999
  71.          low = 9999999
  72.  
  73.          For x As Integer = MinX To MaxX
  74.             For y As Integer = MinY To MaxY
  75.                If Values(x, y) > high Then
  76.                   high = Values(x, y)
  77.                End If
  78.                If Values(x, y) < low Then
  79.                   low = Values(x, y)
  80.                End If
  81.             Next
  82.          Next
  83.  
  84.          Return New Integer() {high, low}
  85.       End Function
  86.  
Last edited by AkramMaTT on Sat Jan 17, 2009 10:05 pm, edited 7 times in total.
AkramMaTT
Little soul
Little soul
 
Posts: 9
Joined: Thu Jan 01, 2009 11:03 pm

Re: [Article] Informations to make a map reader (Vel)

Postby lmame on Fri Jan 16, 2009 4:28 pm

I copied your code into your post because it seems that it'll be deleted in two weeks. Tell me if it's ok with you.
The world is full of love and peace ^_^
Image
User avatar
lmame
Admin
Admin
 
Posts: 8997
Joined: Mon Aug 06, 2007 4:42 pm
Location: July City

Re: [Article] Informations to make a map reader (Vel)

Postby Vel on Fri Jan 16, 2009 5:32 pm

AkramMaTT
I got it, thanks.
Sorry for terrible english. My native language is C++
User avatar
Vel
Pomic
Pomic
 
Posts: 120
Joined: Mon Nov 03, 2008 9:13 am
Location: Ukraine, Kharkov.

Re: [Article] Informations to make a map reader (Vel)

Postby AkramMaTT on Sat Jan 17, 2009 9:52 pm

Yeah it's ok.

Modified the code in my post a bit (added more comments and changed the function output order)
AkramMaTT
Little soul
Little soul
 
Posts: 9
Joined: Thu Jan 01, 2009 11:03 pm

Re: [Article] Informations to make a map reader (Vel) + sources

Postby Vel on Tue Mar 17, 2009 10:56 pm

I add sources, enjoy!
Sorry for terrible english. My native language is C++
User avatar
Vel
Pomic
Pomic
 
Posts: 120
Joined: Mon Nov 03, 2008 9:13 am
Location: Ukraine, Kharkov.

Re: [Article] Informations to make a map reader (Vel) + sources

Postby lmame on Wed Mar 18, 2009 12:22 am

Added to tools forum here.
I added too glaux.lib because I think it's needed and instructions on how to build it with VS 2008.
The world is full of love and peace ^_^
Image
User avatar
lmame
Admin
Admin
 
Posts: 8997
Joined: Mon Aug 06, 2007 4:42 pm
Location: July City

Re: [Article] Informations to make a map reader (Vel) + sources

Postby Vel on Wed Mar 18, 2009 9:00 am

Ok, thanks.
Sorry for terrible english. My native language is C++
User avatar
Vel
Pomic
Pomic
 
Posts: 120
Joined: Mon Nov 03, 2008 9:13 am
Location: Ukraine, Kharkov.

Re: [Article] Informations to make a map reader (Vel) + sources

Postby amaedict on Thu Aug 06, 2009 2:34 pm

any chances of posting a compiled version of the editor ?
We Have it all ... Image
Image
User avatar
amaedict
Clown
Clown
 
Posts: 531
Joined: Thu Apr 23, 2009 2:44 pm

Re: [Article] Informations to make a map reader (Vel) + sources

Postby Vel on Thu Aug 06, 2009 3:36 pm

No
Sorry for terrible english. My native language is C++
User avatar
Vel
Pomic
Pomic
 
Posts: 120
Joined: Mon Nov 03, 2008 9:13 am
Location: Ukraine, Kharkov.

Previous

Return to [Project] Map Editor

Who is online

Users browsing this forum: No registered users and 2 guests

cron