本文整理汇总了C++中HeightMap::reserve方法的典型用法代码示例。如果您正苦于以下问题:C++ HeightMap::reserve方法的具体用法?C++ HeightMap::reserve怎么用?C++ HeightMap::reserve使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类HeightMap
的用法示例。
在下文中一共展示了HeightMap::reserve方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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");
}