Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
// Use IntelliSense to learn about possible Node.js debug attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Launch Program",
"program": "${workspaceRoot}/--inline",
"cwd": "${workspaceRoot}"
},
{
"type": "node",
"request": "attach",
"name": "Attach to Process",
"port": 5858
}
]
}
32 changes: 14 additions & 18 deletions README.md
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,36 +1,26 @@

The objective of this assignment is to create an L System parser and generate interesting looking plants. Start by forking and then cloning this repository: [https://github.com/CIS700-Procedural-Graphics/Project3-LSystems](https://github.com/CIS700-Procedural-Graphics/Project3-LSystems)

# L-System Parser

lsystem.js contains classes for L-system, Rule, and LinkedList. Here’s our suggested structure:
lsystem.js contains classes for L-system, Rule, and LinkedList.

**The Symbol Nodes/Linked List:**

Rather than representing our symbols as a string like in many L-system implementations, we prefer to use a linked list. This allows us to store additional information about each symbol at time of parsing (e.g. what iteration was this symbol added in?) Since we’re adding and replacing symbols at each iteration, we also save on the overhead of creating and destroying strings, since linked lists of course make it easy to add and remove nodes. You should write a Linked List class with Nodes that contain at least the following information:

- The next node in the linked list
- The previous node in the linked list
- The grammar symbol at theis point in the overal string

We also recommend that you write the following functions to interact with your linked list:

- A function to symmetrically link two nodes together (e.g. Node A’s next is Node B, and Node B’s prev is Node A)
- A function to expand one of the symbol nodes of the linked list by replacing it with several new nodes. This function should look at the list of rules associated with the symbol in the linked list’s grammar dictionary, then generate a uniform random number between 0 and 1 in order to determine which of the Rules should be used to expand the symbol node. You will refer to a Rule’s probability and compare it to your random number in order to determine which Rule should be chosen.
The L-System Axiom, Grammar strings are represented as linked lists nodes. This helps when iterating through the linked list to replace with the appropriate replacement rule string. The Linked List structure is opted as Javascript re-creates a new string each time a copy or an append is to be made to the string.

**Rules:**

These are containers for the preconditions, postconditions and probability of a single replacement operation. They should operate on a symbol node in your linked list.
These are containers for the preconditions, postconditions and probability of a single replacement operation. They operate on a symbol node in your linked list.

The rules are selected on a probablity bases which is changable in the UI. Each symbol is changed during the parsing state based on the probablity of choosing the Rule to replace it with. The probablity is stored along with each rule and during execution a random number is generated to either apply or reject the symbol-rule swapping.

**L-system:**

This is the parser, which will loop through your linked list of symbol nodes and apply rules at each iteration.
This is the parser, which loops through the linked list of symbol nodes and apply rules at each iteration.

Implement the following functions in L-System so that you can apply grammar rules to your axiom given some number of iterations. More details and implementation suggestions about functions can be found in the TODO comments
tThe following functions are implemented in the L-System so that you one can apply grammar rules to the axiom given some number of iterations.

- `stringToLinkedList(input_string)`
- `linkedListToString(linkedList)`
- `replaceNode(linkedList, node, replacementString)`
- `replaceNode(linkedList, node, grammar, iterations)`
- `doIterations(num)`

## Turtle
Expand All @@ -43,6 +33,12 @@ Implement the following functions in L-System so that you can apply grammar rule

- In addition to operations for `[` and `]`, you must invent operations for any three symbols of your choosing.

## Symbols

F- moves forward creating a cylinder
X- rotate turtle along Y-axis 90 degrees
A- include a fruit object in the scene


## Interactivity

Expand Down
317 changes: 317 additions & 0 deletions geo/feather.obj
Original file line number Diff line number Diff line change
@@ -0,0 +1,317 @@
# This file uses centimeters as units for non-parametric coordinates.

v 0.021840 0.007498 0.031870
v 1.627541 -0.000403 0.014030
v 0.020817 0.028495 -0.004365
v 1.627544 0.024164 0.003509
v 0.008561 0.008395 -0.025352
v 1.627555 0.005486 -0.017680
v 0.005514 -0.013343 -0.002028
v 1.627554 -0.022364 -0.002045
v 0.620937 -0.010772 -0.005879
v 0.622123 0.005747 0.020990
v 0.622031 0.021952 -0.006975
v 0.621140 0.006113 -0.023702
v 2.215028 -0.012329 -0.001152
v 2.215755 -0.001528 0.005663
v 2.214896 0.000799 -0.007448
v 2.216814 0.009689 0.001213
vt 0.375000 0.000000
vt 0.625000 0.000000
vt 0.375000 0.250000
vt 0.625000 0.250000
vt 0.375000 0.500000
vt 0.625000 0.500000
vt 0.375000 0.750000
vt 0.625000 0.750000
vt 0.375000 1.000000
vt 0.625000 1.000000
vt 0.875000 0.000000
vt 0.875000 0.250000
vt 0.125000 0.000000
vt 0.125000 0.250000
vt 0.440704 0.750000
vt 0.440704 0.000000
vt 0.440704 1.000000
vt 0.440704 0.250000
vt 0.440704 0.500000
vt 0.625000 0.000000
vt 0.875000 0.000000
vt 0.875000 0.250000
vt 0.625000 0.250000
vn 0.011600 0.865261 0.501187
vn 0.005248 0.773886 0.633303
vn 0.005231 0.773619 0.633629
vn 0.011600 0.865261 0.501187
vn 0.004711 0.723113 -0.690714
vn 0.004856 0.733407 -0.679773
vn 0.004852 0.733106 -0.680097
vn 0.004711 0.723113 -0.690714
vn -0.001055 -0.729071 -0.684437
vn -0.000225 -0.650684 -0.759349
vn -0.000230 -0.651224 -0.758886
vn -0.001055 -0.729071 -0.684437
vn 0.006904 -0.852738 0.522293
vn -0.000101 -0.795068 0.606521
vn -0.000269 -0.793583 0.608461
vn 0.006904 -0.852738 0.522293
vn 0.994333 -0.072295 -0.077940
vn 0.994333 -0.072295 -0.077940
vn 0.994333 -0.072295 -0.077940
vn 0.994333 -0.072295 -0.077940
vn -0.912742 0.345987 0.217246
vn -0.912741 0.345987 0.217246
vn -0.912742 0.345987 0.217246
vn -0.912741 0.345987 0.217246
vn -0.001167 -0.698697 0.715417
vn -0.001263 -0.699741 0.714396
vn 0.003991 0.607615 0.794221
vn 0.003936 0.608773 0.793334
vn 0.008567 0.737733 -0.675038
vn 0.008626 0.737706 -0.675067
vn 0.003601 -0.559158 -0.829053
vn 0.003633 -0.558773 -0.829312
vn 0.009551 -0.572855 0.819601
vn 0.009551 -0.572855 0.819601
vn 0.010497 -0.471800 -0.881643
vn 0.010497 -0.471800 -0.881643
vn 0.016532 0.733988 -0.678962
vn 0.016532 0.733988 -0.678961
vn 0.013462 0.385565 0.922583
vn 0.013462 0.385565 0.922583
f 1/1/1 10/16/2 11/18/3 3/3/4
f 3/3/5 11/18/6 12/19/7 5/5/8
f 5/5/9 12/19/10 9/15/11 7/7/12
f 7/7/13 9/15/14 10/17/15 1/9/16
f 14/20/17 13/21/18 15/22/19 16/23/20
f 7/13/21 1/1/22 3/3/23 5/14/24
f 9/15/14 8/8/25 2/10/26 10/17/15
f 11/18/3 10/16/2 2/2/27 4/4/28
f 12/19/7 11/18/6 4/4/29 6/6/30
f 9/15/11 12/19/10 6/6/31 8/8/32
f 2/2/26 8/11/25 13/21/33 14/20/34
f 8/11/32 6/12/31 15/22/35 13/21/36
f 6/12/30 4/4/29 16/23/37 15/22/38
f 4/4/28 2/2/27 14/20/39 16/23/40
v 0.388143 -0.000000 0.081000
v 0.667221 -0.000000 0.197440
v 0.946608 -0.000000 0.192079
v 1.818651 -0.000000 0.164215
v 1.987145 -0.000000 0.113365
v 2.339494 -0.000000 0.052713
v 0.374465 -0.014336 0.006780
v 0.681996 -0.014336 0.006780
v 0.945831 -0.014336 0.006961
v 1.856006 -0.014336 0.006221
v 2.026244 -0.014336 0.006071
v 2.419290 -0.004730 0.006529
v 0.375323 0.000000 -0.047900
v 0.675429 0.000000 -0.141401
v 0.946002 0.000000 -0.163412
v 1.883190 0.000000 -0.133212
v 2.053084 0.000000 -0.132158
v 2.407803 0.000000 -0.041616
v 1.109235 -0.000000 0.157419
v 1.127423 -0.014336 0.006531
v 1.148529 0.000000 -0.153582
v 0.388143 0.003354 0.081000
v 0.667221 0.003354 0.197440
v 0.681996 0.017690 0.006780
v 0.374465 0.017690 0.006780
v 0.946608 0.003354 0.192079
v 0.945831 0.017690 0.006961
v 1.109235 0.003354 0.157419
v 1.127423 0.017690 0.006531
v 1.818651 0.003354 0.164215
v 1.987145 0.003354 0.113365
v 2.026244 0.017690 0.006071
v 1.856006 0.017690 0.006221
v 2.339494 0.003354 0.052713
v 2.419290 0.008084 0.006529
v 0.675429 0.003354 -0.141401
v 0.375323 0.003354 -0.047900
v 0.946002 0.003354 -0.163412
v 1.148529 0.003354 -0.153582
v 2.053084 0.003354 -0.132158
v 1.883190 0.003354 -0.133212
v 2.407803 0.003354 -0.041616
vt 0.000000 0.000000
vt 0.200000 0.000000
vt 0.400000 0.000000
vt 0.600000 0.000000
vt 0.800000 0.000000
vt 1.000000 0.000000
vt 0.000000 0.250000
vt 0.200000 0.250000
vt 0.400000 0.250000
vt 0.600000 0.250000
vt 0.800000 0.250000
vt 1.000000 0.250000
vt 0.000000 0.500000
vt 0.200000 0.500000
vt 0.400000 0.500000
vt 0.600000 0.500000
vt 0.800000 0.500000
vt 1.000000 0.500000
vt 0.433224 0.000000
vt 0.433224 0.250000
vt 0.433224 0.500000
vt 0.000000 0.000000
vt 0.200000 0.000000
vt 0.200000 0.250000
vt 0.000000 0.250000
vt 0.400000 0.000000
vt 0.400000 0.250000
vt 0.433224 0.000000
vt 0.433224 0.250000
vt 0.600000 0.000000
vt 0.800000 0.000000
vt 0.800000 0.250000
vt 0.600000 0.250000
vt 1.000000 0.000000
vt 1.000000 0.250000
vt 0.200000 0.500000
vt 0.000000 0.500000
vt 0.400000 0.500000
vt 0.433224 0.500000
vt 0.800000 0.500000
vt 0.600000 0.500000
vt 1.000000 0.500000
vt 0.000000 0.000000
vt 0.200000 0.000000
vt 0.000000 0.250000
vt 0.400000 0.000000
vt 0.433224 0.000000
vt 0.600000 0.000000
vt 0.800000 0.000000
vt 1.000000 0.000000
vt 1.000000 0.250000
vt 0.200000 0.500000
vt 0.000000 0.500000
vt 0.400000 0.500000
vt 0.433224 0.500000
vt 0.800000 0.500000
vt 0.600000 0.500000
vt 1.000000 0.500000
vn -0.021340 0.993975 0.107507
vn -0.007968 0.996045 0.088493
vn -0.009534 0.999954 -0.000556
vn -0.021551 0.999727 -0.009028
vn 0.003338 0.996855 0.079171
vn 0.001292 0.999998 -0.001352
vn 0.001881 0.995883 0.090624
vn 0.001375 0.999995 0.002737
vn 0.001346 0.995535 0.094383
vn 0.019635 0.992177 0.123289
vn 0.017452 0.999824 0.006871
vn 0.002077 0.999959 -0.008868
vn 0.024195 0.989616 0.141683
vn 0.024875 0.998735 -0.043697
vn -0.010314 0.994073 -0.108221
vn -0.021439 0.990014 -0.139326
vn -0.001161 0.996106 -0.088156
vn 0.001469 0.995639 -0.093282
vn 0.015531 0.994781 -0.100842
vn 0.001085 0.995315 -0.096685
vn 0.024913 0.994705 -0.099708
vn -0.021340 -0.993975 0.107507
vn -0.021551 -0.999727 -0.009028
vn -0.009534 -0.999954 -0.000556
vn -0.007968 -0.996045 0.088493
vn 0.001292 -0.999998 -0.001352
vn 0.003338 -0.996855 0.079171
vn 0.001375 -0.999995 0.002737
vn 0.001881 -0.995883 0.090624
vn 0.001346 -0.995535 0.094383
vn 0.002077 -0.999959 -0.008868
vn 0.017452 -0.999824 0.006871
vn 0.019635 -0.992177 0.123289
vn 0.024875 -0.998735 -0.043697
vn 0.024195 -0.989616 0.141683
vn -0.021439 -0.990014 -0.139326
vn -0.010314 -0.994073 -0.108221
vn -0.001161 -0.996106 -0.088156
vn 0.001469 -0.995639 -0.093282
vn 0.001085 -0.995315 -0.096685
vn 0.015531 -0.994781 -0.100842
vn 0.024913 -0.994705 -0.099708
vn -0.385059 0.000000 0.922892
vn -0.195078 0.000000 0.980788
vn -0.195078 0.000000 0.980788
vn -0.385059 0.000000 0.922892
vn -0.994845 0.000000 0.101409
vn -0.983440 0.000000 0.181234
vn -0.983440 0.000000 0.181234
vn -0.994845 0.000000 0.101409
vn 0.090174 0.000000 0.995926
vn 0.090174 0.000000 0.995926
vn 0.031935 0.000000 0.999490
vn 0.031935 0.000000 0.999490
vn 0.050118 0.000000 0.998743
vn 0.209337 0.000000 0.977844
vn 0.209337 0.000000 0.977844
vn 0.050118 0.000000 0.998743
vn 0.303675 0.000000 0.952776
vn 0.303675 0.000000 0.952776
vn 0.500926 0.000000 0.865490
vn 0.500926 0.000000 0.865490
vn -0.198387 0.000000 -0.980124
vn -0.297457 0.000000 -0.954735
vn -0.297457 0.000000 -0.954735
vn -0.198387 0.000000 -0.980124
vn -0.999877 0.000000 -0.015681
vn -0.999877 0.000000 -0.015681
vn -0.025737 0.000000 -0.999669
vn -0.025737 0.000000 -0.999669
vn 0.032207 0.000000 -0.999481
vn 0.032207 0.000000 -0.999481
vn 0.171995 0.000000 -0.985098
vn 0.023678 0.000000 -0.999720
vn 0.023678 0.000000 -0.999720
vn 0.171995 0.000000 -0.985098
vn 0.972698 0.000000 -0.232074
vn 0.972698 0.000000 -0.232074
vn 0.972698 0.000000 -0.232074
vn 0.972698 0.000000 -0.232074
vn 0.247319 0.000000 -0.968934
vn 0.247319 0.000000 -0.968934
f 38/66/41 39/67/42 40/31/43 41/68/44
f 39/67/42 42/69/45 43/32/46 40/31/43
f 42/69/45 44/70/47 45/43/48 43/32/46
f 46/71/49 47/72/50 48/34/51 49/33/52
f 47/72/50 50/73/53 51/74/54 48/34/51
f 41/68/44 40/31/43 52/75/55 53/76/56
f 40/31/43 43/32/46 54/77/57 52/75/55
f 43/32/46 45/43/48 55/78/58 54/77/57
f 49/33/52 48/34/51 56/79/59 57/80/60
f 51/74/54 58/81/61 56/79/59 48/34/51
f 44/70/47 46/71/49 49/33/52 45/43/48
f 55/78/58 45/43/48 49/33/52 57/80/60
f 17/45/62 23/48/63 24/47/64 18/46/65
f 18/46/65 24/47/64 25/50/66 19/49/67
f 19/49/67 25/50/66 36/52/68 35/51/69
f 20/53/70 26/56/71 27/55/72 21/54/73
f 21/54/73 27/55/72 28/58/74 22/57/75
f 23/48/63 29/60/76 30/59/77 24/47/64
f 24/47/64 30/59/77 31/61/78 25/50/66
f 25/50/66 31/61/78 37/62/79 36/52/68
f 26/56/71 32/64/80 33/63/81 27/55/72
f 28/58/74 27/55/72 33/63/81 34/65/82
f 35/51/69 36/52/68 26/56/71 20/53/70
f 37/62/79 32/64/80 26/56/71 36/52/68
f 17/24/83 18/25/84 39/67/85 38/66/86
f 23/30/87 17/24/88 38/66/89 41/68/90
f 18/25/84 19/26/91 42/69/92 39/67/85
f 19/26/91 35/42/93 44/70/94 42/69/92
f 20/27/95 21/28/96 47/72/97 46/71/98
f 21/28/96 22/29/99 50/73/100 47/72/97
f 22/29/99 28/35/101 51/74/102 50/73/100
f 30/37/103 29/36/104 53/76/105 52/75/106
f 29/36/107 23/30/87 41/68/90 53/76/108
f 31/38/109 30/37/103 52/75/106 54/77/110
f 37/44/111 31/38/109 54/77/110 55/78/112
f 33/40/113 32/39/114 57/80/115 56/79/116
f 28/35/117 34/41/118 58/81/119 51/74/120
f 34/41/121 33/40/113 56/79/116 58/81/122
f 35/42/93 20/27/95 46/71/98 44/70/94
f 32/39/114 37/44/111 55/78/112 57/80/115
Loading