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


C++ LSystem::transform方法代码示例

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


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

示例1: initScene

	void MainApplication::initScene()
	{
		m_components.clear();

		Material * grassMaterial = new Material(Shader::find("shader"));
		grassMaterial->setTexture(new Texture("resources/ground.bmp"));
		grassMaterial->setDiffuseColor(glm::vec4(1.0f, 1.0f, 1.0f, 1.0f));
		grassMaterial->setAmbientColor(glm::vec4(0.5f, 0.5f, 0.5f, 1.0f));

		Mesh * terrain = MeshFactory::Terrain();
		MeshObject * grass = new MeshObject(terrain, grassMaterial);
		grass->transform().scale(glm::vec3(10.0f));
		grass->transform().translate(glm::vec3(-5.0f, 0.0f, -5.0f));

		m_components.push_back(grass);

		{ // palm tree
			PlantDefinition * def = new PlantDefinition();
			def->iterations = 2;
			def->angle = 22.5f;
			def->diameter = 0.10f;
			def->length = 0.20f;
			def->thinning = 1.9f;
			def->axiom = "F";
			def->addTerminals("+-!?&/[]Q");
			def->addProduction('F', "F[-F]F[+F]F[&F]F[/F]F[QQQQQ]F");
			def->barkTexture = "resources/bark_palm.bmp";
			def->leafTexture = "resources/palm_leaf.bmp";
			def->size = 0.5f;

			LSystem * system = new LSystem(def);

			glm::vec3 position = terrain->vertexAt(random.randXX(0, terrain->vertices().size()-1)).position;
			position = glm::vec3(grass->transform().world() * glm::vec4(position, 1.0f));
			system->transform().translate(position);
			m_components.push_back(system);
		}

		{ // tropical tree
			PlantDefinition * def = new PlantDefinition();
			def->addTerminals("+-!?&/[]<Q`");
			def->iterations = 7;
			def->angle = 22.5f;
			def->diameter = 0.15f;
			def->length = 0.15f;
			def->thinning = 1.5f;
			def->axiom = "A";
			def->addProduction('A', "[+FLA]?????[+FLA]???????`[+FLA]");
			def->addProduction('F', "S?????F");
			def->addProduction('S', "F");
			def->addProduction('L', "[Q--Q][Q&&Q]");
			def->barkTexture = "resources/bark.bmp";
			def->leafTexture = "resources/leaf.bmp";

			LSystem * system = new LSystem(def);

			glm::vec3 position = terrain->vertexAt(random.randXX(0, terrain->vertices().size()-1)).position;
			position = glm::vec3(grass->transform().world() * glm::vec4(position, 1.0f));
			system->transform().translate(position);
			m_components.push_back(system);
		}

		{ // small tree
			PlantDefinition * def = new PlantDefinition();
			def->addTerminals("+-!?&/[]<FQ");
			def->iterations = 13;
			def->angle = 15.0f;
			def->diameter = 0.02f;
			def->length = 0.15f;
			def->thinning = 1.3f;
			def->axiom = "FA";
			def->addProduction('A', "/FB???B?????BQ");
			def->addProduction('B', "[//F??????A]");
			def->barkTexture = "resources/bark2.bmp";
			def->leafTexture = "resources/papaya_leaf.bmp";

			LSystem * system = new LSystem(def, 2000.0f);
		
			glm::vec3 position = terrain->vertexAt(random.randXX(0, terrain->vertices().size()-1)).position;
			position = glm::vec3(grass->transform().world() * glm::vec4(position, 1.0f));
			system->transform().translate(position);

			m_components.push_back(system);
		}

		{ // "maple" tree
			PlantDefinition * def = new PlantDefinition();
			def->addTerminals("+-!?&/[]<FQ");
			def->iterations = 6;
			def->angle = 19.0f;
			def->diameter = 0.075f;
			def->length = 0.20f;
			def->thinning = 2.0f;
			def->axiom = "F&A";
			def->addProduction('A', "F[-F/AQ]?[+FAQ]&[!FAQ]");
			def->barkTexture = "resources/bark_maple.bmp";
			def->leafTexture = "resources/maple_leaf.bmp";

			LSystem * system = new LSystem(def, 6000.0f);
		
//.........这里部分代码省略.........
开发者ID:sebis,项目名称:Motion,代码行数:101,代码来源:MainApplication.cpp


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