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


C++ Square::SetTopLeft方法代码示例

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


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

示例1: LoadMesh

// Load functions are performed on initialization
void TextureCorridor::LoadMesh(int corridorType)
{
	for (int i = 0; i < squareList.size(); ++i)
		delete squareList[i];
	squareList.clear();

	Square* square = new Square;

	vector<float> xValues = { corridorWidth,corridorWidth, 2.0f*corridorWidth, 2.0f*corridorWidth, corridorWidth };

	
	square->SetScaling(2.0f*corridorWidth, 60*wallHeight);
	square->SetRotation(-90.0f, 0.0f, 0.0f);
	square->SetPosition(0.0f, 0.0f, -(corridorDepth-wallHeight));
	square->SetTextureID(textureMap["floor"]);
	squareList.push_back(square);

	switch (corridorType)
	{
		// Straight corridor
		case 1:
			for (size_t wallIndex = 1; wallIndex <= 60; ++wallIndex)
			{
				float x1 = corridorWidth;
				float x2 = corridorWidth;
				float y1 = wallHeight ;
				float y2 = 0.0f;
				float z1 = -((wallIndex - 1)*wallHeight);
				float z2 = z1 - wallHeight;

				string texname = "tex" + to_string(((wallIndex - 1) % nTextures) + 1);

				// left wall #1
				square = new Square;
				square->SetTopLeft(x1, y1, z1);;
				square->SetBottomLeft(x1, y2, z1);
				square->SetTopRight(x2, y1, z2);
				square->SetBottomRight(x2, y2, z2);
				square->SetTextureID(textureMap[texname]);
				square->Apply();
				squareList.push_back(square);

				// right wall
				square = new Square;
				square->SetTopLeft(-x1, y1, z1);;
				square->SetBottomLeft(-x1, y2, z1);
				square->SetTopRight(-x2, y1, z2);
				square->SetBottomRight(-x2, y2, z2);
				square->SetTextureID(textureMap[texname]);
				square->Apply();
				squareList.push_back(square);
			}
			break;

		// Corridor with varying geometry
		case 2:
			for (size_t wallIndex = 1; wallIndex <= 60; ++wallIndex)
			{
				float x1 = xValues[(wallIndex - 1) % xValues.size()];
				float x2 = xValues[(wallIndex) % xValues.size()];
				float y1 = wallHeight;
				float y2 = 0.0f;
				float z1 = -((wallIndex - 1)*wallHeight);
				float z2 = z1 - wallHeight;

				string texname = "tex" + to_string(((wallIndex - 1) % nTextures) + 1);

				// left wall #1
				square = new Square;
				square->SetTopLeft(x1, y1, z1);;
				square->SetBottomLeft(x1, y2, z1);
				square->SetTopRight(x2, y1, z2);
				square->SetBottomRight(x2, y2, z2);
				square->SetTextureID(textureMap[texname]);
				square->Apply();
				squareList.push_back(square);

				// right wall
				square = new Square;
				square->SetTopLeft(-x1, y1, z1);;
				square->SetBottomLeft(-x1, y2, z1);
				square->SetTopRight(-x2, y1, z2);
				square->SetBottomRight(-x2, y2, z2);
				square->SetTextureID(textureMap[texname]);
				square->Apply();
				squareList.push_back(square);
			}
			break;
	default:
		break;
	}
}
开发者ID:lbp-leuven,项目名称:Virtual-reality,代码行数:93,代码来源:TexturedCorridor.cpp


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