====== Scripts > Import OpenSim RAW file ====== ^ Description | Import a heightmap from a 13-channel RAW file from OpenSim / Second Life. | ^ Author | [[aaron@bundysoft.com]] | ^ Created | 2013/05/24 | ^ Requires | L3DT v11.11 | ^ Download | {{:scripts:import_opensim_raw.zs|import opensim raw file.zs}} | ^ Forum thread | [[http://www.bundysoft.com/phpBB2/viewtopic.php?f=4&t=2718]] | ===== Script contents ===== // // Title | Import OpenSim RAW.zs // About | A script to import 13 channel 8-bit OpenSim / Second Life RAW files // Author | Aaron Torpy (aaron@bundysoft.com) // Date | 24 May 2013 // filesel fs filesel.Init &fs true NULL "OpenSim/SL RAW files (*.raw)|*.raw|" "raw" NULL if > return -1 endif string FileName set FileName if project.FreeProject endif assert "Cannot initialise project" voidptr fp if > return -1 endif int nx ny set nx 256 set ny 256 hvar pHF set pHF assert "Cannot initialise heightfield" float SeaLevel set SeaLevel 0 progbox prog progbox.SetTitle &prog "Importing RAW file (slowly)" progbox.ShowWnd &prog int i j set j 0 do set i 0 do byte b1 b2 b3 assert "Cannot read file" assert "Cannot read file" assert "Cannot read file" fseek fp 10 1 // skip over next 10 bytes if > set SeaLevel endif float height set height b2> 128.0> SeaLevel> assert "Cannot set pixel" while nx> progbox.SetProgress &prog j ny while ny> fclose fp map.SetFlag pHF 1 true // MAPFLAG_READY view.ShowMap "HF" return 0