本文整理汇总了C++中HeightMap::set方法的典型用法代码示例。如果您正苦于以下问题:C++ HeightMap::set方法的具体用法?C++ HeightMap::set怎么用?C++ HeightMap::set使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HeightMap
的用法示例。
在下文中一共展示了HeightMap::set方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: outDown
TEST_F(Test_WorldTerrainNormalMap, slope45Degree)
{
const int hmSize = 2;
HeightMap hm;
hm.reserve(hmSize);
hm.set(0, 0, 1.0f);
hm.set(1, 0, 1.0f);
hm.set(0, 1, 0);
hm.set(1, 1, 0);
NormalMap nm;
nm.generate(hm);
//only two normals
EXPECT_EQ(nm.size(), 2);
//both normals should be pointing at an angle more downish
Vec3f n1 = nm.get(0);
Vec3f n2 = nm.get(0);
Vec3f outDown(0.0f, -.707107f, -.707107);
expectVec3fAreEqual(n1, outDown);
expectVec3fAreEqual(n2, outDown);
{
Vec3f p1(0, 1, 0);
Vec3f p2(1, 1, 0);
Vec3f p3(0, 0, 1);
}
}
示例2: up
TEST_F(Test_WorldTerrainNormalMap, flatTerrain)
{
const int hmSize = 2;
HeightMap hm;
hm.reserve(hmSize);
for (int y=0; y<hmSize; y++)
{
for (int x=0; x<hmSize; x++)
hm.set(x, y, 0.0f);
}
NormalMap nm;
nm.generate(hm);
//there should be only two normals (since there are two triangles)
EXPECT_EQ(nm.size(), 2);
//both normals should point straight up
Vec3f n1 = nm.get(0);
Vec3f n2 = nm.get(1);
Vec3f up(0.0f, -1.0f, 0.0f);
expectVec3fAreEqual(n1, up, "The normal is not straight up");
expectVec3fAreEqual(n2, up, "The normal is not straight up");
}
示例3: tilable
/**Convert an image to a height map. The image is treated as grey-scale.
@param border create a height map which is larger than the source image. The source
image will be centered in the heightmap which creates a kind of border. This border
is filled with by tiling the soure image. If your source image was
created to be tilable (it ought to be) then the heightmap will be seamless. The whole
point of this is so that you can call HeightMap.blur() without ruining the seamless
nature of your heightmap. (After bluring you should ignore the border region)
*/
HeightMap * imageToHeightMap_tilable(GLImage & img, int border)
{
HeightMap * hmap = new HeightMap(img.width + border + border, img.height + border + border);
for (int y = 0; y < hmap->H; y++)
{
for (int x = 0; x < hmap->W; x++)
{
int imgX = infinite_coord_to_finite(x - border, img.width);
int imgY = infinite_coord_to_finite(y - border, img.height);
//TODO: GLImage should be a class with an inline getPixelPtr(x,y) method.
GLubyte * pixel = &img.texels[((imgY * img.width) + imgX) * img.internalFormat];
hmap->set(x, y, pixel[0] / 255.0f);
}
}
return hmap;
}