本文整理汇总了C++中Mat4x4::CreateTranslation方法的典型用法代码示例。如果您正苦于以下问题:C++ Mat4x4::CreateTranslation方法的具体用法?C++ Mat4x4::CreateTranslation怎么用?C++ Mat4x4::CreateTranslation使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Mat4x4
的用法示例。
在下文中一共展示了Mat4x4::CreateTranslation方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: VGenerateVelocityMap
///////////////////////////////////////////////
//Motion Blur
///////////////////////////////////////////////
AVOID DeferredRenderer::VGenerateVelocityMap(CameraPtr pCamera, Renderer* pRenderer, const Mat4x4 & viewproj)
{
//set screen-aligned quad
m_pVertices->Set(0, 0);
//set shaders
m_pVelocityMapShaders->VBind();
//set shader resources
m_gbuffer.BindPositionTex(0, ST_Pixel);
//set render target
m_pVelocityRTV->Set();
//set constant buffers
//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);
//set previous frame view-projection transform
Mat4x4 currViewProj = viewproj;
Mat4x4 prevViewProj = pCamera->GetPrevView() * pCamera->GetPrevProjection();
//prevViewProj = pCamera->GetView() * pCamera->GetProjection();
//prevViewProj = pCamera->GetProjection();
currViewProj.Transpose();
prevViewProj.Transpose();
//m_pcbPrevViewProj->UpdateSubresource(0, NULL, &prevViewProj, 0, 0);
//m_pcbPrevViewProj->Set(0, ST_Pixel);
struct TwoMatrices
{
Mat4x4 prevViewProj;
Mat4x4 currViewProj;
};
TwoMatrices temp;
temp.prevViewProj =prevViewProj;
temp.currViewProj = currViewProj;
m_pcbWorldPlusWVP->UpdateSubresource(0, nullptr, &temp, 0, 0);
m_pcbWorldPlusWVP->Set(0, ST_Pixel);
//Finally render velocity map
Draw(6, 0);
//unbind views
UnbindShaderResourceViews(0, 1, ST_Pixel);
UnbindRenderTargetViews(1);
}
示例2: CalculateAmbientOcclusion
///////////////////////////////////////////////
//Ambient occlusion
///////////////////////////////////////////////
AVOID DeferredRenderer::CalculateAmbientOcclusion(CameraPtr pCamera)
{
m_pSSAOShaders->VBind();
m_pVertices->Set(0, 0);
//bind matrix constant buffer to the pipeline
Mat4x4 trans;
trans.CreateTranslation(pCamera->GetLookAt());
Mat4x4 rot;
rot = rot.CreateRollPitchYaw(pCamera->GetRoll(), pCamera->GetPitch(), pCamera->GetYaw());
Mat4x4 WVP = rot * trans * pCamera->GetView() * CreateOrthoProjectionLH(SCREEN_WIDTH, SCREEN_HEIGHT, 0.1f, 1000.0f);
WVP.Transpose();
m_pMatrixBuffer->UpdateSubresource(0, NULL, &WVP, 0, 0);
m_pMatrixBuffer->Set(0, ST_Vertex);
//camera params
Vec cameraParams = Vector(pCamera->GetFrustum().GetNearWidth(), pCamera->GetFrustum().GetNearHeight(), 0.0f, 0.0f);
m_pcbFrustumSize->UpdateSubresource(0, NULL, &cameraParams, 0, 0);
m_pcbFrustumSize->Set(0, ST_Pixel);
//depth buffer params
Vec depthBufferParams = Vector(1.0f / SCREEN_WIDTH, 1.0f / SCREEN_HEIGHT, 0.0f, 0.0f);
m_pcbDepthBuffer->UpdateSubresource(0, NULL, &depthBufferParams, 0, 0);
m_pcbDepthBuffer->Set(1, ST_Pixel);
//camera view matrix
Mat4x4 View = pCamera->GetView();
View.Transpose();
m_pcbView->UpdateSubresource(0, NULL, &View, 0, 0);
m_pcbView->Set(2, ST_Pixel);
//send SSAO params
//Vec ssaoParams = Vector(20.0f, 2.0f, 5.0f, 2.0f);
//m_pcbSSAOParams->UpdateSubresource(0, NULL, &ssaoParams, 0, 0);
//m_pcbSSAOParams->Set(2, ST_Pixel);
m_pDepthDisableStencilDisable->Set(0);
//m_pDepthSRV->Set(0, ST_Pixel);
m_gbuffer.m_SRVList.SetView(2, 0, ST_Pixel);
m_gbuffer.m_SRVList.SetView(5, 1, ST_Pixel);
m_pSSAORTV->Set();
//set sampler states
//AnisotropySampler16()->Set(0, ST_Pixel);
PointClampSampler()->Set(0, ST_Pixel);
D3D11DeviceContext()->Draw(6, 0);
//Unbind render target view
UnbindRenderTargetViews(1);
//m_pSSAOSRV->Set(5, ST_Pixel);
UnbindShaderResourceViews(0, 2, ST_Pixel);
GetRenderTargetView()->Set();
}
示例3: 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);
}
示例4: VUpdate
//Update the state
AVOID ShadowTestState::VUpdate( Game * pGame, AREAL64 r64Time, AREAL64 r64ElapsedTime )
{
m_pScene->VUpdate(r64Time, r64ElapsedTime);
//update light
AREAL diffX = r64ElapsedTime * 5.0f;
Vec trans = Vector(40.0f*Cos(r64Time), 8, 40.0f*Sin(r64Time), 1);
//Vec trans = Vector(-15, -2.0f, -8.0f, 1);
Mat4x4 tr;
tr.CreateTranslation(trans);
SpotLightEntity* pLight = static_cast<SpotLightEntity*>(&*m_pLight);
pLight->SetCurrentTransform(tr, r64Time);
Vec dir = Normalize(Vector(0.0f, 0.0f, 0.0f, 1.0f) - trans);
pLight->SetDirection(dir);
//pLight->SetDirection( Vector(0.4f, -0.5f, 0.8f, 2.0f) );
}
示例5: VRenderSky
AVOID DeferredRenderer::VRenderSky(CameraPtr pCamera, const Mat4x4 & viewproj)
{
m_gbuffer.BindRenderTarget(3);
//m_pSkyShaders->VBind();
m_pAtmoShaders->VBind();
Mat4x4 trans;
trans.CreateTranslation(pCamera->GetPosition());
Mat4x4 scale;
scale.CreateScaling(1, 1, 1);
//Mat4x4 worldViewProj = trans * viewproj;
Mat4x4 worldViewProj = scale * viewproj;
worldViewProj.Transpose();
m_pcbWVP->UpdateSubresource(0, nullptr, &worldViewProj, 0, 0);
m_pcbWVP->Set(1, ST_Vertex);
struct WorldData
{
Mat4x4 wvp;
//Vec cameraPos;
};
WorldData worldData;
worldData.wvp = worldViewProj;
//worldData.cameraPos = pCamera->GetPosition();
//m_pcbAtmoWorld->UpdateSubresource(0, nullptr, &worldData, 0, 0);
//m_pcbAtmoWorld->Set(1, ST_Vertex);
m_pSphereMesh->SetPositionBuffer();
m_pSphereMesh->SetIndexBuffer();
this->NoCullingStandardRasterizer()->Set();
this->m_pDepthDisableStencilDisable->Set(0xFF);
//m_pSkySRV->Set(0, ST_Pixel);
m_pSphereMesh->VRender(this);
UnbindRenderTargetViews(1);
UnbindShaderResourceViews(0, 1, ST_Pixel);
}