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


C++ Flag::getZ方法代码示例

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


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

示例1: drawFlag

void Quiddiards::drawFlag(Flag& flag){
	/* draw flag stick */
	glPushMatrix();
	glTranslatef(flag.getX(), flag.getY(), 0);

	bindTexture("stick.jpg");
	gluCylinder(quad, flag.getStickR(), flag.getStickR(), flag.getZ(), 12, 6);
	releaseTexture();
	glPopMatrix();

	glPushMatrix();
	glTranslatef(flag.getX(), flag.getY(), flag.getZ());
	glRotatef(-90.0f, 1, 0, 0);
	float theta = 57.3f*atan2f(wind.y(), wind.x());
	glRotatef(theta, 0, -1, 0);
	glScalef(flag.getWid() / flag.RESO, flag.getHgt() / flag.RESO, flag.getBend());
	glTranslatef(0, 0, -flag.at(0, 0, 2));	// stick the flag to the stick

	/* load flag textures */
	switch (flag.getType()){
	case Flag::GRYFFINDOR:
		bindTexture("gryf.jpg");
		break;
	case Flag::SLYTHERIN:
		bindTexture("slyt.jpg");
		break;
	case Flag::HUFFLEPUFF:
		bindTexture("huff.jpg");
		break;
	case Flag::RAVENCLAW:
		bindTexture("rave.jpg");
		break;
	default:
		QVector3D color = flag.getColor();
		glColor3f(color.x(), color.y(), color.z());
		break;
	}
	/* use nurbs surface */
	/* nurbs points */
	//static const int sn = 8, tn = 4;	// surface and texture's u&v array size
	//static GLfloat texpts1[4 * 2] = { 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f };
	//static GLfloat texpts2[4 * 2] = { 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f };
	//static GLfloat knots[sn] = { 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f };
	//static GLfloat tknots[tn] = { 0.0f, 0.0f, 1.0f, 1.0f };
	///* front */
	//static int n = Flag::RESO;
	//gluBeginSurface(nurbs);
	//gluNurbsSurface(nurbs, tn, tknots, tn, tknots, 2 * 2, 2, texpts1, tn / 2, tn / 2, GL_MAP2_TEXTURE_COORD_2);
	//gluNurbsSurface(nurbs, sn, knots, sn, knots, 3 * n, 3, flag.getPoints(), sn / 2, sn / 2, GL_MAP2_VERTEX_3);
	//gluEndSurface(nurbs);
	///* back */
	//glFrontFace(GL_CW);
	//gluBeginSurface(nurbs);
	//gluNurbsSurface(nurbs, tn, tknots, tn, tknots, 2 * 2, 2, texpts2, tn / 2, tn / 2, GL_MAP2_TEXTURE_COORD_2);
	//gluNurbsSurface(nurbs, sn, knots, sn, knots, 3 * n, 3, flag.getPoints(), sn / 2, sn / 2, GL_MAP2_VERTEX_3);
	//gluEndSurface(nurbs);
	//glFrontFace(GL_CCW);

	/* use quadrics */
	float x1, y1, x2, y2;
	int n = Flag::RESO - 1;
	glBegin(GL_QUADS);
	for (int x = 0; x < n; x++){
		for (int y = 0; y < n; y++){
			x1 = float(x) / n;
			y1 = float(y) / n;
			x2 = float(x + 1) / n;
			y2 = float(y + 1) / n;

			glTexCoord2f(x1, y1);
			glVertex3f(flag.at(x, y, 0), flag.at(x, y, 1), flag.at(x, y, 2));
			glTexCoord2f(x1, y2);
			glVertex3f(flag.at(x, y + 1, 0), flag.at(x, y + 1, 1), flag.at(x, y + 1, 2));
			glTexCoord2f(x2, y2);
			glVertex3f(flag.at(x + 1, y + 1, 0), flag.at(x + 1, y + 1, 1), flag.at(x + 1, y + 1, 2));
			glTexCoord2f(x2, y1);
			glVertex3f(flag.at(x + 1, y, 0), flag.at(x + 1, y, 1), flag.at(x + 1, y, 2));
		}
	}
	glEnd();

	glBegin(GL_QUADS);
	for (int x = 0; x < n; x++){
		for (int y = 0; y < n; y++){
			x1 = float(x) / n;
			y1 = float(y) / n;
			x2 = float(x + 1) / n;
			y2 = float(y + 1) / n;

			glTexCoord2f(x1, y1);
			glVertex3f(flag.at(n - x, y, 0), flag.at(n - x, y, 1), flag.at(n - x, y, 2));
			glTexCoord2f(x1, y2);
			glVertex3f(flag.at(n - x, y + 1, 0), flag.at(n - x, y + 1, 1), flag.at(n - x, y + 1, 2));
			glTexCoord2f(x2, y2);
			glVertex3f(flag.at(n - 1 - x, y + 1, 0), flag.at(n - 1 - x, y + 1, 1), flag.at(n - 1 - x, y + 1, 2));
			glTexCoord2f(x2, y1);
			glVertex3f(flag.at(n - 1 - x, y, 0), flag.at(n - 1 - x, y, 1), flag.at(n - 1 - x, y, 2));
		}
	}
	glEnd();
//.........这里部分代码省略.........
开发者ID:silencious,项目名称:Quiddiards,代码行数:101,代码来源:quiddiards.cpp


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