2
// This unit is part of the GLScene Engine https://github.com/glscene
5
Unit to interface with simple star records aimed for background skies.
8
05/07/03 - EG - Creation
19
TGLStarRecord = packed record
20
RA : Word; // x100 builtin factor, degrees
21
DEC : SmallInt; // x100 builtin factor, degrees
22
BVColorIndex : Byte; // x100 builtin factor
23
VMagnitude : Byte; // x10 builtin factor
25
PGLStarRecord = ^TGLStarRecord;
27
{ Computes position on the unit sphere of a star record (Z=up). }
28
function StarRecordPositionZUp(const starRecord : TGLStarRecord) : TAffineVector;
29
{ Computes position on the unit sphere of a star record (Y=up). }
30
function StarRecordPositionYUp(const starRecord : TGLStarRecord) : TAffineVector;
31
{ Computes star color from BV index (RGB) and magnitude (alpha). }
32
function StarRecordColor(const starRecord : TGLStarRecord; bias : Single) : TVector;
34
// ------------------------------------------------------------------
35
// ------------------------------------------------------------------
36
// ------------------------------------------------------------------
41
// ------------------------------------------------------------------
42
// ------------------------------------------------------------------
43
// ------------------------------------------------------------------
45
// StarRecordPositionYUp
47
function StarRecordPositionYUp(const starRecord : TGLStarRecord) : TAffineVector;
51
SinCos(starRecord.DEC*(0.01*PI/180), Result.V[1], f);
52
SinCos(starRecord.RA*(0.01*PI/180), f, Result.V[0], Result.V[2]);
55
// StarRecordPositionZUp
57
function StarRecordPositionZUp(const starRecord : TGLStarRecord) : TAffineVector;
61
SinCos(starRecord.DEC*(0.01*PI/180), Result.V[2], f);
62
SinCos(starRecord.RA*(0.01*PI/180), f, Result.V[0], Result.V[1]);
67
function StarRecordColor(const starRecord : TGLStarRecord; bias : Single) : TVector;
69
// very *rough* approximation
70
cBVm035 : TVector = (X:0.7; Y:0.8; Z:1.0; W:1);
71
cBV015 : TVector = (X:1.0; Y:1.0; Z:1.0; W:1);
72
cBV060 : TVector = (X:1.0; Y:1.0; Z:0.7; W:1);
73
cBV135 : TVector = (X:1.0; Y:0.8; Z:0.7; W:1);
77
bvIndex100:=starRecord.BVColorIndex-50;
78
// compute RGB color for B&V index
79
if bvIndex100<-035 then
81
else if bvIndex100<015 then
82
VectorLerp(cBVm035, cBV015, (bvIndex100+035)*(1/(015+035)), Result)
83
else if bvIndex100<060 then
84
VectorLerp(cBV015, cBV060, (bvIndex100-015)*(1/(060-015)), Result)
85
else if bvIndex100<135 then
86
VectorLerp(cBV060, cBV135, (bvIndex100-060)*(1/(135-060)), Result)
88
// compute transparency for VMag
89
// the actual factor is 2.512, and not used here
90
Result.V[3]:=Power(1.2, -(starRecord.VMagnitude*0.1-bias));