L/Particle MAT 594P Qian Liu |
System Final Project 2010F |
|
![]() |
||
Project Goals
|
1. Learning LuaAV The biggest achievement of this project is learning LuaAV as a new programming language. The whole project is actually helping me learning luaAV step by step. 2. Create a 3D L-system Begin with 2D L-system, I converted the whole system into 3D and implemented camera to navigate. Several changes to make the code work more efficient: in the rule, convert every rule symbol into a table, which makes the system easier to control. Now, things like branch's length, leave's size, color and position can be given in the rule. instead of using gl.vertex to draw the tree frame by frame, use mesh and lattice to speed up the system. Otherwise, when using the camera to navigate, the system will get really slow. 3. Learning particle system Although didn't get quite far, I got started about the particle system. After learning the physical concept, I made the code in processing. Then converted it into luaAV. There are still a lot more to do about particle system, I will try to go further and finally combine it with my 3D L-system.
|
|
| How 3D L-system work |
Just like 2D L-system, "F" means draw a line, "+" and "-" controls the angle. In 3D L-system, beside "F", you need to create seven other symbols, "+" and "-"(yaw), "<" and ">"(Roll), "&" and "^" (Pitch), which controls the three vectors of the turtle, H, U and L. The seventh symbol is "|" which will turn the turtle's head around 180 degrees. In 2D L-system the turtle is defined as (x, y, angle). In 3D, turtle is (x,y,z,angle_U, angle_L, angle_H). H, L, U: these vectors have unit length, are perpendicular to each other ,and satisfy the equation H cross L = U. Rotations of the turtle are then expressed by the equation: [H' L' U'] = [H L U]R where R is a 3*3 rotation matrix. Specifically, rotations by angle Alfa about vectors U ,L ,H are represented by the following matrices: | cos(Alfa) sin(Alfa) 0 | R_U (Alfa ) = | -sin(Alfa) cos(Alfa) 0 | | 0 0 1 | | cos(Alfa) 0 -sin(Alfa)| R_L (Alfa ) = | 0 1 0 | | sin(Alfa) 0 cos(Alfa)| | 1 0 0 | R_H (Alfa ) = | 0 cos(Alfa) -sin(Alfa)| | 0 sin(Alfa) cos(Alfa)| All these symbols are described as following : "F" : Move forward a step of length d. A line segment between points (X,Y,Z) and (X',Y',Z') is drawn. "[" and "]": bracket - push and pop the current state , in this project it is used to generate the tree branches. "+" and "-":Using rotation matrix R_U(Delta). "&" and "^" : Using rotation matrix R_L(Delta). "<" and ">" : Roll left by angle Delta, Using rotation matrix R_H(Delta). "|" : Turn around, Using rotation matrix R_H(180). |
|
| Sreen shot |
|
|
| How Particle System work | The red points are the attractors, which will never move. Each time, the system will generate 12 attractors and 30 random attracted particles(white points). Initially the particles won't move, that's because the default attractive force is 0. if press "5", the attractive force will become 40 which will make the attractors start attracting all the particles. When press "4", the force becomes 0 again. If press "4" one more time, the particles will start moving into the opposite direction. You can also navigate through the whole system.
|
|
| Particle System Screen Shot |
|
|
| Key Functions | keyboard: "1": you can choose to show the leaves(green points) or not. Press "1" will alternative between drawing or not drawing the leaves. "2": increase the branches' angle of the tree "3": decrease the branches' angle "4": decrease the attractive force of the particle system "5": increase the attractive force of the particle system
|
|
| Visualization |
L/Particle System from Qian Liu on Vimeo. |
|
| References |
L-system introduction http://mathforum.org/advanced/robertd/lsys2d.html The link below is a very detail and nice tutorial about 3D L-system. http://www.nbb.cornell.edu/neurobio/land/OldStudentProjects/cs490-94to95/hwchen/ papers about L-system: http://ieeexplore.ieee.org/xpls/abs_all.jsp?arnumber=4670976&tag=1 http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.79.3468
|
|
| Source Code | Download the code HERE. | |