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


C++ FilePtr::valid方法代码示例

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


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

示例1: loadEntities

bool LevelManager::loadEntities( const std::string& levelFile, std::vector< BaseEntity* >* p_entities, const std::string& instPostfix )
{
    log_info << "LevelManager: loading entities ..." << std::endl;

    // use tiny xml to parser lvl file
    yaf3dTinyXml::TiXmlDocument doc;
    doc.SetCondenseWhiteSpace( false );

    FilePtr file = FileSystem::get()->getFile( levelFile );
    if ( !file.valid() )
    {
        log_error << "LevelManager: file '" << levelFile << "' does not exit" << std::endl;
        return false;
    }

    char* p_filebuf = file->getBuffer();
    if ( !doc.Parse( p_filebuf ) )
    {
        log_error << "LevelManager: cannot load level file: '" << levelFile << "'" << std::endl;
        log_error << "              reason: " << doc.ErrorDesc() << std::endl;
        return false;
    }

    // start evaluating the xml structure
    //---------------------------------//
    yaf3dTinyXml::TiXmlNode*      p_node          = NULL;
    yaf3dTinyXml::TiXmlElement*   p_levelElement  = NULL;
    yaf3dTinyXml::TiXmlElement*   p_mapElement    = NULL;
    char*                         p_bufName       = NULL;

    // get the level entry if one exists
    p_node = doc.FirstChild( YAF3D_LVL_ELEM_LEVEL );
    std::string staticNodeName;
    if ( p_node )
    {
        // get level name
        p_levelElement = p_node->ToElement();
        if ( !p_levelElement )
        {
            log_error << "LevelManager: could not find level element" << std::endl;
            return false;
        }

        p_bufName = ( char* )p_levelElement->Attribute( YAF3D_LVL_ELEM_NAME );
        if ( p_bufName )
            staticNodeName = p_bufName;
        else
            return false;
    }
    else
    {
        log_error << "LevelManager: empty level file" << std::endl;
        return false;
    }

    // get map files, load them and add them to main group
    _levelHasMap = false; // reset the map flag
    p_node = p_levelElement->FirstChild( YAF3D_LVL_ELEM_MAP );
    do
    {
        // a level file can also be without a map
        if ( !p_node )
            break;

        _levelHasMap = true;
        p_mapElement = p_node->ToElement();
        p_bufName    = ( char* )p_mapElement->Attribute( YAF3D_LVL_ELEM_NAME );
        if ( p_bufName == NULL )
        {
            log_error << "LevelManager: missing map name in MAP entry" << std::endl;
            return false;
        }
        else
        {
            log_info << "LevelManager: loading static geometry: " << p_bufName << std::endl;
            osg::Node *p_staticnode = loadStaticWorld( p_bufName );
            if ( p_staticnode )
            {
                p_staticnode->setName( p_bufName );
                _staticMeshGroup->addChild( p_staticnode );
                _staticMesh = p_staticnode;
                _staticMesh->setName( staticNodeName );
            }
            else
                return false;
        }

        p_node = p_node->NextSiblingElement( YAF3D_LVL_ELEM_MAP );

    } while ( p_node );


    // read entity definitions
    //------------------------
    log_info << "LevelManager: creating entities ..." << std::endl;

    unsigned int entityCounter = 0;
    p_node = p_levelElement;
    for ( p_node = p_levelElement->FirstChild( YAF3D_LVL_ELEM_ENTITY ); p_node; p_node = p_node->NextSiblingElement( YAF3D_LVL_ELEM_ENTITY ) )
    {
//.........这里部分代码省略.........
开发者ID:BackupTheBerlios,项目名称:yag2002-svn,代码行数:101,代码来源:levelmanager.cpp


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