Forráskód Böngészése

Updated htf utils demo

GLScene 2 éve
szülő
commit
94c98c03a7

BIN
Demos/media/kapiti.htf


+ 2 - 2
Demos/utilities/HTFUtils/Etopo2.tpcfg

@@ -1,7 +1,7 @@
-HTFName=F:\HTF\etopo2.htf
+HTFName=D:\HTF\etopo2.htf
 WorldSizeX=10800
 WorldSizeY=6336
 TileSize=128
 DefaultZ=0
-DEMPath=F:\DEM
+DEMPath=D:\DEM
 DEMs="topo_8.2.img,""0,0"",10800x6336,""16 bits (non-Intel)"""

+ 2 - 2
Demos/utilities/HTFUtils/Globe.tpcfg

@@ -1,7 +1,7 @@
-HTFName=F:\HTF\globe.htf
+HTFName=D:\HTF\globe.htf
 WorldSizeX=43200
 WorldSizeY=21600
 TileSize=128
 DefaultZ=-500
-DEMPath=F:\DEM
+DEMPath=D:\DEM
 DEMs="a10g,""0,0"",10800x4800,""16 bits (Intel)""","b10g,""10800,0"",10800x4800,""16 bits (Intel)""","c10g,""21600,0"",10800x4800,""16 bits (Intel)""","d10g,""32400,0"",10800x4800,""16 bits (Intel)""","e10g,""0,4800"",10800x6000,""16 bits (Intel)""","f10g,""10800,4800"",10800x6000,""16 bits (Intel)""","g10g,""21600,4800"",10800x6000,""16 bits (Intel)""","h10g,""32400,4800"",10800x6000,""16 bits (Intel)""","i10g,""0,10800"",10800x6000,""16 bits (Intel)""","j10g,""10800,10800"",10800x6000,""16 bits (Intel)""","k10g,""21600,10800"",10800x6000,""16 bits (Intel)""","l10g,""32400,10800"",10800x6000,""16 bits (Intel)""","m10g,""0,16800"",10800x4800,""16 bits (Intel)""","n10g,""10800,16800"",10800x4800,""16 bits (Intel)""","o10g,""21600,16800"",10800x4800,""16 bits (Intel)""","p10g,""32400,16800"",10800x4800,""16 bits (Intel)"""

+ 7 - 7
Demos/utilities/HTFUtils/HTFViewerD.dproj

@@ -7,7 +7,7 @@
         <TargetedPlatforms>1</TargetedPlatforms>
         <AppType>Application</AppType>
         <FrameworkType>VCL</FrameworkType>
-        <ProjectVersion>19.3</ProjectVersion>
+        <ProjectVersion>19.4</ProjectVersion>
         <Platform Condition="'$(Platform)'==''">Win32</Platform>
     </PropertyGroup>
     <PropertyGroup Condition="'$(Config)'=='Base' or '$(Base)'!=''">
@@ -932,17 +932,17 @@
                         <Operation>1</Operation>
                     </Platform>
                 </DeployClass>
+                <ProjectRoot Platform="Android" Name="$(PROJECTNAME)"/>
+                <ProjectRoot Platform="Android64" Name="$(PROJECTNAME)"/>
+                <ProjectRoot Platform="iOSDevice32" Name="$(PROJECTNAME).app"/>
+                <ProjectRoot Platform="iOSDevice64" Name="$(PROJECTNAME).app"/>
+                <ProjectRoot Platform="iOSSimulator" Name="$(PROJECTNAME).app"/>
+                <ProjectRoot Platform="Linux64" Name="$(PROJECTNAME)"/>
                 <ProjectRoot Platform="OSX32" Name="$(PROJECTNAME).app"/>
                 <ProjectRoot Platform="OSX64" Name="$(PROJECTNAME).app"/>
-                <ProjectRoot Platform="Android64" Name="$(PROJECTNAME)"/>
                 <ProjectRoot Platform="OSXARM64" Name="$(PROJECTNAME).app"/>
-                <ProjectRoot Platform="Android" Name="$(PROJECTNAME)"/>
                 <ProjectRoot Platform="Win32" Name="$(PROJECTNAME)"/>
                 <ProjectRoot Platform="Win64" Name="$(PROJECTNAME)"/>
-                <ProjectRoot Platform="Linux64" Name="$(PROJECTNAME)"/>
-                <ProjectRoot Platform="iOSDevice32" Name="$(PROJECTNAME).app"/>
-                <ProjectRoot Platform="iOSDevice64" Name="$(PROJECTNAME).app"/>
-                <ProjectRoot Platform="iOSSimulator" Name="$(PROJECTNAME).app"/>
             </Deployment>
         </BorlandProject>
         <ProjectFileVersion>12</ProjectFileVersion>

+ 2 - 2
Demos/utilities/HTFUtils/Maui_1k.tpcfg

@@ -1,7 +1,7 @@
-HTFName=F:\HTF\maui_1k.htf
+HTFName=D:\HTF\maui_1k.htf
 WorldSizeX=1024
 WorldSizeY=1024
 TileSize=128
 DefaultZ=0
-DEMPath=F:\DEM
+DEMPath=D:\DEM
 DEMs="maui_1k.bt,""0,0"",1025x1025,""VTP's BT (single)"""

+ 2 - 2
Demos/utilities/HTFUtils/TerrainBase.tpcfg

@@ -1,7 +1,7 @@
-HTFName=F:\HTF\tbase.htf
+HTFName=D:\HTF\tbase.htf
 WorldSizeX=4320
 WorldSizeY=2160
 TileSize=128
 DefaultZ=0
-DEMPath=F:\DEM
+DEMPath=D:\DEM
 DEMs="tbase.bin,""0,0"",4320x2160,""16 bits (Intel)"""

+ 3 - 1
Demos/utilities/HTFUtils/TerrainPackD.dpr

@@ -15,7 +15,8 @@ program TerrainPackD;
 uses
   Forms,
   fTerrainPackD in 'fTerrainPackD.pas' {MainForm},
-  fNavD in 'fNavD.pas' {NavForm};
+  fNavD in 'fNavD.pas' {NavForm},
+  fViewerD in 'fViewerD.pas' {ViewerForm};
 
 {$R *.res}
 
@@ -23,5 +24,6 @@ begin
   Application.Initialize;
   Application.CreateForm(TMainForm, MainForm);
   Application.CreateForm(TNavForm, NavForm);
+  Application.CreateForm(TViewerForm, ViewerForm);
   Application.Run;
 end.

+ 11 - 7
Demos/utilities/HTFUtils/TerrainPackD.dproj

@@ -7,7 +7,7 @@
         <TargetedPlatforms>1</TargetedPlatforms>
         <AppType>Application</AppType>
         <FrameworkType>VCL</FrameworkType>
-        <ProjectVersion>19.3</ProjectVersion>
+        <ProjectVersion>19.4</ProjectVersion>
         <Platform Condition="'$(Platform)'==''">Win32</Platform>
     </PropertyGroup>
     <PropertyGroup Condition="'$(Config)'=='Base' or '$(Base)'!=''">
@@ -94,6 +94,10 @@
         <DCCReference Include="fNavD.pas">
             <Form>NavForm</Form>
         </DCCReference>
+        <DCCReference Include="fViewerD.pas">
+            <Form>ViewerForm</Form>
+            <FormType>dfm</FormType>
+        </DCCReference>
         <BuildConfiguration Include="Base">
             <Key>Base</Key>
         </BuildConfiguration>
@@ -931,17 +935,17 @@
                         <Operation>1</Operation>
                     </Platform>
                 </DeployClass>
+                <ProjectRoot Platform="Android" Name="$(PROJECTNAME)"/>
+                <ProjectRoot Platform="Android64" Name="$(PROJECTNAME)"/>
+                <ProjectRoot Platform="iOSDevice32" Name="$(PROJECTNAME).app"/>
+                <ProjectRoot Platform="iOSDevice64" Name="$(PROJECTNAME).app"/>
+                <ProjectRoot Platform="iOSSimulator" Name="$(PROJECTNAME).app"/>
+                <ProjectRoot Platform="Linux64" Name="$(PROJECTNAME)"/>
                 <ProjectRoot Platform="OSX32" Name="$(PROJECTNAME).app"/>
                 <ProjectRoot Platform="OSX64" Name="$(PROJECTNAME).app"/>
-                <ProjectRoot Platform="Android64" Name="$(PROJECTNAME)"/>
                 <ProjectRoot Platform="OSXARM64" Name="$(PROJECTNAME).app"/>
-                <ProjectRoot Platform="Android" Name="$(PROJECTNAME)"/>
                 <ProjectRoot Platform="Win32" Name="$(PROJECTNAME)"/>
                 <ProjectRoot Platform="Win64" Name="$(PROJECTNAME)"/>
-                <ProjectRoot Platform="Linux64" Name="$(PROJECTNAME)"/>
-                <ProjectRoot Platform="iOSDevice32" Name="$(PROJECTNAME).app"/>
-                <ProjectRoot Platform="iOSDevice64" Name="$(PROJECTNAME).app"/>
-                <ProjectRoot Platform="iOSSimulator" Name="$(PROJECTNAME).app"/>
             </Deployment>
         </BorlandProject>
         <ProjectFileVersion>12</ProjectFileVersion>

+ 6 - 11
Demos/utilities/HTFUtils/fNavD.dfm

@@ -3,27 +3,22 @@ object NavForm: TNavForm
   Top = 328
   BorderStyle = bsDialog
   Caption = 'Nav Form'
-  ClientHeight = 240
-  ClientWidth = 240
+  ClientHeight = 192
+  ClientWidth = 192
   Color = clBtnFace
   Font.Charset = DEFAULT_CHARSET
   Font.Color = clWindowText
-  Font.Height = -14
+  Font.Height = -11
   Font.Name = 'MS Sans Serif'
   Font.Style = []
   FormStyle = fsStayOnTop
   Position = poDesktopCenter
-  PixelsPerInch = 120
-  TextHeight = 16
+  TextHeight = 13
   object Image: TImage32
     Left = 0
     Top = 0
-    Width = 240
-    Height = 240
-    Margins.Left = 4
-    Margins.Top = 4
-    Margins.Right = 4
-    Margins.Bottom = 4
+    Width = 192
+    Height = 192
     Bitmap.ResamplerClassName = 'TNearestResampler'
     BitmapAlign = baTopLeft
     Scale = 1.000000000000000000

+ 1 - 1
Demos/utilities/HTFUtils/fNavD.pas

@@ -36,7 +36,7 @@ implementation
 {$R *.dfm}
 
 uses
-  fViewer;
+  fViewerD;
 
 function TNavForm.Execute(htf : TGLHeightTileFile) : Boolean;
 var

+ 130 - 282
Demos/utilities/HTFUtils/fTerrainPackD.dfm

@@ -2,32 +2,28 @@ object MainForm: TMainForm
   Left = 252
   Top = 328
   Caption = 'Terrain Pack v1.1'
-  ClientHeight = 515
-  ClientWidth = 726
+  ClientHeight = 412
+  ClientWidth = 581
   Color = clBtnFace
   Font.Charset = DEFAULT_CHARSET
   Font.Color = clWindowText
-  Font.Height = -14
+  Font.Height = -11
   Font.Name = 'MS Sans Serif'
   Font.Style = []
   Menu = MainMenu
   ShowHint = True
   OnCreate = FormCreate
   OnDestroy = FormDestroy
-  PixelsPerInch = 120
-  TextHeight = 16
+  TextHeight = 13
   object StringGrid: TStringGrid
     Left = 0
-    Top = 351
-    Width = 726
-    Height = 139
-    Margins.Left = 4
-    Margins.Top = 4
-    Margins.Right = 4
-    Margins.Bottom = 4
+    Top = 282
+    Width = 581
+    Height = 110
     Align = alClient
     BorderStyle = bsNone
-    DefaultColWidth = 138
+    DefaultColWidth = 110
+    DefaultRowHeight = 19
     FixedCols = 0
     RowCount = 2
     Options = [goFixedVertLine, goFixedHorzLine, goVertLine, goHorzLine, goRangeSelect, goColSizing, goEditing, goThumbTracking]
@@ -37,277 +33,189 @@ object MainForm: TMainForm
   end
   object Panel1: TPanel
     Left = 0
-    Top = 215
-    Width = 726
-    Height = 136
-    Margins.Left = 4
-    Margins.Top = 4
-    Margins.Right = 4
-    Margins.Bottom = 4
+    Top = 173
+    Width = 581
+    Height = 109
     Align = alTop
     BevelInner = bvRaised
     BevelOuter = bvLowered
     TabOrder = 1
     DesignSize = (
-      726
-      136)
+      581
+      109)
     object Label1: TLabel
