Pārlūkot izejas kodu

Added unit to rantime package

GLScene 2 gadi atpakaļ
vecāks
revīzija
453561ec3c

+ 0 - 0
Examples/AdvDemos/Archipelago/Data/house.mtl → Assets/Model/house.mtl


+ 0 - 0
Examples/AdvDemos/Archipelago/Data/house.obj → Assets/Model/house.obj


+ 0 - 0
Examples/AdvDemos/Archipelago/Data/shark.mtl → Assets/Model/shark.mtl


+ 0 - 0
Examples/AdvDemos/Archipelago/Data/shark.obj → Assets/Model/shark.obj


+ 0 - 0
Examples/AdvDemos/Archipelago/Data/house.jpg → Assets/Texture/house.jpg


+ 0 - 0
Examples/AdvDemos/Archipelago/Data/shark.png → Assets/Texture/shark.png


+ 4 - 5
Examples/AdvDemos/Archipelago/fArchipelagoC.h

@@ -30,6 +30,10 @@
 #include "GLS.SceneViewer.hpp"
 #include "GLS.SkyDome.hpp"
 #include "GLS.TerrainRenderer.hpp"
+
+#include "GLS.VectorLists.hpp"
+#include "GLS.VectorTypes.hpp"
+#include "GLS.VectorGeometry.hpp"
 #include "GLS.VectorFileObjects.hpp"
 #include "GLS.WindowsFont.hpp"
 
@@ -37,11 +41,6 @@
 
 #include "GLS.RoamPatch.hpp"
 #include "GLS.RenderContextInfo.hpp"
-#include "GLS.VectorFileObjects.hpp"
-#include "GLS.BaseClasses.hpp"
-#include "GLS.VectorLists.hpp"
-#include "GLS.VectorTypes.hpp"
-#include "GLS.VectorGeometry.hpp"
 
 #include "GLS.Keyboard.hpp"
 #include "GLS.Context.hpp"

+ 15 - 6
Examples/AdvDemos/Earth/EarthC.cbproj

@@ -50,8 +50,6 @@
         <DCC_CBuilderOutput>JPHNE</DCC_CBuilderOutput>
         <DynamicRTL>true</DynamicRTL>
         <UsePackages>true</UsePackages>
-        <IntermediateOutputDir>.\$(Platform)\$(Config)</IntermediateOutputDir>
-        <FinalOutputDir>.\$(Platform)\$(Config)</FinalOutputDir>
         <BCC_wpar>false</BCC_wpar>
         <BCC_OptimizeForSpeed>true</BCC_OptimizeForSpeed>
         <BCC_ExtendedErrorInfo>true</BCC_ExtendedErrorInfo>
@@ -65,7 +63,6 @@
         <UWP_CppLogo44>$(BDS)\bin\Artwork\Windows\UWP\cppreg_UwpDefault_44.png</UWP_CppLogo44>
         <UWP_CppLogo150>$(BDS)\bin\Artwork\Windows\UWP\cppreg_UwpDefault_150.png</UWP_CppLogo150>
         <IncludePath>D:\GLScene\AdvDemos\Earth\;$(IncludePath)</IncludePath>
-        <ILINK_LibraryPath>D:\GLScene\AdvDemos\Earth\;$(ILINK_LibraryPath)</ILINK_LibraryPath>
         <SanitizedProjectName>EarthC</SanitizedProjectName>
     </PropertyGroup>
     <PropertyGroup Condition="'$(Base_Win32)'!=''">
@@ -110,6 +107,8 @@
         <BCC_UseClassicCompiler>false</BCC_UseClassicCompiler>
         <LinkPackageImports>rtl.bpi;vcl.bpi;GLScene_RT.bpi;xmlrtl.bpi;vclimg.bpi</LinkPackageImports>
         <ILINK_LibraryPath>$(BDSLIB)\$(PLATFORM)$(CC_SUFFIX)\debug;$(ILINK_LibraryPath)</ILINK_LibraryPath>
