本文整理汇总了C++中Orientation::GetFront方法的典型用法代码示例。如果您正苦于以下问题:C++ Orientation::GetFront方法的具体用法?C++ Orientation::GetFront怎么用?C++ Orientation::GetFront使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Orientation
的用法示例。
在下文中一共展示了Orientation::GetFront方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ProcessEntity
//.........这里部分代码省略.........
}
glm::mat4 lazyOrthoAroundMap = glm::ortho(m_minWorldX, m_maxWorldX, m_minWorldY, m_maxWorldY, -m_maxWorldZ, -m_minWorldZ);
// Get the eye camera.
ECS::Entity* cameraEntity = m_world->GetTagManager()->GetEntityByTag("Camera");
RootForce::Camera* camera = m_world->GetEntityManager()->GetComponent<RootForce::Camera>(cameraEntity);
Frustum frustum = camera->m_frustum;
glm::vec4 frustumCorners[8];
frustumCorners[0] = glm::vec4(frustum.ntl, 1.0f);
frustumCorners[1] = glm::vec4(frustum.ntr, 1.0f);
frustumCorners[2] = glm::vec4(frustum.nbl, 1.0f);
frustumCorners[3] = glm::vec4(frustum.nbr, 1.0f);
frustumCorners[4] = glm::vec4(frustum.ftl, 1.0f);
frustumCorners[5] = glm::vec4(frustum.ftr, 1.0f);
frustumCorners[6] = glm::vec4(frustum.fbl, 1.0f);
frustumCorners[7] = glm::vec4(frustum.fbr, 1.0f);
// Convert camera frustrum to view space.
for(int i = 0; i < 8; i++)
{
frustumCorners[i] = camera->m_viewMatrix * frustumCorners[i];
}
// Calculate directions.
glm::vec3 directions[4];
for(int i = 0; i < 4; i++)
{
directions[i].x = glm::normalize(frustumCorners[i+4].x - frustumCorners[i].x);
directions[i].y = glm::normalize(frustumCorners[i+4].y - frustumCorners[i].y);
directions[i].z = glm::normalize(frustumCorners[i+4].z - frustumCorners[i].z);
}
static glm::vec4 localOBB[8] =
{
glm::vec4(-1.0f, -1.0f, -1.0f, 1.0f),
glm::vec4(1.0f, -1.0f, -1.0f, 1.0f),
glm::vec4(1.0f, 1.0f, -1.0f, 1.0f),
glm::vec4(1.0f, 1.0f, 1.0f, 1.0f),
glm::vec4(-1.0f, 1.0f, -1.0f, 1.0f),
glm::vec4(-1.0f, 1.0f, 1.0f, 1.0f),
glm::vec4(-1.0f, -1.0f, 1.0f, 1.0f),
glm::vec4(1.0f, -1.0f, 1.0f, 1.0f)
};
if(RENDER_SHADOW_CASCADES >= 4)
{
// Define near/far planes for the sub frustrums.
float _near[4];
_near[0] = camera->m_frustum.m_near;
_near[1] = 8.0f; //Daniel's 2k-values: 15, 60, 200
_near[2] = 40.0f;
_near[3] = 150.0f;
float _far[4];
_far[0] = _near[1];
_far[1] = _near[2];
_far[2] = _near[3];
_far[3] = camera->m_frustum.m_far;
// Create cascades.
for(int i = 0; i < RENDER_SHADOW_CASCADES; i++)
{
AABB boundingbox;
for(int p = 0; p < 4; p++)
{
glm::vec3 nearCorner;
nearCorner = glm::swizzle<glm::X, glm::Y, glm::Z>(frustumCorners[p]);
boundingbox.Expand(nearCorner + directions[p] * _near[i]);
boundingbox.Expand(nearCorner + directions[p] * _far[i]);
}
glm::vec3 center = boundingbox.GetCenter();
glm::vec3 centerInWorldSpace = glm::swizzle<glm::X, glm::Y, glm::Z>(glm::inverse(camera->m_viewMatrix) * glm::vec4(center, 1.0f));
glm::vec4 centerInViewSpace = lightSpace * glm::vec4(centerInWorldSpace, 1.0f);
float nearPlane = 1.0f;
float lookAtDistance = glm::length(centerInViewSpace - 2000.0f) + nearPlane;
float radius = glm::length(center - glm::vec3(boundingbox.m_maxX, boundingbox.m_maxY, boundingbox.m_maxZ));
float farPlane = lookAtDistance + radius;
sc.m_projectionMatrices[i] = glm::ortho(-radius, radius, -radius, radius, nearPlane, farPlane);
sc.m_viewMatrices[i] = glm::lookAt(centerInWorldSpace + tOr.GetFront() * lookAtDistance, centerInWorldSpace - tOr.GetFront() * lookAtDistance, tOr.GetUp());
sc.m_viewProjections[i] = sc.m_projectionMatrices[i] * sc.m_viewMatrices[i];
}
sc.m_projectionMatrices[RENDER_SHADOW_CASCADES-1] = OrthoProjectionFromFrustum(&camera->m_frustum, lightSpace);
sc.m_viewMatrices[RENDER_SHADOW_CASCADES-1] = lightSpace;
sc.m_viewProjections[RENDER_SHADOW_CASCADES-1] = sc.m_projectionMatrices[RENDER_SHADOW_CASCADES-1] * sc.m_viewMatrices[RENDER_SHADOW_CASCADES-1];
}
else
{
sc.m_projectionMatrices[RENDER_SHADOW_CASCADES-1] = lazyOrthoAroundMap;
sc.m_viewMatrices[RENDER_SHADOW_CASCADES-1] = lightSpace;
sc.m_viewProjections[RENDER_SHADOW_CASCADES-1] = sc.m_projectionMatrices[RENDER_SHADOW_CASCADES-1] * sc.m_viewMatrices[RENDER_SHADOW_CASCADES-1];
}
g_engineContext.m_renderer->AddShadowcaster(sc, (int)shadowcaster->m_directionalLightSlot);
}