-      Left = 10
-      Top = 104
-      Width = 59
-      Height = 16
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
+      Left = 8
+      Top = 83
+      Width = 48
+      Height = 13
       Caption = 'DEM path'
     end
     object Label2: TLabel
-      Left = 10
-      Top = 14
-      Width = 66
-      Height = 16
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
+      Left = 8
+      Top = 11
+      Width = 54
+      Height = 13
       Caption = 'HTF output'
     end
     object Label3: TLabel
-      Left = 10
-      Top = 44
-      Width = 65
-      Height = 16
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
+      Left = 8
+      Top = 35
+      Width = 51
+      Height = 13
       Caption = 'World Size'
     end
     object Label4: TLabel
-      Left = 150
-      Top = 44
-      Width = 21
-      Height = 16
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
+      Left = 120
+      Top = 35
+      Width = 17
+      Height = 13
       Alignment = taCenter
       AutoSize = False
       Caption = 'x'
     end
     object Label5: TLabel
-      Left = 400
-      Top = 44
-      Width = 81
-      Height = 16
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
+      Left = 320
+      Top = 35
+      Width = 66
+      Height = 13
       Caption = 'Default height'
     end
     object Label6: TLabel
-      Left = 260
-      Top = 44
-      Width = 52
-      Height = 16
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
+      Left = 208
+      Top = 35
+      Width = 40
+      Height = 13
       Caption = 'Tile Size'
     end
     object Label7: TLabel
-      Left = 240
-      Top = 74
-      Width = 72
-      Height = 16
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
+      Left = 192
+      Top = 59
+      Width = 55
+      Height = 13
       Caption = 'Tile overlap'
     end
     object Label8: TLabel
-      Left = 400
-      Top = 74
-      Width = 89
-      Height = 16
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
+      Left = 320
+      Top = 59
+      Width = 72
+      Height = 13
       Caption = 'Filter to default:'
     end
     object Label9: TLabel
-      Left = 590
-      Top = 44
-      Width = 46
-      Height = 16
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
+      Left = 472
+      Top = 35
+      Width = 37
+      Height = 13
       Caption = 'Z Scale'
     end
     object EDHTFName: TEdit
-      Left = 90
-      Top = 10
-      Width = 591
-      Height = 24
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
+      Left = 72
+      Top = 8
+      Width = 473
+      Height = 21
       Anchors = [akLeft, akTop, akRight]
       TabOrder = 0
     end
     object EDDEMPath: TEdit
-      Left = 90
-      Top = 100
-      Width = 591
-      Height = 24
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
+      Left = 72
+      Top = 80
+      Width = 473
+      Height = 21
       Anchors = [akLeft, akTop, akRight]
       TabOrder = 1
       OnChange = EDDEMPathChange
     end
     object BUDEMPath: TButton
-      Left = 684
-      Top = 100
-      Width = 30
-      Height = 26
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
+      Left = 547
+      Top = 80
+      Width = 24
+      Height = 21
       Anchors = [akTop, akRight]
       Caption = '...'
       TabOrder = 2
       OnClick = BUDEMPathClick
     end
     object BUPickHTF: TButton
-      Left = 684
-      Top = 10
-      Width = 30
-      Height = 26
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
+      Left = 547
+      Top = 8
+      Width = 24
+      Height = 21
       Anchors = [akTop, akRight]
       Caption = '...'
       TabOrder = 3
       OnClick = BUPickHTFClick
     end
     object EDSizeX: TEdit
-      Left = 90
-      Top = 40
-      Width = 61
-      Height = 24
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
+      Left = 72
+      Top = 32
+      Width = 49
+      Height = 21
       TabOrder = 4
     end
     object EDSizeY: TEdit
-      Left = 170
-      Top = 40
-      Width = 61
-      Height = 24
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
+      Left = 136
+      Top = 32
+      Width = 49
+      Height = 21
       TabOrder = 5
     end
     object EDDefaultZ: TEdit
-      Left = 500
-      Top = 40
-      Width = 61
-      Height = 24
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
+      Left = 400
+      Top = 32
+      Width = 49
+      Height = 21
       TabOrder = 6
       Text = '0'
       OnChange = EDDefaultZChange
     end
     object EDTileSize: TEdit
-      Left = 320
-      Top = 40
-      Width = 61
-      Height = 24
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
+      Left = 256
+      Top = 32
+      Width = 49
+      Height = 21
       TabOrder = 7
       Text = '256'
     end
     object EDTileOverlap: TEdit
-      Left = 320
-      Top = 70
-      Width = 61
-      Height = 24
+      Left = 256
+      Top = 56
+      Width = 49
+      Height = 21
       Hint = 
         'Tile overlap in samples'#13#10'When overlap is 1, righternmost and bot' +
         'tommost undefined samples '#13#10'will be filled completed with last r' +
         'ow value in place of default value'
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
       TabOrder = 8
       Text = '0'
     end
     object EDZFilter: TEdit
-      Left = 500
-      Top = 70
-      Width = 63
-      Height = 24
+      Left = 400
+      Top = 56
+      Width = 50
+      Height = 21
       Hint = 
         'All samples with this altitude will be replaced by default heigh' +
         't'
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
       TabOrder = 9
       OnChange = EDZFilterChange
     end
     object EDZScale: TEdit
-      Left = 644
-      Top = 40
-      Width = 71
-      Height = 24
+      Left = 515
+      Top = 32
+      Width = 57
+      Height = 21
       Hint = 
         'Scaling is applied after filtering, and applied to default heigh' +
         't too'
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
       TabOrder = 10
       Text = '1.0'
       OnChange = EDZScaleChange
     end
     object CBWholeOnly: TCheckBox
-      Left = 590
-      Top = 74
-      Width = 121
-      Height = 21
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
+      Left = 472
+      Top = 59
+      Width = 97
+      Height = 17
       Caption = 'Whole tiles only'
       TabOrder = 11
     end
@@ -315,120 +223,76 @@ object MainForm: TMainForm
   object ToolBar: TToolBar
     Left = 0
     Top = 0
-    Width = 726
-    Height = 215
-    Margins.Left = 4
-    Margins.Top = 4
-    Margins.Right = 4
-    Margins.Bottom = 4
+    Width = 581
+    Height = 173
     AutoSize = True
     BorderWidth = 1
-    ButtonHeight = 211
-    ButtonWidth = 114
+    ButtonHeight = 169
+    ButtonWidth = 91
     Caption = 'ToolBar'
     Images = ImageList
     TabOrder = 2
     object ToolButton1: TToolButton
       Left = 0
       Top = 0
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
       Action = ACOpen
     end
     object ToolButton2: TToolButton
-      Left = 114
+      Left = 91
       Top = 0
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
       Action = ACSave
     end
     object ToolButton3: TToolButton
-      Left = 228
+      Left = 182
       Top = 0
-      Width = 10
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
+      Width = 8
       Caption = 'ToolButton3'
       ImageIndex = 2
       Style = tbsSeparator
     end
     object ToolButton4: TToolButton
-      Left = 238
+      Left = 190
       Top = 0
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
       Action = ACNewDEM
     end
     object ToolButton5: TToolButton
-      Left = 352
+      Left = 281
       Top = 0
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
       Action = ACRemoveDEM
     end
     object ToolButton6: TToolButton
-      Left = 466
+      Left = 372
       Top = 0
-      Width = 10
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
+      Width = 8
       Caption = 'ToolButton6'
       ImageIndex = 6
       Style = tbsSeparator
     end
     object ToolButton7: TToolButton
-      Left = 476
+      Left = 380
       Top = 0
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
       Action = ACProcess
     end
     object ToolButton8: TToolButton
-      Left = 590
+      Left = 471
       Top = 0
-      Width = 10
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
+      Width = 8
       Caption = 'ToolButton8'
       ImageIndex = 4
       Style = tbsSeparator
     end
     object ToolButton9: TToolButton
-      Left = 600
+      Left = 479
       Top = 0
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
       Action = ACViewer
     end
   end
   object CBType: TComboBox
-    Left = 410
-    Top = 230
-    Width = 141
-    Height = 24
+    Left = 328
+    Top = 184
+    Width = 113
+    Height = 21
     Hint = 'Select input file format.'
-    Margins.Left = 4
-    Margins.Top = 4
-    Margins.Right = 4
-    Margins.Bottom = 4
     Style = csDropDownList
     TabOrder = 3
     Visible = False
@@ -443,15 +307,11 @@ object MainForm: TMainForm
       'DTED')
   end
   object CBFile: TComboBox
-    Left = 10
-    Top = 230
-    Width = 141
-    Height = 24
+    Left = 8
+    Top = 184
+    Width = 113
+    Height = 21
     Hint = 'Filename to be inported.'
-    Margins.Left = 4
-    Margins.Top = 4
-    Margins.Right = 4
-    Margins.Bottom = 4
     DropDownCount = 24
     TabOrder = 4
     Visible = False
@@ -459,13 +319,9 @@ object MainForm: TMainForm
   end
   object PanelFoot: TPanel
     Left = 0
-    Top = 490
-    Width = 726
-    Height = 25
-    Margins.Left = 4
-    Margins.Top = 4
-    Margins.Right = 4
-    Margins.Bottom = 4
+    Top = 392
+    Width = 581
+    Height = 20
     Align = alBottom
     BevelOuter = bvNone
     BorderWidth = 3
@@ -473,12 +329,8 @@ object MainForm: TMainForm
     object ProgressBar: TProgressBar
       Left = 3
       Top = 3
-      Width = 720
-      Height = 19
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
+      Width = 575
+      Height = 14
       Align = alClient
       Smooth = True
       Step = 1
@@ -486,17 +338,13 @@ object MainForm: TMainForm
     end
   end
   object CBFlipRotate: TComboBox
-    Left = 560
-    Top = 230
-    Width = 141
-    Height = 24
+    Left = 448
+    Top = 184
+    Width = 113
+    Height = 21
     Hint = 
       'Rotate and/or flip the input data. (Use Rotate 270 for DTED data' +
       '.)'
-    Margins.Left = 4
-    Margins.Top = 4
-    Margins.Right = 4
-    Margins.Bottom = 4
     Style = csDropDownList
     TabOrder = 6
     Visible = False

+ 481 - 389
Demos/utilities/HTFUtils/fTerrainPackD.pas

@@ -4,34 +4,36 @@ interface
 
 uses
   Winapi.Windows,
-  System.SysUtils, 
-  System.Classes, 
-  System.Actions, 
+  System.SysUtils,
+  System.Classes,
+  System.Actions,
   System.Math,
-  Vcl.Graphics, 
-  Vcl.Controls, 
-  Vcl.Forms, 
-  Vcl.Dialogs, 
-  ValEdit, 
-  Vcl.Grids, 
-  Vcl.Menus, 
-  Vcl.StdCtrls, 
-  Vcl.ComCtrls, 
-  Vcl.ToolWin, 
-  Vcl.ExtCtrls, 
-  Vcl.ActnList, 
+  System.ImageList,
+  Vcl.Graphics,
+  Vcl.Controls,
+  Vcl.Forms,
+  Vcl.Dialogs,
+  ValEdit,
+  Vcl.Grids,
+  Vcl.Menus,
+  Vcl.StdCtrls,
+  Vcl.ComCtrls,
+  Vcl.ToolWin,
+  Vcl.ExtCtrls,
+  Vcl.ActnList,
   Vcl.ImgList,
-  
-  GLS.HeightTileFileHDS, System.ImageList;
+
+  GLS.HeightTileFileHDS;
 
 type
-   TSrc = record
-      fs : TFileStream;
-      x, y, w, h : Integer;
-      format : Integer;
-      FlipRotate : Integer;
-   end;
-   PSrc = ^TSrc;
+  TSrc = record
+    fs: TFileStream;
+    x, y, w, h: Integer;
+    format: Integer;
+    FlipRotate: Integer;
+  end;
+
+  PSrc = ^TSrc;
 
   TMainForm = class(TForm)
     MainMenu: TMainMenu;
@@ -123,20 +125,22 @@ type
     procedure EDZFilterChange(Sender: TObject);
     procedure EDZScaleChange(Sender: TObject);
   private
-     
-    sources : array of TSrc;
-    defaultZ : SmallInt;
-    filterZ : SmallInt;
-    zScale : Single;
+
+    sources: array of TSrc;
+    defaultZ: SmallInt;
+    filterZ: SmallInt;
+    zScale: Single;
 
     procedure Parse;
     procedure Cleanup;
-    procedure SrcExtractFlip(src : PSrc; relX, relY, len : Integer; dest : PSmallInt);
-    procedure SrcExtract(src : PSrc; relX, relY, len : Integer; dest : PSmallInt; DiagFlip:boolean=false);
-    procedure WorldExtract(x, y, len : Integer; dest : PSmallInt);
+    procedure SrcExtractFlip(src: PSrc; relX, relY, len: Integer;
+      dest: PSmallInt);
+    procedure SrcExtract(src: PSrc; relX, relY, len: Integer; dest: PSmallInt;
+      DiagFlip: Boolean = false);
+    procedure WorldExtract(x, y, len: Integer; dest: PSmallInt);
 
   public
