# LsystemTrees
**Repository Path**: iceeye001/LsystemTrees
## Basic Information
- **Project Name**: LsystemTrees
- **Description**: 使用L系统建模树
一个基于计算机图形程序方法的项目,通常用于复制虚拟环境中的城市和景观等实体。程序方法使用指令的语义序列描述这些实体,这些指令序列按需生成视觉上复杂的图像,这与将图像另存为数据片段并在需要时从内存中调出的常规方法相反。本应用程序使用L系统的程序方法。类型的形式语法,以创建植物树的复杂3D模型。L系统或Lindenmayer系统类似于常规形式语法,不同之处在于所有规则在每次迭代中均同时应用。L系统用作创建分支模式的基础。用户以JSON格式在文本文件中输入L系统以及各种几何参数和树叶和木材的纹理图像,然后将其转换为3D模型。可以从所有方向查看3D模型,并使用箭头键放大/缩小。
不同类型的L系统,例如 括号,参数,条件,随机和上下文相关的L系统与工厂建模有其自身的联系。该应用程序支持具有这些功能的任意组合的L系统。将具有约40行的输入文件转换为具有约200万个顶点的3D模型,从而展示了数据放大的范例-创建具有较小输入的大型实体。
- **Primary Language**: Unknown
- **License**: Not specified
- **Default Branch**: master
- **Homepage**: None
- **GVP Project**: No
## Statistics
- **Stars**: 0
- **Forks**: 0
- **Created**: 2020-11-16
- **Last Updated**: 2020-12-19
## Categories & Tags
**Categories**: Uncategorized
**Tags**: None
## README
# Using L-systems to Model Trees
A project based on procedural methods in computer graphics, which are commonly used to replicate entities like cities and landscapes for virtual environments.
Procedural methods describe these entities using semantic sequences of instructions which generate visually complex images on demand, as opposed to the conventional method of saving images as pieces of data and recalling them from memory when required
This application uses the procedural methods of L-systems, a type of formal grammar, to create complex 3D models of botanical trees.
L-systems, or Lindenmayer systems are similar to conventional formal grammars, except all the rules are applied simultaneously in every iteration.
The L-system is used as the basis for creating branching patterns. The user inputs an L-system in a text file in JSON format along with various geometric parameters and texture images for leaves and wood, which is transformed into a 3D model.
The 3D model can be viewed from all directions and zoomed in/out using arrow keys.
Different types of L-systems for eg. Bracketed, Parametric, Conditional, Stochastic and Context-sensitive L-systems have their own connections with plant modelling.
The application supports L-systems with any mix of these features. An input file with ~40 lines is transformed to a 3D model with ~2 million vertices, thus showcasing the paradigm of data amplification - creating large entities with small input.
## Example Input
```javascript
{
"branchRadius" : 0.2,
"branchStep" : 0.75,
"branchAngle" : 0.4,
"branchThicknessRatio" : 0.8,
"branchStepRatio" : 0.9,
"minRadius" : 0.00,
"maxLeafRadius" : 0.12,
"leafLength" : 0.4,
"leafWidth" : 0.4,
"leafDensity" : 8,
"leafTextureFile" : "m.bmp",
"woodTextureFile" : "woodtexture.bmp",
"Turtle": {
"x": 0,
"y": -6,
"z": 0
},
"LSystem": {
"Start": "F{5}",
"Rules" : [{
"Input" : "F{x}",
"Output" : "B{x / 2}[&{1.5}/B{x / 4}^{1.5}B{x / 4}]B{x / 2}[+{1.2}B{x / 5}-{1.5}B{x / 5}]&{0.5}B{x / 2}[&{2}/F{x - 0.1}^{1.5}F{x - 0.1}]^[++{1.2}F{x - 0.1}-{1.5}F{x - 0.1}][--F{x - 0.1}+F{x - 0.1}]B{x / 2}[^{1.5}/F{x - 1}&\\F{x - 0.1}]^+{1.5}B{x / 2}[^F{x - 0.1}-/F{x - 0.1}]\\[&{4}F{x - 0.1}-/F{x - 0.1}]",
"Condition" : "x >= 4.9"
},
{
"Input" : "F{x}",
"Output" : "/+{0.9}\\F{x - 0.1}-{0.9}F{x - 0.1}",
"Condition" : "x == 4.8",
"Probability" : 0.6
}, {
"Input" : "F{x}",
"Output" : "/F{x - 0.1}&{0.9}\\F{x - 0.1}^{0.9}F{x - 0.1}",
"Condition" : "x == 4.8",
"Probability" : 0.4
},
{
"Input" : "F{x}",
"Output" : "F{x - 1}[/+F{x - 1}\\&{0.9}F{x - 1}][\\&F{x - 1}^F{x}]",
"Condition" : "x < 4.8"
}]
},
"iterations" : 5
}
```
## Example Screenshots of Models
### Birch Tree Model: Recreation from Photo
### Pine Tree Model: Recreation from Photo
### Birch Tree Model: Recreation from Photo
### Models created by varying Geometric Parameters for a fixed L-system
### Stochastic Models created using Multiple Executions of fixed Stochastic L-system
### Miscellaneous Models
