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


C++ vec3f::flen2D方法代码示例

本文整理汇总了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);
}
开发者ID:Error323,项目名称:CORPSE,代码行数:68,代码来源:SMFRenderer.cpp


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