-     
+
   end;
 
 var
@@ -145,479 +149,567 @@ var
 implementation
 
 uses
-  FViewerForm;
+  fViewerD;
 
 {$R *.dfm}
 
 procedure TMainForm.FormCreate(Sender: TObject);
 var
-   i : Integer;
+  i: Integer;
 begin
-   with ActionList do
-      for i:=0 to ActionCount-1 do with TAction(Actions[i]) do
-         Hint:=Caption;
-   with StringGrid do begin
-      Cells[0, 0]:='File Name';           ColWidths[0]:=140;
-      Cells[1, 0]:='World Offset';        ColWidths[1]:=80;
-      Cells[2, 0]:='Size (rotated)';      ColWidths[2]:=80;
-      Cells[3, 0]:='Data type';           ColWidths[3]:=120;
-      Cells[4, 0]:='Flip and Rotate';     ColWidths[4]:=110;
-      Row:=0;
-   end;
-   zScale:=1;
+  with ActionList do
+    for i := 0 to ActionCount - 1 do
+      with TAction(Actions[i]) do
+        Hint := Caption;
+  with StringGrid do
+  begin
+    Cells[0, 0] := 'File Name';
+    ColWidths[0] := 140;
+    Cells[1, 0] := 'World Offset';
+    ColWidths[1] := 80;
+    Cells[2, 0] := 'Size (rotated)';
+    ColWidths[2] := 80;
+    Cells[3, 0] := 'Data type';
+    ColWidths[3] := 120;
+    Cells[4, 0] := 'Flip and Rotate';
+    ColWidths[4] := 110;
+    Row := 0;
+  end;
+  zScale := 1;
 end;
 
 procedure TMainForm.FormDestroy(Sender: TObject);
 begin
-   Cleanup;
+  Cleanup;
 end;
 
 procedure TMainForm.ACExitExecute(Sender: TObject);
 begin
-   Close;
+  Close;
 end;
 
 procedure TMainForm.BUDEMPathClick(Sender: TObject);
 begin
-   ODPath.InitialDir:=EDDEMPath.Text;
-   ODPath.FileName:=EDDEMPath.Text+'pick a dummy.file';
-   if ODPath.Execute then
-      EDDEMPath.Text:=ExtractFilePath(ODPath.FileName);
+  ODPath.InitialDir := EDDEMPath.Text;
+  ODPath.FileName := EDDEMPath.Text + 'pick a dummy.file';
+  if ODPath.Execute then
+    EDDEMPath.Text := ExtractFilePath(ODPath.FileName);
 end;
 
 procedure TMainForm.BUPickHTFClick(Sender: TObject);
 begin
-   SDHTF.FileName:=EDHTFName.Text;
-   if SDHTF.Execute then
-      EDHTFName.Text:=SDHTF.FileName;
+  SDHTF.FileName := EDHTFName.Text;
+  if SDHTF.Execute then
+    EDHTFName.Text := SDHTF.FileName;
 end;
 
 procedure TMainForm.MIAboutClick(Sender: TObject);
 begin
-   ShowMessage(Caption+#13#10#13#10
-               +'HTF Generation Utility'#13#10
-               +'Part of GLScene library.'#13#10#13#10
-               +'http://glscene.org');
+  ShowMessage(Caption + #13#10#13#10 + 'HTF Generation Utility'#13#10 +
+    'Part of GLScene library.'#13#10#13#10 + 'http://glscene.org');
 end;
 
 procedure TMainForm.ActionListUpdate(Action: TBasicAction;
   var Handled: Boolean);
 begin
-   ACRemoveDEM.Enabled:=(StringGrid.RowCount>2);
+  ACRemoveDEM.Enabled := (StringGrid.RowCount > 2);
 end;
 
 procedure TMainForm.ACNewDEMExecute(Sender: TObject);
 begin
-   StringGrid.RowCount:=StringGrid.RowCount+1;
+  StringGrid.RowCount := StringGrid.RowCount + 1;
 end;
 
 procedure TMainForm.ACRemoveDEMExecute(Sender: TObject);
 var
-   i : Integer;
+  i: Integer;
 begin
-   with StringGrid do begin
-      i:=Row;
-      if i<RowCount-1 then begin
-         while i<RowCount-1 do begin
-            Rows[i]:=Rows[i+1];
-            Inc(i);
-         end;
-      end else Row:=i-1;
-      RowCount:=RowCount-1;
-   end;
+  with StringGrid do
+  begin
+    i := Row;
+    if i < RowCount - 1 then
+    begin
+      while i < RowCount - 1 do
+      begin
+        Rows[i] := Rows[i + 1];
+        Inc(i);
+      end;
+    end
+    else
+      Row := i - 1;
+    RowCount := RowCount - 1;
+  end;
 end;
 
-procedure TMainForm.StringGridSelectCell(Sender: TObject; ACol,
-  ARow: Integer; var CanSelect: Boolean);
-
-   procedure SetCB(const cb : TComboBox);
-   var
-      r : TRect;
-      i : Integer;
-   begin
-      r:=StringGrid.CellRect(ACol, ARow);
-      cb.Left:=r.Left+StringGrid.Left;
-      cb.Top:=r.Top+StringGrid.Top;
-      cb.Width:=r.Right+1-r.Left;
-      i:=cb.Items.IndexOf(StringGrid.Cells[ACol, ARow]);
-      if i>=0 then
-         cb.ItemIndex:=i
-      else cb.Text:=StringGrid.Cells[ACol, ARow];
-      if Visible then
-         cb.SetFocus;
-   end;
+procedure TMainForm.StringGridSelectCell(Sender: TObject; ACol, ARow: Integer;
+  var CanSelect: Boolean);
+
+  procedure SetCB(const cb: TComboBox);
+  var
+    r: TRect;
+    i: Integer;
+  begin
+    r := StringGrid.CellRect(ACol, ARow);
+    cb.Left := r.Left + StringGrid.Left;
+    cb.Top := r.Top + StringGrid.Top;
+    cb.Width := r.Right + 1 - r.Left;
+    i := cb.Items.IndexOf(StringGrid.Cells[ACol, ARow]);
+    if i >= 0 then
+      cb.ItemIndex := i
+    else
+      cb.Text := StringGrid.Cells[ACol, ARow];
+    if Visible then
+      cb.SetFocus;
+  end;
 
 begin
-   if ARow>0 then begin
-      if ACol=0 then begin
-         CBFile.Visible:=True;
-         SetCB(CBFile);
-      end else CBFile.Visible:=False;
-      if ACol=3 then begin
-         CBType.Visible:=True;
-         SetCB(CBType);
-      end else CBType.Visible:=False;
-      if ACol=4 then begin
-         CBFlipRotate.Visible:=True;
-         SetCB(CBFlipRotate);
-      end else CBFlipRotate.Visible:=False;
-      CanSelect:=True;
-   end;
+  if ARow > 0 then
+  begin
+    if ACol = 0 then
+    begin
+      CBFile.Visible := True;
+      SetCB(CBFile);
+    end
+    else
+      CBFile.Visible := false;
+    if ACol = 3 then
+    begin
+      CBType.Visible := True;
+      SetCB(CBType);
+    end
+    else
+      CBType.Visible := false;
+    if ACol = 4 then
+    begin
+      CBFlipRotate.Visible := True;
+      SetCB(CBFlipRotate);
+    end
+    else
+      CBFlipRotate.Visible := false;
+    CanSelect := True;
+  end;
 end;
 
 procedure TMainForm.CBTypeChange(Sender: TObject);
 begin
-   with StringGrid do
-      Cells[Col, Row]:=(Sender as TComboBox).Text;
+  with StringGrid do
+    Cells[Col, Row] := (Sender as TComboBox).Text;
 end;
 
 procedure TMainForm.ACSaveExecute(Sender: TObject);
 var
-   i : Integer;
-   sl, sg : TStringList;
+  i: Integer;
+  sl, sg: TStringList;
 begin
-   if SDTerrainPack.Execute then begin
-      sl:=TStringList.Create;
-      with sl do begin
-         Values['HTFName']:=EDHTFName.Text;
-         Values['WorldSizeX']:=EDSizeX.Text;
-         Values['WorldSizeY']:=EDSizeY.Text;
-         Values['TileSize']:=EDTileSize.Text;
-         Values['TileOverlap']:=EDTileOverlap.Text;
-         Values['DefaultZ']:=EDDefaultZ.Text;
-         Values['FilterZ']:=EDZFilter.Text;
-         Values['ZScale']:=EDZScale.Text;
-         Values['DEMPath']:=EDDEMPath.Text;
-         Values['WholeTiles']:=IntToStr(Integer(CBWholeOnly.Checked));
-         sg:=TStringList.Create;
-         for i:=1 to StringGrid.RowCount-1 do
-            sg.Add(StringGrid.Rows[i].CommaText);
-         Values['DEMs']:=sg.CommaText;
-         sg.Free;
-      end;
-      sl.SaveToFile(SDTerrainPack.FileName);
-      sl.Free;
-   end;
+  if SDTerrainPack.Execute then
+  begin
+    sl := TStringList.Create;
+    with sl do
+    begin
+      Values['HTFName'] := EDHTFName.Text;
+      Values['WorldSizeX'] := EDSizeX.Text;
+      Values['WorldSizeY'] := EDSizeY.Text;
+      Values['TileSize'] := EDTileSize.Text;
+      Values['TileOverlap'] := EDTileOverlap.Text;
+      Values['DefaultZ'] := EDDefaultZ.Text;
+      Values['FilterZ'] := EDZFilter.Text;
+      Values['ZScale'] := EDZScale.Text;
+      Values['DEMPath'] := EDDEMPath.Text;
+      Values['WholeTiles'] := IntToStr(Integer(CBWholeOnly.Checked));
+      sg := TStringList.Create;
+      for i := 1 to StringGrid.RowCount - 1 do
+        sg.Add(StringGrid.Rows[i].CommaText);
+      Values['DEMs'] := sg.CommaText;
+      sg.Free;
+    end;
+    sl.SaveToFile(SDTerrainPack.FileName);
+    sl.Free;
+  end;
 end;
 
 procedure TMainForm.ACOpenExecute(Sender: TObject);
 var
-   i : Integer;
-   sl, sg : TStringList;
+  i: Integer;
+  sl, sg: TStringList;
 begin
-   if ODTerrainPack.Execute then begin
-      sl:=TStringList.Create;
-      sl.LoadFromFile(ODTerrainPack.FileName);
-      with sl do begin
-         EDHTFName.Text:=Values['HTFName'];
-         EDSizeX.Text:=Values['WorldSizeX'];
-         EDSizeY.Text:=Values['WorldSizeY'];
-         EDTileSize.Text:=Values['TileSize'];
-         EDTileOverlap.Text:=Values['TileOverlap'];
-         EDDefaultZ.Text:=Values['DefaultZ'];
-         EDZFilter.Text:=Values['FilterZ'];
-         EDZScale.Text:=Values['ZScale'];
-         EDDEMPath.Text:=Values['DEMPath'];
-         CBWholeOnly.Checked:=(Values['WholeTiles']='1');
-         sg:=TStringList.Create;
-         sg.CommaText:=Values['DEMs'];
-         StringGrid.RowCount:=sg.Count+1;
-         for i:=0 to sg.Count-1 do
-            StringGrid.Rows[i+1].CommaText:=sg[i];
-         sg.Free;
-      end;
-      sl.Free;
-      SDTerrainPack.FileName:=ODTerrainPack.FileName;
-   end;
+  if ODTerrainPack.Execute then
+  begin
+    sl := TStringList.Create;
+    sl.LoadFromFile(ODTerrainPack.FileName);
+    with sl do
+    begin
+      EDHTFName.Text := Values['HTFName'];
+      EDSizeX.Text := Values['WorldSizeX'];
+      EDSizeY.Text := Values['WorldSizeY'];
+      EDTileSize.Text := Values['TileSize'];
+      EDTileOverlap.Text := Values['TileOverlap'];
+      EDDefaultZ.Text := Values['DefaultZ'];
+      EDZFilter.Text := Values['FilterZ'];
+      EDZScale.Text := Values['ZScale'];
+      EDDEMPath.Text := Values['DEMPath'];
+      CBWholeOnly.Checked := (Values['WholeTiles'] = '1');
+      sg := TStringList.Create;
+      sg.CommaText := Values['DEMs'];
+      StringGrid.RowCount := sg.Count + 1;
+      for i := 0 to sg.Count - 1 do
+        StringGrid.Rows[i + 1].CommaText := sg[i];
+      sg.Free;
+    end;
+    sl.Free;
+    SDTerrainPack.FileName := ODTerrainPack.FileName;
+  end;
 end;
 
 procedure TMainForm.EDDEMPathChange(Sender: TObject);
 var
-   f : TSearchRec;
-   r : Integer;
+  f: TSearchRec;
+  r: Integer;
 begin
-   CBFile.Items.Clear;
-   r:=FindFirst(EDDEMPath.Text+'\*.*', faAnyFile, f);
-   while r=0 do begin
-      if (f.Attr and faDirectory)=0 then
-         CBFile.Items.Add(f.Name);
-      r:=FindNext(f);
-   end;
-   FindClose(f);
+  CBFile.Items.Clear;
+  r := FindFirst(EDDEMPath.Text + '\*.*', faAnyFile, f);
+  while r = 0 do
+  begin
+    if (f.Attr and faDirectory) = 0 then
+      CBFile.Items.Add(f.Name);
+    r := FindNext(f);
+  end;
+  FindClose(f);
 end;
 
 procedure TMainForm.EDDefaultZChange(Sender: TObject);
 begin
-   defaultZ:=StrToIntDef(EDDefaultZ.Text, 0);
-   if EDZFilter.Text='' then
-      filterZ:=defaultZ;
+  defaultZ := StrToIntDef(EDDefaultZ.Text, 0);
+  if EDZFilter.Text = '' then
+    filterZ := defaultZ;
 end;
 
 procedure TMainForm.EDZFilterChange(Sender: TObject);
 begin
-   filterZ:=StrToIntDef(EDZFilter.Text, defaultZ);
+  filterZ := StrToIntDef(EDZFilter.Text, defaultZ);
 end;
 
 procedure TMainForm.EDZScaleChange(Sender: TObject);
 begin
-   zScale:=StrToFloatDef(EDZScale.Text, 1.0);
+  zScale := StrToFloatDef(EDZScale.Text, 1.0);
 end;
 
 procedure TMainForm.Parse;
 var
-   i, p : Integer;
-   row : TStrings;
+  i, p: Integer;
+  Row: TStrings;
 begin
-   Cleanup;
-   SetLength(sources, StringGrid.RowCount-1);
-   for i:=0 to High(sources) do begin
-      row:=StringGrid.Rows[i+1];
-      sources[i].fs:=TFileStream.Create(EDDEMPath.Text+'\'+row[0], fmOpenRead+fmShareDenyNone);
-      p:=Pos(',', row[1]);
-      sources[i].x:=StrToInt(Copy(row[1], 1, p-1));
-      sources[i].y:=StrToInt(Copy(row[1], p+1, MaxInt));
-      p:=Pos('x', row[2]);
-      sources[i].w:=StrToInt(Copy(row[2], 1, p-1));
-      sources[i].h:=StrToInt(Copy(row[2], p+1, MaxInt));
-      sources[i].format:=CBType.Items.IndexOf(row[3]);           //File format
-      sources[i].FlipRotate:=CBFlipRotate.Items.IndexOf(row[4]); //Flip and Rotate
-   end;
+  Cleanup;
+  SetLength(sources, StringGrid.RowCount - 1);
+  for i := 0 to High(sources) do
+  begin
+    Row := StringGrid.Rows[i + 1];
+    sources[i].fs := TFileStream.Create(EDDEMPath.Text + '\' + Row[0],
+      fmOpenRead + fmShareDenyNone);
+    p := Pos(',', Row[1]);
+    sources[i].x := StrToInt(Copy(Row[1], 1, p - 1));
+    sources[i].y := StrToInt(Copy(Row[1], p + 1, MaxInt));
+    p := Pos('x', Row[2]);
+    sources[i].w := StrToInt(Copy(Row[2], 1, p - 1));
+    sources[i].h := StrToInt(Copy(Row[2], p + 1, MaxInt));
+    sources[i].format := CBType.Items.IndexOf(Row[3]); // File format
+    sources[i].FlipRotate := CBFlipRotate.Items.IndexOf(Row[4]);
+    // Flip and Rotate
+  end;
 end;
 
 procedure TMainForm.Cleanup;
 var
-   i : Integer;
+  i: Integer;
 begin
-   for i:=0 to High(sources) do
-      sources[i].fs.Free;
-   SetLength(sources, 0);
+  for i := 0 to High(sources) do
+    sources[i].fs.Free;
+  SetLength(sources, 0);
 end;
 
-procedure TMainForm.SrcExtractFlip(src : PSrc; relX, relY, len : Integer; dest : PSmallInt);
-var i:integer;
-    val:SmallInt;
+procedure TMainForm.SrcExtractFlip(src: PSrc; relX, relY, len: Integer;
+  dest: PSmallInt);
+var
+  i: Integer;
+  val: SmallInt;
 begin
-  if src.FlipRotate<=0 then SrcExtract(src,relX, relY, len, dest)  //None
-  else begin
-    for i:=0 to len-1 do begin
+  if src.FlipRotate <= 0 then
+    SrcExtract(src, relX, relY, len, dest) // None
+  else
+  begin
+    for i := 0 to len - 1 do
+    begin
       case src.FlipRotate of
-      //0 : SrcExtract(src,relX, relY+i,1,@val);                   //No change                  (    )
-        1 : SrcExtract(src,src.w-(relX+i),relY,1,@val);            //H-Flip                     (Flip)
-        2 : SrcExtract(src,relY,src.w-(relX+i),1,@val,true);       //DiagFlip + H-Flip          (90deg)
-        3 : SrcExtract(src,src.w-(relX+i),src.h-relY,1,@val);      //H-Flip   + V-Flip          (180deg)
-        4 : SrcExtract(src,src.h-relY,(relX+i),1,@val,true);       //DiagFlip + V-Flip          (270deg)
-        5 : SrcExtract(src,src.h-relY,src.w-(relX+i),1,@val,true); //DiagFlip + V-Flip + H-Flip (Flip-90deg)
-        6 : SrcExtract(src,relX+i,src.h-relY,1,@val);              //V-FLIP                     (Flip-180deg)
-        7 : SrcExtract(src,relY, relX+i,1,@val,true);              //DiagFlip                   (Flip-270deg)
+        // 0 : SrcExtract(src,relX, relY+i,1,@val);                   //No change                  (    )
+        1:
+          SrcExtract(src, src.w - (relX + i), relY, 1, @val);
+          // H-Flip                     (Flip)
+        2:
+          SrcExtract(src, relY, src.w - (relX + i), 1, @val, True);
+          // DiagFlip + H-Flip          (90deg)
+        3:
+          SrcExtract(src, src.w - (relX + i), src.h - relY, 1, @val);
+          // H-Flip   + V-Flip          (180deg)
+        4:
+          SrcExtract(src, src.h - relY, (relX + i), 1, @val, True);
+          // DiagFlip + V-Flip          (270deg)
+        5:
+          SrcExtract(src, src.h - relY, src.w - (relX + i), 1, @val, True);
+          // DiagFlip + V-Flip + H-Flip (Flip-90deg)
+        6:
+          SrcExtract(src, relX + i, src.h - relY, 1, @val);
+          // V-FLIP                     (Flip-180deg)
+        7:
+          SrcExtract(src, relY, relX + i, 1, @val, True);
+          // DiagFlip                   (Flip-270deg)
       end;
-      PSmallIntArray(dest)[i]:=val;
+      PSmallIntArray(dest)[i] := val;
     end;
   end;
 end;
 
-
-procedure TMainForm.SrcExtract(src : PSrc; relX, relY, len : Integer; dest : PSmallInt; DiagFlip:boolean=false);
+procedure TMainForm.SrcExtract(src: PSrc; relX, relY, len: Integer;
+  dest: PSmallInt; DiagFlip: Boolean = false);
 var
-   i, c : Integer;
-   wd : Word;
-   buf : array of Single;
-   bmp : TBitmap;
-   rw    : integer; //rotated width
+  i, c: Integer;
+  wd: Word;
+  buf: array of Single;
+  bmp: TBitmap;
+  rw: Integer; // rotated width
 begin
-   if DiagFlip then rw:=src.h else rw:=src.w;
-
-   with src^ do begin
-      case format of
-         0 : begin // 16bits Intel
-            fs.Position:=(relX+relY*rw)*2;
-            fs.Read(dest^, len*2);
-         end;
-         1 : begin // 16bits unsigned Intel
-            fs.Position:=(relX+relY*rw)*2;
-            fs.Read(dest^, len*2);
-            for i:=0 to len-1 do begin
-               wd:=PWord(Integer(dest)+i*2)^;
-               PSmallInt(Integer(dest)+i*2)^:=Integer(wd)-32768;
-            end;
-         end;
-         2 : begin // 16bits non-Intel
-            fs.Position:=(relX+relY*rw)*2;
-            fs.Read(dest^, len*2);
-            for i:=0 to len-1 do begin
-               wd:=PWord(Integer(dest)+i*2)^;
-               PWord(Integer(dest)+i*2)^:=((wd and 255) shl 8)+(wd shr 8);
-            end;
-         end;
-         3 : begin // VTP's BT single
-            fs.Position:=(relX+relY*rw)*4+256;
-            SetLength(buf, len);
-            fs.Read(buf[0], len*4);
-            for i:=0 to len-1 do
-               PSmallInt(Integer(dest)+i*2)^:=Round(buf[i]);
-         end;
-         4 : begin // windows BMP
-            bmp:=TBitmap.Create;
-            try
-               fs.Position:=0;
-               bmp.LoadFromStream(fs);
-               if DiagFlip then rw:=bmp.Width else rw:=bmp.Height;
-               for i:=0 to len-1 do begin
-                  c:=bmp.Canvas.Pixels[relX+i, rw-relY-1];
-                  PSmallInt(Integer(dest)+i*2)^:=(GetGValue(c)-128) shl 7;
-               end;
-            finally
-               bmp.Free;
-            end;
-         end;
-         5 : begin // 32bits FP Intel
-            fs.Position:=(relX+relY*rw)*4;
-            SetLength(buf, len);
-            fs.Read(buf[0], len*4);
-            for i:=0 to len-1 do
-               PSmallInt(Integer(dest)+i*2)^:=Round((buf[i]-0.5)*32000);
-         end;
-         6 : begin // DTED
-            fs.Position:=3434+(relX+relY*rw)*2 +(relY*12);
-            fs.Read(dest^, len*2);
-            for i:=0 to len-1 do begin
-               wd:=PWord(Integer(dest)+i*2)^;
-               PWord(Integer(dest)+i*2)^:=((wd and 255) shl 8)+(wd shr 8);
+  if DiagFlip then
+    rw := src.h
+  else
+    rw := src.w;
+
+  with src^ do
+  begin
+    case format of
+      0:
+        begin // 16bits Intel
+          fs.Position := (relX + relY * rw) * 2;
+          fs.Read(dest^, len * 2);
+        end;
+      1:
+        begin // 16bits unsigned Intel
+          fs.Position := (relX + relY * rw) * 2;
+          fs.Read(dest^, len * 2);
+          for i := 0 to len - 1 do
+          begin
+            wd := PWord(Integer(dest) + i * 2)^;
+            PSmallInt(Integer(dest) + i * 2)^ := Integer(wd) - 32768;
+          end;
+        end;
+      2:
+        begin // 16bits non-Intel
+          fs.Position := (relX + relY * rw) * 2;
+          fs.Read(dest^, len * 2);
+          for i := 0 to len - 1 do
+          begin
+            wd := PWord(Integer(dest) + i * 2)^;
+            PWord(Integer(dest) + i * 2)^ := ((wd and 255) shl 8) + (wd shr 8);
+          end;
+        end;
+      3:
+        begin // VTP's BT single
+          fs.Position := (relX + relY * rw) * 4 + 256;
+          SetLength(buf, len);
+          fs.Read(buf[0], len * 4);
+          for i := 0 to len - 1 do
+            PSmallInt(Integer(dest) + i * 2)^ := Round(buf[i]);
+        end;
+      4:
+        begin // windows BMP
+          bmp := TBitmap.Create;
+          try
+            fs.Position := 0;
+            bmp.LoadFromStream(fs);
+            if DiagFlip then
+              rw := bmp.Width
+            else
+              rw := bmp.Height;
+            for i := 0 to len - 1 do
+            begin
+              c := bmp.Canvas.Pixels[relX + i, rw - relY - 1];
+              PSmallInt(Integer(dest) + i * 2)^ := (GetGValue(c) - 128) shl 7;
             end;
-         end;
-      end;
-   end;
+          finally
+            bmp.Free;
+          end;
+        end;
+      5:
+        begin // 32bits FP Intel
+          fs.Position := (relX + relY * rw) * 4;
+          SetLength(buf, len);
+          fs.Read(buf[0], len * 4);
+          for i := 0 to len - 1 do
+            PSmallInt(Integer(dest) + i * 2)^ := Round((buf[i] - 0.5) * 32000);
+        end;
+      6:
+        begin // DTED
+          fs.Position := 3434 + (relX + relY * rw) * 2 + (relY * 12);
+          fs.Read(dest^, len * 2);
+          for i := 0 to len - 1 do
+          begin
+            wd := PWord(Integer(dest) + i * 2)^;
+            PWord(Integer(dest) + i * 2)^ := ((wd and 255) shl 8) + (wd shr 8);
+          end;
+        end;
+    end;
+  end;
 end;
 
-procedure TMainForm.WorldExtract(x, y, len : Integer; dest : PSmallInt);
+procedure TMainForm.WorldExtract(x, y, len: Integer; dest: PSmallInt);
 var
-   i, n, rx, ry : Integer;
-   src : PSrc;
+  i, n, rx, ry: Integer;
+  src: PSrc;
 begin
-   while len>0 do begin
-      src:=nil;
-      for i:=0 to High(sources) do begin
-         if (sources[i].x<=x) and (sources[i].y<=y)
-               and (x<sources[i].x+sources[i].w)
-               and (y<sources[i].y+sources[i].h) then begin
-            src:=@sources[i];
-            Break;
-         end;
+  while len > 0 do
+  begin
+    src := nil;
+    for i := 0 to High(sources) do
+    begin
+      if (sources[i].x <= x) and (sources[i].y <= y) and
+        (x < sources[i].x + sources[i].w) and (y < sources[i].y + sources[i].h)
+      then
+      begin
+        src := @sources[i];
+        Break;
+      end;
+    end;
+    if Assigned(src) then
+    begin
+      rx := x - src.x;
+      ry := y - src.y;
+      n := len;
+      if rx + n > src.w then
+        n := src.w - rx;
+      SrcExtractFlip(src, rx, ry, n, dest);
+      if filterZ <> defaultZ then
+      begin
+        for i := 0 to n - 1 do
+          if PSmallIntArray(dest)[i] = filterZ then
+            PSmallIntArray(dest)[i] := defaultZ;
       end;
-      if Assigned(src) then begin
-         rx:=x-src.x;
-         ry:=y-src.y;
-         n:=len;
-         if rx+n>src.w then
-            n:=src.w-rx;
-         SrcExtractFlip(src, rx, ry, n, dest);
-         if filterZ<>defaultZ then begin
-            for i:=0 to n-1 do
-               if PSmallIntArray(dest)[i]=filterZ then
-                  PSmallIntArray(dest)[i]:=defaultZ;
-         end;
-         if zScale<>1 then begin
-            for i:=0 to n-1 do
-               PSmallIntArray(dest)[i]:=Round(PSmallIntArray(dest)[i]*zScale);
-         end;
-         Dec(len, n);
-         Inc(dest, n);
-         Inc(x, n);
-      end else begin
-         dest^:=defaultZ;
-         Inc(dest);
-         Dec(len);
-         Inc(x);
+      if zScale <> 1 then
+      begin
+        for i := 0 to n - 1 do
+          PSmallIntArray(dest)[i] := Round(PSmallIntArray(dest)[i] * zScale);
       end;
-   end;
+      Dec(len, n);
+      Inc(dest, n);
+      Inc(x, n);
+    end
+    else
+    begin
+      dest^ := defaultZ;
+      Inc(dest);
+      Dec(len);
+      Inc(x);
+    end;
+  end;
 end;
 
 procedure TMainForm.ACProcessExecute(Sender: TObject);
 var
-   x, y, wx, wy, ts, tx, ty, i, j, overlap : Integer;
-   n, maxN : Cardinal;
-   htf : TGLHeightTileFile;
-   buf : array of SmallInt;
-   f : file of Byte;
+  x, y, wx, wy, ts, tx, ty, i, j, overlap: Integer;
+  n, maxN: Cardinal;
+  htf: TGLHeightTileFile;
+  buf: array of SmallInt;
+  f: file of Byte;
 begin
-   Screen.Cursor:=crHourGlass;
-
-   wx:=StrToInt(EDSizeX.Text);
-   wy:=StrToInt(EDSizeY.Text);
-   ts:=StrToInt(EDTileSize.Text);
-   overlap:=StrToInt(EDTileOverlap.Text);
-   Parse;
-   SetLength(buf, ts*ts);
-   htf:=TGLHeightTileFile.CreateNew(EDHTFName.Text, wx, wy, ts);
-   htf.DefaultZ:=defaultZ;
-   ProgressBar.Max:=1000;
-   maxN:=Ceil(wx/ts)*Ceil(wy/ts);
-   n:=0;
-   ProgressBar.Position:=0;
-   y:=0; while y<wy do begin
-      ty:=wy+overlap-y;
-      if ty>ts then
-         ty:=ts;
-      x:=0; while x<wx do begin
-         tx:=wx+overlap-x;
-         if (not CBWholeOnly.Checked) or ((tx>=ts) and ((wy-y)>=ts)) then begin
-            if tx>ts then
-               tx:=ts;
-            for i:=0 to ty-1 do begin
-               WorldExtract(x, y+i, tx, @buf[i*ts]);
-               if overlap>0 then begin
-                  for j:=tx to ts-1 do
-                     buf[i*ts+j]:=buf[i*ts+tx-1];
-               end else begin
-                  for j:=tx to ts-1 do
-                     buf[i*ts+j]:=defaultZ;
-               end;
-            end;
-            if overlap>0 then begin
-               for i:=ty to ts-1 do for j:=0 to ts-1 do
-                  buf[i*ts+j]:=buf[(i-1)*ts+j];
-            end else begin
-               for i:=ty to ts-1 do for j:=0 to ts-1 do
-                  buf[i*ts+j]:=defaultZ;
-            end;
-            htf.CompressTile(x, y, ts, ts, @buf[0]);
-         end;
-         Inc(x, ts-overlap);
-         Inc(n);
-         ProgressBar.Position:=(n*1000) div maxN;
-         if (n and 15)=0 then begin
-            Application.ProcessMessages;
-         end;
+  Screen.Cursor := crHourGlass;
+
+  wx := StrToInt(EDSizeX.Text);
+  wy := StrToInt(EDSizeY.Text);
+  ts := StrToInt(EDTileSize.Text);
+  overlap := StrToInt(EDTileOverlap.Text);
+  Parse;
+  SetLength(buf, ts * ts);
+  htf := TGLHeightTileFile.CreateNew(EDHTFName.Text, wx, wy, ts);
+  htf.defaultZ := defaultZ;
+  ProgressBar.Max := 1000;
+  maxN := Ceil(wx / ts) * Ceil(wy / ts);
+  n := 0;
+  ProgressBar.Position := 0;
+  y := 0;
+  while y < wy do
+  begin
+    ty := wy + overlap - y;
+    if ty > ts then
+      ty := ts;
+    x := 0;
+    while x < wx do
+    begin
+      tx := wx + overlap - x;
+      if (not CBWholeOnly.Checked) or ((tx >= ts) and ((wy - y) >= ts)) then
+      begin
+        if tx > ts then
+          tx := ts;
+        for i := 0 to ty - 1 do
+        begin
+          WorldExtract(x, y + i, tx, @buf[i * ts]);
+          if overlap > 0 then
+          begin
+            for j := tx to ts - 1 do
+              buf[i * ts + j] := buf[i * ts + tx - 1];
+          end
+          else
+          begin
+            for j := tx to ts - 1 do
+              buf[i * ts + j] := defaultZ;
+          end;
+        end;
+        if overlap > 0 then
+        begin
+          for i := ty to ts - 1 do
+            for j := 0 to ts - 1 do
+              buf[i * ts + j] := buf[(i - 1) * ts + j];
+        end
+        else
+        begin
+          for i := ty to ts - 1 do
+            for j := 0 to ts - 1 do
+              buf[i * ts + j] := defaultZ;
+        end;
+        htf.CompressTile(x, y, ts, ts, @buf[0]);
       end;
-      Inc(y, ts-overlap);
-   end;
-   htf.Free;
-   Cleanup;
+      Inc(x, ts - overlap);
+      Inc(n);
+      ProgressBar.Position := (n * 1000) div maxN;
+      if (n and 15) = 0 then
+      begin
+        Application.ProcessMessages;
+      end;
+    end;
+    Inc(y, ts - overlap);
+  end;
+  htf.Free;
+  Cleanup;
 
-   Screen.Cursor:=crDefault;
+  Screen.Cursor := crDefault;
 
-   AssignFile(f, EDHTFName.Text);
-   Reset(f);
-   i:=FileSize(f);
-   CloseFile(f);
+  AssignFile(f, EDHTFName.Text);
+  Reset(f);
+  i := FileSize(f);
+  CloseFile(f);
 
-   ShowMessage( 'HTF file created.'#13#10#13#10
-               +IntToStr(i)+' bytes in file'#13#10
-               +'('+IntToStr(wx*wy*2)+' raw bytes)');
+  ShowMessage('HTF file created.'#13#10#13#10 + IntToStr(i) +
+    ' bytes in file'#13#10 + '(' + IntToStr(wx * wy * 2) + ' raw bytes)');
 end;
 
 procedure TMainForm.ACViewerExecute(Sender: TObject);
 var
-   viewer : TViewerForm;
+  viewer: TViewerForm;
 begin
-   viewer:=TViewerForm.Create(nil);
-   try
-      Viewer.htf:=TGLHeightTileFile.Create(EDHTFName.Text);                   //R
-      Viewer.Caption:='HTFViewer - '+ExtractFileName(EDHTFName.Text);       //R
-
-      viewer.ShowModal;
-   finally
-      viewer.Free;
-   end;
+  viewer := TViewerForm.Create(nil);
+  try
+    viewer.htf := TGLHeightTileFile.Create(EDHTFName.Text); // R
+    viewer.Caption := 'HTFViewer - ' + ExtractFileName(EDHTFName.Text); // R
+
+    viewer.ShowModal;
+  finally
+    viewer.Free;
+  end;
 end;
 
 end.

+ 38 - 90
Demos/utilities/HTFUtils/fViewer.dfm → Demos/utilities/HTFUtils/fViewerD.dfm

@@ -2,81 +2,56 @@ object ViewerForm: TViewerForm
   Left = 99
   Top = 98
   Caption = 'HTFViewer'
-  ClientHeight = 602
-  ClientWidth = 786
+  ClientHeight = 482
+  ClientWidth = 629
   Color = clBtnFace
   Font.Charset = DEFAULT_CHARSET
   Font.Color = clWindowText
-  Font.Height = -14
+  Font.Height = -11
   Font.Name = 'MS Sans Serif'
   Font.Style = []
   Position = poScreenCenter
   OnCreate = FormCreate
   OnDestroy = FormDestroy
-  PixelsPerInch = 120
-  TextHeight = 16
+  TextHeight = 13
   object ToolBar: TToolBar
     Left = 0
     Top = 0
-    Width = 786
-    Height = 58
-    Margins.Left = 4
-    Margins.Top = 4
-    Margins.Right = 4
-    Margins.Bottom = 4
+    Width = 629
+    Height = 56
     AutoSize = True
     BorderWidth = 1
-    ButtonWidth = 246
+    ButtonWidth = 197
     Caption = 'ToolBar'
     Images = ImageList
     TabOrder = 0
     object ToolButton1: TToolButton
       Left = 0
       Top = 0
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
       Action = ACOpen
     end
     object ToolButton3: TToolButton
-      Left = 246
+      Left = 197
       Top = 0
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
       Action = ACExit
     end
     object ToolButton2: TToolButton
-      Left = 492
+      Left = 394
       Top = 0
-      Width = 10
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
+      Width = 8
       Caption = 'ToolButton2'
       ImageIndex = 1
       Style = tbsSeparator
     end
     object ToolButton6: TToolButton
-      Left = 502
+      Left = 402
       Top = 0
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
       Action = ACNavMap
     end
     object ToolButton5: TToolButton
       Left = 0
       Top = 0
-      Width = 10
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
+      Width = 8
       Caption = 'ToolButton5'
       ImageIndex = 3
       Wrap = True
@@ -84,12 +59,8 @@ object ViewerForm: TViewerForm
     end
     object TBGrid: TToolButton
       Left = 0
-      Top = 32
+      Top = 30
       Hint = 'Toggle Grid'
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
       Caption = 'TBGrid'
       Down = True
       ImageIndex = 3
@@ -97,41 +68,29 @@ object ViewerForm: TViewerForm
       OnClick = TBGridClick
     end
     object ToolButton7: TToolButton
-      Left = 246
-      Top = 32
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
+      Left = 197
+      Top = 30
       Action = ACPalette
       DropdownMenu = PMPalettes
       Style = tbsDropDown
     end
     object ToolButton4: TToolButton
-      Left = 511
-      Top = 32
-      Width = 10
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
+      Left = 413
+      Top = 30
+      Width = 8
       Caption = 'ToolButton4'
       ImageIndex = 2
       Style = tbsSeparator
     end
     object LAMap: TLabel
-      Left = 521
-      Top = 32
-      Width = 61
-      Height = 22
-      Margins.Left = 4
-      Margins.Top = 4
-      Margins.Right = 4
-      Margins.Bottom = 4
+      Left = 421
+      Top = 30
+      Width = 49
+      Height = 16
       Caption = ' No map'
       Font.Charset = ANSI_CHARSET
       Font.Color = clWindowText
-      Font.Height = -16
+      Font.Height = -13
       Font.Name = 'Arial'
       Font.Style = [fsItalic]
       ParentFont = False
@@ -140,60 +99,49 @@ object ViewerForm: TViewerForm
   end
   object PaintBox: TPaintBox32
     Left = 0
-    Top = 58
-    Width = 786
-    Height = 520
+    Top = 56
+    Width = 629
+    Height = 406
     Cursor = crCross
-    Margins.Left = 4
-    Margins.Top = 4
-    Margins.Right = 4
-    Margins.Bottom = 4
     Align = alClient
     TabOrder = 1
     OnMouseDown = PaintBoxMouseDown
     OnMouseMove = PaintBoxMouseMove
     OnMouseUp = PaintBoxMouseUp
     OnResize = PaintBoxResize
-    ExplicitTop = 1452
-    ExplicitWidth = 721
-    ExplicitHeight = 456
+    ExplicitTop = 46
+    ExplicitHeight = 416
   end
   object StatusBar: TStatusBar
     Left = 0
-    Top = 578
-    Width = 786
-    Height = 24
-    Margins.Left = 4
-    Margins.Top = 4
-    Margins.Right = 4
-    Margins.Bottom = 4
+    Top = 462
+    Width = 629
+    Height = 20
     Font.Charset = ANSI_CHARSET
     Font.Color = clBtnText
-    Font.Height = -14
+    Font.Height = -11
     Font.Name = 'Arial'
     Font.Style = []
     Panels = <
       item
-        Width = 81
+        Width = 65
       end
       item
-        Width = 81
+        Width = 65
       end
       item
-        Width = 81
+        Width = 65
       end
       item
-        Width = 81
+        Width = 65
       end
       item
-        Width = 131
+        Width = 105
       end
       item
-        Width = 63
+        Width = 50
       end>
     UseSystemFont = False
-    ExplicitTop = 489
-    ExplicitWidth = 721
   end
   object ImageList: TImageList
     Left = 40

+ 7 - 5
Demos/utilities/HTFUtils/fViewer.pas → Demos/utilities/HTFUtils/fViewerD.pas

@@ -1,4 +1,4 @@
-unit fViewer;
+unit fViewerD;
 
 interface
 
@@ -7,6 +7,7 @@ uses
   System.SysUtils,
   System.Classes,
   System.Actions,
+  System.ImageList,
   Vcl.Graphics,
   Vcl.Controls,
   Vcl.Forms,
@@ -24,7 +25,7 @@ uses
 
   GLS.HeightTileFileHDS,
   GLS.VectorGeometry,
-  GLS.Utils, System.ImageList;
+  GLS.Utils;
 
 type
   TViewerForm = class(TForm)
@@ -85,13 +86,14 @@ implementation
 uses
   fNavD;
 
-{ Quick'n dirty parser for palette file format '.pal', in which each line defines
+(*
+  Quick'n dirty parser for palette file format '.pal', in which each line defines
   nodes in the color ramp palette:
 
   value:red,green,blue
 
   color is then interpolated between node values (ie. between each line in the file)
-}
+*)
 procedure PreparePal(const fileName: String);
 
   procedure ParseLine(buf: String; var n: Integer; var c: TAffineVector);
@@ -224,7 +226,7 @@ var
   scanLine: PColor32Array;
   tileInfo: PGLHeightTileInfo;
   dataRow: PSmallIntArray;
-  tile: PHeightTile;
+  tile: PGLHeightTile;
   start, lap, stop, htfTime, drawTime, freq: Int64;
   tileList: TList;
   bmp: TBitmap32;

+ 244 - 136
Source/GLS.Utils.pas

@@ -2,9 +2,12 @@
 // The graphics rendering engine GLScene http://glscene.org
 //
 unit GLS.Utils;
+
 (* Miscellaneous support utilities & classes for localization *)
 interface
+
 {$I GLScene.inc}
+
 uses
   Winapi.Windows,
   Winapi.ShellApi,
@@ -18,22 +21,26 @@ uses
   Vcl.ExtDlgs,
   GLS.VectorGeometry,
   GLS.Strings;
+
 type
   THalfFloat = type Word;
   PHalfFloat = ^THalfFloat;
   EGLOSError = EOSError;
   EGLUtilsException = class(Exception);
-  TSqrt255Array = array[0..255] of Byte;
+  TSqrt255Array = array [0 .. 255] of Byte;
   PSqrt255Array = ^TSqrt255Array;
   TProjectTargetNameFunc = function(): string;
+
 const
   FONT_CHARS_COUNT = 2024;
+
 var
   IsDesignTime: Boolean = False;
   vProjectTargetName: TProjectTargetNameFunc;
 
 // Copies the values of Source to Dest (converting word values to integer values)
-procedure WordToIntegerArray(Source: PWordArray; Dest: PIntegerArray; Count: Cardinal);
+procedure WordToIntegerArray(Source: PWordArray; Dest: PIntegerArray;
+  Count: Cardinal);
 // Round ups to the nearest power of two, value must be positive
 function RoundUpToPowerOf2(value: Integer): Integer;
 // Round down to the nearest power of two, value must be strictly positive
@@ -45,60 +52,69 @@ function ReadCRLFString(aStream: TStream): String;
 // Write the string and a CRLF in the stream
 procedure WriteCRLFString(aStream: TStream; const aString: String);
 // Similar to SysUtils.StrToFloatDef, but ignores user's locale
-function StrToFloatDef(const strValue: string; defValue: Extended = 0): Extended;
+function StrToFloatDef(const strValue: string; defValue: Extended = 0)
+  : Extended;
+// Trying to read string otherwise using '.' as Decimal Separator
+function Str2Float(const S: string): Single;
 // Converts a string into color
-function StringToColorAdvancedSafe(const Str: string; const Default: TColor): TColor;
+function StringToColorAdvancedSafe(const Str: string;
+  const Default: TColor): TColor;
 // Converts a string into color
-function TryStringToColorAdvanced(const Str: string; var OutColor: TColor): Boolean;
+function TryStringToColorAdvanced(const Str: string;
+  var OutColor: TColor): Boolean;
 // Converts a string into color
 function StringToColorAdvanced(const Str: string): TColor;
-(*Parses the next integer in the string. 
-   Initial non-numeric characters are skipper, p is altered, returns 0 if none
-   found. '+' and '-' are acknowledged. *)
+(* Parses the next integer in the string.
+  Initial non-numeric characters are skipper, p is altered, returns 0 if none
+  found. '+' and '-' are acknowledged. *)
 function ParseInteger(var p: PChar): Integer;
-(* Parses the next integer in the string. 
-   Initial non-numeric characters are skipper, p is altered, returns 0 if none
-   found. Both '.' and ',' are accepted as decimal separators. *)
+(* Parses the next integer in the string.
+  Initial non-numeric characters are skipper, p is altered, returns 0 if none
+  found. Both '.' and ',' are accepted as decimal separators. *)
 function ParseFloat(var p: PChar): Extended;
-//Saves ansistring "data" to "filename". 
+// Saves ansistring "data" to "filename".
 procedure SaveAnsiStringToFile(const fileName: string; const data: AnsiString);
-//Returns the ansistring content of "filename". 
+// Returns the ansistring content of "filename".
 function LoadAnsiStringFromFile(const fileName: string): AnsiString;
-//Saves string "data" to "filename". 
+// Saves string "data" to "filename".
 procedure SaveStringToFile(const fileName: string; const data: String);
-//Returns the string content of "filename". 
+// Returns the string content of "filename".
 function LoadStringFromFile(const fileName: string): String;
-//Saves component to a file.
-procedure SaveComponentToFile(const Component: TComponent; const FileName: string; const AsText: Boolean = True);
+// Saves component to a file.
+procedure SaveComponentToFile(const Component: TComponent;
+  const fileName: string; const AsText: Boolean = True);
 // Loads component from a file.
-procedure LoadComponentFromFile(const Component: TComponent; const FileName: string; const AsText: Boolean = True);
-(* Returns the size of "filename". 
-   Returns 0 (zero) is file does not exists. *)
+procedure LoadComponentFromFile(const Component: TComponent;
+  const fileName: string; const AsText: Boolean = True);
+(* Returns the size of "filename".
+  Returns 0 (zero) is file does not exists. *)
 function SizeOfFile(const fileName: string): Int64;
-// Returns a pointer to an array containing the results of "255*sqrt(i/255)". 
+// Returns a pointer to an array containing the results of "255*sqrt(i/255)".
 function GetSqrt255Array: PSqrt255Array;
-// Pops up a simple dialog with msg and an Ok button. 
+// Pops up a simple dialog with msg and an Ok button.
 procedure InformationDlg(const msg: string);
 (* Pops up a simple question dialog with msg and yes/no buttons.
-   Returns True if answer was "yes". *)
+  Returns True if answer was "yes". *)
 function QuestionDlg(const msg: string): Boolean;
 // Posp a simple dialog with a string input.
 function InputDlg(const aCaption, aPrompt, aDefault: string): string;
 // Pops up a simple save picture dialog.
-function SavePictureDialog(var aFileName: string; const aTitle: string = ''): Boolean;
+function SavePictureDialog(var aFileName: string;
+  const aTitle: string = ''): Boolean;
 // Pops up a simple open picture dialog.
-function OpenPictureDialog(var aFileName: string; const aTitle: string = ''): Boolean;
+function OpenPictureDialog(var aFileName: string;
+  const aTitle: string = ''): Boolean;
 procedure SetGLSceneMediaDir();
-//------------------ from CrossPlatform -----------------------
+// ------------------ from CrossPlatform -----------------------
 function GetGLRect(const aLeft, aTop, aRight, aBottom: Integer): TRect;
 (* Increases or decreases the width and height of the specified rectangle.
-   Adds dx units to the left and right ends of the rectangle and dy units to
-   the top and bottom. *)
+  Adds dx units to the left and right ends of the rectangle and dy units to
+  the top and bottom. *)
 procedure InflateGLRect(var aRect: TRect; dx, dy: Integer);
 procedure IntersectGLRect(var aRect: TRect; const rect2: TRect);
 procedure RaiseLastOSError;
 (* Number of pixels per logical inch along the screen width for the device.
-   Under Win32 awaits a HDC and returns its LOGPIXELSX. *)
+  Under Win32 awaits a HDC and returns its LOGPIXELSX. *)
 function GetDeviceLogicalPixelsX(device: HDC): Integer;
 // Number of bits per pixel for the current desktop resolution.
 function GetCurrentColorDepth: Integer;
