本文整理汇总了C++中Frame::GetBodyFor方法的典型用法代码示例。如果您正苦于以下问题:C++ Frame::GetBodyFor方法的具体用法?C++ Frame::GetBodyFor怎么用?C++ Frame::GetBodyFor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Frame
的用法示例。
在下文中一共展示了Frame::GetBodyFor方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ParentSafetyAdjust
// ok, need thing to step down through bodies and find closest approach
// modify targpos directly to aim short of dangerous bodies
static bool ParentSafetyAdjust(Ship *ship, Frame *targframe, const vector3d &posoff, vector3d &targpos)
{
Body *body = 0;
Frame *frame = targframe->IsRotatingFrame() ? targframe->m_parent : targframe;
while (frame)
{
double sdist = ship->GetPositionRelTo(frame).Length(); // ship position in that frame
if (sdist < frame->GetRadius()) break;
while (frame && !(body = frame->GetBodyFor()))
frame = frame->m_parent;
if (!frame) return false;
frame = body->GetFrame()->m_parent;
if (body->HasDoubleFrame()) frame = frame->m_parent;
}
if (!body) return false;
// ok, so if body != 0, aim for zero velocity at distance to surface of that body
// still along path to target
vector3d targpos2 = targpos - ship->GetPosition();
double targdist = targpos2.Length();
double bodydist = body->GetPositionRelTo(ship).Length() - MaxEffectRad(body, ship)*1.5;
if (targdist < bodydist) return false;
targpos -= (targdist - bodydist) * targpos2 / targdist;
// printf("Adjusted targpos for safety from %s: old = %.1f, new = %.1f\n",
// body->GetLabel().c_str(), targdist, (targpos-ship->GetPosition()).Length());
return true;
}
示例2: l_body_attr_frame_body
/*
* Attribute: frameBody
*
* The non-dynamic body attached to the frame this dynamic body is in.
*
* Only valid for dynamic <Bodies>. For non-dynamic bodies <frameBody> will be
* nil.
*
* <frameBody> can also be nil if this dynamic body is in a frame with no
* non-dynamic body. This most commonly occurs when the player is in
* hyperspace.
*
* Availability:
*
* alpha 12
*
* Status:
*
* experimental
*/
static int l_body_attr_frame_body(lua_State *l)
{
Body *b = LuaBody::GetFromLua(1);
if (!b->IsType(Object::DYNAMICBODY)) {
lua_pushnil(l);
return 1;
}
Frame *f = b->GetFrame();
LuaBody::PushToLua(f->GetBodyFor());
return 1;
}