|
|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* TODO: |
|
|
|
|
* - add coordinate directions overlay |
|
|
|
|
* - impulsive orbital maneuvers |
|
|
|
|
* - replace instances of glm:: with using directives |
|
|
|
|
* - compile with '-pedantic' and fix macro warnings |
|
|
|
|
@ -48,6 +49,7 @@ initCamera(RenderState* rs, vec3 cam_pos, vec3 cam_focus, vec3 cam_up)
|
|
|
|
|
assert(xform_ubo != nullptr); |
|
|
|
|
updateGLBuffer(xform_ubo, &rs->camera->xforms); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
void |
|
|
|
|
initLights(RenderState* rs) |
|
|
|
|
{ |
|
|
|
|
@ -65,6 +67,49 @@ initLights(RenderState* rs)
|
|
|
|
|
updateGLBuffer(lights_ubo, lb->buffer); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Entity* |
|
|
|
|
addCoordinateOverlay(RenderState* rs) |
|
|
|
|
{ |
|
|
|
|
const u32 num_vertices = 6, num_indicies = 6; |
|
|
|
|
Mesh* m = meshInit(rs->assets.arena, |
|
|
|
|
num_vertices, |
|
|
|
|
num_indicies, |
|
|
|
|
false, |
|
|
|
|
true); |
|
|
|
|
|
|
|
|
|
m->vertices[0] = vec3(0, 0, 0); |
|
|
|
|
m->vertices[1] = vec3(1, 0, 0); |
|
|
|
|
m->vertices[2] = vec3(0, 0, 0); |
|
|
|
|
m->vertices[3] = vec3(0, 1, 0); |
|
|
|
|
m->vertices[4] = vec3(0, 0, 0); |
|
|
|
|
m->vertices[5] = vec3(0, 0, 1); |
|
|
|
|
u16 indices[num_indicies] = { 0, 1, 2, 3, 4, 5 }; |
|
|
|
|
memcpy(m->indices, indices, num_indicies * sizeof(*indices)); |
|
|
|
|
m->colors[0] = vec3(1, 0, 0); |
|
|
|
|
m->colors[1] = vec3(1, 0, 0); |
|
|
|
|
m->colors[2] = vec3(0, 1, 0); |
|
|
|
|
m->colors[3] = vec3(0, 1, 0); |
|
|
|
|
m->colors[4] = vec3(0, 0, 1); |
|
|
|
|
m->colors[5] = vec3(0, 0, 1); |
|
|
|
|
|
|
|
|
|
Model* mdl = modelInitManual(rs->assets.arena, 1, m); |
|
|
|
|
RenderGroup* rg = getRenderGroupByName(rs, "manual mesh group"); |
|
|
|
|
Entity* e = getFreeEntity(rg); |
|
|
|
|
initEntity(e, rs->gl_ctx, |
|
|
|
|
rs->rg_arena, |
|
|
|
|
mdl, |
|
|
|
|
rg->shader->num_vertex_attribs, |
|
|
|
|
rg->shader->attrib_mappings, |
|
|
|
|
"coordinate overlay", |
|
|
|
|
GL_LINES); |
|
|
|
|
scaleEntity(e, 5); |
|
|
|
|
// TODO: add a gameoverlay that can 'unproject' world coordinates to screen
|
|
|
|
|
// coords
|
|
|
|
|
setEntityPosition(e, vec3(0, -75 / SCALING + 100, 0)); |
|
|
|
|
|
|
|
|
|
return e; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
Entity* |
|
|
|
|
initEllipseEntity(RenderState* rs, |
|
|
|
|
const EllipseParameters& ep, |
|
|
|
|
@ -97,7 +142,7 @@ initEllipseEntity(RenderState* rs,
|
|
|
|
|
rg->shader->num_vertex_attribs, |
|
|
|
|
rg->shader->attrib_mappings, |
|
|
|
|
"ellipse 01", |
|
|
|
|
GL_LINE_LOOP); |
|
|
|
|
GL_LINES); |
|
|
|
|
|
|
|
|
|
return e; |
|
|
|
|
} |
|
|
|
|
@ -202,6 +247,8 @@ loadScene(GameState* gs, RenderState* rs)
|
|
|
|
|
RenderGroup* rg = getFreeRenderGroup(rs); |
|
|
|
|
initRenderGroup(rg, rs->rg_arena, shader, 256, "manual mesh group"); |
|
|
|
|
|
|
|
|
|
gs->coord_overlay = addCoordinateOverlay(rs); |
|
|
|
|
|
|
|
|
|
#if 0 |
|
|
|
|
double a = 26564.5; // semi-major axis in km
|
|
|
|
|
double e = 0.7411; // eccentricity
|
|
|
|
|
|