代码拉取完成,页面将自动刷新
同步操作将从 找不到服务器/satellitesim 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
#include "orbitalsim.hpp"
#include "utils.h"
#include "tracelog.h"
int main(void) {
/*初始化场景*/
Camera camera;
SetTraceLogLevel(LOG_WARNING);
SetConfigFlags(FLAG_MSAA_4X_HINT);
SetConfigFlags(FLAG_FULLSCREEN_MODE);
SetTargetFPS(60);
// InitGraph(1024, 768, "RayLib-3D");
InitGraph(1920, 1200, "RayLib-3D");
Init_Camera(&camera);
Init_Skybox();
/*加载卫星*/
Orbital_Object satellites[3];
satellites[0].Set_initRV(Vector3{15, 0, 0}, Vector3{0, 20, 0});
satellites[1].Set_initRV(Vector3{15, 0, 5}, Vector3{0, 21, 0});
satellites[2].Set_initRV(Vector3{15, 1, -5}, Vector3{0, 20, 0});
for (int i = 0; i < 3; i++) {
satellites[i].Set_ID(i);
satellites[i].Load_Model("resources/satellite.obj", "resources/satellite.png");
satellites[i].Set_Scale(0.01);
}
/*加载地球模型和纹理*/
Model modelEarth = LoadModel("resources/sphere.obj");
Texture2D imgEarth = LoadTexture("resources/earth.png");
modelEarth.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = imgEarth;
/*添加全局变量*/
Vector3 ShuttleVelocity[3];
Vector3 vec3d;
int cnt = 30;
int showfps=0, showcpu=0;
/*场景循环*/
while (!WindowShouldClose()) {
for (int i = 0; i < 3; i++) {
satellites[i].Simulate(10);
vec3d = satellites[i].Get_V();
ShuttleVelocity[i].x = vec3d.x;
ShuttleVelocity[i].y = vec3d.z;
ShuttleVelocity[i].z = vec3d.y;
}
Update_Camera(&camera);
BeginDrawing();
ClearBackground(RAYWHITE);
BeginMode3D(camera);
Update_Skybox();
DrawModel(modelEarth, (Vector3){ 0.0f, 0.0f, 0.0f }, 10.0f, WHITE);
for (int i = 0; i < 3; i++)
satellites[i].Update_Model(MatrixRotateXYZ((Vector3){0, atan2f(-ShuttleVelocity[i].x, ShuttleVelocity[i].z), 0}));
EndMode3D();
cnt++;
if (cnt>=30) {
cnt = 0;
showfps = GetFPS();
showcpu = GetCPUusage();
}
DrawText(TextFormat("%2i FPS", showfps), 0, 0, 20, LIME);
DrawText(TextFormat("%2i %%", showcpu), 0, 30, 20, LIME);
EndDrawing();
}
CloseGraph();
return 0;
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。