3D drawing

This commit is contained in:
Zeno Rogue 2020-12-30 20:21:07 +01:00
parent 49f0c248bd
commit d5fc277531
3 changed files with 20 additions and 8 deletions

View File

@ -100,8 +100,8 @@ EX shiftmatrix minimize_point_value(shiftmatrix T, function<ld(const shiftmatrix
ld best = value(T); ld best = value(T);
for(int it=0; it<50; it++) for(int it=0; it<50; it++)
for(int s=0; s<4; s++) { for(int s=0; s<2*WDIM; s++) {
shiftmatrix T1 = T * spin(s * quarter_circle) * xpush(pow(1.2, -it)); shiftmatrix T1 = T * cpush(s/2, (s&1?1:-1) * pow(1.2, -it));
ld dist = value(T1); ld dist = value(T1);
if(dist < best) best = dist, T = T1; if(dist < best) best = dist, T = T1;
if(mdBandAny()) { if(mdBandAny()) {
@ -1111,8 +1111,11 @@ EX void apply_other_model(shiftpoint H_orig, hyperpoint& ret, eModel md) {
d = sqrt(2*(1 - cos(d))) * M_PI / 2; d = sqrt(2*(1 - cos(d))) * M_PI / 2;
else if(pmodel == mdEquiarea && hyperbolic) else if(pmodel == mdEquiarea && hyperbolic)
d = sqrt(2*(cosh(d) - 1)) / 1.5; d = sqrt(2*(cosh(d) - 1)) / 1.5;
ld factor = d * df / rad;
if(!vrhr::rendering()) factor /= M_PI;
ret = H * (d * df / rad / M_PI); ret = H * factor;
if(GDIM == 2) ret[2] = 0; if(GDIM == 2) ret[2] = 0;
if(MAXMDIM == 4) ret[3] = 1; if(MAXMDIM == 4) ret[3] = 1;
if(zlev != 1 && use_z_coordinate()) if(zlev != 1 && use_z_coordinate())

View File

@ -1584,7 +1584,7 @@ EX namespace mapeditor {
} }
EX shiftpoint find_mouseh3() { EX shiftpoint find_mouseh3() {
if(vrhr::active() && WDIM == 2) if(vrhr::active())
return mouseh; return mouseh;
if(front_config == eFront::sphere_camera) if(front_config == eFront::sphere_camera)
return in_front_dist(front_edit); return in_front_dist(front_edit);

17
vr.cpp
View File

@ -41,6 +41,8 @@ EX cell *forward_cell;
EX ld vraim_x, vraim_y, vrgo_x, vrgo_y; EX ld vraim_x, vraim_y, vrgo_x, vrgo_y;
EX ld pointer_length = 1;
vector<pair<string, string> > headset_desc = { vector<pair<string, string> > headset_desc = {
{"none", "Ignore the headset movement and rotation."}, {"none", "Ignore the headset movement and rotation."},
{"rotation only", "Ignore the headset movement but do not ignore its rotation."}, {"rotation only", "Ignore the headset movement but do not ignore its rotation."},
@ -472,9 +474,15 @@ ld vr_distance(shiftpoint h, int id, ld& dist) {
E4; hscr[3] = 1; E4; hscr[3] = 1;
hyperpoint hc = inverse(sm * hmd_at * vrdata.pose_matrix[id] * sm) * hmd_mv * hscr; hyperpoint hc = inverse(sm * hmd_at * vrdata.pose_matrix[id] * sm) * hmd_mv * hscr;
if(hc[2] > 0.1) return 1e6; /* behind */ if(WDIM == 2) {
dist = -hc[2]; if(hc[2] > 0.1) return 1e6; /* behind */
return sqhypot_d(2, hc); dist = -hc[2];
return sqhypot_d(2, hc);
}
else {
hc[2] += dist;
return sqhypot_d(3, hc);
}
} }
EX hyperpoint vr_direction; EX hyperpoint vr_direction;
@ -489,8 +497,9 @@ EX void compute_point(int id, shiftpoint& res, cell*& c, ld& dist) {
movedir md = vectodir(vr_direction); movedir md = vectodir(vr_direction);
cellwalker xc = cwt + md.d + wstep; cellwalker xc = cwt + md.d + wstep;
forward_cell = xc.at; forward_cell = xc.at;
return;
} }
dist = pointer_length;
gen_mv(); gen_mv();
set_vr_sphere(); set_vr_sphere();