+        <VerInfo_IncludeVerInfo>true</VerInfo_IncludeVerInfo>
+        <VerInfo_Locale>1033</VerInfo_Locale>
     </PropertyGroup>
     <PropertyGroup Condition="'$(Cfg_2)'!=''">
         <Defines>NDEBUG;$(Defines)</Defines>
@@ -125,7 +124,7 @@
             <BuildOrder>0</BuildOrder>
         </CppCompile>
         <CppCompile Include="fEarthC.cpp">
-            <Form>Form3</Form>
+            <Form>frmEarth</Form>
             <FormType>dfm</FormType>
             <DependentOn>fEarthC.h</DependentOn>
             <BuildOrder>2</BuildOrder>
@@ -157,6 +156,16 @@
                 <Source>
                     <Source Name="MainSource">EarthC.cpp</Source>
                 </Source>
+                <Excluded_Packages>
+                    <Excluded_Packages Name="C:\Users\Public\Documents\Embarcadero\Studio\22.0\Bpl\GBComps.bpl">Geoblock - Components</Excluded_Packages>
+                    <Excluded_Packages Name="C:\Users\Public\Documents\Embarcadero\Studio\22.0\Bpl\GR32_DT.bpl">File C:\Users\Public\Documents\Embarcadero\Studio\22.0\Bpl\GR32_DT.bpl not found</Excluded_Packages>
+                    <Excluded_Packages Name="C:\Users\Public\Documents\Embarcadero\Studio\22.0\Bpl\GEdgeIO.bpl">File C:\Users\Public\Documents\Embarcadero\Studio\22.0\Bpl\GEdgeIO.bpl not found</Excluded_Packages>
+                    <Excluded_Packages Name="C:\Users\Public\Documents\Embarcadero\Studio\22.0\Bpl\GEdgeIODB.bpl">File C:\Users\Public\Documents\Embarcadero\Studio\22.0\Bpl\GEdgeIODB.bpl not found</Excluded_Packages>
+                    <Excluded_Packages Name="$(BDSBIN)\bcboffice2k280.bpl">Embarcadero C++Builder Office 2000 Servers Package</Excluded_Packages>
+                    <Excluded_Packages Name="$(BDSBIN)\bcbofficexp280.bpl">Embarcadero C++Builder Office XP Servers Package</Excluded_Packages>
+                    <Excluded_Packages Name="$(BDSBIN)\dcloffice2k280.bpl">Microsoft Office 2000 Sample Automation Server Wrapper Components</Excluded_Packages>
+                    <Excluded_Packages Name="$(BDSBIN)\dclofficexp280.bpl">Microsoft Office XP Sample Automation Server Wrapper Components</Excluded_Packages>
+                </Excluded_Packages>
             </CPlusPlusBuilder.Personality>
             <Deployment Version="3">
                 <DeployFile Condition="'$(UsingDelphiRTL)'=='true'" LocalName="$(BDS)\bin64\borlndmm.dll" Class="DependencyModule">
@@ -209,13 +218,13 @@
                         <Overwrite>true</Overwrite>
                     </Platform>
                 </DeployFile>
-                <DeployFile LocalName=".\Win32\Debug\EarthC.exe" Configuration="Debug" Class="ProjectOutput">
+                <DeployFile LocalName="EarthC.exe" Configuration="Debug" Class="ProjectOutput">
                     <Platform Name="Win32">
                         <RemoteName>EarthC.exe</RemoteName>
                         <Overwrite>true</Overwrite>
                     </Platform>
                 </DeployFile>
-                <DeployFile LocalName=".\Win32\Debug\EarthC.tds" Configuration="Debug" Class="DebugSymbols">
+                <DeployFile LocalName="EarthC.tds" Configuration="Debug" Class="DebugSymbols">
                     <Platform Name="Win32">
                         <RemoteName>EarthC.tds</RemoteName>
                         <Overwrite>true</Overwrite>

+ 2 - 2
Examples/AdvDemos/Earth/EarthC.cpp

@@ -4,7 +4,7 @@
 #pragma hdrstop
 #include <tchar.h>
 //---------------------------------------------------------------------------
