1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-12-25 01:20:37 +00:00

more intuitive 3D setting

This commit is contained in:
Zeno Rogue 2022-12-15 12:48:25 +01:00
parent 18cc8cbba3
commit 9498a1de03
2 changed files with 64 additions and 20 deletions

View File

@ -837,6 +837,9 @@ EX void initConfig() {
param_f(geom3::euclid_embed_scale, "euclid_embed_scale", "euclid_embed_scale");
param_b(geom3::auto_configure, "auto_configure_3d", "auto_configure_3d")
-> editable("set 3D settings automatically", 'A');
param_enum(geom3::spatial_embedding, "spatial_embedding", "spatial_embedding", geom3::seDefault)
->editable(geom3::spatial_embedding_options, "3D embedding method", 'E')
->set_reaction([] {
@ -2203,6 +2206,53 @@ EX void edit_levellines(char c) {
});
}
EX geom3::eSpatialEmbedding shown_spatial_embedding() {
if(GDIM == 2) {
if(pmodel == mdDisk && pconf.camera_angle)
return geom3::seTPP;
else
return geom3::seNone;
}
return geom3::spatial_embedding;
}
EX void show_spatial_embedding() {
cmode = sm::SIDE | sm::MAYDARK | sm::CENTER | sm::PANNING | sm::SHOWCURSOR;
gamescreen();
dialog::init(XLAT("3D styles"));
auto emb = shown_spatial_embedding();
add_edit(geom3::auto_configure);
dialog::addBreak(100);
auto &seo = geom3::spatial_embedding_options;
for(int i=0; i<isize(seo); i++) {
auto se = geom3::eSpatialEmbedding(i);
if(!geom3::auto_configure && geom3::is_suboption(se)) continue;
dialog::addBoolItem(XLAT(seo[i].first), emb == i, 'a' + i);
dialog::add_action([se, emb] {
if(GDIM == 3) { if(geom3::auto_configure) geom3::switch_fpp(); else geom3::switch_always3(); }
if(se == geom3::seNone && emb == geom3::seTPP) geom3::switch_tpp();
if(se == geom3::seTPP && emb == geom3::seNone) geom3::switch_tpp();
if(se != geom3::seNone && se != geom3::seTPP) {
println(hlog, "set spatial_embedding to ", int(se));
geom3::spatial_embedding = se;
if(geom3::auto_configure) geom3::switch_fpp(); else geom3::switch_always3();
delete_sky();
resetGL();
}
});
}
dialog::addBreak(100);
dialog::addHelp(XLAT(seo[emb].second));
dialog::addBreak(100);
dialog::addBack();
dialog::display();
}
EX void show3D() {
cmode = sm::SIDE | sm::MAYDARK;
gamescreen();
@ -2210,27 +2260,12 @@ EX void show3D() {
#if MAXMDIM >=4
if(WDIM == 2) {
if(WDIM == 2) add_edit(geom3::spatial_embedding);
dialog::addBoolItem(XLAT("configure FPP automatically"), GDIM == 3, 'F');
dialog::add_action(geom3::switch_fpp);
dialog::addSelItem("3D style", geom3::spatial_embedding_options[shown_spatial_embedding()].first, 'E');
dialog::add_action_push(show_spatial_embedding);
dialog::addBreak(50);
}
#endif
dialog::addBreak(50);
if(GDIM == 2) {
dialog::addBoolItem(XLAT("configure TPP automatically"), pmodel == mdDisk && pconf.camera_angle, 'T');
dialog::add_action(geom3::switch_tpp);
}
dialog::addBreak(50);
#if MAXMDIM >= 4
if(WDIM == 2) {
dialog::addBoolItem(XLAT("use the full 3D models"), vid.always3, 'U');
dialog::add_action(geom3::switch_always3);
}
#endif
if(vid.use_smart_range == 0 && GDIM == 2) {
add_edit(vid.highdetail);
add_edit(vid.middetail);

View File

@ -1073,6 +1073,8 @@ EX namespace geom3 {
#if HDR
enum eSpatialEmbedding {
seNone,
seTPP,
seDefault,
seFlat,
seInverted,
@ -1088,7 +1090,9 @@ EX namespace geom3 {
#endif
EX vector<pair<string, string>> spatial_embedding_options = {
{"default", "Embed as a equidistant surface in the 3D version of the same geometry. This is the model used by HyperRogue in its 2D graphics."},
{"2D engine", "Use HyperRogue's 2D engine to simulate 'default 3D' top-down."},
{"2D engine in TPP","HyperRogue's 2D engine, but using third-person perspective."},
{"default 3D", "Embed as a equidistant surface in the 3D version of the same geometry."},
{"flat", "Embed as a flat surface in the 3D version of the same geometry."},
{"inverted", "Embed as a equidistant surface, but this time it is inverted."},
{"lower curvature", "Embed as a convex surface in a space of lower curvature."},
@ -1103,8 +1107,13 @@ EX namespace geom3 {
{"stretched hyperbolic inverted", "Embed into stretched hyperbolic geometry as a concave horosphere. Works only with Euclidean. You need to set the variation to Pure."},
};
EX eSpatialEmbedding spatial_embedding;
EX eSpatialEmbedding spatial_embedding = seDefault;
EX ld euclid_embed_scale = 1;
EX bool auto_configure = true;
EX bool is_suboption(eSpatialEmbedding se) {
return among(se, seTPP, seInverted, seFlat, seLowerCurvatureInverted, seMuchLowerCurvatureInverted, seNIH_inv);
}
EX vector<geometryinfo> ginf_backup;