openvr icon indicating copy to clipboard operation
openvr copied to clipboard

Change pitch and roll rotation of universe

Open DantaliaN00 opened this issue 8 years ago • 13 comments

I'm trying to rotate seat position by

vr::VRChaperoneSetup()->GetWorkingStandingZeroPoseToRawTrackingPose(&curPos);
vr::VRChaperoneSetup()->SetWorkingStandingZeroPoseToRawTrackingPose(&newPos);

If I rotate by Y-axis everything fine. But if I try rotate by X-axis or Z-axis, SetPose do not save new position

Any ideas?

DantaliaN00 avatar Jun 07 '18 04:06 DantaliaN00

Another try

vr::TrackedDevicePose_t trackedDevicePose_all_devices[16];
vr::VRSystem()->GetDeviceToAbsoluteTrackingPose(universe, 0, trackedDevicePose_all_devices, 16);

vr::TrackedDevicePose_t newPose;
vr::VRSystem()->ApplyTransform(&newPose, &trackedDevicePose_all_devices[0], &rotMat);

ApplyTransform change newPose, but not current device position and rotation

DantaliaN00 avatar Jun 07 '18 16:06 DantaliaN00

There is no API to change the pitch and roll of the universe. Pitch and roll is determined by the driver (Lighthouse, Oculus, Windows MR, etc).

The second API ("ApplyTransform") is a utility function to ensure that all of the parts of the pose (velocity, acceleration, angular velocity, etc) are updated appropriately for you given a desired transformation. It is a pure function that does not affect the results of any other API call.

bjj avatar Jun 08 '18 03:06 bjj

Thanks for answer. One more question..

Can I use virtual uint32_t DriverDebugRequest( vr::TrackedDeviceIndex_t unDeviceIndex, const char *pchRequest, VR_OUT_STRING() char *pchResponseBuffer, uint32_t unResponseBufferSize ) = 0; to change driver data? I can't find usage example for this function

DantaliaN00 avatar Jun 08 '18 06:06 DantaliaN00

That call is just for the convenience of driver writers to be able to talk to their drivers in driver-specific ways.

bjj avatar Jun 08 '18 06:06 bjj

Bad news. But still thanks

DantaliaN00 avatar Jun 08 '18 06:06 DantaliaN00

This is not trivial. You'll need to develop a 'hook' driver that intercepts the TrackedDevicePoseUpdated() method of the VRServerDriverHost and modify it before passing it to the original VRServerDriverHost method. You are going to have to figure out how to do that yourself. Use the PseudoVive project as a starting point for developing a 'hook' driver.

TheDeveloperGuy avatar Jun 08 '18 09:06 TheDeveloperGuy

For some reasons I need use oculus or same devices with they motion controllers.

If I create my own driver, I'll need to represent all behavior of current oculus driver. This is really not good way for me

Can I somehow use current VR driver and make something like "patch" for it?

DantaliaN00 avatar Jun 08 '18 10:06 DantaliaN00

That is what a 'hook' driver is, one that patches an existing driver. Now go and do your research... ;)

TheDeveloperGuy avatar Jun 08 '18 10:06 TheDeveloperGuy

Thanks, man. Now i understand what it does

https://github.com/schellingb/PseudoVive/blob/master/Source/driver_2vive.cpp

DantaliaN00 avatar Jun 08 '18 10:06 DantaliaN00

I'm trying to make it real.. but something went wrong

I create my own TrackedDevicePoseUpdated method, and trying to set pose.

In SteamVR headset mirror everything as i want. but in oculus rift I see "real" space rotation with black border

something like that

image

Why this happens?

Code


virtual void TrackedDevicePoseUpdated(uint32_t unWhichDevice, const vr::DriverPose_t & newPose, uint32_t unPoseStructSize)
	{
		auto* self = (vr::IVRServerDriverHost*)this;

		vr::DriverPose_t pose = {0};

		if (unWhichDevice == vr::k_unTrackedDeviceIndex_Hmd)
		{
			pose.poseIsValid = true;
			pose.result = vr::TrackingResult_Running_OK;
			pose.deviceIsConnected = true;

			pose.qWorldFromDriverRotation = HmdQuaternion_Init(1, 0, 0, 0);
			pose.qDriverFromHeadRotation = HmdQuaternion_Init(1, 0, 0, 0);

			 //tmp rotate by 30 degree by X axis
			auto baseRotation = HmdQuaternion_Init(0.966, 0.259, 0.0, 0.0);
			pose.qRotation = QuaternionMultiple(baseRotation, newPose.qRotation);
		} 
		else
		{
			pose = newPose;
		}

		Org_TrackedDevicePoseUpdated(self, unWhichDevice, pose, unPoseStructSize);
	}

DantaliaN00 avatar Jun 15 '18 14:06 DantaliaN00

You're tricking the game into rendering the tilted image, but the Oculus SW knows what the latest true pose is (internally) and is doing rotational reprojection ("async timewarp" I think they call it) to correct the image.

bjj avatar Jun 15 '18 16:06 bjj

I don't think oculus use some timewarp, b/c I made change every function call But definitely somewhere has one more place with change space

I really want to find it

By the way.. If i run steam vr room settings, i see correct space rotation in my glasses. But only for short time when i make room setup

Is it a specific oculus behavior? Maybe if i try to use Vive or another glasses everything was fine.. But how to know that before buy new device?

DantaliaN00 avatar Jun 15 '18 23:06 DantaliaN00

This is a really Oculus bug ̷o̷r̷ ̷f̷e̷a̷t̷u̷r̷e̷ Everything fine with MS Mixed Reality

Thanks all

DantaliaN00 avatar Jun 23 '18 16:06 DantaliaN00