@@ -109,20 +125,20 @@ procedure FixPathDelimiter(var S: string);
 // Remove if possible part of path witch leads to project executable.
 function RelativePath(const S: string): string;
 (* Returns the current value of the highest-resolution counter.
-   If the platform has none, should return a value derived from the highest
-   precision time reference available, avoiding, if possible, timers that
-   allocate specific system resources. *)
+  If the platform has none, should return a value derived from the highest
+  precision time reference available, avoiding, if possible, timers that
+  allocate specific system resources. *)
 procedure QueryPerformanceCounter(out val: Int64);
 (* Returns the frequency of the counter used by QueryPerformanceCounter.
-   Return value is in ticks per second (Hz), returns False if no precision
-   counter is available. *)
+  Return value is in ticks per second (Hz), returns False if no precision
+  counter is available. *)
 function QueryPerformanceFrequency(out val: Int64): Boolean;
 (* Starts a precision timer.
-   Returned value should just be considered as 'handle', even if it ain't so.
-   Default platform implementation is to use QueryPerformanceCounter and
-   QueryPerformanceFrequency, if higher precision references are available,
-   they should be used. The timer will and must be stopped/terminated/released
-   with StopPrecisionTimer. *)
+  Returned value should just be considered as 'handle', even if it ain't so.
+  Default platform implementation is to use QueryPerformanceCounter and
+  QueryPerformanceFrequency, if higher precision references are available,
+  they should be used. The timer will and must be stopped/terminated/released
+  with StopPrecisionTimer. *)
 function StartPrecisionTimer: Int64;
 // Computes time elapsed since timer start. Return time lap in seconds.
 function PrecisionTimerLap(const precisionTimer: Int64): Double;
