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


C++ VertexArray::SetTexCoordSets方法代码示例

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


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

示例1: if

VertexArray VertexArray::operator+ (const VertexArray & v) const
{
	VertexArray out;

	COMBINEVECTORS(colors);

	COMBINEVECTORS(normals);

	COMBINEVECTORS(vertices);

	int idxoffset = vertices.size() / 3;
	out.faces.reserve(faces.size() + v.faces.size());
	out.faces.insert(out.faces.end(), faces.begin(), faces.end());
	for (size_t i = 0; i < v.faces.size(); i++)
	{
		out.faces.push_back(v.faces[i]+idxoffset);
	}

	int maxtcsets = GetTexCoordSets();
	if (v.GetTexCoordSets() > maxtcsets)
		maxtcsets = v.GetTexCoordSets();
	int tcsets1 = GetTexCoordSets();
	int tcsets2 = v.GetTexCoordSets();
	out.SetTexCoordSets(maxtcsets);
	for (int i = 0; i < maxtcsets; i++)
	{
		if (i >= tcsets1 && i < tcsets2)
		{
			out.texcoords[i] = v.texcoords[i];
		}
		else if (i < tcsets1 && i >= tcsets2)
		{
			out.texcoords[i] = texcoords[i];
		}
		else if (i < tcsets1 && i < tcsets2)
		{
			COMBINEVECTORS(texcoords[i]);
		}
	}

	return out;
}
开发者ID:HaohaoLau,项目名称:vdrift,代码行数:42,代码来源:vertexarray.cpp

示例2: RenderCharacter

float TextDraw::RenderCharacter(
	const Font & font, char c,
	float x, float y, float scalex, float scaley,
	VertexArray & output_array)
{
	const Font::CharInfo * ci = 0;
	if (!font.GetCharInfo(c, ci)) return 0;

	float invsize = font.GetInvSize();
	float x1 = x + ci->xoffset * invsize * scalex;
	float x2 = x1 + ci->width * invsize * scalex;
	float y1 = y - ci->yoffset * invsize * scaley;
	float y2 = y1 + ci->height * invsize * scaley;

	float u1 = ci->x;
	float u2 = u1 + ci->width;
	float v1 = ci->y;
	float v2 = v1 + ci->height;

	float v[] = {x1, y1, 0, x2, y1, 0, x2, y2, 0, x1, y2, 0};
	float t[] = {u1, v1, u2, v1, u2, v2, u1, v2};
	int f[] = {0, 1, 2, 0, 2, 3};

	if (output_array.GetTexCoordSets() == 0)
	{
		output_array.SetFaces(f, 6);
		output_array.SetVertices(v, 12);
		output_array.SetTexCoordSets(1);
		output_array.SetTexCoords(0, t, 8);
	}
	else
	{
		float * n = 0;
		output_array.Add(0, 0, n, 0, v, 12, f, 6, t, 8);
	}

	return ci->xadvance * invsize * scalex;
}
开发者ID:HaohaoLau,项目名称:vdrift,代码行数:38,代码来源:text_draw.cpp

示例3: Set

void HudGauge::Set(
	SceneNode & parent,
	const std::tr1::shared_ptr<Texture> & texture,
	const Font & font,
	float hwratio,
	float centerx,
	float centery,
	float radius,
	float startangle,
	float endangle,
	float startvalue,
	float endvalue,
	float valuedelta)
{
	assert(texture);

	// calculate number of segments (max 9)
	float segments = (endvalue - startvalue) / valuedelta;
	float factor = ceil(segments / 9.0f);
	segments = ceil(segments / factor);
	valuedelta = valuedelta * factor;
	endvalue = startvalue + segments * valuedelta;

	this->texture = texture;
	this->centerx = centerx;
	this->centery = centery;
	this->scalex = radius * hwratio;
	this->scaley = radius;
	this->startangle = startangle;
	this->endangle = endangle;
	this->scale = (endangle - startangle) / (endvalue - startvalue);

	// reset
	EraseTextDrawable(parent, dialnum_draw);
	EraseDrawable(parent, pointer_draw);
	EraseDrawable(parent, dial_draw);
	pointer_rotated.Clear();
	pointer.Clear();
	dial_label.Clear();
	dial_marks.Clear();

	// dial marks
	{
		// big marker
		float pb[] = {-0.02, 1, 0, 0.02, 1, 0, 0.02, 0.92, 0, -0.02, 0.92, 0};
		float t[] = {0, 0, 1, 0, 1, 1, 0, 1};
		int f[] = {0, 2, 1, 0, 3, 2};
		VertexArray bm;
		bm.SetVertices(pb, 12);
		bm.SetTexCoordSets(1);
		bm.SetTexCoords(0, t, 8);
		bm.SetFaces(f, 6);

		// small marker
		float ps[] = {-0.01, 1, 0, 0.01, 1, 0, 0.01, 0.95, 0, -0.01, 0.95, 0};
		VertexArray sm;
		sm.SetVertices(ps, 12);
		sm.SetTexCoordSets(1);
		sm.SetTexCoords(0, t, 8);
		sm.SetFaces(f, 6);

		float delta = (endangle - startangle) / (3.0 * segments);
		float angle = startangle;
		for (int i = 0; i <= 3 * segments; ++i)
		{
			VertexArray temp = (i % 3) ? sm : bm;
			temp.Rotate(angle, 0, 0, -1);
			dial_marks = dial_marks + temp;
			angle = angle + delta;
		}
		dial_marks.Scale(radius * hwratio, radius, 1);
		dial_marks.Translate(centerx, centery, 0.0);

		dial_draw = AddDrawable(parent);
		Drawable & drawref = GetDrawable(parent, dial_draw);
		drawref.SetTextures(texture->GetID());
		drawref.SetVertArray(&dial_marks);
		drawref.SetCull(false, false);
		//drawref.SetColor(1, 1, 1, 0.5);
		drawref.SetDrawOrder(1);
	}

	// dial label
	{
		VertexArray temp;
		float w = 0.25 * radius * hwratio;
		float h = 0.25 * radius;
		float angle = startangle;
		float angle_delta = (endangle - startangle) / segments;
		float value = startvalue;
		float value_delta = (endvalue - startvalue) / segments;
		for (int i = 0; i <= segments; ++i)
		{
			std::stringstream sstr;
			std::string text;
			sstr << value;
			sstr >> text;
			float x = centerx + 0.75 * sin(angle) * radius * hwratio;
			float y = centery + 0.75 * cos(angle) * radius;
			float xn = TextDraw::RenderText(font, text, x, y, w, h, temp);
//.........这里部分代码省略.........
开发者ID:lwllovewf2010,项目名称:vdrift,代码行数:101,代码来源:hudgauge.cpp


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