本文整理汇总了C++中Heightmap::HeightAt方法的典型用法代码示例。如果您正苦于以下问题:C++ Heightmap::HeightAt方法的具体用法?C++ Heightmap::HeightAt怎么用?C++ Heightmap::HeightAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Heightmap
的用法示例。
在下文中一共展示了Heightmap::HeightAt方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: InitializeNode
void RenderDataManager::InitializeNode (TQuad *q)
{
assert (!q->renderData);
QuadRenderData *rd = q->renderData = Allocate ();
// Allocate vertex data space
int vertexSize = q->GetVertexSize ();
if (vertexSize != rd->vertexSize) {
int size = NUM_VERTICES * vertexSize;
if (rd->vertexBuffer.GetSize () != size)
rd->vertexBuffer.Init (size);
rd->vertexSize = vertexSize;
}
// build the vertex buffer
Vector3 *v = (Vector3*)rd->vertexBuffer.LockData ();
uint vda = q->textureSetup->vertexDataReq; // vertex data requirements
Heightmap *hm = roothm->GetLevel (q->depth); // get the right heightmap level
for(int y=q->hmPos.y;y<=q->hmPos.y+QUAD_W;y++)
for(int x=q->hmPos.x;x<=q->hmPos.x+QUAD_W;x++)
{
*(v++) = Vector3(x * hm->squareSize, hm->HeightAt (x,y), y * hm->squareSize);
Vector3 tangent, binormal;
CalculateTangents (hm, x,y, tangent, binormal);
Vector3 normal = binormal.cross(tangent);
normal.ANormalize ();
if (vda & VRT_Normal)
*(v++) = normal;
if (vda & VRT_TangentSpaceMatrix)
{
tangent.ANormalize ();
binormal.ANormalize ();
// orthonormal matrix, so inverse=transpose
// Take the inverse of the tangent space -> world space transformation
Vector3* tgs2ws = v;
tgs2ws[0] = Vector3(tangent.x, binormal.x, normal.x);
tgs2ws[1] = Vector3(tangent.y, binormal.y, normal.y);
tgs2ws[2] = Vector3(tangent.z, binormal.z, normal.z);
v+=3;
}
}
rd->vertexBuffer.UnlockData ();
rd->SetQuad(q);
}