use vr hiddenarea mask

This commit is contained in:
milek7
2020-11-18 22:18:28 +01:00
parent 8889872f39
commit 79b0216b55
7 changed files with 82 additions and 7 deletions

View File

@@ -25,8 +25,39 @@ vr_openvr::vr_openvr()
vr::VRInput()->GetActionSetHandle("/actions/main", &actionset);
vr::VRInput()->GetActionHandle("/actions/main/in/PrimaryAction", &primary_action);
vr::VRInput()->GetActionHandle("/actions/main/in/SecondaryAction", &secondary_action);
hiddenarea_mesh[(size_t)vr_interface::eye_left] = create_hiddenarea_model(vr_interface::eye_left);
hiddenarea_mesh[(size_t)vr_interface::eye_right] = create_hiddenarea_model(vr_interface::eye_right);
}
std::unique_ptr<TModel3d> vr_openvr::create_hiddenarea_model(vr_interface::eye_e e)
{
vr::HiddenAreaMesh_t mesh = vr_system->GetHiddenAreaMesh((e == vr_interface::eye_left) ? vr::Eye_Left : vr::Eye_Right, vr::k_eHiddenAreaMesh_Standard);
if (!mesh.unTriangleCount)
return nullptr;
gfx::vertex_array vertices;
for (size_t v = 0; v < mesh.unTriangleCount * 3; v++) {
const vr::HmdVector2_t vertex = mesh.pVertexData[v];
vertices.push_back(gfx::basic_vertex(
glm::vec3(vertex.v[0], vertex.v[1], 0.0f),
glm::vec3(0.0f),
glm::vec2(0.0f)));
}
std::unique_ptr<TModel3d> model = std::make_unique<TModel3d>();
model->AppendChildFromGeometry("__root", "none", vertices, gfx::index_array());
model->Init();
return model;
}
TModel3d* vr_openvr::get_hiddenarea_mesh(eye_e eye)
{
return hiddenarea_mesh[(size_t)eye].get();
};
glm::ivec2 vr_openvr::get_target_size()
{
uint32_t vr_w, vr_h;

View File

@@ -22,6 +22,8 @@ private:
vr::VRInputValueHandle_t inputhandle_left = 0;
vr::VRInputValueHandle_t inputhandle_right = 0;
std::array<std::unique_ptr<TModel3d>, 2> hiddenarea_mesh;
uint32_t primary_controller;
glm::mat4 primary_controller_transform;
@@ -29,6 +31,7 @@ private:
bool update_component(const std::string &rendermodel, vr::VRInputValueHandle_t handle, TSubModel *component);
glm::mat4 get_matrix(const vr::HmdMatrix34_t &src);
std::unique_ptr<TModel3d> create_hiddenarea_model(eye_e e);
vr::VRActionSetHandle_t actionset = 0;
vr::VRActionHandle_t primary_action = 0;
@@ -52,6 +55,7 @@ public:
void begin_frame() override;
void submit(eye_e, opengl_texture*) override;
std::vector<TModel3d*> get_render_models() override;
TModel3d* get_hiddenarea_mesh(eye_e) override;
glm::mat4 get_pick_transform() override;
void finish_frame() override;
~vr_openvr() override;

View File

@@ -12,6 +12,7 @@ public:
};
virtual viewport_proj_config get_proj_config(eye_e) = 0;
virtual TModel3d* get_hiddenarea_mesh(eye_e) = 0;
virtual glm::ivec2 get_target_size() = 0;
virtual void begin_frame() = 0;
virtual void submit(eye_e, opengl_texture*) = 0;