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
24 changes: 24 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,29 @@
# Homework 4: L-systems

David Li: 13109274.

External Resourcess:

https://community.khronos.org/t/quaternion-functions-for-glsl/50140 - For Quaternion Transformations

https://github.com/helenl9098/hw04-l-systems/blob/master/src/lsystem/turtle.ts - For Quaternion Transformations (Used with permission from creator)

http://dev.thi.ng/gradients/ - cosine color pallete picker

https://stackoverflow.com/questions/8798771/perlin-noise-for-1d - very simple 1d noise

https://stackoverflow.com/questions/14446447/how-to-read-a-local-text-file - for loading obj

GH pages link: https://thecollegeboardofc.github.io/hw04-l-systems/

Description:

Implemented the recommended classes. Turtle class stores a forward vector an up vector. When rotations are applied to the Turtle the forward vector is changed. When the Turtle is moved, it moves along the foward vector. Everytime we want to save the turtle's position, a copy of the current turtle is made and the current turtle's iteration is incremented. Iteration is used to determine the scale factor of the branches. Drawing Rule has all possible operations that the turtle may take. Expansion Rule has the rules that dictate how the LString expands. The instance renderer draws a cylinder and a leaf. These simple objs were made in Maya. The LSystem class has a function that returns all transformations for instances based on the provided LSystem String. These instances are fed into the Shaderprogram which in turn sends the drawings to the shader files. In the vertex shader all the different transformations are applied, and sin function is used to animate the tree with y position as input. The background is created using a cosine color pallete and simple 1d noise function. The angle, iterations and a randomness factor can be adjusted to manipulate the shape of the tree.





For this assignment, you will design a set of formal grammar rules to create
a plant life using an L-system program. Once again, you will work from a
TypeScript / WebGL 2.0 base code like the one you used in homework 0. You will
Expand Down
6 changes: 6 additions & 0 deletions assets/cyl.mtl
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
newmtl initialShadingGroup
illum 4
Kd 0.50 0.50 0.50
Ka 0.00 0.00 0.00
Tf 1.00 1.00 1.00
Ni 1.00
277 changes: 277 additions & 0 deletions assets/cyl.obj
Original file line number Diff line number Diff line change
@@ -0,0 +1,277 @@
# This file uses centimeters as units for non-parametric coordinates.

