work on openxr controllers
This commit is contained in:
@@ -25,16 +25,11 @@ void C_MOBAPlayer::Think( float fDelta )
|
||||
|
||||
if (pPlayerEntity == this)
|
||||
{
|
||||
Vector vCameraPos;
|
||||
vCameraPos = GetAbsOrigin();
|
||||
vCameraPos.z = 20;
|
||||
vCameraPos.y+=3;
|
||||
g_pWorldRenderer->SetCameraPosition(vCameraPos);
|
||||
Quat vCameraRot;
|
||||
glm_euler_yxz_quat((vec3){m_fPitch, m_fYaw, 0}, *(versor*)&vCameraRot);
|
||||
g_pWorldRenderer->SetCameraRotation(vCameraRot);
|
||||
}
|
||||
m_pLeftHand = (C_MOBAPlayerHandController*)EntitySystem()->GetEntities()[m_leftHandId];
|
||||
m_pRightHand = (C_MOBAPlayerHandController*)EntitySystem()->GetEntities()[m_rightHandId];
|
||||
BaseClass::Think(fDelta);
|
||||
V_printf("device: %p %p\n", m_pLeftHand, m_pRightHand );
|
||||
};
|
||||
|
||||
LINK_ENTITY_TO_CLASS(player, C_MOBAPlayer)
|
||||
@@ -43,6 +38,8 @@ BEGIN_DATADESC(C_MOBAPlayer)
|
||||
END_DATADESC()
|
||||
|
||||
IMPLEMENT_RECV_DT(C_MOBAPlayer)
|
||||
NetPropInt(m_leftHandId),
|
||||
NetPropInt(m_rightHandId),
|
||||
END_RECV_DT()
|
||||
|
||||
IMPLEMENT_SEND_DT(C_MOBAPlayer)
|
||||
@@ -162,3 +159,63 @@ void Game_OnGameAxisDiff( EInputDeviceType eDevice, EInputAxis eAxis, float fVal
|
||||
}
|
||||
|
||||
|
||||
void C_MOBAPlayerHandController::Precache()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void C_MOBAPlayerHandController::Spawn()
|
||||
{
|
||||
BaseClass::Spawn();
|
||||
SetThink(Think);
|
||||
};
|
||||
|
||||
void C_MOBAPlayerHandController::Think( float fDelta )
|
||||
{
|
||||
V_printf("controller: %p %f %f %f\n", this, m_vDesiredHandPosition.x, m_vDesiredHandPosition.y, m_vDesiredHandPosition.z );
|
||||
SetAbsOrigin(m_vDesiredHandPosition);
|
||||
BaseClass::Think(fDelta);
|
||||
};
|
||||
|
||||
LINK_ENTITY_TO_CLASS(player_hand_controller, C_MOBAPlayerHandController)
|
||||
|
||||
BEGIN_DATADESC(C_MOBAPlayerHandController)
|
||||
END_DATADESC()
|
||||
|
||||
IMPLEMENT_RECV_DT(C_MOBAPlayerHandController)
|
||||
END_RECV_DT()
|
||||
|
||||
IMPLEMENT_SEND_DT(C_MOBAPlayerHandController)
|
||||
END_SEND_DT()
|
||||
|
||||
void XRInputCallback( IXRController *pController, EXRInputType_t eType, const char *szType, EXRInputActionType_t action, EXRInputValue_t value )
|
||||
{
|
||||
|
||||
C_BaseEntity *pPlayer = UTIL_GetLocalPlayer();
|
||||
if (!pPlayer)
|
||||
return;
|
||||
if (!dynamic_cast<C_MOBAPlayer*>(pPlayer))
|
||||
return;
|
||||
C_MOBAPlayer *p = (C_MOBAPlayer*)pPlayer;
|
||||
C_MOBAPlayerHandController *pCon = NULL;
|
||||
|
||||
if (pController->GetControllerSide() == k_EXRController_Left)
|
||||
pCon = p->m_pLeftHand;
|
||||
|
||||
if (pController->GetControllerSide() == k_EXRController_Right)
|
||||
pCon = p->m_pRightHand;
|
||||
|
||||
if (pCon == NULL)
|
||||
return;
|
||||
|
||||
switch (action)
|
||||
{
|
||||
case k_EXRInputAction_Pose:
|
||||
pCon->m_vDesiredHandPosition = value.pose.pos;
|
||||
V_printf("callback: %p %f %f %f\n", pCon, pCon->m_vDesiredHandPosition.x, pCon->m_vDesiredHandPosition.y, pCon->m_vDesiredHandPosition.z );
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user