Menu

Move from TGLHeightField to TGLTerrainRenderer

Help
2 days ago
14 hours ago
  • Eric Walmsley

    Eric Walmsley - 2 days ago

    Hi,

    So, at the moment, I have GeoTIFF files and I'm using TGLHeightField to display the grid and create a DEM. The GeoTIFF files are huge and the performance of TGLHeightfield has fallen offa cliff, so I'm looking at TGLTerrainRenderer instead. TGLHeightTileFileHDS seems to be perfect for what I need to do, so I'm trying to create the HTF file from the TIFF using TGLHeightTileFile.
    When trying to add the height value, my data consists of Single values, but TGLHeightTileFile.CompressTile(x, y, ts, ts, @buf[0]) is a SmallInt array? That's nowhere near the precision or range I need. Am I missing something, or going about this the wrong way?

    Cheers

     
  • lnebel

    lnebel - 17 hours ago

    Hi Eric,

    I struggled with this as well when I first implemented the TGLTerrainRenderer many years ago. It is not logic at all, but you need to normalize the vertical scale of TGLTerrainRenderer with the actual range of your data.

    The procedure below is taken out of context, but I think you can see what it is doing.

    procedure TGridTerrain.UpdateHDSScale;
    var
    HDSMaxAbsValue : Double;
    begin
    inherited;
    HDSMaxAbsValue := 32767;
    if (Grid.MaxValue - Grid.MinValue) <> 0 then begin
    if Abs(Grid.MaxValue) > Abs(Grid.MinValue) then begin
    HDSMaxAbsValue := Abs(Grid.MaxValue);
    end else
    if Abs(Grid.MaxValue) < Abs(Grid.MinValue) then begin
    HDSMaxAbsValue := Abs(Grid.MinValue);
    end;
    end;
    FHDSScale := 32767 / HDSMaxAbsValue;
    end;

    The procedure updates the scaling factor FHDSScale which is applied elsewhere in the code:
    FGLTerrainrenderer.Scale.Z := FHDSScale;

    When you add your elevation values:
    RasterLine[X - HeightData.XLeft] := Elevation * FHDSScale;

    Materials need to be scaled as well

    The TGLTerrainRenderer and related components are made for large terrains but because they so hard to use, undocumented, and also plagued with bugs I have moved away from them. I use only small terrains so for me a TGLFreeform does the job and is much simpler to implement.

    Lars

     
  • Eric Walmsley

    Eric Walmsley - 14 hours ago

    Hey Lars,

    Thanks for that - it's saved me days of effort. I got wrapped up in another issue that's needing sorted first. I was struggling to get sensible data from some TIFFs, but I think it's because they're way over the 4Gb limit and have been saved as BigTIFFs, so I need a Delphi unit/library that handles BigTIFF.

    Some months are just like the labours of Sisyphus ....

    Eric

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.