本文整理汇总了C++中Fvector2::sub方法的典型用法代码示例。如果您正苦于以下问题:C++ Fvector2::sub方法的具体用法?C++ Fvector2::sub怎么用?C++ Fvector2::sub使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Fvector2
的用法示例。
在下文中一共展示了Fvector2::sub方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Draw
void CUIDragItem::Draw()
{
Fvector2 tmp;
tmp.sub (GetWndPos(), GetUICursor().GetCursorPosition());
tmp.sub (m_pos_offset);
tmp.mul (-1.0f);
MoveWndDelta (tmp);
inherited::Draw ();
if(m_custom_draw)
m_custom_draw->OnDraw(this);
}
示例2: Draw
void CUIDragItem::Draw()
{
Fvector2 tmp;
tmp.sub (GetWndPos(), GetUICursor()->GetCursorPosition());
tmp.sub (m_pos_offset);
tmp.mul (-1.0f);
MoveWndDelta (tmp);
UI()->PushScissor (UI()->ScreenRect(),true);
inherited::Draw();
UI()->PopScissor();
}
示例3: Draw
void CUIArtefactDetectorElite::Draw()
{
Fmatrix LM;
GetUILocatorMatrix (LM);
IUIRender::ePointType bk = UI().m_currentPointType;
UI().m_currentPointType = IUIRender::pttLIT;
UIRender->CacheSetXformWorld(LM);
UIRender->CacheSetCullMode (IUIRender::cmNONE);
CUIWindow::Draw ();
//. Frect r = m_wrk_area->GetWndRect();
Fvector2 wrk_sz = m_wrk_area->GetWndSize();
Fvector2 rp;
m_wrk_area->GetAbsolutePos (rp);
Fmatrix M, Mc;
float h,p;
Device.vCameraDirection.getHP(h,p);
Mc.setHPB (h,0,0);
Mc.c.set (Device.vCameraPosition);
M.invert (Mc);
UI().ScreenFrustumLIT().CreateFromRect(Frect().set( rp.x,
rp.y,
wrk_sz.x,
wrk_sz.y ));
xr_vector<SDrawOneItem>::const_iterator it = m_items_to_draw.begin();
xr_vector<SDrawOneItem>::const_iterator it_e = m_items_to_draw.end();
for(;it!=it_e;++it)
{
Fvector p = (*it).pos;
Fvector pt3d;
M.transform_tiny (pt3d,p);
float kz = wrk_sz.y / m_parent->m_fAfDetectRadius;
pt3d.x *= kz;
pt3d.z *= kz;
pt3d.x += wrk_sz.x/2.0f;
pt3d.z -= wrk_sz.y;
Fvector2 pos;
pos.set (pt3d.x, -pt3d.z);
pos.sub (rp);
if(1 /* r.in(pos)*/ )
{
(*it).pStatic->SetWndPos (pos);
(*it).pStatic->Draw ();
}
}
UI().m_currentPointType = bk;
}
示例4:
void S2DVert::rotate_pt(const Fvector2& pivot, float cosA, float sinA, float kx)
{
Fvector2 t = pt;
t.sub (pivot);
pt.x = t.x*cosA+t.y*sinA;
pt.y = t.y*cosA-t.x*sinA;
pt.x *= kx;
pt.add (pivot);
}
示例5: Draw
void CUIArtefactDetectorElite::Draw()
{
Fmatrix LM;
GetUILocatorMatrix (LM);
IUIRender::ePointType bk = UI()->m_currentPointType;
UI()->m_currentPointType = IUIRender::pttLIT;
UIRender->CacheSetXformWorld(LM);
UIRender->CacheSetCullMode (IUIRender::cmNONE);
CUIWindow::Draw ();
Frect r = m_wrk_area->GetWndRect();
Fvector2 rp;
m_wrk_area->GetAbsolutePos (rp);
Fmatrix M, Mc;
float h,p;
Device.vCameraDirection.getHP(h,p);
Mc.setHPB (h,0,0);
Mc.c.set (Device.vCameraPosition);
M.invert (Mc);
xr_vector<Fvector>::const_iterator it = m_af_to_draw.begin();
xr_vector<Fvector>::const_iterator it_e = m_af_to_draw.end();
for(;it!=it_e;++it)
{
Fvector p = (*it);
Fvector pt3d;
M.transform_tiny (pt3d,p);
// float kx = m_wrk_area->GetWndSize().x / m_parent->m_fAfDetectRadius;
float kz = m_wrk_area->GetWndSize().y / m_parent->m_fAfDetectRadius;
pt3d.x *= kz;
pt3d.z *= kz;
pt3d.x += m_wrk_area->GetWndSize().x/2.0f;
pt3d.z -= m_wrk_area->GetWndSize().y;
Fvector2 pos;
pos.set (pt3d.x, -pt3d.z);
pos.sub (rp);
if( r.in(pos) )
{
m_af_sign->SetWndPos (pos);
m_af_sign->Draw ();
}
}
UI()->m_currentPointType = bk;
}
示例6: ConvertRealToLocal
Fvector2 CUICustomMap::ConvertRealToLocal (const Fvector2& src)// meters->pixels (relatively own left-top pos)
{
Fvector2 res;
if( !Heading() ){
return ConvertRealToLocalNoTransform(src);
}else{
Fvector2 heading_pivot = GetStaticItem()->GetHeadingPivot();
res = ConvertRealToLocalNoTransform(src);
res.sub(heading_pivot);
rotation_(res.x, res.y, GetHeading(), res.x, res.y);
res.add(heading_pivot);
return res;
};
}
示例7: CalcOpenRect
float CUIGlobalMap::CalcOpenRect(const Fvector2& center_point, Frect& map_desired_rect, float tgt_zoom)
{
Fvector2 new_center_pt;
// calculate desired rect in new zoom
map_desired_rect.set (0.0f,0.0f, BoundRect().width()*tgt_zoom,BoundRect().height()*tgt_zoom);
// calculate center point in new zoom (center_point is in identity global map space)
new_center_pt.set (center_point.x*tgt_zoom,center_point.y*tgt_zoom);
// get vis width & height
Frect vis_abs_rect = m_mapWnd->ActiveMapRect();
float vis_w = vis_abs_rect.width();
float vis_h = vis_abs_rect.height();
// calculate center delta from vis rect
Fvector2 delta_pos;
delta_pos.set (new_center_pt.x-vis_w*0.5f,new_center_pt.y-vis_h*0.5f);
// correct desired rect
map_desired_rect.sub (delta_pos.x,delta_pos.y);
// clamp pos by vis rect
const Frect& r = map_desired_rect;
Fvector2 np = r.lt;
if (r.x2<vis_w) np.x += vis_w-r.x2;
if (r.y2<vis_h) np.y += vis_h-r.y2;
if (r.x1>0.0f) np.x = 0.0f;
if (r.y1>0.0f) np.y = 0.0f;
np.sub (r.lt);
map_desired_rect.add (np.x,np.y);
// calculate max way dist
float dist = 0.f;
Frect s_rect,t_rect;
s_rect.div (GetWndRect(),GetCurrentZoom(),GetCurrentZoom());
t_rect.div (map_desired_rect,tgt_zoom,tgt_zoom);
Fvector2 cpS,cpT;
s_rect.getcenter (cpS);
t_rect.getcenter (cpT);
dist = cpS.distance_to(cpT);
return dist;
}