User Tools

Site Tools


tutorials:using-mesh-clouds-as-organ

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
tutorials:using-mesh-clouds-as-organ [2024/11/04 15:28] timtutorials:using-mesh-clouds-as-organ [2024/12/06 14:37] (current) – [Preparation] tim2
Line 3: Line 3:
 ===== Idea ===== ===== Idea =====
  
-This tutorial uses a ply file of a leaf with points and meshes to simulate a small branch.+This tutorial uses a {{ :tutorials:random_leaf3_mesh.ply |ply}} file of a leaf with points and meshes to simulate a small branch.
 The leaf is transformed and added several times to a branch model, to simulate leaf growth and light absorption. The leaf is transformed and added several times to a branch model, to simulate leaf growth and light absorption.
  
Line 10: Line 10:
  
  
 +The example model can be found in the GroIMP example explorer (File/Example projects) under Point cloud/branch.
 +
 +===== Preparation =====
 +
 +Before you start modeling with point clouds it is recommended to do two settings:
 +   - On the view3d in the menu view/navigators and select Point cloud handlers. This stops the 3d view from visiting every point for highlighting which improves the speed.
 +   - In the preferences, go on User Interface/view3d and set the resolution to 2. This will give the visitor the instruction to not visit any point but use the mesh collector. Which makes the visualization simpler and faster. 
 ===== Loading cloud ===== ===== Loading cloud =====
  
-Since the point cloud is used as an changeable asset in this model, we will use the GraphExplorer plugin to import it as a GraphObject+In order to proper ship this project, the used point cloud is added as a file to the GroIMP file explorer.{{ :tutorials:file_dialog_all_files.png?direct&200|}}  
-To do so first open the Graph Objects explorer ''/Panels/Explorers/Graph Objects'' +Therefore we first need to add the ply file to the [[user-guide:common_panels#file_explorer|file explorer]]. With clicking on Objects/new/Add file in this explorer, a file dialog is opened. In this dialog   
-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 [[groimp-platform:pointcloud|here]]. Make sure to import the point cloud as a graph. +select "All files" as type, to show files that can be edited in the text editor(see image).  
-Afterwards the graph object can be referenced using the GraphObjectRef class and clone can be added several times using XL rewriting rules.+After load the ply file, it can now be loaded in RGG as an input Stream with the function ''getInputStreamFromProject("leaf.ply")'' and this stream can be used in the ''loadNodeFromStream'' function to interpret the file according to the given mime type (explained in  [[tutorials:pointcloud-io|I/O Point Cloud]])This interpretation will then provide you the root of the created graph structure as a nodeThe so created node can be used like all other nodes in GroIMP, for instance in a rewriting query as shown below: 
 + 
 <code java> <code java>
- GraphObjectRef x = new GraphObjectRef("random_leaf3_mesh.ply");+ Node x =Utils.loadNodeFromStream(getInputStreamFromProject("leaf.ply"),"model/x-grogra-pointcloud-graph+ply");
 [ [
- A ==> x.cloneGraph();+ A ==> x;
 ] ]
 </code> </code>
Line 45: Line 54:
 </code> </code>
  
-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 ([[groimp-platform:pointcloud|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. +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 ([[tutorials:pointcloud-io#as_graph|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. 
 <code java> <code java>
 void redraw_Mesh()[ void redraw_Mesh()[
Line 71: Line 80:
 ==== Manipulate the whole cloud ==== ==== Manipulate the whole cloud ====
  
-The imported cloud will behave similar to other subset of the graph in GroIMP.  Meaning if the point cloud is added after a transformation node or an object with an axis it will be moved, rotated or scaled regarding the previous nodes. (This also works with colors and other turtle attributes.) +The imported cloud will behave similar to other subset of the graph in GroIMP.  Meaning if the point cloud is added after a transformation node or an object with an axisit will be moved, rotated or scaled regarding the previous nodes. (This also works with colors and other turtle attributes.)
- +
-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 ''Rotation'' Node above the cloud and select this node. Then it is possible to change the angels in the properties editor and afterwards transfer the values in to the RGG code.+
  
 +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 ''Rotation'' Node above the cloud and select this node. Then it is possible to change the angels in the properties editor and afterwards transfer the values in to the RGG code.
  
 After the right rotation and scale is estimated, these values can be used on top of any turtle state.  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 "placeholder-leaves" that are already scaled and rotated to the wished location. Then with the loading of the point cloud these placeholders are replaced by not only the leaf but also the needed rotation estimated for the leaf.+Therefore a leaf can be added in different angles using the same rotation. In the given example the model starts with simple "placeholder-leaves" that are already scaled and rotated to the wished location. Then with the loading of the point cloud these placeholders are replaced by not only the leaf but also the needed rotation estimated for the leaf. In order to minimize computational power, a two step process is used, first the point cloud is loaded once and moved to 0,0,0 and than this moved cloud is cloned to replace the other "placeholder-leaves"
  
  
Line 93: Line 101:
 public void loadPC() public void loadPC()
 {  {
- GraphObjectRef x = new GraphObjectRef("random_leaf3_mesh.ply");+ // load ply graph from  
 + Node x =Utils.loadNodeFromStream(getInputStreamFromProject("leaf.ply"),"model/x-grogra-pointcloud-graph+ply");
  [  [
-  r:RL(80)  m:M s:Scale Rotate Parallelogram==> r m s Rotate(-120,-50,-40) x.cloneGraph(); +  r:RL(80)  m:M s:Scale(10) Rotate Parallelogram ==> r m s Rotate(-120,-50,-40) x;
-  r:RL(-80)  m:M s:Scale Rotate Parallelogram==> r m s Rotate(270,-100,-50) x.cloneGraph();+
  ]  ]
- derive();+ derive(); // apply the changes to the graph
  move_toZero();  move_toZero();
 + [
 +  r:RL(80)  m:M s:Scale Rotate Parallelogram ==> r m s Rotate(-120,-50,-40) cloneSubgraph(x);
 +  r:RL(-80)  m:M s:Scale Rotate Parallelogram==> r m s Rotate(270,-100,-50) cloneSubgraph(x);
 + ]
 } }
 </code> </code>
Line 122: Line 134:
  ]  ]
  redraw_Mesh();  redraw_Mesh();
- (*Cloud*).setUpdate(true);+ (*Imp3dCloud*).setUpdate(true);
 } }
 </code> </code>
tutorials/using-mesh-clouds-as-organ.1730730512.txt.gz · Last modified: 2024/11/04 15:28 by tim