General stochastic bracketed L-system engine. 更多...
#include <LSystem.h>
Public 成员函数 | |
| LSystem () | |
| L system. | |
| void | setAxiom (const std::string &axiom) |
| Set the starting string. | |
| void | addRule (char symbol, const std::string &production) |
| Add a deterministic production for one symbol. | |
| void | addRules (char symbol, const std::vector< std::string > &productions, const std::vector< float > &weights) |
| Add weighted (stochastic) productions for one symbol. | |
| void | clearRules () |
| Remove all production rules (the axiom and alphabet remain). | |
| void | setAngle (float degrees) |
| Set the turtle turn angle. | |
| void | setStep (float step) |
| Set the forward distance per F. | |
| void | setIterations (int iterations) |
| Set the grammar expansion count. | |
| void | setSeed (uint32_t seed) |
| Set the deterministic seed. | |
| void | setInitialHeading (float x, float y, float z) |
| Set the initial heading (normalized). | |
| void | setBranchRadius (float radius) |
| Set the trunk radius at depth 0. | |
| void | setBranchRadiusFalloff (float factor) |
| Set the per-depth radius multiplier. | |
| void | setLeafSize (float size) |
| Set the foliage card size. | |
| void | setLeafSymbols (const std::string &symbols) |
| Set the set of symbols that emit a leaf marker. | |
| void | setTropism (float x, float y, float z) |
| Bias growth toward a direction (phototropism). | |
| uint32_t | getSeed () const |
| Current seed. | |
| int | getIterations () const |
| Current iteration count. | |
| std::string | derive () const |
Expand the grammar iterations times. | |
| void | generate (LSystemResult &out) const |
| Expand then interpret with the turtle. | |
| void | toPointSet (PointSet &out) const |
| Generate and pack segment endpoints into a PointSet. | |
详细描述
General stochastic bracketed L-system engine.
A starting axiom is rewritten iterations times using production rules; a symbol may carry several weighted productions (chosen deterministically from the seed). The derived word is then interpreted by a 3D turtle:
F draw forward one step f move forward, no draw
- / - yaw (heading around up) & / ^ pitch (down / up) \ / / roll around the heading [ ] push / pop turtle state <leaf> emit a leaf (see setLeafSymbols)
Limb thickness falls off with bracket depth, so [ ] bracketing produces tapering branches. The engine is not tied to mesh output: call toPointSet() to recover segments as spline control points (roads, 2D layouts) or run the mesh.lsystem recipe for tree/plant meshes. A fixed seed reproduces the exact same result.
构造及析构函数说明
◆ LSystem()
| eve::procgen::LSystem::LSystem | ( | ) |
L system.
在文件 LSystem.cpp 第 20 行定义.
成员函数说明
◆ addRule()
| void eve::procgen::LSystem::addRule | ( | char | symbol, |
| const std::string & | production | ||
| ) |
Add a deterministic production for one symbol.
- 参数
-
symbol Source symbol. production Replacement.
在文件 LSystem.cpp 第 26 行定义.
◆ addRules()
| void eve::procgen::LSystem::addRules | ( | char | symbol, |
| const std::vector< std::string > & | productions, | ||
| const std::vector< float > & | weights | ||
| ) |
◆ clearRules()
| void eve::procgen::LSystem::clearRules | ( | ) |
Remove all production rules (the axiom and alphabet remain).
在文件 LSystem.cpp 第 41 行定义.
◆ derive()
| std::string eve::procgen::LSystem::derive | ( | ) | const |
Expand the grammar iterations times.
- 返回
- The derived word.
在文件 LSystem.cpp 第 96 行定义.
被这些函数引用 generate().
◆ generate()
| void eve::procgen::LSystem::generate | ( | LSystemResult & | out | ) | const |
Expand then interpret with the turtle.
- 参数
-
out Result to fill.
在文件 LSystem.cpp 第 231 行定义.
引用了 eve::procgen::LSystemResult::derivation, derive(), eve::procgen::LSystemResult::leafCount , 以及 eve::procgen::LSystemResult::segments.
被这些函数引用 eve::procgen::generateLSystemMesh() , 以及 toPointSet().
◆ getIterations()
| int eve::procgen::LSystem::getIterations | ( | ) | const |
◆ getSeed()
| uint32_t eve::procgen::LSystem::getSeed | ( | ) | const |
◆ setAngle()
| void eve::procgen::LSystem::setAngle | ( | float | degrees | ) |
Set the turtle turn angle.
- 参数
-
degrees Angle in degrees.
在文件 LSystem.cpp 第 45 行定义.
引用了 degrees.
被这些函数引用 eve::procgen::generateLSystemMesh().
◆ setAxiom()
| void eve::procgen::LSystem::setAxiom | ( | const std::string & | axiom | ) |
◆ setBranchRadius()
| void eve::procgen::LSystem::setBranchRadius | ( | float | radius | ) |
Set the trunk radius at depth 0.
- 参数
-
radius Radius.
在文件 LSystem.cpp 第 56 行定义.
引用了 radius.
被这些函数引用 eve::procgen::generateLSystemMesh().
◆ setBranchRadiusFalloff()
| void eve::procgen::LSystem::setBranchRadiusFalloff | ( | float | factor | ) |
Set the per-depth radius multiplier.
- 参数
-
factor Factor in (0, 1].
在文件 LSystem.cpp 第 57 行定义.
被这些函数引用 eve::procgen::generateLSystemMesh().
◆ setInitialHeading()
| void eve::procgen::LSystem::setInitialHeading | ( | float | x, |
| float | y, | ||
| float | z | ||
| ) |
◆ setIterations()
| void eve::procgen::LSystem::setIterations | ( | int | iterations | ) |
Set the grammar expansion count.
- 参数
-
iterations Rewrite count.
在文件 LSystem.cpp 第 47 行定义.
引用了 iterations.
被这些函数引用 eve::procgen::generateLSystemMesh().
◆ setLeafSize()
| void eve::procgen::LSystem::setLeafSize | ( | float | size | ) |
Set the foliage card size.
- 参数
-
size Size.
在文件 LSystem.cpp 第 58 行定义.
引用了 size.
被这些函数引用 eve::procgen::generateLSystemMesh().
◆ setLeafSymbols()
| void eve::procgen::LSystem::setLeafSymbols | ( | const std::string & | symbols | ) |
Set the set of symbols that emit a leaf marker.
- 参数
-
symbols Character list, e.g. "L@".
在文件 LSystem.cpp 第 60 行定义.
引用了 c.
◆ setSeed()
| void eve::procgen::LSystem::setSeed | ( | uint32_t | seed | ) |
Set the deterministic seed.
- 参数
-
seed Seed.
在文件 LSystem.cpp 第 48 行定义.
引用了 seed.
被这些函数引用 eve::procgen::generateLSystemMesh().
◆ setStep()
| void eve::procgen::LSystem::setStep | ( | float | step | ) |
◆ setTropism()
| void eve::procgen::LSystem::setTropism | ( | float | x, |
| float | y, | ||
| float | z | ||
| ) |
Bias growth toward a direction (phototropism).
- 参数
-
x X. y Y. z Z.
在文件 LSystem.cpp 第 65 行定义.
被这些函数引用 eve::procgen::generateLSystemMesh().
◆ toPointSet()
| void eve::procgen::LSystem::toPointSet | ( | PointSet & | out | ) | const |
Generate and pack segment endpoints into a PointSet.
- 参数
-
out Set to fill.
在文件 LSystem.cpp 第 238 行定义.
引用了 eve::procgen::PointSet::add(), generate() , 以及 eve::procgen::LSystemResult::segments.
该类的文档由以下文件生成:
- src/modules/procgen/algorithms/LSystem.h
- src/modules/procgen/algorithms/LSystem.cpp