-USEFORM("fEarthC.cpp", Form3);
+USEFORM("fEarthC.cpp", frmEarth);
 //---------------------------------------------------------------------------
 int WINAPI _tWinMain(HINSTANCE, HINSTANCE, LPTSTR, int)
 {
@@ -12,7 +12,7 @@ int WINAPI _tWinMain(HINSTANCE, HINSTANCE, LPTSTR, int)
 	{
 		Application->Initialize();
 		Application->MainFormOnTaskBar = true;
-		Application->CreateForm(__classid(TForm3), &Form3);
+		Application->CreateForm(__classid(TfrmEarth), &frmEarth);
 		Application->Run();
 	}
 	catch (Exception &exception)

+ 3 - 3
Examples/AdvDemos/Earth/EarthD.dpr

@@ -13,13 +13,13 @@ program EarthD;
 
 uses
   Forms,
-  fEarthD in 'fEarthD.pas',
-  USolarSystem in 'USolarSystem.pas';
+  fEarthD in 'fEarthD.pas' {FormEarth},
+  GLS.SolarSystem in 'GLS.SolarSystem.pas';
 
 {$R *.res}
 
 begin
   Application.Initialize;
-  Application.CreateForm(TForm1, Form1);
+  Application.CreateForm(TFormEarth, FormEarth);
   Application.Run;
 end.

+ 1 - 1
Examples/AdvDemos/Earth/EarthD.dproj

@@ -119,7 +119,7 @@
             <MainSource>MainSource</MainSource>
         </DelphiCompile>
         <DCCReference Include="fEarthD.pas">
-            <Form>Form1</Form>
+            <Form>FormEarth</Form>
         </DCCReference>
         <DCCReference Include="USolarSystem.pas"/>
         <BuildConfiguration Include="Base">

+ 2 - 2
Examples/AdvDemos/Earth/fEarthC.cpp

@@ -17,9 +17,9 @@
 #pragma link "GLS.SkyDome"
 #pragma link "GLSL.TextureShaders"
 #pragma resource "*.dfm"
-TForm3 *Form3;
+TfrmEarth *frmEarth;
 //---------------------------------------------------------------------------
-__fastcall TForm3::TForm3(TComponent* Owner)
+__fastcall TfrmEarth::TfrmEarth(TComponent* Owner)
 	: TForm(Owner)
 {
 }

+ 2 - 1
Examples/AdvDemos/Earth/fEarthC.dfm

@@ -1,4 +1,4 @@
-object Form3: TForm3
+object frmEarth: TfrmEarth
   Left = 0
   Top = 0
   Caption = 'Earth'
@@ -10,6 +10,7 @@ object Form3: TForm3
   Font.Height = -12
   Font.Name = 'Segoe UI'
   Font.Style = []
+  Position = poScreenCenter
   TextHeight = 15
   object GLSceneViewer: TGLSceneViewer
     Left = 0

+ 3 - 3
Examples/AdvDemos/Earth/fEarthC.h

@@ -19,7 +19,7 @@
 #include "GLSL.TextureShaders.hpp"
 #include <Vcl.ExtCtrls.hpp>
 //---------------------------------------------------------------------------
-class TForm3 : public TForm
+class TfrmEarth : public TForm
 {
 __published:	// IDE-managed Components
 	TGLSceneViewer *GLSceneViewer;
@@ -42,9 +42,9 @@ __published:	// IDE-managed Components
 	TGLTexCombineShader *EarthCombiner;
 private:	// User declarations
 public:		// User declarations
-	__fastcall TForm3(TComponent* Owner);
+	__fastcall TfrmEarth(TComponent* Owner);
 };
 //---------------------------------------------------------------------------
-extern PACKAGE TForm3 *Form3;
+extern PACKAGE TfrmEarth *frmEarth;
 //---------------------------------------------------------------------------
 #endif

+ 1 - 1
Examples/AdvDemos/Earth/fEarthD.dfm

@@ -1,4 +1,4 @@
-object Form1: TForm1
+object FormEarth: TFormEarth
   Left = 412
   Top = 123
   Caption = 'Earth'

+ 34 - 22
Examples/AdvDemos/Earth/fEarthD.pas

@@ -36,7 +36,7 @@ uses
   GLS.BaseClasses;
 
 type
-  TForm1 = class(TForm)
+  TFormEarth = class(TForm)
     GLScene: TGLScene;
     GLSceneViewer: TGLSceneViewer;
     Camera: TGLCamera;
@@ -85,7 +85,7 @@ type
   end;
 
 var
-  Form1: TForm1;
+  FormEarth: TFormEarth;
 
 const
   cOpacity: Single = 5;
@@ -106,14 +106,14 @@ implementation
 
 uses
   // accurate movements left for later... or the astute reader
-  USolarSystem;
+  GLS.SolarSystem;
 
-procedure TForm1.FormCreate(Sender: TObject);
+procedure TFormEarth.FormCreate(Sender: TObject);
 var
   FileName: TFileName;
 begin
   Path := GetCurrentAssetPath();
-  SetCurrentDir(Path + '\Data');
+  SetCurrentDir(Path + '\data');
   FileName := 'Yale_BSC.stars';
   SkyDome.Bands.Clear;
   if FileExists(FileName) then
@@ -122,7 +122,9 @@ begin
   TimeMultiplier := 1;
 end;
 
-procedure TForm1.GLSceneViewerBeforeRender(Sender: TObject);
+//--------------------------------------------------------------------------------
+
+procedure TFormEarth.GLSceneViewerBeforeRender(Sender: TObject);
 begin
   LensFlareSun.PreRender(Sender as TGLSceneBuffer);
   // if no multitexturing or no combiner support, turn off city lights
@@ -130,7 +132,9 @@ begin
   GLMatLib.Materials[0].Texture2Name := 'earthNight';
 end;
 
-function TForm1.AtmosphereColor(const rayStart, rayEnd: TGLVector): TGLColorVector;
+//--------------------------------------------------------------------------------
+
+function TFormEarth.AtmosphereColor(const rayStart, rayEnd: TGLVector): TGLColorVector;
 var
   i, n: Integer;
   atmPoint, normal: TGLVector;
@@ -175,9 +179,9 @@ begin
   Result.W := n * contrib * cOpacity * 0.1;
 end;
 
-// ---------------------------------------------------------
-//
-function TForm1.ComputeColor(var rayDest: TGLVector; mayHitGround: Boolean): TGLColorVector;
+//--------------------------------------------------------------------------------
+
+function TFormEarth.ComputeColor(var rayDest: TGLVector; mayHitGround: Boolean): TGLColorVector;
 var
   ai1, ai2, pi1, pi2: TGLVector;
   rayVector: TGLVector;
@@ -203,7 +207,9 @@ begin
     Result := clrTransparent;
 end;
 
-procedure TForm1.DirectOpenGLRender(Sender: TObject; var rci: TGLRenderContextInfo);
+//--------------------------------------------------------------------------------
+
+procedure TFormEarth.DirectOpenGLRender(Sender: TObject; var rci: TGLRenderContextInfo);
 
 const
   cSlices = 60;
@@ -297,7 +303,7 @@ begin
   FreeMem(pColor);
 end;
 
-function TForm1.LonLatToPos(lon, lat: Single): TAffineVector;
+function TFormEarth.LonLatToPos(lon, lat: Single): TAffineVector;
 var
   f: Single;
 begin
@@ -305,9 +311,9 @@ begin
   SinCosine(lon * (360 / 24 * PI / 180), f, Result.X, Result.Z);
 end;
 
-// -------------------------------------------
-//
-procedure TForm1.LoadConstellationLines;
+//--------------------------------------------------------------------------------
+
+procedure TFormEarth.LoadConstellationLines;
 var
   sl, line: TStrings;
   pos1, pos2: TAffineVector;
@@ -330,13 +336,15 @@ begin
   line.Free;
 end;
 
-procedure TForm1.Timer1Timer(Sender: TObject);
+procedure TFormEarth.Timer1Timer(Sender: TObject);
 begin
   Caption := Format('Earth ' + '%.1f FPS', [GLSceneViewer.FramesPerSecond]);
   GLSceneViewer.ResetPerformanceMonitor;
 end;
 
-procedure TForm1.GLCadencerProgress(Sender: TObject; const deltaTime, newTime: Double);
+//--------------------------------------------------------------------------------
+
+procedure TFormEarth.GLCadencerProgress(Sender: TObject; const deltaTime, newTime: Double);
 // var
 // d : Double;
 // p : TAffineVector;
@@ -381,14 +389,16 @@ begin
   end;
 end;
 
-procedure TForm1.GLSceneViewerMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState;
+//--------------------------------------------------------------------------------
+
+procedure TFormEarth.GLSceneViewerMouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState;
   X, Y: Integer);
 begin
   mx := X;
   my := Y;
 end;
 
