Jump to content

  • Log In with Google      Sign In   
  • Create Account

Set Oculus Rift matrices in directx


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
No replies to this topic

#1 ggeasy   Members   -  Reputation: 103

Like
0Likes
Like

Posted 24 April 2014 - 07:07 AM

Hi everyone,
 
I am implementing the oculus in directx. Now everything works only I get double vision and I think the matrices are not set correctly. I think I do the exact same thing as in the SDK but I am not sure anymore. Can anyone see what I am doing wrong so the double vision goes away?
 
void RendererDX9::setViewMatrix(float lookAt[3], float up[3], float position[3], const OVR::Util::Render::StereoEyeParams& params, OVR::Util::Render::StereoConfig SConfig)
{
	float viewCenter = SConfig.GetHMDInfo().HScreenSize * 0.25f;
	float halfIPD = SConfig.GetHMDInfo().InterpupillaryDistance * 0.5f;

	D3DXMATRIXA16 viewMatrix;
	if (params.Eye == OVR::Util::Render::StereoEye_Left){
		D3DXMatrixTranslation(&viewMatrix, halfIPD, 0, 0);
		viewMatrix = scalarMultiply(&viewMatrix, viewCenter);
	}
	else{
		D3DXMatrixTranslation(&viewMatrix, -halfIPD, 0, 0);
		viewMatrix = scalarMultiply(&viewMatrix, viewCenter);
	}

	pd3dDevice->SetTransform(D3DTS_VIEW, &viewMatrix);
};
void RendererDX9::setProjectionMatrix(float fov, float nearClippingPlane, float farClippingPlane, float aspectRatio, const OVR::Util::Render::StereoEyeParams& params, OVR::Util::Render::StereoConfig SConfig)
{
	float projectionCenterOffset = SConfig.GetProjectionCenterOffset();
	//float projectionCenterOffset = 0.05;
	D3DXMATRIXA16 projectionCenterMatrix;
	D3DXMatrixPerspectiveFovLH(&projectionCenterMatrix,
		SConfig.GetYFOVRadians(),    // the horizontal field of view
		SConfig.GetAspect(),    // aspect ratio
		0.3f,    // the near view-plane
		farClippingPlane);    // the far view-plane

	D3DXMATRIXA16 projectionMatrix;
	if (params.Eye == OVR::Util::Render::StereoEye_Left){
		D3DXMatrixTranslation(&projectionMatrix, projectionCenterOffset, 0, 0);
		projectionMatrix = projectionMatrix * projectionCenterMatrix;
	}
	else{
		D3DXMatrixTranslation(&projectionMatrix, -projectionCenterOffset, 0, 0);
		projectionMatrix = projectionMatrix * projectionCenterMatrix;
	}

	pd3dDevice->SetTransform(D3DTS_PROJECTION, &projectionMatrix);    // set the projection transform	
};
Thanks in advance!


Sponsor:



Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS