vr:: works with raycasting
This commit is contained in:
parent
f41414a705
commit
926ca2808a
|
@ -77,7 +77,8 @@ bool need_many_cell_types() {
|
||||||
/** is the raycaster available? */
|
/** is the raycaster available? */
|
||||||
EX bool available() {
|
EX bool available() {
|
||||||
#if CAP_VR
|
#if CAP_VR
|
||||||
if(vrhr::state) return false; /* not implemented */
|
/* would need a completely different implementation */
|
||||||
|
if(vrhr::state && vrhr::eyes == vrhr::eEyes::equidistant) return false;
|
||||||
#endif
|
#endif
|
||||||
if(noGUI) return false;
|
if(noGUI) return false;
|
||||||
if(!vid.usingGL) return false;
|
if(!vid.usingGL) return false;
|
||||||
|
@ -1338,11 +1339,16 @@ EX void cast() {
|
||||||
cd->set_viewport(global_projection);
|
cd->set_viewport(global_projection);
|
||||||
cd->set_mask(global_projection);
|
cd->set_mask(global_projection);
|
||||||
|
|
||||||
transmatrix proj = Id;
|
if(vrhr::state == 2) {
|
||||||
proj = eupush(-global_projection * d, 0) * proj;
|
glUniformMatrix4fv(o->uProjection, 1, 0, glhr::tmtogl_transpose3(vrhr::eyeproj).as_array());
|
||||||
proj = euscale(cd->tanfov / (vid.stereo_mode == sLR ? 2 : 1), cd->tanfov * cd->ysize / cd->xsize) * proj;
|
}
|
||||||
proj = eupush(-((cd->xcenter-cd->xtop)*2./cd->xsize - 1), -((cd->ycenter-cd->ytop)*2./cd->ysize - 1)) * proj;
|
else {
|
||||||
glUniformMatrix4fv(o->uProjection, 1, 0, glhr::tmtogl_transpose3(proj).as_array());
|
transmatrix proj = Id;
|
||||||
|
proj = eupush(-global_projection * d, 0) * proj;
|
||||||
|
proj = euscale(cd->tanfov / (vid.stereo_mode == sLR ? 2 : 1), cd->tanfov * cd->ysize / cd->xsize) * proj;
|
||||||
|
proj = eupush(-((cd->xcenter-cd->xtop)*2./cd->xsize - 1), -((cd->ycenter-cd->ytop)*2./cd->ysize - 1)) * proj;
|
||||||
|
glUniformMatrix4fv(o->uProjection, 1, 0, glhr::tmtogl_transpose3(proj).as_array());
|
||||||
|
}
|
||||||
|
|
||||||
if(!callhandlers(false, hooks_rayset, o)) {
|
if(!callhandlers(false, hooks_rayset, o)) {
|
||||||
|
|
||||||
|
|
8
vr.cpp
8
vr.cpp
|
@ -100,6 +100,8 @@ vr_framebuffer::vr_framebuffer(int xsize, int ysize) {
|
||||||
rb.reset();
|
rb.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EX transmatrix eyeproj;
|
||||||
|
|
||||||
vr_framebuffer::~vr_framebuffer() {
|
vr_framebuffer::~vr_framebuffer() {
|
||||||
glDeleteRenderbuffers( 1, &m_nDepthBufferId );
|
glDeleteRenderbuffers( 1, &m_nDepthBufferId );
|
||||||
glDeleteTextures( 1, &m_nRenderTextureId );
|
glDeleteTextures( 1, &m_nRenderTextureId );
|
||||||
|
@ -117,6 +119,7 @@ struct vrdata_t {
|
||||||
uint32_t xsize, ysize;
|
uint32_t xsize, ysize;
|
||||||
vr_framebuffer *eyes[2];
|
vr_framebuffer *eyes[2];
|
||||||
transmatrix proj[2];
|
transmatrix proj[2];
|
||||||
|
transmatrix iproj[2]; /* inverse of proj */
|
||||||
transmatrix eyepos[2];
|
transmatrix eyepos[2];
|
||||||
vr::TrackedDevicePose_t poses[ vr::k_unMaxTrackedDeviceCount ];
|
vr::TrackedDevicePose_t poses[ vr::k_unMaxTrackedDeviceCount ];
|
||||||
transmatrix pose_matrix[vr::k_unMaxTrackedDeviceCount ];
|
transmatrix pose_matrix[vr::k_unMaxTrackedDeviceCount ];
|
||||||
|
@ -588,6 +591,8 @@ EX void start_vr() {
|
||||||
vrdata.proj[a] =
|
vrdata.proj[a] =
|
||||||
vr_to_hr(vrdata.vr->GetProjectionMatrix(eye, 0.01, 300));
|
vr_to_hr(vrdata.vr->GetProjectionMatrix(eye, 0.01, 300));
|
||||||
|
|
||||||
|
vrdata.iproj[a] = MirrorZ * inverse(vrdata.proj[a]);
|
||||||
|
|
||||||
println(hlog, "projection = ", vrdata.proj[a]);
|
println(hlog, "projection = ", vrdata.proj[a]);
|
||||||
|
|
||||||
vrdata.eyepos[a] =
|
vrdata.eyepos[a] =
|
||||||
|
@ -788,9 +793,10 @@ EX void render() {
|
||||||
}
|
}
|
||||||
hmd_mvp = vrdata.proj[i] * hmd_mvp;
|
hmd_mvp = vrdata.proj[i] * hmd_mvp;
|
||||||
}
|
}
|
||||||
|
eyeproj = vrdata.iproj[i];
|
||||||
|
drawqueue();
|
||||||
}
|
}
|
||||||
|
|
||||||
drawqueue();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
rb.reset();
|
rb.reset();
|
||||||
|
|
Loading…
Reference in New Issue