Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1511)

Unified Diff: chrome/browser/android/vr_shell/vr_shell_gl.cc

Issue 2775283004: Rendering Daydream controller in a fixed position. (Closed)
Patch Set: Using textures for corresponding button states. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/android/vr_shell/vr_shell_gl.cc
diff --git a/chrome/browser/android/vr_shell/vr_shell_gl.cc b/chrome/browser/android/vr_shell/vr_shell_gl.cc
index c3b906768d2fd7e09fea01670323b19e788e14ad..5f2210afa4cf32c1c591673cabe802f49de3a11a 100644
--- a/chrome/browser/android/vr_shell/vr_shell_gl.cc
+++ b/chrome/browser/android/vr_shell/vr_shell_gl.cc
@@ -56,6 +56,7 @@ static constexpr gvr::Vec3f kOrigin = {0.0f, 0.0f, 0.0f};
// In lieu of an elbow model, we assume a position for the user's hand.
// TODO(mthiesse): Handedness options.
static constexpr gvr::Vec3f kHandPosition = {0.2f, -0.5f, -0.2f};
+static constexpr gvr::Vec3f kControllerPosition = {0.2f, -0.5f, -0.15f};
// Fraction of the distance to the object the cursor is drawn at to avoid
// rounding errors drawing the cursor behind the object.
@@ -935,6 +936,7 @@ void VrShellGl::DrawUiView(const gvr::Mat4f& head_pose,
DrawElements(render_matrix, elementsInDrawOrder);
if (draw_cursor) {
DrawCursor(render_matrix);
+ DrawController(render_matrix);
}
}
}
@@ -1095,6 +1097,33 @@ void VrShellGl::DrawCursor(const gvr::Mat4f& render_matrix) {
}
}
+void VrShellGl::DrawController(const gvr::Mat4f& view_proj_matrix) {
+ if (!controller_model_)
+ return;
+ gvr::Mat4f mat;
+ SetIdentityM(mat);
+ // TODO(acondor): Placing controller in temporary position before
cjgrant 2017/03/29 13:20:54 Maybe I'm missing something, but in addition to pu
acondor_ 2017/03/29 20:13:26 Done. It will be changed to the elbow model soon,
cjgrant 2017/03/29 20:22:37 Thanks. From a live demo, this looks really good
+ // implementing the elbow model.
+ TranslateM(mat, mat, kControllerPosition.x, kControllerPosition.y,
+ kControllerPosition.z);
+
+ auto transform = MatrixMul(view_proj_matrix, mat);
+
+ VrControllerModel::State state = VrControllerModel::IDLE;
cjgrant 2017/03/29 13:20:54 - Volume buttons? - Can multiple buttons be presse
acondor_ 2017/03/29 20:13:26 I'm not sure if they can, but the textures provide
+ if (controller_->ButtonState(
+ gvr::ControllerButton::GVR_CONTROLLER_BUTTON_CLICK))
+ state = VrControllerModel::TOUCHPAD;
+ else if (controller_->ButtonState(
+ gvr::ControllerButton::GVR_CONTROLLER_BUTTON_APP))
+ state = VrControllerModel::APP;
+ else if (controller_->ButtonState(
+ gvr::ControllerButton::GVR_CONTROLLER_BUTTON_HOME))
+ state = VrControllerModel::SYSTEM;
+
+ vr_shell_renderer_->GetControllerRenderer()->Draw(*controller_model_, state,
+ transform);
+}
+
bool VrShellGl::ShouldDrawWebVr() {
return web_vr_mode_ && scene_->GetWebVrRenderingEnabled();
}
@@ -1189,6 +1218,12 @@ base::WeakPtr<VrShellGl> VrShellGl::GetWeakPtr() {
return weak_ptr_factory_.GetWeakPtr();
}
+void VrShellGl::SetControllerModel(std::unique_ptr<VrControllerModel> model) {
+ controller_model_ = std::move(model);
+ vr_shell_renderer_->GetControllerRenderer()->SetUp(*controller_model_);
+ controller_model_->Free();
cjgrant 2017/03/29 13:20:54 Michael already commented on this Free() approach.
acondor_ 2017/03/29 20:13:26 The new approach is that the renderer gathers all
+}
+
void VrShellGl::OnVSync() {
while (premature_received_frames_ > 0) {
TRACE_EVENT0("gpu", "VrShellGl::OnWebVRFrameAvailableRetry");

Powered by Google App Engine
This is Rietveld 408576698