本文整理汇总了C++中CGroupMap::getMeterPerPixel方法的典型用法代码示例。如果您正苦于以下问题:C++ CGroupMap::getMeterPerPixel方法的具体用法?C++ CGroupMap::getMeterPerPixel怎么用?C++ CGroupMap::getMeterPerPixel使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CGroupMap
的用法示例。
在下文中一共展示了CGroupMap::getMeterPerPixel方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: onUpdate
//*********************************************************************************************************
void CInstanceMapDeco::onUpdate(CGroupMap &groupMap)
{
//H_AUTO(R2_CInstanceMapDeco_onUpdate)
if (!_Active) return;
nlassert(_Instance);
_GlowStarActive = false;
if (!_Main || !_Over || !_OverInvalid) return;
sint32 x;
sint32 y;
CVector2f worldPos = getWorldPos();
// if not in current map then don't disply anything
CIslandCollision &col = getEditor().getIslandCollision();
R2::CScenarioEntryPoints::CCompleteIsland *currIsland = col.getCurrIslandDesc();
if (currIsland)
{
if (!currIsland->isIn(worldPos))
{
setActive(false);
return;
}
}
groupMap.worldToWindowSnapped(x, y, getWorldPos());
_Main->setX(x);
_Main->setY(y);
CDisplayerVisual *vd = _Instance->getDisplayerVisual();
if (!vd)
{
_Over->setActive(false);
_OverInvalid->setActive(false);
return;
}
//
bool closeView = _CloseTexture.empty() ? false : groupMap.getMeterPerPixel() < CV_MapEntityCloseDist.get();
//
bool selected = vd->getDisplayFlag(CDisplayerVisual::FlagSelected);
bool hasFocus = vd->getDisplayFlag(CDisplayerVisual::FlagHasFocus);
//
setTextureAndFit(closeView ? _CloseTexture : CV_MapEntitySmallTexture.get());
_Main->setColor((selected && ! closeView) ? CV_MapEntitySelectColor.get() : vd->getDisplayModeColorInMap()); // if small icon, then change the icon color directly, because no over will be displayed
//
if (selected || hasFocus)
{
// if the selection is out of the window, then draw an arrow to locate it
const CVector2f &wmin = groupMap.getVisibleWorldMin();
const CVector2f &wmax = groupMap.getVisibleWorldMax();
if (worldPos.x < wmin.x || worldPos.x > wmax.x ||
worldPos.y < wmin.y || worldPos.y > wmax.y)
{
// OUT OF VISIBLE REGION CASE
_Over->setActive(true);
_Over->setColorRGBA(selected ? CV_MapEntitySelectColor.get() : CV_MapEntityHighlightColor.get());
// out of the visible portion, so draw an arrow instead
_Over->setTexture(CV_MapEntityFarTexture.get());
// snap position to inner visible world rect
CVector2f m = 0.5f * (wmin + wmax);
CVector2f dir = worldPos - m;
CVector2f inter;
float d0;
float d1;
if (dir.x > 0.f)
{
d0 = (wmax.x - m.x) / dir.x;
if (dir.y > 0.f)
{
d1 = (wmax.y - m.y) / dir.y;
inter = m + std::min(d0, d1) * dir;
}
else if (dir.y < 0.f)
{
d1 = (wmin.y - m.y) / dir.y;
inter = m + std::min(d0, d1) * dir;
}
else
{
inter.set(wmax.x, m.y);
}
}
else if (dir.x < 0.f)
{
d0 = (wmin.x - m.x) / dir.x;
if (dir.y > 0.f)
{
d1 = (wmax.y - m.y) / dir.y;
inter = m + std::min(d0, d1) * dir;
}
else if (dir.y < 0.f)
{
d1 = (wmin.y - m.y) / dir.y;
inter = m + std::min(d0, d1) * dir;
}
else
{
inter.set(wmin.x, m.y);
}
}
else
{
if (dir.y > 0.f)
{
//.........这里部分代码省略.........
示例2: onPreRender
//*********************************************************************************************************
void CInstanceMapDeco::onPreRender(CGroupMap &groupMap)
{
//H_AUTO(R2_CInstanceMapDeco_onPreRender)
if (!_Active) return;
nlassert(_Instance);
if (_GlowStarActive)
{
if (_GlowStar[0])
{
// draw glowing stars on the edge to signal position well
for(uint k = 0; k < 2; ++k)
{
_GlowStar[k]->setActive(true);
_GlowStar[k]->setQuad(_GlowStarPos, CV_MapGlowStarSize.get(), (float) (CV_MapGlowStarSpeed[k].get() * 0.001 * (double) T1));
_GlowStar[k]->updateCoords();
}
}
}
//
if (_Orient)
{
bool closeView = groupMap.getMeterPerPixel() < CV_MapEntityCloseDist.get();
CDisplayerVisual *vd = _Instance->getDisplayerVisual();
if (vd)
{
if (_LastCloseView!= closeView)
{
_OrientBlendFactor = closeView ? 0.5f : 0.f;
}
if (vd->getRotateInProgress())
{
_OrientBlendFactor = 1.f;
}
else
{
// fade to default alpha
NLMISC::incrementalBlend(_OrientBlendFactor, closeView ? 0.5f : 0.f, DT * 1000.f / favoid0(CV_MapEntityOrientBlendTimeInMs.get()));
}
}
else
{
_OrientBlendFactor = 0.f;
}
if (_OrientBlendFactor == 0.f)
{
_Orient->setActive(false);
}
else
{
_Orient->setActive(true);
_Orient->setColorRGBA(CRGBA(255, 255, 255, (uint8) (255 * _OrientBlendFactor)));
CVector2f worldPos = getWorldPos();
sint32 x;
sint32 y;
groupMap.worldToWindowSnapped(x, y, getWorldPos());
_Orient->setQuad(CV_MapEntityOrientTexture.get(), CVector((float) x, (float) y, 0.f), vd->getAngle(), closeView ? CV_MapEntityOrientOriginDist.get() : CV_MapEntityOrientOriginDistSmall.get());
_Orient->updateCoords();
}
_LastCloseView = closeView;
}
if (_OverInvalid->getActive())
{
_OverInvalid->setColorRGBA(CTool::getInvalidPosColor());
}
}