implement motion controllers and vr drawing with brush preview

This commit is contained in:
2018-11-02 13:49:15 +01:00
parent 3b73e84fe9
commit 3ee10bb88d
13 changed files with 202 additions and 46 deletions

View File

@@ -219,6 +219,41 @@ void App::vr_draw(const glm::mat4& proj, const glm::mat4& camera, const glm::mat
m_face_plane.draw_fill();
}
// draw the motion controller sphere
/*
{
auto mvp = proj * camera * glm::translate(glm::normalize(vr_controller_pos));
ui::ShaderManager::use(kShader::Color);
ui::ShaderManager::u_vec4(kShaderUniform::Col, { 0, 0, 0, 1 });
ui::ShaderManager::u_mat4(kShaderUniform::MVP, mvp * glm::scale(glm::vec3(.025)));
sphere.draw_fill();
}
*/
// draw the motion controller brush
{
auto pos = glm::translate(glm::normalize(vr_controller_pos));
ui::ShaderManager::use(ui::kShader::StrokePreview);
ui::ShaderManager::u_int(ui::kShaderUniform::Tex, 0);
ui::ShaderManager::u_float(ui::kShaderUniform::Alpha, canvas->m_canvas->m_current_brush.m_tip_flow);
auto tip_color = glm::vec4(glm::vec3(canvas->m_canvas->m_current_brush.m_tip_color), 1);
ui::ShaderManager::u_vec4(ui::kShaderUniform::Col, tip_color);
ui::ShaderManager::u_mat4(ui::kShaderUniform::MVP,
proj * camera * pos *
glm::inverse(glm::lookAt({ 0, 0, 0 }, vr_controller_pos, { 0, 1, 0 })) *
//glm::scale(glm::vec3(0.1)) *
glm::scale(glm::vec3(canvas->m_canvas->m_current_brush.m_tip_size * 800.f / App::I.height)) *
glm::eulerAngleZ(canvas->m_canvas->m_current_brush.m_tip_angle * (float)(M_PI * 2.0))
);
glEnable(GL_BLEND);
glActiveTexture(GL_TEXTURE0);
auto& tex = TextureManager::get(canvas->m_canvas->m_current_brush.m_tex_id);
tex.bind();
sampler_linear.bind(0);
m_face_plane.draw_fill();
tex.unbind();
}
/*
for (auto& mode : *m_canvas->m_mode)
mode->on_Draw(ortho_proj, proj, camera);