-
Notifications
You must be signed in to change notification settings - Fork 1
/
star_data.gd
174 lines (139 loc) · 3.35 KB
/
star_data.gd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
extends Node
@export var star_scale = 1000
var star = preload("res://scenes/star.tscn")
var table = "res://assets/data/star_data2.json"
var star_data = []
var mapWidth = 500
var mapHeight = 500
var white = preload("res://assets/mat/star_white.tres")
var O = preload("res://assets/mat/star_O.tres")
var B = preload("res://assets/mat/star_B.tres")
var A = preload("res://assets/mat/star_A.tres")
var F = preload("res://assets/mat/star_F.tres")
var G = preload("res://assets/mat/star_G.tres")
var K = preload("res://assets/mat/star_K.tres")
var M = preload("res://assets/mat/star_M.tres")
var starMap = [
{
"name": "Betelgeuse",
"RA": 88.79295833,
"dec":7.407055556,
"app_mag":0.45,
"abs_mag":-6.02
},
{
"name": "Rigel",
"RA":78.63446667,
"dec":-8.201638889,
"app_mag":0.18,
"abs_mag":-6.95
},
{
"name": "Bellatrix",
"RA":81.2827625,
"dec":6.349702778,
"app_mag":1.64,
"abs_mag":-2.72
},
{
"name": "Mintaka",
"RA":83.00166667,
"dec":-0.299094444,
"app_mag":2.25,
"abs_mag":-4.47
},
{
"name": "Alnilam",
"RA":84.0533875,
"dec":-1.201919444,
"app_mag":1.69,
"abs_mag":-6.38
},
{
"name": "Alnitak",
"RA":85.18969583,
"dec":-1.942572222,
"app_mag":1.74,
"abs_mag":-5.15
},
{
"name": "Saiph",
"RA":86.93912,
"dec":-9.669605,
"app_mag":2.07,
"abs_mag":-4.65
}
]
func _ready():
table = FileAccess.get_file_as_string(table)
table = JSON.parse_string(table)
table = table["simbad"]
#print(table)
for s in table:
star_data.append(createStar(s))
func createStar(data):
#var star_scene = star.instantiate()
var col = data["spec_type"]
var nam = data["identifier"]
var type = data["typ"]
var sc = 1
var mat
var pos = Vector2(-data["ra_deg"]/90 * star_scale + 1000, -data["dec_deg"]/90 * star_scale)
data["x"] = pos.x
data["y"] = pos.y
if nam.begins_with("NAME"):
data["identifier"] = nam.trim_prefix("NAME ")
elif nam.begins_with("*"):
data["identifier"] = nam.trim_prefix("* ")
if col.begins_with("O"):
col = Color("#81a4ff")
mat = O
elif col.begins_with("B"):
col = Color("#99B9FF")
mat = B
elif col.begins_with("A"):
col = Color("#C9D9FF")
mat = A
elif col.begins_with("F"):
col = Color("#ECEEFF")
mat = F
elif col.begins_with("G"):
col = Color("#FFF2EE")
mat = G
elif col.begins_with("K"):
col = Color("#FFE7D2")
mat = K
elif col.begins_with("M"):
col = Color("#FFCC98")
mat = M
else:
col = Color("#FFFFFF")
mat = white
if type.ends_with("SG") || type == "Supergiant" || type.ends_with("SG*"):
sc = 1.5
elif type.begins_with("Massiv"):
sc = 1.3
data["scale"] = sc
data["col"] = col
data["mat"] = mat
return data
#star_scene.set("position", pos)
#star_scene.set("data", data)
#add_child(star_scene)
#
#func randPosition():
# return Vector2(randi() % 200, randi() % 200)
#
#func getXY(s_ra, s_dec, c_ra, c_dec):
# s_ra = s_ra * (180/PI)
# s_dec = s_dec * (180/PI)
# c_ra = c_ra * (180/PI)
# c_dec = c_dec * (180/PI)
#
# var stdX = cos(s_dec) * sin(s_ra - c_ra) / (cos(c_dec) * cos(s_dec) * cos(s_ra - c_ra) + sin(c_dec) * sin(s_dec))
# var stdY = (sin(c_dec) * cos(s_dec) * cos(s_ra - c_ra) - cos(c_dec) * sin(s_dec)) / (cos(c_dec) * cos(s_dec) * cos(s_ra - c_ra) + sin(c_dec) * sin(s_dec))
#
# var starX = mapWidth - (pixelsPerRadW * stdX + mapCenterX)
# var starY = pixelsPerRadH * stdY + mapCenterY
#
# return Vector2(starX, starY)