本文整理汇总了C++中vec3f::flen2D方法的典型用法代码示例。如果您正苦于以下问题:C++ vec3f::flen2D方法的具体用法?C++ vec3f::flen2D怎么用?C++ vec3f::flen2D使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类vec3f
的用法示例。
在下文中一共展示了vec3f::flen2D方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawSquare
void CSMFRenderer::DrawSquare(RSquare& q, const vec3f& v, const CReadMap* rm, const float* hm) {
const float d = v.flen2D() - 0.01f;
const int xshift = GetXLOD(d, viewRadius, squareSizeX, lodDists);
const int zshift = GetZLOD(d, viewRadius, squareSizeZ, lodDists);
const int xlod = (1 << xshift);
const int zlod = (1 << zshift);
const int xverts = (squareSizeX / xlod) + 1; // #vertices in the x-direction for this square
const int zverts = (squareSizeZ / zlod) + 1; // #vertices in the z-direction for this square
const int numQuads = (xverts - 1) * (zverts - 1); // #quads needed to cover square at wanted LOD
const bool wantList = (xlod == 1 && zlod == 1); // highest-LOD squares are rendered from dlists
int vertex = 0;
int offset = 0;
const float r = 1.0f - (xshift * 0.1667f), g = 0.333f, b = (zshift * 0.1667f);
glColor3f(r, g, b);
if (q.hasDisLst && wantList) {
// note: for deformable terrain, the list
// would possibly need to be invalidated
glCallList(q.disLstID);
} else {
if (!q.hasDisLst && wantList) {
q.disLstID = glGenLists(1);
glNewList(q.disLstID, GL_COMPILE);
}
va.Initialize();
va.EnlargeArrays(numQuads * 4, 0, VA_SIZE_N);
// note: LESS OR EQUAL, so that when {x, z}lod == squareSize{X, Z}
// four vertices (two in each direction) are added instead of one
for (int x = 0; x <= squareSizeX; x += xlod) {
for (int z = 0; z <= squareSizeZ; z += zlod) {
vec3f tl(q.tlp.x + x, 0.0f, q.tlp.z + z); tl.y = GetHeight(hm, tl.x, tl.z);
vec3f nv = GetVertexNormal(hm, q, tl, rm->maxxpos, rm->maxzpos, x, xlod, z, zlod);
va.AddVertexN(tl, nv);
// the bottom- and right-most row and column
// of vertices do not define any new quads
// if ((x < squareSizeX && z < squareSizeZ)) {
if (!(x & squareSizeX) && !(z & squareSizeZ)) {
indices[offset++] = vertex + 0; // tl
indices[offset++] = vertex + zverts; // tr
indices[offset++] = vertex + zverts + 1; // br
indices[offset++] = vertex + 1; // bl
}
vertex++;
}
}
/// FIXME: add indexed drawing to VA class
/// va.Draw(numQuads, indices);
va.DrawArrayN(GL_QUADS);
if (!q.hasDisLst && wantList) {
q.hasDisLst = true;
glEndList();
}
}
glColor3f(1.0f, 1.0f, 1.0f);
}