本文整理汇总了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);
//.........这里部分代码省略.........