Jump to content

Vive Lock position


photo

Recommended Posts

Hello everyone, I am using a HTC Vive. And have the problem that as soon as I lock the position of the headset, the position of the VR player is not on the same position as that of the headset. But is approximately around the vector (0.5, 0.5, 1.7) shifted.

 

Here is an example:

int AppWorldLogic::init()
{       
    proxy = new AppViveProxy();
    proxy->init();

    proxy->setHeadPositionLock(1);
    
    return 1;
}

int AppWorldLogic::update()
{
    VRPlayer* vr_player = VRPlayer::get();
    NodePtr Node1 = World::getNodeByName("NodeDummy_3");
    vr_player->getPlayer()->setWorldTransform(Node1->getWorldTransform());
    

    
    return 1;
}

Link to comment

Hello silent,
unfortunately this has not solved my problem yet. I'll try to explain it a bit more in detail again. 
When I rotate the controller in front of the VR glasses, the controller rotates around the axis of the offset and not around the locked VR glasses position.

Thanks

Link to comment

Hello,

You can try to fix the controller position update function void controller_update(int num, const Mat4 &player_transform, int device_id) in class VRPlayerVive.

void VRPlayerVive::controller_update(int num, const Mat4 &player_transform, int device_id)
{
	if (device_id != -1 && vive.isDeviceConnected(device_id))
	{
		mat4 transform = vive.getDevicePose(device_id);

		// get controller position for custom player transform
		Mat4 hmd_transform = Mat4(vive.getDevicePose(HMD_DEVICE_0));
		vec3 delta = inverse(translate(hmd_transform.getTranslate())) * transform.getTranslate();
		transform.setColumn3(3, delta);

		controller[num]->setWorldTransform(player_transform * Mat4(transform) * Mat4(rotateX(-90.0f)));
//...
}

We change the position of the controller from global to local relative to the HMD.

  • Like 1
Link to comment
×
×
  • Create New...