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


C++ Point2F::length方法代码示例

本文整理汇总了C++中Point2F::length方法的典型用法代码示例。如果您正苦于以下问题:C++ Point2F::length方法的具体用法?C++ Point2F::length怎么用?C++ Point2F::length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Point2F的用法示例。


在下文中一共展示了Point2F::length方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: render


//.........这里部分代码省略.........
	glEnable(GL_CULL_FACE);
	glEnable(GL_ALPHA);
	glEnable(GL_MULTISAMPLE);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

	//Camera
	viewMatrix = glm::mat4x4(1);
	viewMatrix = glm::rotate(viewMatrix, pitch, glm::vec3(1, 0, 0));
	viewMatrix = glm::rotate(viewMatrix, yaw, glm::vec3(0, 1, 0));
	viewMatrix = glm::rotate(viewMatrix, -90.0f, glm::vec3(1, 0, 0));
	//	viewMatrix = glm::translate(viewMatrix, -cameraPosition);
	viewMatrix = glm::translate(viewMatrix, cameraPosition);

	glLoadMatrixf(&modelviewMatrix[0][0]);

	//Clear
	glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
	glClearColor(0.5f, 0.5f, 0.5f, 1.0f);
	glLightfv(GL_LIGHT0, GL_POSITION, gLightDirection);

	Point3F offset = {0.f, 0.f, 0.f};

	if (listNeedsDisplay) {
		displayList = glGenLists(1);
		glNewList(displayList, GL_COMPILE_AND_EXECUTE);
		for (U32 index = 0; index < difCount; index ++) {
			difs[index]->render();
		}
		glEndList();
		listNeedsDisplay = false;
	} else {
		glCallList(displayList);
	}

	sphere->render(ColorF(1, 1, 0, 1));
	glDisable(GL_CULL_FACE);

	if (selection.hasSelection) {
		Surface surface = selection.interior->surface[selection.surfaceIndex];
		TexGenEq texGenEq = selection.interior->texGenEq[surface.texGenIndex];
		Point3F normal = selection.interior->normal[selection.interior->plane[surface.planeIndex].normalIndex];
		Point3F first = selection.interior->point[selection.interior->index[surface.windingStart]];
		F32 len = 0;

		glBegin(GL_TRIANGLE_STRIP);
		for (U32 i = 0; i < surface.windingCount; i ++) {
			Point3F vert = selection.interior->point[selection.interior->index[surface.windingStart + i]];

			glVertex3f(vert.x, vert.y, vert.z);

			Point2F point = point3F_project_plane(vert, normal, first);
			F32 distance = point.length();
			len = (distance > len ? distance : len);
		}
		glEnd();

		glMatrixMode(GL_PROJECTION);
		glPushMatrix();
		glLoadIdentity();
		glOrtho(-1, 1, -1, 1, -100, 100);
		glMatrixMode(GL_MODELVIEW);
		glDisable(GL_LIGHTING);
		glEnable(GL_TEXTURE_2D);
		glLoadIdentity();

		Texture *texture = selection.interior->texture[surface.textureIndex];
		if (texture) {
			if (!texture->generated) {
				texture->generateBuffer();
			}
			texture->activate();
		}

		glBegin(GL_TRIANGLE_STRIP);

		int w, h;
		SDL_GetWindowSize(window, &w, &h);

		GLfloat aspect = (GLfloat)w / (GLfloat)h;

		for (U32 i = 0; i < surface.windingCount; i ++) {
			Point3F vert = selection.interior->point[selection.interior->index[surface.windingStart + i]];

			Point2F texuv = Point2F(planeF_distance_to_point(texGenEq.planeX, vert), planeF_distance_to_point(texGenEq.planeY, vert));
			glTexCoord2fv(&texuv.x);

			Point2F point = point3F_project_plane(vert, (surface.planeFlipped ? normal * -1 : normal), first);
			glVertex3f(point.x / len / aspect, point.y / len, 0);
		}
		glEnd();

		if (texture)
			texture->deactivate();
		glDisable(GL_TEXTURE_2D);
		glEnable(GL_LIGHTING);
		glMatrixMode(GL_PROJECTION);
		glPopMatrix();
	}
#endif
}
开发者ID:AbhinavJain13,项目名称:DifViewer,代码行数:101,代码来源:scene.cpp


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