MCPcopy Create free account
hub / github.com/ValveSoftware/openvr / UpdateControllerAxes

Method UpdateControllerAxes

samples/hellovr_vulkan/hellovr_vulkan_main.cpp:2469–2567  ·  view source on GitHub ↗

----------------------------------------------------------------------------- Purpose: Update the vertex data for the controllers as X/Y/Z lines -----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

2467// Purpose: Update the vertex data for the controllers as X/Y/Z lines
2468//-----------------------------------------------------------------------------
2469void CMainApplication::UpdateControllerAxes()
2470{
2471 // Don't attempt to update controllers if input is not available
2472 if( !m_pHMD->IsInputAvailable() )
2473 return;
2474
2475 std::vector<float> vertdataarray;
2476
2477 m_uiControllerVertcount = 0;
2478 m_iTrackedControllerCount = 0;
2479
2480 for ( vr::TrackedDeviceIndex_t unTrackedDevice = vr::k_unTrackedDeviceIndex_Hmd + 1; unTrackedDevice < vr::k_unMaxTrackedDeviceCount; ++unTrackedDevice )
2481 {
2482 if ( !m_pHMD->IsTrackedDeviceConnected( unTrackedDevice ) )
2483 continue;
2484
2485 if( m_pHMD->GetTrackedDeviceClass( unTrackedDevice ) != vr::TrackedDeviceClass_Controller )
2486 continue;
2487
2488 m_iTrackedControllerCount += 1;
2489
2490 if( !m_rTrackedDevicePose[ unTrackedDevice ].bPoseIsValid )
2491 continue;
2492
2493 const Matrix4 & mat = m_rmat4DevicePose[unTrackedDevice];
2494
2495 Vector4 center = mat * Vector4( 0, 0, 0, 1 );
2496
2497 for ( int i = 0; i < 3; ++i )
2498 {
2499 Vector3 color( 0, 0, 0 );
2500 Vector4 point( 0, 0, 0, 1 );
2501 point[i] += 0.05f; // offset in X, Y, Z
2502 color[i] = 1.0; // R, G, B
2503 point = mat * point;
2504 vertdataarray.push_back( center.x );
2505 vertdataarray.push_back( center.y );
2506 vertdataarray.push_back( center.z );
2507
2508 vertdataarray.push_back( color.x );
2509 vertdataarray.push_back( color.y );
2510 vertdataarray.push_back( color.z );
2511
2512 vertdataarray.push_back( point.x );
2513 vertdataarray.push_back( point.y );
2514 vertdataarray.push_back( point.z );
2515
2516 vertdataarray.push_back( color.x );
2517 vertdataarray.push_back( color.y );
2518 vertdataarray.push_back( color.z );
2519
2520 m_uiControllerVertcount += 2;
2521 }
2522
2523 Vector4 start = mat * Vector4( 0, 0, -0.02f, 1 );
2524 Vector4 end = mat * Vector4( 0, 0, -39.f, 1 );
2525 Vector3 color( .92f, .92f, .71f );
2526

Callers

nothing calls this directly

Calls 7

Vector4Class · 0.85
CreateVulkanBufferFunction · 0.85
IsInputAvailableMethod · 0.80
sizeMethod · 0.80
dprintfFunction · 0.70
GetTrackedDeviceClassMethod · 0.45

Tested by

no test coverage detected