本文整理汇总了C++中Vec3::CrossN方法的典型用法代码示例。如果您正苦于以下问题:C++ Vec3::CrossN方法的具体用法?C++ Vec3::CrossN怎么用?C++ Vec3::CrossN使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Vec3
的用法示例。
在下文中一共展示了Vec3::CrossN方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: _updateCamera
void Shadow::_updateCamera()
{
Camera * worldCam = World::Instance()->MainCamera();
mInverseWorldCameraVP = World::Instance()->MainCamera()->GetViewProjMatrix().Inverse();
float nearClip = worldCam->GetNearClip();
float farClip = mDist[K_NumShadowLayers - 1];
Vec3 xAixs = worldCam->GetDirection();
Vec3 yAixs = worldCam->GetUp();
Vec3 zAixs = Environment::Instance()->GetEvParam()->LightDir;
if (Math::Abs(zAixs.Dot(yAixs)) > 0.99f)
{
yAixs = zAixs.CrossN(xAixs);
xAixs = yAixs.CrossN(zAixs);
}
else
{
xAixs = yAixs.CrossN(zAixs);
yAixs = zAixs.CrossN(xAixs);
}
if (xAixs.Dot(worldCam->GetDirection()) < 0)
xAixs = -xAixs;
yAixs = zAixs.CrossN(xAixs);
Mat4 matView;
Quat qOrient = Quat::S_FromAxis(xAixs, yAixs, zAixs);
matView.MakeViewLH(worldCam->GetPosition(), qOrient);
Vec3 corner[8], t_corner[8];
worldCam->GetWorldCorner(t_corner, nearClip, farClip);
float dist = t_corner[4].Distance(t_corner[5]);
for (int i = 0; i < 8; ++i)
{
corner[i] = t_corner[i] * matView;
}
Aabb aabb = Aabb::Invalid;
for (int i = 0; i < 8; ++i)
{
aabb.minimum = aabb.minimum.Minimum(corner[i]);
aabb.maximum = aabb.maximum.Maximum(corner[i]);
}
Vec3 center = aabb.GetCenter();
float width = aabb.GetWidth();
float height = aabb.GetHeight();
float depth = aabb.GetDepth();
center *= matView.Inverse();
Vec3 lightPos = center - zAixs * mOffset;
mLightCamera->SetPosition(lightPos);
mLightCamera->SetOrientation(qOrient);
mLightCamera->SetOrthoWidth(width);
mLightCamera->SetOrthoHeight(height);
mLightCamera->SetNearClip(nearClip);
mLightCamera->SetFarClip(mOffset + depth);
mLightCamera->SetProjectionType(PROJTYPE_ORTHO);
}
示例2: _calcuCascadedMatrix
void Shadow::_calcuCascadedMatrix(int layer)
{
Camera * worldCam = World::Instance()->MainCamera();
mInverseWorldCameraVP = World::Instance()->MainCamera()->GetViewProjMatrix().Inverse();
float nearClip, farClip = mDist[layer];
if (layer == 0)
nearClip = worldCam->GetNearClip();
else
nearClip = mDist[layer - 1];
Vec3 xAixs = worldCam->GetDirection();
Vec3 yAixs = worldCam->GetUp();
Vec3 zAixs = Environment::Instance()->GetEvParam()->LightDir;
if (Math::Abs(zAixs.Dot(yAixs)) > 0.99f)
{
yAixs = zAixs.CrossN(xAixs);
xAixs = yAixs.CrossN(zAixs);
}
else
{
xAixs = yAixs.CrossN(zAixs);
yAixs = zAixs.CrossN(xAixs);
}
if (xAixs.Dot(worldCam->GetDirection()) < 0)
xAixs = -xAixs;
yAixs = zAixs.CrossN(xAixs);
Mat4 matView, matProj;
Quat qOrient = Quat::S_FromAxis(xAixs, yAixs, zAixs);
matView.MakeViewLH(worldCam->GetPosition(), qOrient);
Vec3 corner[8], t_corner[8];
worldCam->GetWorldCorner(t_corner, nearClip, farClip);
float dist = t_corner[4].Distance(t_corner[5]);
for (int i = 0; i < 8; ++i)
{
corner[i] = t_corner[i] * matView;
}
Aabb aabb = Aabb::Invalid;
for (int i = 0; i < 8; ++i)
{
aabb.minimum = aabb.minimum.Minimum(corner[i]);
aabb.maximum = aabb.maximum.Maximum(corner[i]);
}
Vec3 center = aabb.GetCenter();
float width = aabb.GetWidth();
float height = aabb.GetHeight();
float depth = aabb.GetDepth();
center *= matView.Inverse();
Vec3 lightPos = center - zAixs * mOffset;
matView.MakeViewLH(lightPos, qOrient);
matProj.MakeOrthoLH(width, height, nearClip, mOffset + depth);
mCascadedMatrix[layer].mView = matView;
mCascadedMatrix[layer].mProj = matProj;
mCascadedMatrix[layer].mViewProj = matView * matProj;
}