Aller au contenu

Photo

Meters to NWN height scale


  • Veuillez vous connecter pour répondre
15 réponses à ce sujet

#1
Celludriel

Celludriel
  • Members
  • 19 messages

Hey,

 

I'm trying to fix the old Terrain Importer plugin.  To do this I had to introduce the new kind of heightfield in use by L3DT.  However I'm stuck on something.  The old author seems to have used his own calculation on height instead of starting from the real meter height as it is represented in the file.  Now this new heightfield format is less forgiving due to the use of a compression algorithm in it , I can't use the same calculation the old author used.

 

However what I can do is convert the value from the old heightfield to the real meter height representation.  For the same pixel in the same heightfield one in format HFF and the other in the new format HFZ, the result is 79,188999192 meters.  Now I have to find a magic formula to scale it down to NWN2 standards.  To get one meter representation by what measure should I have to divide the real life meters ?

 

Has anyone got any idea about this.  The old author also used a min height and max height.  Maybe I can work with those values but I'm not exactly sure how relevant they still are in this new calculation method.



#2
kamal_

kamal_
  • Members
  • 5 254 messages

If it helps, the standard NWN2 human male is 2 meters tall.

 

Apparently they're tall in Faerun.



#3
Celludriel

Celludriel
  • Members
  • 19 messages

If it helps, the standard NWN2 human male is 2 meters tall.

 

Apparently they're tall in Faerun.

 

Well I could create a heightfield with a square of 2 m high, then see how many humans fit in those two meter blocks and extrapolate a scale.



#4
kevL

kevL
  • Members
  • 4 070 messages

isn't a meter a meter, i mean apart from algorithms that use pseudo-meters?

in NwN2 they've tried to keep it believable (tho there have been quibble-threads about heights of elves, ofc )


If you're asking, if (1m <-> 79.188999192), then multiply by its inverse.

0.012628016646m <-> 1

is that what you mean?


Also, i think a tile is 10m x 10m if you want to use that as a gauge.



#5
Kanis-Greataxe

Kanis-Greataxe
  • Members
  • 158 messages

If you go to the nwn2 vault and look up NTB's Eroded Hills and Valleys he has a spreadsheet of the number relations between l3dt, yatt and nwn2 it may give you what you are looking for as far as the scaling issue. as far as the min and max heights that pertains to the lowest and highest levels of the map and should be adjusted by the user to get the look they are wanting.as it basically sets the lowest and highest points on the terrain.



#6
Celludriel

Celludriel
  • Members
  • 19 messages

I'll have a look, Kanis.  Maybe I do have to take the min and max value into account for the formula.  However I do like to use the real meters as a starting point.  The original author just took depending on the byte depth of the heightmap a byte, short or float from the stream and then divided it by the max value of respectivly a byte , short or float.  Then that value got used in another formula which I haven't quite figured out  yet what he was doing since the decompiler made a mess of the code :(

    //height from the HFF height map
 
    public override float GetHeight(int x, int y)
    {
      float height = 0.0f;
      this.file.BaseStream.Seek((long) this.dataOffset + ((long) y * (long) this.mapWidth + (long) x) * (long) this.dataSize, SeekOrigin.Begin);
      switch (this.dataSize)
      {
        case (byte) 1:
          height = Convert.ToSingle(this.file.ReadByte()) / (float) byte.MaxValue;
          break;
        case (byte) 2:
          height = Convert.ToSingle(this.file.ReadUInt16()) / (float) ushort.MaxValue;
          break;
        case (byte) 4:
          height = this.file.ReadSingle();
          break;
      }
      return height;
    }
 
    //final value calculation
  
    unmodifiedHeight * heightDiff + minHeight;
 
    //heightDiff being : float heightDiff = Convert.ToSingle(importerSettings.numMaxHeight.Value - importerSettings.numMinHeight.Value);
    //minHeight being : float minHeight = Convert.ToSingle(importerSettings.numMinHeight.Value);


#7
Kanis-Greataxe

Kanis-Greataxe
  • Members
  • 158 messages

there is also a tutorial called erikbreau's L3DT/yatt tutorial for dummies (and me) on the nwn2 vault that may have some usefull info



#8
Kanis-Greataxe

Kanis-Greataxe
  • Members
  • 158 messages

To give an example of what I meant by the min and max should be settable by the user is I can take a height map use yatt input a min of -5 and a max of 70 and get an output area with the lowest point being around -5 and the highest being 70, I can also take the some heath map and change the min and max heights and get either an area that is either flatter ( by using a min of -5 and a max of 30) or taller * by using a min of -15 and a max of 170)



