Game Development Community

Atlas raw files - signed or unsigned?

by Dave · in Torque Game Engine Advanced · 05/12/2006 (7:52 am) · 10 replies

Hi,

I'm working with the author of a terrain generator program and trying to get his raw files imported into TSE. While trying to figure out what was going wrong he asked a question regarding whether the file should be signed or unsigned. I've always assumed unsigned as I recall reading it in the Atlas overview and also the import GUI has a label saying use an unsigned file.

Just to double check I went back to the Atlas overview doc on TDN, and found these two sentences right next to each other

*******

only loads from a raw unsigned 16bit heightfield, such as Terragen produces.

The values from the .RAW file are signed 16 bit integers. They go from about -32767 to +32767

*******

So my question is - which is correct??

Thanks,

Dave.

#1
05/12/2006 (8:15 am)
It's gotta be an error in the documentation or something.

You load *unsigned integer* values, and TSE stores them as *signed integer* values.
#2
05/12/2006 (8:25 am)
Ah right. I can't make it read that way myself, but I see exactly what you mean. Thanks Stefan.
#3
05/12/2006 (8:27 am)
Hey, I answered a different comment by Stefan and now it's changed! Must have been an edit while I was replying. Sorry if my reply above makes no sense now. But thx Stefan.
#4
05/12/2006 (8:33 am)
Hey Dave,

Look at this quote, taken from here.

Quote:
The values from the .RAW file are signed 16 bit integers. They go from about -32767 to +32767. In whole numbers. Atlas works in whole meter units, so that means you get from -32km to +32km, in whole meter increments.

The first part is exactly the same as in the docs, which makes me worried. :p
I'm sure that the .RAW files you read in are UNSIGNED 16-bit Intel-Byte-Order integers, but I'm not so sure about .CHU anymore..

I might be incorrect in that they are signed.
#5
05/12/2006 (8:38 am)
Perhaps this is what it was intended to say:
Quote:
The values from the .CHU file are signed 16 bit integers. They go from about -32767 to +32767

The odd thing is that Ben said it was the .RAW in his post as well. Maybe he quoted the docs without noticing the error? I don't know.

And looking at this, it seems like they are stored as floating point numbers?

Quote:
So we have a scaling factor. The raw integer values are multiplied by the scaling factor to convert to floating point values that are more useful for realistic terrains.

Oh well.

Edit: Sorry for all the rambling, hopefully someone can set you straight that knows this stuff. (: Cheers
#6
05/12/2006 (8:45 am)
You'd think Ben would know as he wrote the thing :-)

Ben? Help!
#7
05/12/2006 (10:27 am)
A .raw file contains intel-byte-order unsigned 16 bit integers (U16). When the file is loaded this data is internally converted to signed 16 bit data (S16). For the .chu file, geometry is stored using S16, and compressed on the X and Y axes. Z values in the .chu geometry are stored the same as the internal heightfield data.

In the new Atlas rewrite, the internal datapaths are all F32, making this a largely moot point. :)
#8
05/13/2006 (6:43 am)
Great, thanks Ben.

When will this become moot? ;-)
#9
05/13/2006 (12:20 pm)
As soon as I can get the last bugs knocked out and the code into CVS. Then we will have a refactor of the core Atlas code checked in, at which point I and several contractors will start really rolling out and polshing a ton of new features...
#10
05/13/2006 (2:01 pm)
Hey, thanks, I didn't expect a reply (well, OK maybe a sarcastic one:-) )

That's cheered me up anyway! In fact cheered me up a *lot*. Didn't get home from the pub until 5 o'clock this morning. My head is killing me. The pubs keep late hours here in Ireland :-)

Dave.