mtllib cyl.mtl
g default
v 0.475529 -1.000000 -0.154509
v 0.404509 -1.000000 -0.293893
v 0.293893 -1.000000 -0.404509
v 0.154509 -1.000000 -0.475529
v 0.000000 -1.000000 -0.500000
v -0.154509 -1.000000 -0.475528
v -0.293893 -1.000000 -0.404509
v -0.404509 -1.000000 -0.293893
v -0.475528 -1.000000 -0.154509
v -0.500000 -1.000000 0.000000
v -0.475528 -1.000000 0.154509
v -0.404509 -1.000000 0.293893
v -0.293893 -1.000000 0.404509
v -0.154509 -1.000000 0.475528
v -0.000000 -1.000000 0.500000
v 0.154508 -1.000000 0.475528
v 0.293893 -1.000000 0.404509
v 0.404509 -1.000000 0.293893
v 0.475528 -1.000000 0.154509
v 0.500000 -1.000000 0.000000
v 0.475529 0.000000 -0.154509
v 0.404509 0.000000 -0.293893
v 0.293893 0.000000 -0.404509
v 0.154509 0.000000 -0.475529
v 0.000000 0.000000 -0.500000
v -0.154509 0.000000 -0.475528
v -0.293893 0.000000 -0.404509
v -0.404509 0.000000 -0.293893
v -0.475528 0.000000 -0.154509
v -0.500000 0.000000 0.000000
v -0.475528 0.000000 0.154509
v -0.404509 0.000000 0.293893
v -0.293893 0.000000 0.404509
v -0.154509 0.000000 0.475528
v -0.000000 0.000000 0.500000
v 0.154508 0.000000 0.475528
v 0.293893 0.000000 0.404509
v 0.404509 0.000000 0.293893
v 0.475528 0.000000 0.154509
v 0.500000 0.000000 0.000000
v 0.000000 -1.000000 0.000000
v 0.000000 0.000000 0.000000
vt 0.648603 0.107966
vt 0.626409 0.064408
vt 0.591842 0.029841
vt 0.548284 0.007647
vt 0.500000 -0.000000
vt 0.451716 0.007647
vt 0.408159 0.029841
vt 0.373591 0.064409
vt 0.351397 0.107966
vt 0.343750 0.156250
vt 0.351397 0.204534
vt 0.373591 0.248091
vt 0.408159 0.282659
vt 0.451716 0.304853
vt 0.500000 0.312500
vt 0.548284 0.304853
vt 0.591841 0.282659
vt 0.626409 0.248091
vt 0.648603 0.204534
vt 0.656250 0.156250
vt 0.375000 0.312500
vt 0.387500 0.312500
vt 0.400000 0.312500
vt 0.412500 0.312500
vt 0.425000 0.312500
vt 0.437500 0.312500
vt 0.450000 0.312500
vt 0.462500 0.312500
vt 0.475000 0.312500
vt 0.487500 0.312500
vt 0.500000 0.312500
vt 0.512500 0.312500
vt 0.525000 0.312500
vt 0.537500 0.312500
vt 0.550000 0.312500
vt 0.562500 0.312500
vt 0.575000 0.312500
vt 0.587500 0.312500
vt 0.600000 0.312500
vt 0.612500 0.312500
vt 0.625000 0.312500
vt 0.375000 0.688440
vt 0.387500 0.688440
vt 0.400000 0.688440
vt 0.412500 0.688440
vt 0.425000 0.688440
vt 0.437500 0.688440
vt 0.450000 0.688440
vt 0.462500 0.688440
vt 0.475000 0.688440
vt 0.487500 0.688440
vt 0.500000 0.688440
vt 0.512500 0.688440
vt 0.525000 0.688440
vt 0.537500 0.688440
vt 0.550000 0.688440
vt 0.562500 0.688440
vt 0.575000 0.688440
vt 0.587500 0.688440
vt 0.600000 0.688440
vt 0.612500 0.688440
vt 0.625000 0.688440
vt 0.648603 0.795466
vt 0.626409 0.751908
vt 0.591842 0.717341
vt 0.548284 0.695147
vt 0.500000 0.687500
vt 0.451716 0.695147
vt 0.408159 0.717341
vt 0.373591 0.751909
vt 0.351397 0.795466
vt 0.343750 0.843750
vt 0.351397 0.892034
vt 0.373591 0.935591
vt 0.408159 0.970159
vt 0.451716 0.992353
vt 0.500000 1.000000
vt 0.548284 0.992353
vt 0.591841 0.970159
vt 0.626409 0.935591
vt 0.648603 0.892034
vt 0.656250 0.843750
vt 0.500000 0.150000
vt 0.500000 0.837500
vn 0.951057 0.000000 -0.309016
vn 0.809017 0.000000 -0.587785
vn 0.809017 0.000000 -0.587785
vn 0.951057 0.000000 -0.309016
vn 0.587785 0.000000 -0.809017
vn 0.587785 0.000000 -0.809017
vn 0.309017 0.000000 -0.951057
vn 0.309017 0.000000 -0.951057
vn -0.000000 0.000000 -1.000000
vn -0.000000 0.000000 -1.000000
vn -0.309017 0.000000 -0.951056
vn -0.309017 0.000000 -0.951056
vn -0.587785 0.000000 -0.809017
vn -0.587785 0.000000 -0.809017
vn -0.809017 0.000000 -0.587785
vn -0.809017 0.000000 -0.587785
vn -0.951057 0.000000 -0.309017
vn -0.951057 0.000000 -0.309017
vn -1.000000 0.000000 0.000000
vn -1.000000 0.000000 0.000000
vn -0.951057 0.000000 0.309017
vn -0.951057 0.000000 0.309017
vn -0.809017 0.000000 0.587785
vn -0.809017 0.000000 0.587785
vn -0.587785 0.000000 0.809017
vn -0.587785 0.000000 0.809017
vn -0.309017 0.000000 0.951057
vn -0.309017 0.000000 0.951057
vn 0.000000 0.000000 1.000000
vn 0.000000 0.000000 1.000000
vn 0.309017 0.000000 0.951057
vn 0.309017 0.000000 0.951057
vn 0.587785 0.000000 0.809017
vn 0.587785 0.000000 0.809017
vn 0.809017 0.000000 0.587785
vn 0.809017 0.000000 0.587785
vn 0.951057 0.000000 0.309017
vn 0.951057 0.000000 0.309017
vn 1.000000 0.000000 0.000001
vn 1.000000 0.000000 0.000001
vn 0.000000 -1.000000 0.000000
vn 0.000000 -1.000000 0.000000
vn 0.000000 -1.000000 0.000000
vn 0.000000 -1.000000 0.000000
vn 0.000000 -1.000000 0.000000
vn 0.000000 -1.000000 0.000000
vn 0.000000 -1.000000 0.000000
vn 0.000000 -1.000000 0.000000
vn 0.000000 -1.000000 0.000000
vn 0.000000 -1.000000 0.000000
vn 0.000000 -1.000000 0.000000
vn 0.000000 -1.000000 0.000000
vn 0.000000 -1.000000 0.000000
vn 0.000000 -1.000000 0.000000
vn 0.000000 -1.000000 0.000000
vn 0.000000 -1.000000 0.000000
vn 0.000000 -1.000000 0.000000
vn 0.000000 -1.000000 0.000000
vn 0.000000 -1.000000 0.000000
vn 0.000000 -1.000000 0.000000
vn 0.000000 -1.000000 0.000000
vn 0.000000 1.000000 0.000000
vn 0.000000 1.000000 0.000000
vn 0.000000 1.000000 0.000000
vn 0.000000 1.000000 0.000000
vn 0.000000 1.000000 0.000000
vn 0.000000 1.000000 0.000000
vn 0.000000 1.000000 0.000000
vn 0.000000 1.000000 0.000000
vn 0.000000 1.000000 0.000000
vn 0.000000 1.000000 0.000000
vn 0.000000 1.000000 0.000000
vn 0.000000 1.000000 0.000000
vn 0.000000 1.000000 0.000000
vn 0.000000 1.000000 0.000000
vn 0.000000 1.000000 0.000000
vn 0.000000 1.000000 0.000000
vn 0.000000 1.000000 0.000000
vn 0.000000 1.000000 0.000000
vn 0.000000 1.000000 0.000000
vn 0.000000 1.000000 0.000000
vn 0.000000 1.000000 0.000000
s 1
g pCylinder1
usemtl initialShadingGroup
f 1/21/1 2/22/2 22/43/3 21/42/4
f 2/22/2 3/23/5 23/44/6 22/43/3
f 3/23/5 4/24/7 24/45/8 23/44/6
f 4/24/7 5/25/9 25/46/10 24/45/8
f 5/25/9 6/26/11 26/47/12 25/46/10
f 6/26/11 7/27/13 27/48/14 26/47/12
f 7/27/13 8/28/15 28/49/16 27/48/14
f 8/28/15 9/29/17 29/50/18 28/49/16
f 9/29/17 10/30/19 30/51/20 29/50/18
f 10/30/19 11/31/21 31/52/22 30/51/20
f 11/31/21 12/32/23 32/53/24 31/52/22
f 12/32/23 13/33/25 33/54/26 32/53/24
f 13/33/25 14/34/27 34/55/28 33/54/26
f 14/34/27 15/35/29 35/56/30 34/55/28
f 15/35/29 16/36/31 36/57/32 35/56/30
f 16/36/31 17/37/33 37/58/34 36/57/32
f 17/37/33 18/38/35 38/59/36 37/58/34
f 18/38/35 19/39/37 39/60/38 38/59/36
f 19/39/37 20/40/39 40/61/40 39/60/38
f 20/40/39 1/41/1 21/62/4 40/61/40
s 2
f 2/2/41 1/1/42 41/83/43
f 3/3/44 2/2/41 41/83/43
f 4/4/45 3/3/44 41/83/43
f 5/5/46 4/4/45 41/83/43
f 6/6/47 5/5/46 41/83/43
f 7/7/48 6/6/47 41/83/43
f 8/8/49 7/7/48 41/83/43
f 9/9/50 8/8/49 41/83/43
f 10/10/51 9/9/50 41/83/43
f 11/11/52 10/10/51 41/83/43
f 12/12/53 11/11/52 41/83/43
f 13/13/54 12/12/53 41/83/43
f 14/14/55 13/13/54 41/83/43
f 15/15/56 14/14/55 41/83/43
f 16/16/57 15/15/56 41/83/43
f 17/17/58 16/16/57 41/83/43
f 18/18/59 17/17/58 41/83/43
f 19/19/60 18/18/59 41/83/43
f 20/20/61 19/19/60 41/83/43
f 1/1/42 20/20/61 41/83/43
s 3
f 21/81/62 22/80/63 42/84/64
f 22/80/63 23/79/65 42/84/64
f 23/79/65 24/78/66 42/84/64
f 24/78/66 25/77/67 42/84/64
f 25/77/67 26/76/68 42/84/64
f 26/76/68 27/75/69 42/84/64
f 27/75/69 28/74/70 42/84/64
f 28/74/70 29/73/71 42/84/64
f 29/73/71 30/72/72 42/84/64
f 30/72/72 31/71/73 42/84/64
f 31/71/73 32/70/74 42/84/64
f 32/70/74 33/69/75 42/84/64
f 33/69/75 34/68/76 42/84/64
f 34/68/76 35/67/77 42/84/64
f 35/67/77 36/66/78 42/84/64
f 36/66/78 37/65/79 42/84/64
f 37/65/79 38/64/80 42/84/64
f 38/64/80 39/63/81 42/84/64
f 39/63/81 40/82/82 42/84/64
f 40/82/82 21/81/62 42/84/64
Loading