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


C++ ShapeList::push_back方法代码示例

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


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

示例1: sceneBoundary

DemoScene raytracer::gui::constructDemoScene()
{
    /// Load resources
    ResourceManager* resourceManager = ResourceManager::getInstance();
    Texture* terrainTexture = new TerrainHeightTexture( // multitexture for terrain
	    resourceManager->createImage("terrainImage1", "resources/terrain_dirt.tga"),
	    resourceManager->createImage("terrainImage2", "resources/terrain_grass.tga"),
	    resourceManager->createImage("terrainImage3", "resources/terrain_rock.tga"),
	    resourceManager->createImage("terrainImage4", "resources/terrain_snow.tga")
    );
    std::vector<Image*> skyBoxImages(6);
    skyBoxImages[0] = resourceManager->createImage("skyboxFront", "resources/miramar_ft.tga");
    skyBoxImages[1] = resourceManager->createImage("skyboxRight", "resources/miramar_rt.tga");
    skyBoxImages[2] = resourceManager->createImage("skyboxBack", "resources/miramar_bk.tga");
    skyBoxImages[3] = resourceManager->createImage("skyboxLeft", "resources/miramar_lf.tga");
    skyBoxImages[4] = resourceManager->createImage("skyboxUp", "resources/miramar_up.tga");
    skyBoxImages[5] = resourceManager->createImage("skyboxDown", "resources/miramar_dn.tga");
    std::vector<Texture*> skyBoxTextures(6);
    skyBoxTextures[0] = resourceManager->createTexture("skyboxFrontTexture", "skyboxFront");
    skyBoxTextures[1] = resourceManager->createTexture("skyboxRightTexture", "skyboxRight");
	skyBoxTextures[2] = resourceManager->createTexture("skyboxBackTexture", "skyboxBack");
	skyBoxTextures[3] = resourceManager->createTexture("skyboxLeftTexture", "skyboxLeft");
	skyBoxTextures[4] = resourceManager->createTexture("skyboxUpTexture", "skyboxUp");
	skyBoxTextures[5] = resourceManager->createTexture("skyboxDownTexture", "skyboxDown");
    // Define scene
    AABB sceneBoundary(Vector3(-1000, -1000, -1000), Vector3(1000, 1000, 1000));
    ShapeList shapes;
    shapes.push_back(new Sphere(Vector3(0.0f, 8.0f, -25.0f), 2.0f,
        new Material(0.5f, 1.2f, 0.5f, 20.0f, Material::NO_REFLECTION,
        Material::NO_REFRACTION, Colour(0.4f, 0.4f, 0.8f), NULL)
    ));
    shapes.push_back(new Sphere(Vector3(-4.0f, 10.0f, -20.0f), 2.0f,
        new Material(0.5f, 3.0f, 1.0f, 20.0f, 1.0f,
        Material::NO_REFRACTION, Colour(), NULL)
    ));
    shapes.push_back(new Sphere(Vector3(0.0f, 5.0f, -15.0f), 2.0f,
        new Material(0.5f, 1.2f, 0.5f, 20.0f, 0.5f,
            1.6666, Colour(0.8f, 0.2f, 0.2f), NULL)
    ));
    shapes.push_back(new Sphere(Vector3(3.0f, 5.0f, -26.5f), 1.0f,
        new Material(5.0f, 0.0f, 0.0f, 0.0f, 0.4f,
        Material::NO_REFRACTION, Colour(0.9f, 0.65f, 0.0f), NULL)
    ));
    // Load skybox
    shapes.push_back(shapeloaders::getSkyBox(common::SKYBOX_SIZE, skyBoxTextures));

	// Define all possible viewpoints
	std::vector<Camera> cameras;
	cameras.reserve(3);
	cameras.push_back(Camera(
        Vector3(0, 5.0f, 0), Vector3(0, 0, -1), Vector3(0, 1, 0),
        Rect(-100, 100, -100, 100), 200, false));
	cameras.push_back(Camera(
        Vector3(-10, 3.0f, -10.0f), Vector3(1, 0.2f, -1), Vector3(0, 1, 0),
        Rect(-100, 100, -100, 100), 200, false));        
	cameras.push_back(Camera(
        Vector3(5.0f, 30.0f, -50.0f), Vector3(0.0f, -0.6f, 1), Vector3(0, 1, 0),
        Rect(-100, 100, -100, 100), 200, false));
        
    // Load all possible terrain
    std::vector<std::string> heightmapFilenames;
    heightmapFilenames.push_back("resources/heightmap.tga");
    heightmapFilenames.push_back("resources/heightmap2.tga");
    heightmapFilenames.push_back("resources/heightmap3.tga");
    std::vector<Image*> heightmaps;
    for (unsigned int i = 0; (i < heightmapFilenames.size()); i++)
    	heightmaps.push_back( resourceManager->createImage("heightmap", heightmapFilenames[i]) );
    std::vector<Vector3> terrainOffsets;
    for (unsigned int i = 0; (i < heightmaps.size()); i++)
    {
		terrainOffsets.push_back(Vector3(
			-((common::TERRAIN_CELL_SIZE * heightmaps[i]->getWidth()) / 2.0f),
			0.0f, -((common::TERRAIN_CELL_SIZE * heightmaps[i]->getHeight()) / 2.0f))
		);
	}
	ShapeList terrainVariants;
    for (unsigned int i = 0; (i < heightmaps.size()); i++)
    {
		Shape* unoptimisedTerrain = shapeloaders::getTerrainFromHeightmap(
			heightmapFilenames[i], common::TERRAIN_CELL_SIZE,
			common::TERRAIN_MAX_HEIGHT, terrainOffsets[i], terrainTexture, false);
		Shape* optimisedTerrain = shapeloaders::getTerrainFromHeightmap(
			heightmapFilenames[i], common::TERRAIN_CELL_SIZE,
			common::TERRAIN_MAX_HEIGHT, terrainOffsets[i], terrainTexture, true);
	    terrainVariants.push_back(unoptimisedTerrain);
        terrainVariants.push_back(optimisedTerrain);
    }
    
    // Construct test shapes (lines of each terrain's octree)
    ShapeList octreeLines;
    for (unsigned int i = 0; (i < terrainVariants.size()); i += 2) // go in 2s so unoptimised terrain is skipped
    {
        LineList lines = dynamic_cast<Octree*>(terrainVariants[i + 1])->getBoundingLines();
        ShapeList lineShapes = generateLines(lines, 0.4f, NULL);
        BoundingShape* rootOfLines = new BoundingShape(lineShapes, sceneBoundary);
        octreeLines.push_back(rootOfLines);
    }

	// Create renderer to render scene
	Raytracer* renderer = new Raytracer(cameras[0]);
//.........这里部分代码省略.........
开发者ID:DonaldWhyte,项目名称:raytracer-experiments,代码行数:101,代码来源:DemoScene.cpp


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