本文整理汇总了C++中vector3d::LengthSqr方法的典型用法代码示例。如果您正苦于以下问题:C++ vector3d::LengthSqr方法的具体用法?C++ vector3d::LengthSqr怎么用?C++ vector3d::LengthSqr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vector3d
的用法示例。
在下文中一共展示了vector3d::LengthSqr方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Render
void SpaceStation::Render(Graphics::Renderer *r, const Camera *camera, const vector3d &viewCoords, const matrix4x4d &viewTransform)
{
Body *b = GetFrame()->GetBody();
assert(b);
if (!b->IsType(Object::PLANET)) {
// orbital spaceport -- don't make city turds or change lighting based on atmosphere
RenderModel(r, camera, viewCoords, viewTransform);
r->GetStats().AddToStatCount(Graphics::Stats::STAT_SPACESTATIONS, 1);
} else {
// don't render city if too far away
if (viewCoords.LengthSqr() >= SQRMAXCITYDIST) {
return;
}
std::vector<Graphics::Light> oldLights;
Color oldAmbient;
SetLighting(r, camera, oldLights, oldAmbient);
if (!m_adjacentCity) {
m_adjacentCity = new CityOnPlanet(static_cast<Planet*>(b), this, m_sbody->GetSeed());
}
m_adjacentCity->Render(r, camera->GetContext()->GetFrustum(), this, viewCoords, viewTransform);
RenderModel(r, camera, viewCoords, viewTransform, false);
ResetLighting(r, oldLights, oldAmbient);
r->GetStats().AddToStatCount(Graphics::Stats::STAT_GROUNDSTATIONS, 1);
}
}
示例2: GetGravityAtPos
// returns acceleration due to gravity at that point
static double GetGravityAtPos(Frame *targframe, const vector3d &posoff)
{
Body *body = targframe->GetBodyFor();
if (!body || body->IsType(Object::SPACESTATION)) return 0;
double rsqr = posoff.LengthSqr();
return G * body->GetMass() / rsqr;
// inverse is: sqrt(G * m1m2 / thrust)
}
示例3: GetGravityAtPos
/// Calculates acceleration due to gravity at given position
static double GetGravityAtPos(Frame *target_frame, const vector3d &position)
{
Body *body = target_frame->GetBody();
if (!body || body->IsType(Object::SPACESTATION)) {
return 0.0;
}
return G * body->GetMass() / position.LengthSqr(); // inverse is: sqrt(G * m1m2 / thrust)
}