This is an old revision of the document!
Table of Contents
Using a mesh cloud as a high resolution organ
Idea
In this tutorial we will use a ply file of a leaf including points and meshes to simulate a small branch. The leaf is added and transformed several times to simulate simple leaf growth and high resolution light absorption.
Loading cloud
Since the point cloud is an changeable asset in this model, we will use the GraphExplorer plugin to import it as a Graph Object.
To do so first open the Graph Objects explorer /Panels/Explorers/Graph Objects
.
In the newly opened panel an external file can be added through Objects/new/add
, the dialog that follows works similar to the one described here. Make sure to import the point cloud as a graph.
Afterwards the graph object can be referenced using the GraphObjectRef class and a clone can be added several times using XL rewriting rules.
GraphObjectRef x = new GraphObjectRef("random_leaf3_mesh.ply"); [ A ==> x.cloneGraph(); ]
Transforming / Moving
In order to use the imported cloud as an organ it might be necessary to fit it in the right spot and size.
Move to (0,0,0)
The first step is to make sure that the point that describes the “root” of the leaf, is at the local position of (0,0,0), meaning the leaf starts where the point cloud object was added. If you are lucky this was done on a previous step, if not you have to guess the root point. Guessing this point can be done the easiest by loading the point cloud, zooming in and selecting the point closest to the root. The translation of this point (highlighted in the image below), describes the current offset of the point cloud.
In order to cancel out this offset, we have to move all points to the opposite direction:
void move_toZero()[ p:Point::>{ p[x]-=-1.328728; p[y]-=19.368984; p[z]-=-4.860407; }
Even so this code moves the points to the right position, this is not enough for this tutorial. We need to move the connected meshes as well. To do so we use the structure of the imported CollectionCloud (as described here). Following this structure we know that each mesh is connected to three points by decomposition edges and since we already moved the points we can use there information to create a new mesh.
void redraw_Mesh()[ m:MeshNode ==> { float[] fl =new float[9]; int i=0; [ m /> p:Point::>{ fl[i]=p[x]; i++; fl[i]=p[y]; i++; fl[i]=p[z]; i++; } ] } getMesh(fl); ]
Growth
- manipulation of each point
Light
- creating a heat map of light input