本文整理汇总了C++中CGroupMap::mapToWorld方法的典型用法代码示例。如果您正苦于以下问题:C++ CGroupMap::mapToWorld方法的具体用法?C++ CGroupMap::mapToWorld怎么用?C++ CGroupMap::mapToWorld使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGroupMap
的用法示例。
在下文中一共展示了CGroupMap::mapToWorld方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: computeWorldViewRay
//***************************************************************
void CTool::computeWorldViewRay(sint32 posX, sint32 posY, CWorldViewRay &dest)
{
//H_AUTO(R2_CTool_computeWorldViewRay)
CGroupMap *gm = isMouseOnWorldMap();
if (gm)
{
sint32 windowX = posX - gm->getXReal();
sint32 windowY = posY - gm->getYReal();
CVector2f mapPos;
gm->windowToMap(mapPos, windowX, windowY);
if (mapPos.x >= 0.f && mapPos.y >= 0.f && mapPos.x <= 1.f && mapPos.y <= 1.f)
{
CVector2f worldPos;
gm->mapToWorld(worldPos, mapPos);
dest.Dir = -CVector::K;
dest.Origin.set(worldPos.x, worldPos.y, 10000.f); // look from above
dest.OnMiniMap = true;
dest.Right = CVector(1.f, 0.f, 0.f);
dest.Up = CVector(0.f, 1.f, 0.f);
dest.Valid = true;
return;
}
else
{
dest.OnMiniMap = true;
dest.Valid = false;
return;
}
}
uint32 scrW, scrH;
getScreenSize(scrW, scrH);
const NL3D::CFrustum &fru = MainCam.getFrustum();
//
dest.Dir.x = posX / (float) scrW;
dest.Dir.x = fru.Left + (fru.Right - fru.Left) * dest.Dir.x;
dest.Dir.z = posY / (float) scrH;
dest.Dir.z = fru.Bottom + (fru.Top - fru.Bottom) * dest.Dir.z;
dest.Dir.y = fru.Near;
//
dest.Dir /= fru.Near;
CMatrix camMatrix = MainCam.getMatrix();
dest.Right = camMatrix.getI().normed();
dest.Up = camMatrix.getK().normed();
dest.Dir = camMatrix.mulVector(dest.Dir);
dest.Origin = camMatrix.getPos();
dest.OnMiniMap = false;
dest.Valid = true;
// When looking upward, the camera may be "snapped" to the ground
// In this case, false intersection with the ground may be detected, so move forward
// in ray direction to resolve that problem
const float distBias = 0.20f;
dest.Origin += distBias * dest.Dir;
}