Advertisement Jump to content
Sign in to follow this  
Denzin

Calculating Dimensions of a .Raw(8)

This topic is 3101 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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!