02_user_tutorials:pointclouds:04_using-mesh-clouds-as-organ
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| 02_user_tutorials:pointclouds:04_using-mesh-clouds-as-organ [2025/12/10 13:14] – removed - external edit (Unknown date) 127.0.0.1 | 02_user_tutorials:pointclouds:04_using-mesh-clouds-as-organ [2025/12/12 13:09] (current) – [Loading cloud] groimp | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== Using a mesh cloud as a high resolution organ ====== | ||
| + | This tutorial uses a {{ : | ||
| + | The leaf is transformed and added several times to a branch model, to simulate leaf growth and light absorption. | ||
| + | |||
| + | |{{ : | ||
| + | |The rendered result of the example branch | | ||
| + | |||
| + | |||
| + | The example model can be found in the GroIMP example explorer (File/ | ||
| + | |||
| + | ===== Preparation ===== | ||
| + | |||
| + | Before you start modeling with point clouds it is recommended to do two settings: | ||
| + | - On the view3d in the menu view/ | ||
| + | - In the preferences, | ||
| + | ===== Loading cloud ===== | ||
| + | |||
| + | In order to proper ship this project, the used point cloud is added as a file to the GroIMP file explorer.{{ : | ||
| + | Therefore we first need to add the ply file to the [[01_user_documentation: | ||
| + | select "All files" as type, to show files that can be edited in the text editor(see image). | ||
| + | After load the ply file, it can now be loaded in RGG as an input Stream with the function '' | ||
| + | |||
| + | |||
| + | <code java> | ||
| + | Node x =Utils.loadNodeFromStream(getInputStreamFromProject(" | ||
| + | [ | ||
| + | A ==> x; | ||
| + | ] | ||
| + | </ | ||
| + | |||
| + | |||
| + | =====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 " | ||
| + | {{ : | ||
| + | |||
| + | |||
| + | In order to cancel out this offset, we have to move all points to the opposite direction: | ||
| + | |||
| + | <code java> | ||
| + | void move_toZero()[ | ||
| + | | ||
| + | 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 ([[02_user_tutorials: | ||
| + | <code java> | ||
| + | void redraw_Mesh()[ | ||
| + | | ||
| + | { | ||
| + | | ||
| + | int i=0; | ||
| + | [ | ||
| + | m /> p: | ||
| + | | ||
| + | i++; | ||
| + | | ||
| + | i++; | ||
| + | | ||
| + | i++; | ||
| + | } | ||
| + | ] | ||
| + | } | ||
| + | | ||
| + | ] | ||
| + | </ | ||
| + | |||
| + | After these steps the point and mesh cloud should start at the location of the root node and can be easily transformed by turtle geometry. | ||
| + | |||
| + | ==== Manipulate the whole cloud ==== | ||
| + | |||
| + | The imported cloud will behave similar to other subset of the graph in GroIMP. | ||
| + | |||
| + | The rotation of a point cloud can be quite tricky depending on the the rotations in the measurement. A simple trick for the modelling is to add a '' | ||
| + | |||
| + | After the right rotation and scale is estimated, these values can be used on top of any turtle state. | ||
| + | Therefore a leaf can be added in different angles using the same rotation. In the given example the model starts with simple " | ||
| + | |||
| + | |||
| + | |||
| + | <code java> | ||
| + | protected void init () | ||
| + | [ | ||
| + | Axiom ==> | ||
| + | P(4)RU(70)F(2) //creating a brown branch rotate by 70 | ||
| + | [ P(2) M(-1.3)RL(80) M(0.05)Scale(10)Rotate(0, | ||
| + | [ P(2) M(-.6)RL(-80) M(0.05)Scale(10)Rotate(0, | ||
| + | ; | ||
| + | ] | ||
| + | |||
| + | public void loadPC() | ||
| + | { | ||
| + | // load ply graph from | ||
| + | Node x =Utils.loadNodeFromStream(getInputStreamFromProject(" | ||
| + | [ | ||
| + | r: | ||
| + | ] | ||
| + | | ||
| + | | ||
| + | [ | ||
| + | r: | ||
| + | r: | ||
| + | ] | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | |||
| + | |{{ : | ||
| + | |A branch with leaves, first with place holders and then with point clouds| | ||
| + | |||
| + | ===== Growth ===== | ||
| + | |||
| + | Even so the growth described here is only increasing the width and height of the leaf by 10% and the length by 20%, it highlights the ability to transform the organ on a high resolution. | ||
| + | |||
| + | To do this change, each point is moved similar to the translation to 0,0,0 and then the meshes are redrawn again. | ||
| + | <code java> | ||
| + | public void grow(){ | ||
| + | [ | ||
| + | p: | ||
| + | | ||
| + | | ||
| + | | ||
| + | } | ||
| + | ] | ||
| + | | ||
| + | | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | |{{ : | ||
| + | |The branch in 4 growth steps | | ||
| + | |||
| + | ===== Light ===== | ||
| + | |||
| + | Using any of the GroIMP raytracer it is possible to receive the amount of intercepted energy for each mesh. | ||
| + | This information can be used for detailed analysis or specific growth behavior. | ||
| + | In this example the absorbed power per area is used to set the RGBAShader of each mesh in order to create a heat map like representation. | ||
| + | |||
| + | <code java> | ||
| + | |||
| + | public void light(){ | ||
| + | | ||
| + | float max = max(flm.getAbsorbedPower3d((*mn: | ||
| + | | ||
| + | [ | ||
| + | mn: | ||
| + | float inp = flm.getAbsorbedPower3d(mn).getMax(); | ||
| + | inp= inp/ | ||
| + | // estimate RGB values | ||
| + | inp=2*inp/ | ||
| + | int r = (int)(255*(inp-1)); | ||
| + | r = (r> | ||
| + | int b = (int)(255*(1-inp)); | ||
| + | b = (b> | ||
| + | int g = 255-r-b; | ||
| + | // change shaders | ||
| + | mn.setShader(new RGBAShader(r, | ||
| + | } | ||
| + | ] | ||
| + | } | ||
| + | </ | ||
| + | |||
| + | In order to see the result of the scene needs to be rendered, since the 3d view is otherwise using the mesh collector. | ||
| + | |||
| + | |{{ : | ||
| + | |The rendered leaves with color coded meshes, from red (high) over green (medium) to red(low)| | ||