#9
Celludriel

Celludriel
  • Members
  • 19 messages

ok so lets think about this, take this L3DT project here that has a min value of -199.78 m and a max value of 539.09 m.  It seems that I get a reasonable looking terrain when I divide those values by 10.  Now if we put those min and max values in the mix , maybe I should just do value / (max - abs(min)).  Although not sure about this



#10
kevL

kevL
  • Members
  • 4 070 messages

not sure if this helps, but the waterbrush in the toolset has a height slider. It ranged from -100 to +100 ... seems to be in meters. ( 2 units covers Ammon Jerro )



#11
Morbane

Morbane
  • Members
  • 1 883 messages

i'm clueless on how to help but,

 

glad to see this kind of effort in improving plugins.

 

thanks Celludriel :)


  • Celludriel aime ceci

#12
Celludriel

Celludriel
  • Members
  • 19 messages

i'm clueless on how to help but,

 

glad to see this kind of effort in improving plugins.

 

thanks Celludriel :)

 

Your welcome, the biggest problems I'm facing is how backwards compatible do I keep it since most of the new file formats of L3DT don't mix well with the old way of doing things.  And deciphering the variables that the decompiler renamed to num1 ... n or string1 ... n

 

UPDATE

=======

 

As it turned out I didn't need a conversion, I put square of 2m up in L3DT then imported it into NWN2 without any height alteration.  Next I took a commoner and put it next to the raised terrain and it fit perfectly.  So 1m in L3DT equals 1m in NWN2.  But I don't get it then why did the original author provide that formula while he could perfectly calculate the real height from the old HFF format with an easy formula. 

 

Best I can figure is that he wanted one line of code to handle L3DT files and regular bitmaps ... but why make your life hard that way, just extrapolate it behind an interface and when a map is of the bitmap kind, do formula a and when L3DT do formula b ... 

 

Once I got this all working again , I'm going to create my own project , clean up the gui and rerelease it with all this new knowledge cause atm it's hard to put myself in the original authors mind, with these kind of fubar lines of code.



#13
Morbane

Morbane
  • Members
  • 1 883 messages


Once I got this all working again , I'm going to create my own project , clean up the gui and rerelease it with all this new knowledge cause atm it's hard to put myself in the original authors mind, with these kind of fubar lines of code.

 

made me laugh - i mean i know how to code but not really - i just know when i try to use something then realise; there's just a heap of nonsense in this.

 

if i stuck harder to it in the past year, i might understand what you were talking about :P

 

this is one of my Win API gadgets from 3 years after i changed my major from programming to soc sci :)



#14
rjshae

rjshae
  • Members
  • 4 497 messages

In Blender, an imported tile base is exactly 9.0 x 9.0 units, which is probably in meters. (Since 9 meters ~ 10 yards.) I think the outdoor minor grid lines may be 10m apart, IIRC.


  • Celludriel aime ceci

#15
Celludriel

Celludriel
  • Members
  • 19 messages

In Blender, an imported tile base is exactly 9.0 x 9.0 units, which is probably in meters. (Since 9 meters ~ 10 yards.) I think the outdoor minor grid lines may be 10m apart, IIRC.

 

Well I made it more difficult then  it was the sollution was actually childs play, just divide the height by max height and multiply it by max user wanted height, and I had the perfect scale.  Just the simple rule of three ...



#16
4760

4760
  • Members
  • 1 212 messages

Also, i think a tile is 10m x 10m if you want to use that as a gauge.

 

 

In Blender, an imported tile base is exactly 9.0 x 9.0 units, which is probably in meters. (Since 9 meters ~ 10 yards.) I think the outdoor minor grid lines may be 10m apart, IIRC.

 

I don't remember where it's written, but it's definitely in the books (or pdf files) that come with the game: a square is 10 m x 10 m outside, but 9 m x 9 m for interiors.