-procedure TForm1.GLSceneViewerMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
+procedure TFormEarth.GLSceneViewerMouseMove(Sender: TObject; Shift: TShiftState; X, Y: Integer);
 begin
   if Shift = [ssLeft] then
   begin
@@ -401,7 +411,7 @@ begin
   my := Y;
 end;
 
-procedure TForm1.FormMouseWheel(Sender: TObject; Shift: TShiftState; WheelDelta: Integer;
+procedure TFormEarth.FormMouseWheel(Sender: TObject; Shift: TShiftState; WheelDelta: Integer;
   MousePos: TPoint; var Handled: Boolean);
 var
   f: Single;
@@ -414,7 +424,7 @@ begin
   Handled := True;
 end;
 
-procedure TForm1.GLSceneViewerDblClick(Sender: TObject);
+procedure TFormEarth.GLSceneViewerDblClick(Sender: TObject);
 begin
   GLSceneViewer.OnMouseMove := nil;
   if WindowState = wsMaximized then
@@ -430,7 +440,9 @@ begin
   GLSceneViewer.OnMouseMove := GLSceneViewerMouseMove;
 end;
 
-procedure TForm1.FormKeyPress(Sender: TObject; var Key: Char);
+//--------------------------------------------------------------------------------
+
+procedure TFormEarth.FormKeyPress(Sender: TObject; var Key: Char);
 
   procedure LoadHighResTexture(LibMat: TGLLibMaterial; const FileName: string);
   begin

+ 7 - 5
Examples/AdvDemos/Forest/fForestD.dfm

@@ -3,8 +3,8 @@ object Form1: TForm1
   Top = 166
   BorderStyle = bsNone
   Caption = 'Form1'
-  ClientHeight = 413
-  ClientWidth = 505
+  ClientHeight = 457
+  ClientWidth = 611
   Color = clBtnFace
   Font.Charset = DEFAULT_CHARSET
   Font.Color = clWindowText
@@ -22,8 +22,8 @@ object Form1: TForm1
   object SceneViewer: TGLSceneViewer
     Left = 0
     Top = 0
-    Width = 505
-    Height = 413
+    Width = 611
+    Height = 457
     Camera = Camera
     Buffer.FogEnvironment.FogColor.Color = {9CC4403FFED4583F48E17A3F0000803F}
     Buffer.FogEnvironment.FogStart = 3500.000000000000000000
@@ -33,10 +33,12 @@ object Form1: TForm1
     Buffer.FogEnable = True
     Buffer.Lighting = False
     Buffer.AntiAliasing = aaNone
-    FieldOfView = 152.777770996093800000
+    FieldOfView = 155.314346313476600000
     PenAsTouch = False
     Align = alClient
     TabOrder = 0
+    ExplicitWidth = 507
+    ExplicitHeight = 415
   end
   object GLScene: TGLScene
     ObjectsSorting = osNone

+ 0 - 20
Examples/Demos/rendering/SkyBox/fSkyBoxD.dfm

@@ -164,24 +164,4 @@ object FormSkyBox: TFormSkyBox
     Left = 296
     Top = 24
   end
-  object GLSimpleNavigation1: TGLSimpleNavigation
-    Form = Owner
-    GLSceneViewer = GLSceneViewer1
-    FormCaption = 'GLScene SkyBox - %FPS'
-    KeyCombinations = <
-      item
-        ShiftState = [ssLeft, ssRight]
-        Action = snaZoom
-      end
-      item
-        ShiftState = [ssLeft]
-        Action = snaMoveAroundTarget
-      end
-      item
-        ShiftState = [ssRight]
-        Action = snaMoveAroundTarget
-      end>
-    Left = 296
-    Top = 88
-  end
 end

+ 11 - 5
Examples/Demos/rendering/SkyBox/fSkyBoxD.pas

@@ -55,7 +55,6 @@ type
     GLSkyBox2: TGLSkyBox;
     GLSphere1: TGLSphere;
     GLSphere2: TGLSphere;
-    GLSimpleNavigation1: TGLSimpleNavigation;
     procedure FormCreate(Sender: TObject);
     procedure GLCadencer1Progress(Sender: TObject;
       const deltaTime, newTime: Double);
@@ -63,6 +62,7 @@ type
     procedure HandleKeys(d: Double);
     function LoadTexture(Matname, Filename: string): TGLLibMaterial;
   public
+    PathToAsset: TFileName;
   end;
 
 var
@@ -79,10 +79,12 @@ begin
   Result.Material.Texture.TextureMode := tmDecal;
 end;
 
+//------------------------------------------------
+
 procedure TFormSkyBox.FormCreate(Sender: TObject);
 begin
-  var Path: TFileName := GetCurrentAssetPath();
-  SetCurrentDir(Path  + '\cubemap');
+  PathToAsset := GetCurrentAssetPath();
+  SetCurrentDir(PathToAsset  + '\cubemap');
   GLMatLibCubeMap.TexturePaths := GetCurrentDir();
 
   // Skybox cubemaps
@@ -94,7 +96,7 @@ begin
   LoadTexture('Back', 'icecraterbk.jpg');
 
   // back to folder with textures
-  SetCurrentDir(Path  + '\texture');
+  SetCurrentDir(PathToAsset  + '\texture');
   with LoadTexture('Clouds', 'Clouds.jpg') do
   begin
     // Add transparency to clouds
@@ -120,7 +122,7 @@ begin
   end;
 
   // Moon
-  SetCurrentDir(Path  + '\map');
+  SetCurrentDir(PathToAsset  + '\map');
   LoadTexture('Moon', 'moon.jpg').Material.Texture.TextureMode := tmModulate;
 
   // -----------------------------------------
@@ -141,6 +143,8 @@ begin
   //GLUserInterface1.MouseLookActive := true;
 end;
 
+//------------------------------------------------
+
 procedure TFormSkyBox.GLCadencer1Progress(Sender: TObject;
   const deltaTime, newTime: Double);
 begin
@@ -161,6 +165,8 @@ begin
   GLSceneViewer1.Invalidate;
 end;
 
+//------------------------------------------------
+
 procedure TFormSkyBox.HandleKeys(d: Double);
 begin
   if IsKeyDown('W') or IsKeyDown('Z') then

+ 1 - 0
Examples/_cleanexamples.cmd

@@ -45,6 +45,7 @@ del *.ilf /s
 del *.ils /s
 del *.pdi /s
 del *.vlb /s
+del *.obj /s
 
 echo ************************************************
 echo             Don't delete some files

+ 2 - 1
Packages/GLScene_RT.dpk

@@ -266,7 +266,8 @@ contains
   GLS.VectorGeometry in '..\Source\GLS.VectorGeometry.pas',
   GLS.VectorTypes in '..\Source\GLS.VectorTypes.pas',
   GLS.VectorTypesExt in '..\Source\GLS.VectorTypesExt.pas',
-  GLS.Logger in '..\Source\GLS.Logger.pas';
+  GLS.Logger in '..\Source\GLS.Logger.pas',
+  GLS.SolarSystem in '..\Source\GLS.SolarSystem.pas';
 
 end.
 

+ 1 - 0
Packages/GLScene_RT.dproj

@@ -371,6 +371,7 @@
         <DCCReference Include="..\Source\GLS.VectorTypes.pas"/>
         <DCCReference Include="..\Source\GLS.VectorTypesExt.pas"/>
         <DCCReference Include="..\Source\GLS.Logger.pas"/>
+        <DCCReference Include="..\Source\GLS.SolarSystem.pas"/>
         <BuildConfiguration Include="Base">
             <Key>Base</Key>
         </BuildConfiguration>

+ 3 - 0
Source/GLS.Coordinates.pas

@@ -225,6 +225,9 @@ procedure Spherical_Cartesian(const r, theta, phi: double; var x, y, z: double;
   Ref: http://mathworld.wolfram.com/SphericalCoordinates.html
   NB: Could be optimised by using jclmath.pas unit *)
 procedure Cartesian_Spherical(const x, y, z: single; var r, theta, phi: single); overload;
+(* Convert Cartesian to Spherical, no checks, single
+  Ref: http://mathworld.wolfram.com/SphericalCoordinates.html
+  NB: Could be optimised by using fastmath.pas unit *)
 procedure Cartesian_Spherical(const v: TAffineVector; var r, theta, phi: single); overload;
 (* convert Cartesian to Spherical, no checks, double
   Ref: http://mathworld.wolfram.com/SphericalCoordinates.html

+ 13 - 7
Examples/AdvDemos/Earth/USolarSystem.pas → Source/GLS.SolarSystem.pas

@@ -1,7 +1,7 @@
 //
 // The graphics engine GLScene https://github.com/glscene
 //
-unit USolarSystem;
+unit GLS.SolarSystem;
 
 (*
   Solar system planetary elements and positions utility unit.
@@ -10,6 +10,7 @@ unit USolarSystem;
   Coordinates system takes Z as "up", ie. normal to the ecliptic plane,
   "axis" around which the planets turn.
 *)
+
 interface
 
 uses
@@ -40,8 +41,7 @@ type
   end;
 
 const
-
-  // geocentric sun elements (?)
+  // geocentric sun elements 
   cSunOrbitalElements: TOrbitalElementsData = (NConst: 0.0; NVar: 0.0;
     iConst: 0.0; iVar: 0.0; wConst: 282.9404; wVar: 4.70935E-5;
     aConst: 1.000000; aVar: 0.0; // (AU)
@@ -96,15 +96,15 @@ const
     eConst: 0.008606; eVar: 2.15E-9; MConst: 260.2471; MVar: 0.005995147);
 
   cAUToKilometers = 149.6E6; // astronomical units to kilometers
-  cEarthRadius = 6400; // earth radius in kilometers
+  cEarthRadius = 6371; // average earth radius in kilometers
 
-// Converts a TDateTime (GMT+0) into the julian day used for computations.
+// Converts a TDateTime (GMT+0) into the Julian day used for computations.
 function GMTDateTimeToJulianDay(const dt: TDateTime): Double;
-// Compute orbital elements for given julian day.
+// Compute orbital elements for given Julian day.
 function ComputeOrbitalElements(const oeData: TOrbitalElementsData;
   const d: Double): TOrbitalElements;
 
-// Compute the planet position for given julian day (in AU).
+// Compute the planet position for given Julian day (in AU).
 function ComputePlanetPosition(const orbitalElements: TOrbitalElements)
   : TAffineVector; overload;
 function ComputePlanetPosition(const orbitalElementsData: TOrbitalElementsData;
@@ -119,6 +119,8 @@ begin
   Result := dt - EncodeDate(2000, 1, 1);
 end;
 
+//--------------------------------------------------------------------------------
+
 function ComputeOrbitalElements(const oeData: TOrbitalElementsData;
   const d: Double): TOrbitalElements;
 begin
@@ -133,6 +135,8 @@ begin
   end;
 end;
 
+//--------------------------------------------------------------------------------
+
 function ComputePlanetPosition(const orbitalElements: TOrbitalElements)
   : TAffineVector;
 var
@@ -176,6 +180,8 @@ begin
   Result.Z := r * (svw * si);
 end;
 
+//--------------------------------------------------------------------------------
+
 function ComputePlanetPosition(const orbitalElementsData: TOrbitalElementsData;
   const d: Double): TAffineVector;
 var