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

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

Issue 2775283004: Rendering Daydream controller in a fixed position. (Closed)
Patch Set: Removing ownership of Buffers from the gltf asset 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..b5fb5bfca1476f172090ad1ea7ca42404d0ed66e 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,35 @@ void VrShellGl::DrawCursor(const gvr::Mat4f& render_matrix) {
}
}
+void VrShellGl::DrawController(const gvr::Mat4f& view_proj_matrix) {
asimjour1 2017/03/29 20:40:44 I think this method also doesn't belong here. it s
+ if (!vr_shell_renderer_->GetControllerRenderer()->IsSetUp())
+ return;
+ // TODO(acondor): Placing the controller in a fixed position before
amp 2017/03/29 20:54:56 Format the TODO's as what needs to be done next, n
acondor_ 2017/03/29 22:46:44 Done.
+ // implementing the elbow model.
+ gvr::Mat4f mat;
+ SetIdentityM(mat);
+ // Changing rotation point.
+ TranslateM(mat, mat, 0, 0, 0.05);
cjgrant 2017/03/29 20:22:38 Normally you'd want a constant for 0.05, but assum
acondor_ 2017/03/29 22:46:45 Acknowledged.
+ mat = MatrixMul(QuatToMatrix(controller_->Orientation()), mat);
+ TranslateM(mat, mat, kControllerPosition.x, kControllerPosition.y,
+ kControllerPosition.z - 0.05);
+
+ auto transform = MatrixMul(view_proj_matrix, mat);
+
+ VrControllerModel::State state = VrControllerModel::IDLE;
+ 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(state, transform);
+}
+
bool VrShellGl::ShouldDrawWebVr() {
return web_vr_mode_ && scene_->GetWebVrRenderingEnabled();
}
@@ -1189,6 +1220,10 @@ base::WeakPtr<VrShellGl> VrShellGl::GetWeakPtr() {
return weak_ptr_factory_.GetWeakPtr();
}
+void VrShellGl::SetControllerModel(std::unique_ptr<VrControllerModel> model) {
+ vr_shell_renderer_->GetControllerRenderer()->SetUp(std::move(model));
+}
+
void VrShellGl::OnVSync() {
while (premature_received_frames_ > 0) {
TRACE_EVENT0("gpu", "VrShellGl::OnWebVRFrameAvailableRetry");

Powered by Google App Engine
This is Rietveld 408576698