提交 ccb48510 编写于 作者: 三月三net's avatar 三月三net

Python超人-宇宙模拟器

上级 30857964
...@@ -371,12 +371,15 @@ class Body(metaclass=ABCMeta): ...@@ -371,12 +371,15 @@ class Body(metaclass=ABCMeta):
except Exception as e: except Exception as e:
err_msg = f"{json_file} 格式错误:" + str(e) err_msg = f"{json_file} 格式错误:" + str(e)
raise Exception(err_msg) raise Exception(err_msg)
is_fixed_star = False
if "is_fixed_star" in body_data: if "is_fixed_star" in body_data:
if body_data["is_fixed_star"]: if body_data["is_fixed_star"]:
body_data.pop("is_fixed_star") is_fixed_star = True
body = FixedStar(**body_data) if is_fixed_star:
else: body_data.pop("is_fixed_star")
body = FixedStar(**body_data) body = FixedStar(**body_data)
else:
body = Body(**body_data)
bodies.append(body) bodies.append(body)
if "params" in json_data: if "params" in json_data:
params = json_data["params"] params = json_data["params"]
......
...@@ -24,7 +24,12 @@ ...@@ -24,7 +24,12 @@
"distance_scale": 1.0, "distance_scale": 1.0,
"rotation_speed": 0.613, "rotation_speed": 0.613,
"ignore_mass": false, "ignore_mass": false,
"is_fixed_star": true "is_fixed_star": true,
"trail_color": [
170,
98,
25
]
}, },
{ {
"name": "地球", "name": "地球",
...@@ -50,15 +55,22 @@ ...@@ -50,15 +55,22 @@
"distance_scale": 1.0, "distance_scale": 1.0,
"rotation_speed": 15, "rotation_speed": 15,
"ignore_mass": false, "ignore_mass": false,
"is_fixed_star": false "is_fixed_star": false,
"trail_color": [
1,
89,
162
]
} }
], ],
"params": { "params": {
"dt": 2592000, "dt": 2592000,
"position": [ "position": [
0, 0,
149597870.7, 74798935.35,
-448793612.09999996 -598391482.8
] ],
"show_trail": true,
"show_name": false
} }
} }
\ No newline at end of file
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
"position": [ "position": [
0, 0,
149597870.7, 149597870.7,
-448793612.09999996 -598391482.8
] ]
} }
} }
\ No newline at end of file
...@@ -24,7 +24,12 @@ ...@@ -24,7 +24,12 @@
"distance_scale": 1.0, "distance_scale": 1.0,
"rotation_speed": 0.613, "rotation_speed": 0.613,
"ignore_mass": false, "ignore_mass": false,
"is_fixed_star": true "is_fixed_star": true,
"trail_color": [
170,
98,
25
]
}, },
{ {
"name": "地球", "name": "地球",
...@@ -50,7 +55,12 @@ ...@@ -50,7 +55,12 @@
"distance_scale": 1, "distance_scale": 1,
"rotation_speed": 15, "rotation_speed": 15,
"ignore_mass": false, "ignore_mass": false,
"is_fixed_star": false "is_fixed_star": false,
"trail_color": [
1,
89,
162
]
} }
], ],
"params": { "params": {
...@@ -58,7 +68,9 @@ ...@@ -58,7 +68,9 @@
"position": [ "position": [
0, 0,
149597870.7, 149597870.7,
-448793612.09999996 -598391482.8
] ],
"show_trail": true,
"show_name": false
} }
} }
\ No newline at end of file
...@@ -117,6 +117,8 @@ ...@@ -117,6 +117,8 @@
0, 0,
149597870.7, 149597870.7,
-1495978707.0 -1495978707.0
] ],
"show_trail": true,
"show_name": false
} }
} }
\ No newline at end of file
...@@ -94,6 +94,8 @@ ...@@ -94,6 +94,8 @@
0, 0,
149597870.7, 149597870.7,
-1495978707.0 -1495978707.0
] ],
"show_trail": true,
"show_name": false
} }
} }
\ No newline at end of file
...@@ -94,6 +94,8 @@ ...@@ -94,6 +94,8 @@
0, 0,
149597870.7, 149597870.7,
-1495978707.0 -1495978707.0
] ],
"show_trail": true,
"show_name": false
} }
} }
\ No newline at end of file
...@@ -33,7 +33,7 @@ if __name__ == '__main__': ...@@ -33,7 +33,7 @@ if __name__ == '__main__':
dt = params["dt"] if "dt" in params else SECONDS_PER_YEAR dt = params["dt"] if "dt" in params else SECONDS_PER_YEAR
position = params["position"] if "position" in params else (0, 0, 0) position = params["position"] if "position" in params else (0, 0, 0)
show_trail = params["show_trail"] if "show_trail" in params else True show_trail = params["show_trail"] if "show_trail" in params else False
# 使用 ursina 查看的运行效果 # 使用 ursina 查看的运行效果
# 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹 # 常用快捷键: P:运行和暂停 O:重新开始 I:显示天体轨迹
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册