本文整理汇总了C++中Mat4x4::Inverse方法的典型用法代码示例。如果您正苦于以下问题:C++ Mat4x4::Inverse方法的具体用法?C++ Mat4x4::Inverse怎么用?C++ Mat4x4::Inverse使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mat4x4
的用法示例。
在下文中一共展示了Mat4x4::Inverse方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PrepareForLightPass
AVOID DeferredRenderer::PrepareForLightPass(CameraPtr pCamera)
{
//set vertex buffer with positions
m_pVertices->Set(0, 0);
//set vertex buffer with texture data
m_pTexCoords->Set(1, 0);
//bind matrix constant buffer to the pipeline
Mat4x4 trans;
//trans.CreateTranslation(pCamera->GetLookAt() + 10000 * pCamera->GetDir());
trans.CreateTranslation(pCamera->GetPosition() + 500* pCamera->GetDir());
Mat4x4 rot;
rot = rot.CreateRollPitchYaw(pCamera->GetRoll(), pCamera->GetPitch(), pCamera->GetYaw());
Mat4x4 WVP = rot * trans * pCamera->GetView() * CreateOrthoProjectionLH(SCREEN_WIDTH, SCREEN_HEIGHT, 1.0f, 1000.0f);
WVP.Transpose();
m_pMatrixBuffer->UpdateSubresource(0, NULL, &WVP, 0, 0);
m_pMatrixBuffer->Set(0, ST_Vertex);
struct CameraBuffer
{
Mat4x4 inverseViewProjection;
Vec pos;
};
CameraBuffer cameraBuffer;
Mat4x4 inverseViewProjection = pCamera->GetViewProjection();
inverseViewProjection.Inverse();
cameraBuffer.pos = pCamera->GetPosition();
cameraBuffer.inverseViewProjection = inverseViewProjection;
cameraBuffer.inverseViewProjection.Transpose();
m_pcbCameraPos->UpdateSubresource(0, nullptr, &pCamera->GetPosition(), 0, 0);
//m_pcbCameraPos->UpdateSubresource(0, NULL, &cameraBuffer, 0, 0);
m_pcbCameraPos->Set(0, ST_Pixel);
//pCamera->SetViewport();
SetGlobalViewport();
//set shader resources
m_pSSAOBlurredSRV->Set(6, ST_Pixel);
m_pDepthSRV->Set(8, ST_Pixel);
//set blending functionality
//this->BlendLightPass()->Set(nullptr);
}
示例2: Pick
HRESULT RayCast::Pick(Scene * pScene, ActorId actorId, ModelClass * pMesh)
{
if (!m_bAllHits && m_numIntersections)
return S_OK;
HRESULT hr;
const Mat4x4 matView = pScene->GetCamera()->GetView();
const Mat4x4 matWorld = pScene->GetTopMatrix();
const Mat4x4 proj = pScene->GetCamera()->GetProjection();
//Compute Pickray in screen space
Vec3 v;
v.x = (((2.0f * m_point.x) / g_pApp->GetScreenSize().x) - 1) / proj._11;
v.y = (((2.0f * m_point.y) / g_pApp->GetScreenSize().y) - 1) / proj._22;
v.z = 1.0f;
Mat4x4 worldView = matWorld * matView;
Mat4x4 inverseWorld = worldView.Inverse();
//Screen space pick ray into 3d space
m_vPickRayDir.x = v.x * inverseWorld._11 + v.y * inverseWorld._21 + v.z * inverseWorld._31;
m_vPickRayDir.y = v.x * inverseWorld._12 + v.y * inverseWorld._22 + v.z * inverseWorld._32;
m_vPickRayDir.z = v.x * inverseWorld._13 + v.y * inverseWorld._23 + v.z * inverseWorld._33;
m_vPickRayOrigin.x = inverseWorld._41;
m_vPickRayOrigin.y = inverseWorld._42;
m_vPickRayOrigin.z = inverseWorld._43;
if (!m_bAllHits)
{
//Find closest intersection
for (auto meshIt = pMesh->meshes.begin(); meshIt != pMesh->meshes.end(); meshIt++)
{
for (auto it = (*meshIt).vertices.begin(); it != (*meshIt).vertices.end(); it++)
{
}
}
}
}
示例3:
Transform::Transform( const Mat4x4& toWorld )
{
m_ToWorld = toWorld;
m_FromWorld = toWorld.Inverse();
m_IsFromWorldDirty = false;
}