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


C++ Path::Load方法代码示例

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


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

示例1: Load

bool Level::Load(std::string aFilename) {
  //Open xml
  pugi::xml_document doc;
  if (!doc.load_file(aFilename.c_str())) {
    std::cout << "Could not open file " << aFilename << " on Level::Load" << std::endl;
    return false;
  }
  
  //Load map
  if(!mMap.Load(doc.child("level").child("map"))) {
    std::cout << "Level loading error: could not load <map>, son of <level> on " << aFilename << std::endl;
    assert(0);
    return false;
  }

  //Load paths
  for(pugi::xml_node const& pathNode : doc.child("level").child("paths").children("path")) {
    Path p;
    bool const ret_val = p.Load(pathNode);
    if(!ret_val) {
      std::cout << "Could not load a <path> node while loading a <level><paths>" << std::endl;
      assert(0);
      return false;
    }
    mAssociatedPaths.push_back(p);
  }

  //Load avalanchas
  float accum_time=0.0f;
  for(pugi::xml_node const& avalanchaNode : doc.child("level").child("avalanchas").children()) {
    Avalancha *const p = BuildAvalancha(avalanchaNode, accum_time);
    if(p==nullptr) {
      std::cout << "Could not load an <avalancha> node while loading a <level><avalanchas>" << std::endl;
      assert(0);
      return false;
    }
    accum_time += p->temporal_length();
    mAvalanchas.push_back(p);
  }
  return true;
}
开发者ID:alexgg-developer,项目名称:3d_vj2014,代码行数:41,代码来源:Level.cpp

示例2: LoadScene

void World::LoadScene(const char * scene_path)
{
	// Using case-insensitive strings and streams for easier parsing
	ci_ifstream input;
	input.open(scene_path, ios::in);

	// Invalid file
	if(input.fail() )
	{	 
		fprintf(stderr, "Error loading file: %s\n", scene_path);
		getchar();
		exit(-1);
	}

	ci_string item;
	while( std::getline( input, item, '[' ) )   
	{
        ci_istringstream iss( item );

		ci_string result;
		if( std::getline( iss, result, ']') )
		{
			if( result == "cube" )
			{
				// Box attributes
				CubeModel* cube = new CubeModel();
				cube->Load(iss);
				mModel.push_back(cube);
			}
            else if( result == "sphere" )
            {
                SphereModel* sphere = new SphereModel();
                sphere->Load(iss);
                mModel.push_back(sphere);
            }
            else if( result == "path" )
			{
				Path* path = new Path();
				path->Load(iss);
                mPath.push_back(path);
			}
            else if( result == "spline" )
			{
				BSpline* path = new BSpline();
				path->Load(iss);
                mSpline.push_back(path);
			}
		
			else if ( result.empty() == false && result[0] == '#')
			{
				// this is a comment line
			}
			else
			{
				fprintf(stderr, "Error loading scene file... !");
				getchar();
				exit(-1);
			}
	    }
	}
	input.close();

	// Set PATH vertex buffers
	for (vector<Path*>::iterator it = mPath.begin(); it < mPath.end(); ++it)
	{
		// Draw model
		(*it)->CreateVertexBuffer();
	}

    // Set B-SPLINE vertex buffers
    for (vector<BSpline*>::iterator it = mSpline.begin(); it < mSpline.end(); ++it)
	{
		// Draw model
		(*it)->CreateVertexBuffer();
	}

	//LOAD DAT OBJ MODEL YO
	vector<OBJModel*> pokemon = PokemonGenerator::GeneratePokemon();
	for (int i = 0; i < pokemon.size(); i++)
		mModel.push_back(pokemon[i]);
	srand(20);

	OBJModel* grass = new OBJModel("../Models/Grass_02.obj");
	for (int i = 0; i < 50; i++){

		OBJModel* newgrass = new OBJModel(*grass);
		newgrass->SetPosition(vec3(rand() % 150 - 75, 0, rand() % 150 - 75));
		newgrass->SetScaling(vec3(1, 1, 1));
		mModel.push_back(newgrass);
	}

	// DAYTIME - default
	groundDay = new SkyboxModel("../Models/cube.obj");
	groundDay->SetSwitch(true);
	groundDay->SetPosition(vec3(0, -2.5, 0));
	groundDay->SetScaling(vec3(150, 5, 150));
	mModel.push_back(groundDay);

	skyboxDay = new SkyboxModel("../Models/ds.obj");
	skyboxDay->SetSwitch(true);
//.........这里部分代码省略.........
开发者ID:tawjaw,项目名称:IslandAdventures,代码行数:101,代码来源:World.cpp


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