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


C++ Terrain::computeNormals方法代码示例

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


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

示例1: loadTerrain

Terrain* loadTerrain(const char* filename, float height) {
	Image* image = loadBMP(filename);
	Terrain* t = new Terrain(image->width, image->height);
	for (int y = 0; y < image->height; y++) {
		for (int x = 0; x < image->width; x++) {
			unsigned char color =
				(unsigned char)image->pixels[3 * (y * image->width + x)];
			float h = height * ((color / 255.0f) - 0.5f);
			t->setHeight(x, y, h);
		}
	}
	delete image;
	t->computeNormals();
	return t;
}
开发者ID:shujie-ali,项目名称:Displacement-Texture-Mapping,代码行数:15,代码来源:Source.cpp

示例2: loadTerrain

//Loads a terrain from a heightmap.  The heights of the terrain range from
//-height / 2 to height / 2.
Terrain* loadTerrain(float width, float length) {
    //Build basic terrain
    Terrain* t = new Terrain(width, length);
    for(int y = 0; y < length; y++) {
        for(int x = 0; x < width; x++) {
            float min = -2.0f;
            float max =  3.0f;
            float h = 1.0f;//min + (float)rand()/((float)RAND_MAX/(max-min));
            t->setHeight(x, y, h);
        }
    }

    //squareStep(Terrain* t, int xStart, int yStart, int d, float height)
    int d = 4;
    int h = 3;
    for(int x = 0; x < t->length(); x += d) {
        for(int y = 0; y < t->width(); y += d) {
            //printf("Starting Squares\n");
            squareStep( t, x, y, d, h);
            //printf("Starting Diamonds\n");
            diamondStep(t, x, y, d, h);
            //d--;
            //h--;
        }
    }

    int numMount = rand() % 20 + 1;
    printf ("Making %d mountains.\n", numMount);
    for(int i = 0; i < numMount; i++) {
        //buildMountain(t);
    }

    int numRivers = rand() % 3 + 1;
    printf ("Making %d rivers.\n", numRivers);
    for(int i = 0; i < numRivers; i++) {
        //buildRiver(t);
    }

    int terPasses = 20;
    printf ("Generating terrain.\n");
    for (int i = 0; i < terPasses; i++) {
        //buildTerrain(t);
    }

    t->computeNormals();
    return t;
}
开发者ID:blhall,项目名称:terrainbuilder,代码行数:49,代码来源:main.bu.cpp

示例3: loadTerrain

//Loads a terrain from a heightmap.  The heights of the terrain range from
//-height / 2 to height / 2.
Terrain* loadTerrain(const char* filename, float height) {
    Image* image = loadBMP(filename);
    int  span=2;
    Terrain* t = new Terrain(image->width*span, image->height*span);
    for(int y = 0; y < image->height*span; y++) {
        for(int x = 0; x < image->width*span; x++) {
            unsigned char color =
                (unsigned char)image->pixels[3 * ((y%image->height) * image->width + x%image->width)];
            float h = height * ((color / 255.0f) - 0.5f);
            if(h<0)
                t->setHeight(x, y, 0);
            else
                t->setHeight(x, y, h);

        }
    }

    delete image;
    t->computeNormals();
    return t;
}
开发者ID:Sushmareddy05,项目名称:3D-game-project,代码行数:23,代码来源:graphics.cpp


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