当前位置: 首页>>代码示例>>C++>>正文


C++ SolarSystem::getPlanets方法代码示例

本文整理汇总了C++中SolarSystem::getPlanets方法的典型用法代码示例。如果您正苦于以下问题:C++ SolarSystem::getPlanets方法的具体用法?C++ SolarSystem::getPlanets怎么用?C++ SolarSystem::getPlanets使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SolarSystem的用法示例。


在下文中一共展示了SolarSystem::getPlanets方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: selectPlanet

// Choose a planet around a star given it's index in the planetary system.
// The planetary system is either the system of the selected object, or the
// nearest planetary system if no object is selected.  If index is less than
// zero, pick the star.  This function should probably be in celestiacore.cpp.
void Simulation::selectPlanet(int index)
{
    if (index < 0)
    {
        if (selection.getType() == Selection::Type_Body)
        {
            PlanetarySystem* system = selection.body()->getSystem();
            if (system != NULL)
                setSelection(system->getStar());
        }
    }
    else
    {
        const Star* star = NULL;
        if (selection.getType() == Selection::Type_Star)
            star = selection.star();
        else if (selection.getType() == Selection::Type_Body)
            star = getSun(selection.body());

        SolarSystem* solarSystem = NULL;
        if (star != NULL)
            solarSystem = universe->getSolarSystem(star);
        else
            solarSystem = closestSolarSystem;

        if (solarSystem != NULL &&
            index < solarSystem->getPlanets()->getSystemSize())
        {
            setSelection(Selection(solarSystem->getPlanets()->getBody(index)));
        }
    }
}
开发者ID:sanyaade-embedded-systems,项目名称:STA,代码行数:36,代码来源:simulation.cpp

示例2: LoadSolarSystemObjects


//.........这里部分代码省略.........
                string::size_type next    = nameList.find(':', startPos);
                string::size_type length  = string::npos;
                if (next != string::npos)
                {
                    length   = next - startPos;
                    ++next;
                }
                names.push_back(nameList.substr(startPos, length));
                startPos   = next;
            }
        }
        string primaryName = names.front();

        BodyType bodyType = UnknownBodyType;
        if (itemType == "Body")
            bodyType = NormalBody;
        else if (itemType == "ReferencePoint")
            bodyType = ReferencePoint;
        else if (itemType == "SurfaceObject")
            bodyType = SurfaceObject;
        
        if (bodyType != UnknownBodyType)
        {
            //bool orbitsPlanet = false;
            if (parent.star() != NULL)
            {
                SolarSystem* solarSystem = universe.getSolarSystem(parent.star());
                if (solarSystem == NULL)
                {
                    // No solar system defined for this star yet, so we need
                    // to create it.
                    solarSystem = universe.createSolarSystem(parent.star());
                }
                parentSystem = solarSystem->getPlanets();
            }
            else if (parent.body() != NULL)
            {
                // Parent is a planet or moon
                parentSystem = parent.body()->getSatellites();
                if (parentSystem == NULL)
                {
                    // If the planet doesn't already have any satellites, we
                    // have to create a new planetary system for it.
                    parentSystem = new PlanetarySystem(parent.body());
                    parent.body()->setSatellites(parentSystem);
                }
                //orbitsPlanet = true;
            }
            else
            {
                errorMessagePrelude(tokenizer);
                cerr << _("parent body '") << parentName << _("' of '") << primaryName << _("' not found.") << endl;
            }

            if (parentSystem != NULL)
            {
                Body* existingBody = parentSystem->find(primaryName);
                if (existingBody)
                {
                    if (disposition == AddObject)
                    {
                        errorMessagePrelude(tokenizer);
                        cerr << _("warning duplicate definition of ") <<
                            parentName << " " <<  primaryName << '\n';
                    }
                    else if (disposition == ReplaceObject)
开发者ID:nisselarsson,项目名称:Celestia,代码行数:67,代码来源:solarsys.cpp

示例3: createBody

static bool createBody(ParserContext* ctx, const xmlChar** att)
{
    const xmlChar* name = NULL;
    const xmlChar* parentName = NULL;

    // Get the name and parent attributes
    if (att != NULL)
    {
        for (int i = 0; att[i] != NULL; i += 2)
        {
            if (matchName(att[i], "name"))
                name = att[i + 1];
            else if (matchName(att[i], "parent"))
                parentName = att[i + 1];
        }
    }

    // Require that both are present
    if (name == NULL)
    {
        return false;
    }
    else if (parentName == NULL)
    {
        return false;
    }

    bool orbitsPlanet = false;
    Selection parent = ctx->universe->findPath(reinterpret_cast<const char*>(parentName), NULL, 0);
    PlanetarySystem* parentSystem = NULL;
    if (parent.star != NULL)
    {
        SolarSystem* solarSystem = ctx->universe->getSolarSystem(parent.star);
        if (solarSystem == NULL)
        {
            // No solar system defined for this star yet, so we need
            // to create it.
            solarSystem = ctx->universe->createSolarSystem(parent.star);
        }
        parentSystem = solarSystem->getPlanets();
    }
    else if (parent.body != NULL)
    {
        // Parent is a planet or moon
        parentSystem = parent.body->getSatellites();
        if (parentSystem == NULL)
        {
            // If the planet doesn't already have any satellites, we
            // have to create a new planetary system for it.
            parentSystem = new PlanetarySystem(parent.body);
            parent.body->setSatellites(parentSystem);
        }
        orbitsPlanet = true;
    }
    else
    {
        cout << "Parent body '" << parentName << "' of '" << name << "' not found.\n";
        return false;
    }

    if (parentSystem != NULL)
    {
        ctx->body = new Body(parentSystem);
        ctx->body->setName(reinterpret_cast<const char*>(name));
        parentSystem->addBody(ctx->body);
        return true;
    }

    return false;
}
开发者ID:jpcoles,项目名称:ZM,代码行数:70,代码来源:solarsysxml.cpp


注:本文中的SolarSystem::getPlanets方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。