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


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

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


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

示例2: main

int main()
{
	InitGlfw initGlfw;
	ShaderLoader shaderLoader;
	TextureLoader textureLoader;
	TextRenderer textRenderer;

	// Init
	initGlfw.Init();
	textRenderer.Init();
	glfwSetKeyCallback(initGlfw.window, KeyCallback);
	glfwSetMouseButtonCallback(initGlfw.window, MouseButtonCallback);
	glfwSetCursorPosCallback(initGlfw.window, MouseMoveCallback);

	// Shader loading
	GLuint defaultShaderProgram;
	GLuint textShaderProgram;
	GLuint simpleShaderProgram;
	defaultShaderProgram = shaderLoader.CreateProgram("Shaders\\vertex_shader.glsl", "Shaders\\fragment_shader.glsl");
	textShaderProgram = shaderLoader.CreateProgram("Shaders\\text_vs.glsl", "Shaders\\text_fs.glsl");
	simpleShaderProgram = shaderLoader.CreateProgram("Shaders\\simple_vertex_shader.glsl", "Shaders\\simple_fragment_shader.glsl");
	

	// Load texture
	GLuint texture = textureLoader.LoadRGB("Images\\container.jpg");
	GLuint blankTexture = textureLoader.LoadBlank();
	cout << "Blank texture status: " << blankTexture << endl;

	// Define camera component vectors
	float wallDistanceMargin = 0.2f;
	float currentX;
	float currentZ;

	glm::vec3 cameraPos = glm::vec3(0.0f, -0.5f, 6.0f);
	glm::vec3 cameraFront = glm::vec3(0.0f, 0.0f, -1.0f);
	glm::vec3 cameraUp = glm::vec3(0.0f, 1.0f, 0.0f);
	float yaw = -90.0f;
	glm::vec3 front(cos(glm::radians(yaw)), 0.0f, sin(glm::radians(yaw)));
	
	// Define model and view matrices and get shader locations
	GLuint modelLocation = glGetUniformLocation(defaultShaderProgram, "model");
	GLuint viewLocation = glGetUniformLocation(defaultShaderProgram, "view");
	GLuint projectionLocation = glGetUniformLocation(defaultShaderProgram, "projection");

	double currentTime = glfwGetTime();
	double delta;

	glm::mat4 view;
	glm::mat4 proj1;
	glm::mat4 idm  = glm::mat4();
	
	// Hard-coded virtual environment
	Square backWall;
	Square leftWall;
	Square rightWall;
	Square floorSquare;
	Square frontWall;
	Square rewardZone;

	float corridorDepth = 10.0f;
	float corridorWidth = 3.0f;
	float wallHeight = 2.0f;

	float rewardZoneDepth = 2.0f;
	float rewardZonePosition = -3.0f;

	float rewardZoneLowZ = rewardZonePosition - rewardZoneDepth;
	float rewardZoneHighZ = rewardZonePosition + rewardZoneDepth;
	bool inRewardZone = false;

	backWall.SetColor(0.5f, 0.5f, 0.9f);
	backWall.SetScaling(corridorWidth, wallHeight);
	backWall.SetPosition(0.0f, wallHeight/2, -corridorDepth);
	
	frontWall.SetColor(0.5f, 0.5f, 0.9f);
	frontWall.SetScaling(corridorWidth, wallHeight);
	frontWall.SetPosition(0.0f, wallHeight / 2.0f, corridorDepth);

	leftWall.SetColor(0.5f, 0.9f, 0.5f);
	leftWall.SetScaling(corridorDepth, wallHeight);
	leftWall.SetRotation(0.0f, 90.0f, 0.0f);
	leftWall.SetPosition(-corridorWidth, wallHeight/2, 0.0f);
	
	rightWall.SetColor(0.5f, 0.9f, 0.5f);
	rightWall.SetScaling(corridorDepth, wallHeight);
	rightWall.SetRotation(0.0f, 90.0f, 0.0f);
	rightWall.SetPosition(corridorWidth,wallHeight/2, 0.0f);
	
	floorSquare.SetColor(0.1f, 0.1f, 0.1f);
	floorSquare.SetScaling(corridorWidth, corridorDepth);
	floorSquare.SetRotation(-90.0f, 0.0f, 0.0f);
	floorSquare.SetPosition(0.0f, -wallHeight/2.0f, 0.0f);

	rewardZone.SetColor(0.2f, 0.9f, 0.2f);
	rewardZone.SetScaling(corridorWidth, rewardZoneDepth);
	rewardZone.SetRotation(-90.0f, 0.0f, 0.0f);
	rewardZone.SetPosition(0.0f, -wallHeight / 2.0f + 0.01f, rewardZonePosition);

	proj1 = glm::perspective(45.0f, (float)2.0f*initGlfw.windowInfo.width / initGlfw.windowInfo.height, 0.1f, 100.0f);
	glEnable(GL_DEPTH_TEST);
//.........这里部分代码省略.........
开发者ID:benvermaercke,项目名称:Virtual-reality,代码行数:101,代码来源:main.cpp


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