tutorials:leaf-triangulation
                Differences
This shows you the differences between two versions of the page.
| Next revision | Previous revision | ||
| tutorials:leaf-triangulation [2024/12/05 19:54] – created MH | tutorials:leaf-triangulation [2024/12/09 21:51] (current) – changed some minors MH | ||
|---|---|---|---|
| Line 23: | Line 23: | ||
| import de.grogra.xl.util.FloatList; | import de.grogra.xl.util.FloatList; | ||
| - | static final float[] p0 = {0,0,0}; | + | const float[] p0 = {0,0,0}; | 
| - | static final float[] p1 = {-2.85, | + | const float[] p1 = {-2.85, | 
| - | static final float[] p2 = {0,10,0}; | + | const float[] p2 = {0,10,0}; | 
| - | static final float[] p3 = {2.85, | + | const float[] p3 = {2.85, | 
| - | private static | + | const FloatList vertexDataLeaflet = new FloatList(new float[] { | 
| //left | //left | ||
| p0[0], p0[1], p0[2], p1[0], p1[1], p1[2], p2[0], p2[1], p2[2],//T1 | p0[0], p0[1], p0[2], p1[0], p1[1], p1[2], p2[0], p2[1], p2[2],//T1 | ||
| Line 51: | Line 51: | ||
| </ | </ | ||
| - | The output of the above code could then look like this: | + | The output of the above code could then look like this. Note: The blue lines to highlight the edges are just added to increase understanding - they will be not shown when running the above code.: | 
| - | {{ :tutorials:leaflet_model_s.png? | + | {{ :tutorials:leaf_s.png? | 
| + | For convex shapes, the //Library// function //leaf3d// can be used to generate a triangulation like the above one. It assumes that the first point is the origin of all faces and builds a series of triangles from this point on. In XL this could look like this: | ||
| + | |||
| + | <code java> | ||
| + | const float[] pointlist = new float[] {0, | ||
| + | |||
| + | protected void init() [ | ||
| + | Axiom ==> leaf3d(pointlist); | ||
| + | ] | ||
| + | </ | ||
| - | The //Library// function //getMesh// takes a // | + | Coming back to the // | 
| <code java> | <code java> | ||
| Line 95: | Line 104: | ||
| import de.grogra.xl.util.FloatList; | import de.grogra.xl.util.FloatList; | ||
| - | static final float[] p0 = {0,0,0}; | + | const float[] p0 = {0,0,0}; | 
| - | static final float[] p1 = {-0.1, | + | const float[] p1 = {-0.1, | 
| - | static final float[] p2 = {-0.2, | + | const float[] p2 = {-0.2, | 
| - | static final float[] p3 = {-0.25, | + | const float[] p3 = {-0.25, | 
| - | static final float[] p4 = {0, | + | const float[] p4 = {0, | 
| - | static final float[] p5 = {-0.285, | + | const float[] p5 = {-0.285, | 
| - | static final float[] p6 = {0, | + | const float[] p6 = {0, | 
| - | static final float[] p7 = {-0.22, | + | const float[] p7 = {-0.22, | 
| - | static final float[] p8 = {0, | + | const float[] p8 = {0, | 
| - | static final float[] p9 = {0,1,1.0}; | + | const float[] p9 = {0,1,1.0}; | 
| - | private static | + | const FloatList vertexDataLeaflet = new FloatList(new float[] { | 
| //left | //left | ||
| p0[0], p0[1], p0[2], p1[0], p1[1], p1[2], p2[0], p2[1], p2[2],//T1 | p0[0], p0[1], p0[2], p1[0], p1[1], p1[2], p2[0], p2[1], p2[2],//T1 | ||
| Line 127: | Line 136: | ||
| }); | }); | ||
| - | const PolygonMesh polygonMesh = new PolygonMesh(); | + | static MeshNode LeafletMesh; | 
| static { | static { | ||
| - |  | + |  | 
| - | for(int i = 0; i< | + | |
| - | // set a list of the indices of the used list of vertices | + | |
| - | // normally = {0, | + | |
| - | polygonMesh.setIndexData(new IntList(tmp)); | + | |
| - | // set the list of vertices | + | |
| - | polygonMesh.setVertexData(vertexDataLeaflet); | + | |
| } | } | ||
| protected void init() [ | protected void init() [ | ||
| - | Axiom ==> Scale(0.07, 0.07, 0.01) | + | Axiom ==> Scale(0.07, 0.07, 0.01) LeafletMesh.(setShader(GREEN)); | 
| ] | ] | ||
| </ | </ | ||
| Line 159: | Line 162: | ||
| as it was used within Zhang //et al.// 2021 (High resolution 3D simulation of light climate and thermal performance of a solar greenhouse model under tomato canopy structure; //Renewable Energy//, 160, 730-745, doi: [[https:// | as it was used within Zhang //et al.// 2021 (High resolution 3D simulation of light climate and thermal performance of a solar greenhouse model under tomato canopy structure; //Renewable Energy//, 160, 730-745, doi: [[https:// | ||
| + | |||
| + | GroIMP provides a few predefined 3D leaves that can be accessed using the Library function leaf3d(id). There are shapes for: " | ||
| + | |||
| + | The code below will generate them one by one next to each other. | ||
| + | |||
| + | <code java> | ||
| + | protected void init() [ | ||
| + | Axiom ==> | ||
| + | for(int i=0; i< | ||
| + | [ Null(i*0.3, | ||
| + | ) | ||
| + | ] | ||
| + | </ | ||
| + | |||
| + | The predefined 3D leaf shapes will look as shown below: | ||
| + | |||
| + | {{ : | ||
| + | |||
tutorials/leaf-triangulation.1733424867.txt.gz · Last modified: 2024/12/05 19:54 by MH
                
                