How to set camera node's target after I setProjectionMatrix?
-
- Posts: 7
- Joined: Tue May 31, 2016 9:01 am
How to set camera node's target after I setProjectionMatrix?
Hi, I am new to irrlicht and new to 3D programming, recently I'm doing a vr project, I set the camera's projection matrix from the vr glasses' result, and now I need to set the 'right' target to 'fit' the new projection matrix, for which I mean is the target-posistion vector is at the center of the screen. And for my few days experiences I assume that every time after setting the camera target irrlicht would change the camera's projection matrix, by default irrlicht would match them (target-position vector and projection matrix) and make the target-position vector at the center of screen, so how do I set target after I set a new camera projection matrix and make it like default. Thanks.
Re: How to set camera node's target after I setProjectionMat
Setting the target only changes the view matrix, as expected. What is the issue? The projection matrix does not affect the target.
-
- Posts: 7
- Joined: Tue May 31, 2016 9:01 am
Re: How to set camera node's target after I setProjectionMat
hendu wrote:Setting the target only changes the view matrix, as expected. What is the issue? The projection matrix does not affect the target.
Code: Select all
if(mpHmd)
{
ovrHmd_BeginFrame(mpHmd, 0);
//Get eye poses, feeding in correct IPD offset
ovrVector3f ViewOffset[2] = {mpVrData->EyeRenderDesc[0].HmdToEyeViewOffset,mpVrData->EyeRenderDesc[1].HmdToEyeViewOffset};
ovrPosef EyeRenderPose[2];
ovrHmd_GetEyePoses(mpHmd, 0, ViewOffset, EyeRenderPose, NULL);
scene::ICameraSceneNode* camNow = mpDevice->getSceneManager()->getActiveCamera();
for (int i = 0; i < 2; i++)
{
mpDevice->getVideoDriver()->setRenderTarget(mTargets[i], true, true, video::SColor(0,0,0,0));
SetAffect(i, EyeRenderPose, camNow);
mpDevice->getSceneManager()->drawAll();
mpDevice->getGUIEnvironment()->drawAll();
pGame->Render();
mpDevice->getVideoDriver()->setRenderTarget(0, true, true, 0);
ovrFovPort fov;
fov = mpHmd->DefaultEyeFov[i];
fov.LeftTan *= 0.7f;
fov.RightTan *= 0.7f;
fov.UpTan *= 0.7f;
fov.DownTan *= 0.7f;
ovrMatrix4f proj = ovrMatrix4f_Projection(fov, camNow->getNearValue(), camNow->getFarValue(), ovrProjection_None);
camNow->setProjectionMatrix(CConvertUseful::MatOvrToIrr(proj)); /*this is the place of applying the VR glasses matrix to the camera*/
}
ovrHmd_EndFrame(mpHmd, EyeRenderPose, &mpVrData->eyeTex[0].Texture);
//camNow->setViewMatrixAffector(tmp2);
}