I'm trying to convert this camera to left hand, but I can't figure it out.
[source lang = "cpp"]
D3DXMATRIX mTrans, mMatView, mMatProjection;
D3DXMatrixIdentity (&mMatView);
D3DXMatrixIdentity (&mMatProjection);
// ----- View matrix -----
pCamera2d->mLook = D3DXVECTOR3 (0.0f, 0.0f, 1.0f);
pCamera2d->mUp = D3DXVECTOR3 (0.0f, 1.0f, 0.0f);
pCamera2d->mRight = D3DXVECTOR3 (-1.0f, 0.0f, 0.0f);
// ----- Rotation -----
// Roll is rotation around the z axis (m_look)
// Create a matrix that can carry out this rotation
D3DXMATRIX rollMatrix;
D3DXMatrixRotationAxis (&rollMatrix, &pCamera2d->mLook, D3DXToRadian(pCamera2d->mAngle));
// To apply roll we rotate up and right about the look vector (using our roll matrix)
D3DXVec3TransformCoord (&pCamera2d->mRight, &pCamera2d->mRight, &rollMatrix);
D3DXVec3TransformCoord (&pCamera2d->mUp, &pCamera2d->mUp, &rollMatrix);
// Build the view matrix from the transformed camera axis
mMatView._11 = pCamera2d->mRight.x; mMatView._12 = pCamera2d->mUp.x; mMatView._13 = pCamera2d->mLook.x;
mMatView._21 = pCamera2d->mRight.y; mMatView._22 = pCamera2d->mUp.y; mMatView._23 = pCamera2d->mLook.y;
mMatView._31 = pCamera2d->mRight.z; mMatView._32 = pCamera2d->mUp.z; mMatView._33 = pCamera2d->mLook.z;
mMatView._41 = -D3DXVec3Dot (&pCamera2d->mPos, &pCamera2d->mRight);
mMatView._42 = -D3DXVec3Dot (&pCamera2d->mPos, &pCamera2d->mUp);
mMatView._43 = -D3DXVec3Dot (&pCamera2d->mPos, &pCamera2d->mLook);
// ---- 2d set ----
D3DXMatrixRotationZ (&mTrans, (float) PI);
D3DXMatrixMultiply (&mMatView, &mTrans, &mMatView);
D3DXMatrixTranslation (&mTrans, -0.5f, -0.5f, 0);
D3DXMatrixMultiply (&mMatView, &mTrans, &mMatView);
// ---- Zoom ----
if (pCamera2d->mZoom != 1.0f)
{
D3DXMatrixScaling (&mTrans, pCamera2d->mZoom, pCamera2d->mZoom, pCamera2d->mZoom);
D3DXMatrixMultiply (&mMatView, &mMatView, &mTrans);
}
// ----- Set transformation -----
mInfo.mDevice->SetTransform (D3DTS_VIEW, &mMatView);
// ----- Projection matrix -----
D3DXMatrixOrthoRH (&mMatProjection, (float) mInfo.mViewPortWidth, (float) mInfo.mViewPortHeight, -2048.0f, 2048.0f);
mInfo.mDevice->SetTransform (D3DTS_PROJECTION, &mMatProjection);
[/source]
I know to changed anything with "RH" to "LH", but the view matrix is throwing me off. Any suggestions?
Convert right hand camera to left hand
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement