fix stroke preview, use hmd pose instead of eye, fix vr fullscreen mode
This commit is contained in:
@@ -80,6 +80,7 @@ public:
|
||||
bool keys[256];
|
||||
bool redraw = true;
|
||||
bool animate = false;
|
||||
bool ui_visible = true;
|
||||
glm::mat4 vr_rot{ 0 };
|
||||
glm::mat4 vr_uirot{ 0 };
|
||||
glm::vec2 cursor{ 0, 0 };
|
||||
@@ -124,7 +125,7 @@ public:
|
||||
void clear();
|
||||
void tick(float dt);
|
||||
void update(float dt);
|
||||
void vr_draw(const glm::mat4& proj, const glm::mat4& view);
|
||||
void vr_draw(const glm::mat4& proj, const glm::mat4& view, const glm::mat4& pose);
|
||||
void async_start();
|
||||
void async_update();
|
||||
void async_redraw();
|
||||
|
||||
@@ -301,11 +301,10 @@ bool App::key_char(char key)
|
||||
|
||||
void App::toggle_ui()
|
||||
{
|
||||
static bool fullscreen = false;
|
||||
auto m = layout[main_id]->m_children[1];
|
||||
ui_visible = !ui_visible;
|
||||
for (int i = 1; i < m->m_children.size(); i++)
|
||||
m->m_children[i]->m_display = fullscreen;
|
||||
fullscreen = !fullscreen;
|
||||
m->m_children[i]->m_display = ui_visible;
|
||||
}
|
||||
|
||||
void App::set_stylus()
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
#include "pch.h"
|
||||
#include "app.h"
|
||||
|
||||
void App::vr_draw(const glm::mat4& proj, const glm::mat4& camera)
|
||||
void App::vr_draw(const glm::mat4& proj, const glm::mat4& camera, const glm::mat4& pose)
|
||||
{
|
||||
using namespace ui;
|
||||
|
||||
@@ -14,7 +14,7 @@ void App::vr_draw(const glm::mat4& proj, const glm::mat4& camera)
|
||||
// glm::scale(glm::vec3(sz, 1));
|
||||
|
||||
//glm::extractEulerAngleXYZ(camera, vr_rot.y, vr_rot.x, vr_rot.z);
|
||||
vr_rot = camera;
|
||||
vr_rot = pose;
|
||||
|
||||
sampler.bind(0);
|
||||
sampler.bind(1);
|
||||
@@ -141,19 +141,32 @@ void App::vr_draw(const glm::mat4& proj, const glm::mat4& camera)
|
||||
|
||||
float tan_fov = glm::tan(glm::radians(canvas->m_canvas->m_cam_fov / 2.f));
|
||||
glm::vec3 aspect = { (float)uirtt.getWidth() / (float)uirtt.getHeight(), 1.f, 1.f };
|
||||
// draw the 2D UI
|
||||
|
||||
// draw the frame
|
||||
{
|
||||
auto plane_mvp_z = proj * camera *
|
||||
auto mvp = proj * camera *
|
||||
glm::scale(glm::vec3(100)) *
|
||||
glm::transpose(canvas->m_canvas->m_cam_rot) *
|
||||
glm::translate(glm::vec3(0, 0, -1)) *
|
||||
glm::scale(aspect * tan_fov);
|
||||
ui::ShaderManager::use(kShader::Color);
|
||||
ui::ShaderManager::u_vec4(kShaderUniform::Col, { 0, 0, 0, 1 });
|
||||
ui::ShaderManager::u_mat4(kShaderUniform::MVP, mvp);
|
||||
m_face_plane.draw_stroke();
|
||||
}
|
||||
|
||||
// draw the 2D UI
|
||||
if (ui_visible)
|
||||
{
|
||||
auto mvp = proj * camera *
|
||||
glm::scale(glm::vec3(100)) *
|
||||
//glm::eulerAngleYXZ(yaw, pitch, roll) *
|
||||
//canvas->m_canvas->m_plane_transform[plane_index] *
|
||||
glm::transpose(canvas->m_canvas->m_cam_rot) *
|
||||
glm::translate(glm::vec3(0, 0, -1)) *
|
||||
glm::scale(aspect * tan_fov);
|
||||
sampler.bind(0);
|
||||
ui::ShaderManager::use(kShader::Texture);
|
||||
ui::ShaderManager::u_int(kShaderUniform::Tex, 0);
|
||||
ui::ShaderManager::u_mat4(kShaderUniform::MVP, plane_mvp_z);
|
||||
ui::ShaderManager::u_mat4(kShaderUniform::MVP, mvp);
|
||||
glActiveTexture(GL_TEXTURE0);
|
||||
uirtt.bindTexture();
|
||||
m_face_plane.draw_fill();
|
||||
|
||||
@@ -201,7 +201,7 @@ void Vive::Draw()
|
||||
}
|
||||
|
||||
if (on_draw)
|
||||
on_draw(proj[eye], view[eye]);
|
||||
on_draw(proj[eye], view[eye], mat_pose);
|
||||
|
||||
eyes[eye].unbindFramebuffer();
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ struct Vive
|
||||
std::string dev_model{ "Vive" };
|
||||
std::string dev_tracksys{ "lighthouse" };
|
||||
std::string dev_manufacturer{ "HTC" };
|
||||
std::function<void(const glm::mat4& proj, const glm::mat4& view)> on_draw = nullptr;
|
||||
std::function<void(const glm::mat4& proj, const glm::mat4& view, const glm::mat4& pose)> on_draw = nullptr;
|
||||
std::function<void(const Controller&, Controller::Button, Controller::Action)> on_button = nullptr;
|
||||
|
||||
Vive();
|
||||
|
||||
@@ -569,7 +569,7 @@ int main(int argc, char** argv)
|
||||
if (!sandboxed)
|
||||
{
|
||||
vive = new Vive;
|
||||
vive->on_draw = [](const glm::mat4& proj, const glm::mat4& view) { App::I.vr_draw(proj, view); };
|
||||
vive->on_draw = [](const glm::mat4& proj, const glm::mat4& view, const glm::mat4& pose) { App::I.vr_draw(proj, view, pose); };
|
||||
async_lock();
|
||||
if (!vive->Initialize())
|
||||
{
|
||||
|
||||
@@ -69,6 +69,8 @@ void NodeStrokePreview::draw_stroke()
|
||||
glm::mat4 proj = glm::ortho<float>(0, (float)m_rtt.getWidth(), 0, (float)m_rtt.getHeight(), -1, 1);
|
||||
|
||||
auto b = m_brush;
|
||||
m_stroke.m_camera.fov = ui::Canvas::I->m_cam_fov;
|
||||
m_stroke.m_camera.rot = ui::Canvas::I->m_cam_rot;
|
||||
m_stroke.reset();
|
||||
m_stroke.start(b);
|
||||
if (!m_stroke.m_keypoints.empty())
|
||||
|
||||
@@ -9,6 +9,7 @@ RTT::RTT()
|
||||
rboID = 0;
|
||||
w = 0;
|
||||
h = 0;
|
||||
bound = false;
|
||||
}
|
||||
|
||||
RTT::~RTT()
|
||||
|
||||
Reference in New Issue
Block a user