User Tools

Site Tools


documentation:viewing_in_3d_trees_with_a_simple_crown_profile

Viewing in 3D trees with a simple crown profile

When a model is individual based and spatially explicit, it is possible to view the scene in a 3D viewer in Capsis. The only thing to do is ensure that the tree description implements the TreeWithCrownProfile interface (jeeb.lib.util).

An example can be found in the MaddModel test module. The MaddTree implements the interface this way :

public class MaddTree extends GMaddTree implements SimpleCrownDescription, 
      TreeWithCrownProfile, Speciable {
   (...)

In the constructor, create a crown profile with the help of the CrownProfileUtil helper method.

The passed array contains pairs of values. For each pair, the first value is a height in the crown in percentage of the total crown height. The second value is a radius at this height, in percentage of the maximum radius of the crown (see getCrownRadius () below). First pair is ganerally 0, 0 and last pair is 100, 0.

// A crown profile is created in the constuctor this way
try {
   // Create a crown profile for Spruce
   ((Immutable) immutable).crownProfile = CrownProfileUtil.createRelativeCrownProfile (
      new double[] {0, 0, 10, 60, 35, 100, 80, 50, 100, 0});
} catch (Exception e) {}
(...)

The implementation of the TreeWithCrownProfile interface can be done as below.

  • getTreeX (), getTreeY () and getTreeZ () return the location of the tree on the ground.
  • getTreeDbh () and getTreeHeight () return the dbh (cm) and the height (m) of the tree.
  • the other methods return values of the crown.
   // TreeWithCrownProfile interface
      // Location of the tree on the scene (in m.)
      public double getTreeX () {return getX ();}
      public double getTreeY () {return getY ();}
      public double getTreeZ () {return getZ ();}
 
      // Trunk dimensions
      public double getTreeDbh () {return getDbh ();}			// in cm.
      public double getTreeHeight () {return getHeight ();}	// in m.
 
      // List of height / radius (in percentage of the crown height / the crown radius)
      // - first entry should be (0, 0) : bottom of the crown
      // - possibly several intermediate entries to describe the profile between
      //   crownBaseHeight and treeHeight
      // - last entry should be (100, 0) : top of the crown
      public double[][] getCrownProfile () {return getImmutable ().crownProfile;} // array of (height%, radius%)
 
      public double getCrownBaseHeight () {...}	// in m.
      public double getCrownRadius () {...}	// in m.
 
      public Color getCrownColor () {...}	// ex : Color.GREEN, RED
      public float getCrownTransparency () {...}	// 0.0 (opaque) to 1.0 (transparent)
   // TreeWithCrownProfile interface

When used in SVSimple (Visu simple / Simple viewer) by selection of some trees in the LollypopOV (Sucettes 3D / Lollypop 3D) Object Viewer, the result looks like this :

documentation/viewing_in_3d_trees_with_a_simple_crown_profile.txt ยท Last modified: 2021/12/13 09:28 by 127.0.0.1