@@ -132,35 +148,40 @@ function StopPrecisionTimer(const precisionTimer: Int64): Double;
 function AppTime: Double;
 // Returns the number of CPU cycles since startup. Use the similarly named CPU instruction.
 function GLOKMessageBox(const Text, Caption: string): Integer;
-procedure GLLoadBitmapFromInstance(Instance: LongInt; ABitmap: TBitmap; const AName: string);
+procedure GLLoadBitmapFromInstance(Instance: LongInt; ABitmap: TBitmap;
+  const AName: string);
 procedure ShowHTMLUrl(const Url: string);
 procedure SetExeDirectory;
 // StrUtils.pas
 function AnsiStartsText(const ASubText, AText: string): Boolean;
 // Classes.pas
 function IsSubComponent(const AComponent: TComponent): Boolean; inline;
-procedure MakeSubComponent(const AComponent: TComponent; const Value: Boolean);
+procedure MakeSubComponent(const AComponent: TComponent; const value: Boolean);
 function FindUnitName(anObject: TObject): string; overload;
 function FindUnitName(aClass: TClass): string; overload;
 function FloatToHalf(Float: Single): THalfFloat;
 function HalfToFloat(Half: THalfFloat): Single;
-function GetValueFromStringsIndex(const AStrings: TStrings; const AIndex: Integer): string;
+function GetValueFromStringsIndex(const AStrings: TStrings;
+  const AIndex: Integer): string;
 // Determine if the directory is writable.
 function IsDirectoryWriteable(const AName: string): Boolean;
 function CharToWideChar(const AChar: AnsiChar): WideChar;
 
