Jump to content
  • Advertisement
Sign in to follow this  
Denzin

Calculating Dimensions of a .Raw(8)

This topic is 3013 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Currently I'm using .raw files for height mapping terrain, however the only way I can accomplish this is with pre-defined dimensions or square height maps.
Is there a method of calculating the dimensions from a raw file?

Share this post


Link to post
Share on other sites
Advertisement
Nope, the main point of .raw is that it generally doesn't have a header, just data. The only thing you can do is, if the height map is always square, you can determine the file length, then take its square root to get the side length.

you could also create your own raw format that has a header, plenty of options.

Share this post


Link to post
Share on other sites
You could use a pattern sensing algorithm to detect the width of the data by trying various row lengths and testing the value of each value in the neighboring rows. This is similar to what I use to automatically find struct widths in array-of-struct data when reverse engineering binary files.

loop over possible row lengths (any value that evenly divides your input data length)
foreach row, compare each element with the one in the next row |> absolute value |> sum
choose minimum sum and the rowLength which generated that sum.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!