-(* 
+(*
   Added by PAL to fix problem with decimal separator in not En-US configurations
-  Decimal separator in text descriptions of meshes for import/export is always '.' char 
+  Decimal separator in text descriptions of meshes for import/export is always '.' char
   But in System.SysUtils.TextToFloat is Windows char, maybe ',' or others...
 *)
-function GLStrToFloatDef(const S: string; const Default: Extended; fs: TFormatSettings): Extended; overload;
-function GLStrToFloatDef(const S: string; const Default: Extended): Extended; overload;
+function GLStrToFloatDef(const S: string; const Default: Extended;
+  fs: TFormatSettings): Extended; overload;
+function GLStrToFloatDef(const S: string; const Default: Extended)
+  : Extended; overload;
 function GLStrToFloatDef(const S: string): Extended; overload;
 
-//------------------------------------------------------
+// ------------------------------------------------------
 implementation
-//------------------------------------------------------
+
+// ------------------------------------------------------
 
 var
   vSqrt255: TSqrt255Array;
@@ -168,20 +189,23 @@ var
   vInvPerformanceCounterFrequencyReady: Boolean = False;
   vLastProjectTargetName: string;
 
-//---------------from Utils -----------------------
-procedure WordToIntegerArray(Source: PWordArray; Dest: PIntegerArray; Count: Cardinal);
+  // ---------------from Utils -----------------------
+procedure WordToIntegerArray(Source: PWordArray; Dest: PIntegerArray;
+  Count: Cardinal);
 var
-  i: integer;
+  i: Integer;
 begin
   for i := 0 to Count - 1 do
     Dest^[i] := Source^[i];
 end;
+
 function RoundUpToPowerOf2(value: Integer): Integer;
 begin
   Result := 1;
   while (Result < value) do
     Result := Result shl 1;
 end;
+
 function RoundDownToPowerOf2(value: Integer): Integer;
 begin
   if value > 0 then
@@ -193,10 +217,12 @@ begin
   else
     Result := 1;
 end;
+
 function IsPowerOf2(value: Integer): Boolean;
 begin
   Result := (RoundUpToPowerOf2(value) = value);
 end;
+
 function ReadCRLFString(aStream: TStream): String;
 var
   c: Char;
@@ -209,6 +235,7 @@ begin
   end;
   Result := Copy(Result, 1, Length(Result) - 2);
 end;
+
 procedure WriteCRLFString(aStream: TStream; const aString: String);
 const
   cCRLF: Integer = $0A0D;
@@ -220,46 +247,65 @@ begin
   end;
 end;
 
-function StrToFloatDef(const strValue: string; defValue: Extended = 0): Extended;
+function StrToFloatDef(const strValue: string; defValue: Extended = 0)
+  : Extended;
 begin
   if not TryStrToFloat(strValue, Result) then
-    result := defValue;
+    Result := defValue;
 end;
-function StringToColorAdvancedSafe(const Str: string; const Default: TColor): TColor;
+
+function Str2Float(const S: string): Single;
+var
+  fs: TFormatSettings;
+begin                                                                                                           fs.DecimalSeparator := ',';
+  if not TryStrToFloat(S, Result, fs) then
+  begin
+    fs.DecimalSeparator := '.';
+    if not TryStrToFloat(S, Result, fs) then
+      Result := 0;
+  end;
+end;
+
+function StringToColorAdvancedSafe(const Str: string;
+  const Default: TColor): TColor;
 begin
   if not TryStringToColorAdvanced(Str, Result) then
     Result := Default;
 end;
+
 function StringToColorAdvanced(const Str: string): TColor;
 begin
   if not TryStringToColorAdvanced(Str, Result) then
     raise EGLUtilsException.CreateResFmt(@strInvalidColor, [Str]);
 end;
-function TryStringToColorAdvanced(const Str: string; var OutColor: TColor): Boolean;
+
+function TryStringToColorAdvanced(const Str: string;
+  var OutColor: TColor): Boolean;
 var
-  Code, I: Integer;
+  Code, i: Integer;
   Temp: string;
 begin
   Result := True;
   Temp := Str;
-  Val(Temp, I, Code); //to see if it is a number
+  val(Temp, i, Code); // to see if it is a number
   if Code = 0 then
-    OutColor := TColor(I) //Str = $0000FF
+    OutColor := TColor(i) // Str = $0000FF
   else
   begin
-    if not IdentToColor(Temp, Longint(OutColor)) then //Str = clRed
+    if not IdentToColor(Temp, LongInt(OutColor)) then // Str = clRed
     begin
-      if AnsiStartsText('clr', Temp) then //Str = clrRed
+      if AnsiStartsText('clr', Temp) then // Str = clrRed
       begin
         Delete(Temp, 3, 1);
-        if not IdentToColor(Temp, Longint(OutColor)) then
+        if not IdentToColor(Temp, LongInt(OutColor)) then
           Result := False;
       end
-      else if not IdentToColor('cl' + Temp, Longint(OutColor)) then //Str = Red
+      else if not IdentToColor('cl' + Temp, LongInt(OutColor)) then // Str = Red
         Result := False;
     end;
   end;
 end;
+
 function ParseInteger(var p: PChar): Integer;
 var
   neg: Boolean;
@@ -270,7 +316,7 @@ begin
     Exit;
   neg := False;
   // skip non-numerics
-  while not CharInSet(p^, [#0, '0'..'9', '+', '-']) do
+  while not CharInSet(p^, [#0, '0' .. '9', '+', '-']) do
     Inc(p);
   c := p^;
   if c = '+' then
@@ -284,7 +330,7 @@ begin
   while True do
   begin
     c := p^;
-    if not CharInSet(c, ['0'..'9']) then
+    if not CharInSet(c, ['0' .. '9']) then
       Break;
     Result := Result * 10 + Integer(c) - Integer('0');
     Inc(p);
@@ -292,6 +338,7 @@ begin
   if neg then
     Result := -Result;
 end;
+
 function ParseFloat(var p: PChar): Extended;
 var
   decimals, expSign, exponent: Integer;
@@ -302,7 +349,7 @@ begin
   if p = nil then
     Exit;
   // skip non-numerics
-  while not CharInSet(p^, [#0, '0'..'9', '+', '-']) do
+  while not CharInSet(p^, [#0, '0' .. '9', '+', '-']) do
     Inc(p);
   c := p^;
   if c = '+' then
@@ -318,7 +365,7 @@ begin
   else
     neg := False;
   // parse numbers
-  while CharInSet(p^, ['0'..'9']) do
+  while CharInSet(p^, ['0' .. '9']) do
   begin
     Result := Result * 10 + (Integer(p^) - Integer('0'));
     Inc(p);
@@ -328,7 +375,7 @@ begin
   if (p^ = '.') then
   begin
     Inc(p);
-    while CharInSet(p^, ['0'..'9']) do
+    while CharInSet(p^, ['0' .. '9']) do
     begin
       Result := Result * 10 + (Integer(p^) - Integer('0'));
       Inc(p);
@@ -355,7 +402,7 @@ begin
       expSign := 1;
     // parse exponent
     exponent := 0;
-    while CharInSet(p^, ['0'..'9']) do
+    while CharInSet(p^, ['0' .. '9']) do
     begin
       exponent := exponent * 10 + (Integer(p^) - Integer('0'));
       Inc(p);
@@ -367,6 +414,7 @@ begin
   if neg then
     Result := -Result;
 end;
+
 procedure SaveAnsiStringToFile(const fileName: string; const data: AnsiString);
 var
   n: Cardinal;
@@ -381,6 +429,7 @@ begin
     fs.Free;
   end;
 end;
+
 function LoadAnsiStringFromFile(const fileName: string): AnsiString;
 var
   n: Cardinal;
@@ -401,6 +450,7 @@ begin
   else
     Result := '';
 end;
+
 procedure SaveStringToFile(const fileName: string; const data: String);
 var
   n: Cardinal;
@@ -415,6 +465,7 @@ begin
     fs.Free;
   end;
 end;
+
 function LoadStringFromFile(const fileName: string): String;
 var
   n: Cardinal;
@@ -436,12 +487,13 @@ begin
     Result := '';
 end;
 
-procedure SaveComponentToFile(const Component: TComponent; const FileName: string; const AsText: Boolean);
+procedure SaveComponentToFile(const Component: TComponent;
+  const fileName: string; const AsText: Boolean);
 var
   Stream: TStream;
   MemStream: TMemoryStream;
 begin
-  Stream := TFileStream.Create(FileName, fmCreate);
+  Stream := TFileStream.Create(fileName, fmCreate);
   try
     if AsText then
     begin
@@ -460,12 +512,14 @@ begin
     Stream.Free;
   end;
 end;
-procedure LoadComponentFromFile(const Component: TComponent; const FileName: string; const AsText: Boolean = True);
+
+procedure LoadComponentFromFile(const Component: TComponent;
+  const fileName: string; const AsText: Boolean = True);
 var
   Stream: TStream;
   MemStream: TMemoryStream;
 begin
-  Stream := TFileStream.Create(FileName, fmOpenRead);
+  Stream := TFileStream.Create(fileName, fmOpenRead);
   try
     if AsText then
     begin
@@ -484,6 +538,7 @@ begin
     Stream.Free;
   end;
 end;
+
 function SizeOfFile(const fileName: string): Int64;
 var
   fs: TStream;
@@ -500,6 +555,7 @@ begin
   else
     Result := 0;
 end;
+
 function GetSqrt255Array: PSqrt255Array;
 const
   cOneDiv255 = 1 / 255;
@@ -513,19 +569,24 @@ begin
   end;
   Result := @vSqrt255;
 end;
+
 procedure InformationDlg(const msg: string);
 begin
   ShowMessage(msg);
 end;
+
 function QuestionDlg(const msg: string): Boolean;
 begin
   Result := (MessageDlg(msg, mtConfirmation, [mbYes, mbNo], 0) = mrYes);
 end;
+
 function InputDlg(const aCaption, aPrompt, aDefault: string): string;
 begin
   Result := InputBox(aCaption, aPrompt, aDefault);
 end;
-function SavePictureDialog(var aFileName: string; const aTitle: string = ''): Boolean;
+
+function SavePictureDialog(var aFileName: string;
+  const aTitle: string = ''): Boolean;
 var
   saveDialog: TSavePictureDialog;
 begin
@@ -536,16 +597,18 @@ begin
       Options := [ofHideReadOnly, ofNoReadOnlyReturn];
       if aTitle <> '' then
         Title := aTitle;
-      FileName := aFileName;
+      fileName := aFileName;
       Result := Execute;
       if Result then
-        aFileName := FileName;
+        aFileName := fileName;
     end;
   finally
     saveDialog.Free;
   end;
 end;
-function OpenPictureDialog(var aFileName: string; const aTitle: string = ''): Boolean;
+
+function OpenPictureDialog(var aFileName: string;
+  const aTitle: string = ''): Boolean;
 var
   openDialog: TOpenPictureDialog;
 begin
@@ -556,28 +619,29 @@ begin
       Options := [ofHideReadOnly, ofNoReadOnlyReturn];
       if aTitle <> '' then
         Title := aTitle;
-      FileName := aFileName;
+      fileName := aFileName;
       Result := Execute;
       if Result then
-        aFileName := FileName;
+        aFileName := fileName;
     end;
   finally
     openDialog.Free;
   end;
 end;
+
 procedure SetGLSceneMediaDir();
 var
   path: String;
   p: Integer;
 begin
-   path := ParamStr(0);
-   path := LowerCase(ExtractFilePath(path));
-   p := Pos('demos', path);
-   Delete(path, p+5, Length(path));
-   path := IncludeTrailingPathDelimiter(path) + 'media';
-   SetCurrentDir(path);
+  path := ParamStr(0);
+  path := LowerCase(ExtractFilePath(path));
+  p := Pos('demos', path);
+  Delete(path, p + 5, Length(path));
+  path := IncludeTrailingPathDelimiter(path) + 'media';
+  SetCurrentDir(path);
 end;
-//------------ from CrossPfatform -------------------
+// ------------ from CrossPfatform -------------------
 
 procedure RaiseLastOSError;
 var
@@ -586,30 +650,38 @@ begin
   e := EGLOSError.Create('OS Error : ' + SysErrorMessage(GetLastError));
   raise e;
 end;
+
 function IsSubComponent(const AComponent: TComponent): Boolean;
 begin
   Result := (csSubComponent in AComponent.ComponentStyle);
 end;
-procedure MakeSubComponent(const AComponent: TComponent; const Value: Boolean);
+
+procedure MakeSubComponent(const AComponent: TComponent; const value: Boolean);
 begin
-  AComponent.SetSubComponent(Value);
+  AComponent.SetSubComponent(value);
 end;
+
 function AnsiStartsText(const ASubText, AText: string): Boolean;
 begin
   Result := AnsiStartsText(ASubText, AText);
 end;
+
 function GLOKMessageBox(const Text, Caption: string): Integer;
 begin
   Result := Application.MessageBox(PChar(Text), PChar(Caption), MB_OK);
 end;
-procedure GLLoadBitmapFromInstance(Instance: LongInt; ABitmap: TBitmap; const AName: string);
+
+procedure GLLoadBitmapFromInstance(Instance: LongInt; ABitmap: TBitmap;
+  const AName: string);
 begin
   ABitmap.Handle := LoadBitmap(Instance, PChar(AName));
 end;
+
 procedure ShowHTMLUrl(const Url: string);
 begin
   ShellExecute(0, 'open', PChar(Url), nil, nil, SW_SHOW);
 end;
+
 function GetGLRect(const aLeft, aTop, aRight, aBottom: Integer): TRect;
 begin
   Result.Left := aLeft;
@@ -617,6 +689,7 @@ begin
   Result.Right := aRight;
   Result.Bottom := aBottom;
 end;
+
 procedure InflateGLRect(var aRect: TRect; dx, dy: Integer);
 begin
   aRect.Left := aRect.Left - dx;
@@ -628,12 +701,13 @@ begin
   if aRect.Bottom < aRect.Top then
     aRect.Bottom := aRect.Top;
 end;
+
 procedure IntersectGLRect(var aRect: TRect; const rect2: TRect);
 var
   a: Integer;
 begin
-  if (aRect.Left > rect2.Right) or (aRect.Right < rect2.Left)
-    or (aRect.Top > rect2.Bottom) or (aRect.Bottom < rect2.Top) then
+  if (aRect.Left > rect2.Right) or (aRect.Right < rect2.Left) or
+    (aRect.Top > rect2.Bottom) or (aRect.Bottom < rect2.Top) then
   begin
     // no intersection
     a := 0;
@@ -654,59 +728,72 @@ begin
       aRect.Bottom := rect2.Bottom;
   end;
 end;
+
 type
   TDeviceCapabilities = record
-    Xdpi, Ydpi: integer; // Number of pixels per logical inch.
-    Depth: integer; // The bit depth.
-    NumColors: integer; // Number of entries in the device's color table.
+    Xdpi, Ydpi: Integer; // Number of pixels per logical inch.
+    Depth: Integer; // The bit depth.
+    NumColors: Integer; // Number of entries in the device's color table.
   end;
+
 function GetDeviceCapabilities: TDeviceCapabilities;
 var
-  Device: HDC;
+  device: HDC;
 begin
-  Device := GetDC(0);
+  device := GetDC(0);
   try
-    result.Xdpi := GetDeviceCaps(Device, LOGPIXELSX);
-    result.Ydpi := GetDeviceCaps(Device, LOGPIXELSY);
-    result.Depth := GetDeviceCaps(Device, BITSPIXEL);
-    result.NumColors := GetDeviceCaps(Device, NUMCOLORS);
+    Result.Xdpi := GetDeviceCaps(device, LOGPIXELSX);
+    Result.Ydpi := GetDeviceCaps(device, LOGPIXELSY);
+    Result.Depth := GetDeviceCaps(device, BITSPIXEL);
+    Result.NumColors := GetDeviceCaps(device, NumColors);
   finally
-    ReleaseDC(0, Device);
+    ReleaseDC(0, device);
   end;
 end;
+
 function GetDeviceLogicalPixelsX(device: HDC): Integer;
 begin
-  result := GetDeviceCapabilities().Xdpi;
+  Result := GetDeviceCapabilities().Xdpi;
 end;
+
 function GetCurrentColorDepth: Integer;
 begin
-  result := GetDeviceCapabilities().Depth;
+  Result := GetDeviceCapabilities().Depth;
 end;
+
 function PixelFormatToColorBits(aPixelFormat: TPixelFormat): Integer;
 begin
   case aPixelFormat of
     pfCustom{$IFDEF WIN32}, pfDevice{$ENDIF}: // use current color depth
       Result := GetCurrentColorDepth;
-    pf1bit: Result := 1;
+    pf1bit:
+      Result := 1;
 {$IFDEF WIN32}
-    pf4bit: Result := 4;
-    pf15bit: Result := 15;
+    pf4bit:
+      Result := 4;
+    pf15bit:
+      Result := 15;
 {$ENDIF}
-    pf8bit: Result := 8;
-    pf16bit: Result := 16;
-    pf32bit: Result := 32;
+    pf8bit:
+      Result := 8;
+    pf16bit:
+      Result := 16;
+    pf32bit:
+      Result := 32;
   else
     Result := 24;
   end;
 end;
+
 procedure FixPathDelimiter(var S: string);
 var
-  I: Integer;
+  i: Integer;
 begin
-  for I := Length(S) downto 1 do
-    if (S[I] = '/') or (S[I] = '\') then
-      S[I] := PathDelim;
+  for i := Length(S) downto 1 do
+    if (S[i] = '/') or (S[i] = '\') then
+      S[i] := PathDelim;
 end;
+
 function RelativePath(const S: string): string;
 var
   path: string;
@@ -716,7 +803,7 @@ begin
   begin
     if Assigned(vProjectTargetName) then
     begin
-      path :=  vProjectTargetName();
+      path := vProjectTargetName();
       if Length(path) = 0 then
         path := vLastProjectTargetName
       else
@@ -724,7 +811,7 @@ begin
       path := IncludeTrailingPathDelimiter(ExtractFilePath(path));
     end
     else
-      exit;
+      Exit;
   end
   else
   begin
@@ -734,23 +821,28 @@ begin
   if Pos(path, S) = 1 then
     Delete(Result, 1, Length(path));
 end;
+
 procedure QueryPerformanceCounter(out val: Int64);
 begin
   Winapi.Windows.QueryPerformanceCounter(val);
 end;
+
 function QueryPerformanceFrequency(out val: Int64): Boolean;
 begin
   Result := Boolean(Winapi.Windows.QueryPerformanceFrequency(val));
 end;
+
 function StartPrecisionTimer: Int64;
 begin
   QueryPerformanceCounter(Result);
 end;
+
 function PrecisionTimerLap(const precisionTimer: Int64): Double;
 begin
   // we can do this, because we don't really stop anything
   Result := StopPrecisionTimer(precisionTimer);
 end;
+
 function StopPrecisionTimer(const precisionTimer: Int64): Double;
 var
   cur, freq: Int64;
@@ -764,31 +856,34 @@ begin
   end;
   Result := (cur - precisionTimer) * vInvPerformanceCounterFrequency;
 end;
+
 var
-  vSStartTime : TDateTime;
+  vSStartTime: TDateTime;
   vLastTime: TDateTime;
   vDeltaMilliSecond: TDateTime;
+
 function AppTime: Double;
 var
   SystemTime: TSystemTime;
 begin
   GetLocalTime(SystemTime);
   with SystemTime do
-    Result := (wHour * (MinsPerHour * SecsPerMin * MSecsPerSec) +
-             wMinute * (SecsPerMin * MSecsPerSec) +
-               wSecond * MSecsPerSec +
-             wMilliSeconds) - vSStartTime;
+    Result := (wHour * (MinsPerHour * SecsPerMin * MSecsPerSec) + wMinute *
+      (SecsPerMin * MSecsPerSec) + wSecond * MSecsPerSec + wMilliSeconds) -
+      vSStartTime;
   // Hack to fix time precession
   if Result - vLastTime = 0 then
   begin
     Result := Result + vDeltaMilliSecond;
     vDeltaMilliSecond := vDeltaMilliSecond + 0.1;
   end
-  else begin
+  else
+  begin
     vLastTime := Result;
     vDeltaMilliSecond := 0.1;
   end;
 end;
+
 function FindUnitName(anObject: TObject): string;
 begin
   if Assigned(anObject) then
@@ -796,6 +891,7 @@ begin
   else
     Result := '';
 end;
+
 function FindUnitName(aClass: TClass): string;
 begin
   if Assigned(aClass) then
@@ -803,6 +899,7 @@ begin
   else
     Result := '';
 end;
+
 procedure SetExeDirectory;
 var
   path: string;
@@ -811,7 +908,7 @@ begin
   begin
     if Assigned(vProjectTargetName) then
     begin
-      path :=  vProjectTargetName();
+      path := vProjectTargetName();
       if Length(path) = 0 then
         path := vLastProjectTargetName
       else
@@ -828,10 +925,12 @@ begin
   end;
 end;
 
-function GetValueFromStringsIndex(const AStrings: TStrings; const AIndex: Integer): string;
+function GetValueFromStringsIndex(const AStrings: TStrings;
+  const AIndex: Integer): string;
 begin
   Result := AStrings.ValueFromIndex[AIndex];
 end;
+
 function IsDirectoryWriteable(const AName: string): Boolean;
 var
   LFileName: String;
@@ -898,7 +997,7 @@ begin
     // +/- infinity
     Dst := (Sign shl 31) or $7F800000;
   end
-  else //if (Exp = 31) and (Mantisa <> 0) then
+  else // if (Exp = 31) and (Mantisa <> 0) then
   begin
     // not a number - preserve sign and mantissa
     Dst := (Sign shl 31) or $7F800000 or (Mantissa shl 13);
@@ -906,6 +1005,7 @@ begin
   // reinterpret LongWord as Single
   Result := PSingle(@Dst)^;
 end;
+
 function FloatToHalf(Float: Single): THalfFloat;
 var
   Src: LongWord;
@@ -986,31 +1086,39 @@ begin
   end;
 end;
 
-//By PAL, added to fix problem with decimal separator in non En configurations
-function GLStrToFloatDef(const S: string; const Default: Extended; fs: TFormatSettings): Extended; overload;
+// By PAL, added to fix problem with decimal separator in non En configurations
+function GLStrToFloatDef(const S: string; const Default: Extended;
+  fs: TFormatSettings): Extended; overload;
 begin
   fs.DecimalSeparator := '.';
-  if not System.SysUtils.TextToFloat(S, Result, fs) then
+  if not TextToFloat(S, Result, fs) then
     Result := Default;
 end;
-//By PAL, added to fix problem with decimal separator in non En configurations
-function GLStrToFloatDef(const S: string; const Default: Extended): Extended; overload;
-  var fs: TFormatSettings;
+
+// By PAL, added to fix problem with decimal separator in non En configurations
+function GLStrToFloatDef(const S: string; const Default: Extended)
+  : Extended; overload;
+var
+  fs: TFormatSettings;
 begin
   fs.DecimalSeparator := '.';
-  if not System.SysUtils.TextToFloat(S, Result, fs) then
+  if not TextToFloat(S, Result, fs) then
     Result := Default;
 end;
-//By PAL, added to fix problem with decimal separator in non En configurations
+
+// By PAL, added to fix problem with decimal separator in non En configurations
 function GLStrToFloatDef(const S: string): Extended; overload;
-  var fs: TFormatSettings;
+var
+  fs: TFormatSettings;
 begin
   fs.DecimalSeparator := '.';
-  if not System.SysUtils.TextToFloat(S, Result, fs) then
+  if not TextToFloat(S, Result, fs) then
     Result := 0;
 end;
-//----------------------------------------
+
+// ----------------------------------------
 initialization
-//----------------------------------------
-  vSStartTime := AppTime;
+// ----------------------------------------
+vSStartTime := AppTime;
+
 end.