|
89 | 89 | tiles = vec([create_tile(origin, dx, dy) for origin in origins]); |
90 | 90 | ``` |
91 | 91 |
|
92 | | -Now we can combine the plants and tiles into a single scene. We randomize the color of each |
| 92 | +Now we can combine the plants and tiles into a single mesh. We randomize the color of each |
93 | 93 | tile to help identify them in the visualization: |
94 | 94 |
|
95 | 95 | ```julia |
96 | | -plant_scene = Scene(vec(plants)); |
97 | | -soil_scene = Scene() |
| 96 | +plant_mesh = Mesh(vec(plants)); |
| 97 | +soil_mesh = Mesh() |
98 | 98 | for tile in tiles |
99 | | - add!(soil_scene, mesh = tile, colors = RGB(rand(), rand(), rand())) |
| 99 | + add!(soil_mesh, tile, colors = RGB(rand(), rand(), rand())) |
100 | 100 | end |
101 | | -scene = Scene([plant_scene, soil_scene]); |
102 | | -render(scene) |
| 101 | +mesh = Mesh([plant_mesh, soil_mesh]); |
| 102 | +render(mesh) |
103 | 103 | ``` |
104 | 104 |
|
105 | | -We can also visualize the bounding boxes of a scene (and any clone). If we just want the |
106 | | -box for the original scene, we can create a grid with no clones. The build the acceleration |
| 105 | +We can also visualize the bounding boxes of a mesh (and any clone). If we just want the |
| 106 | +box for the original mesh, we can create a grid with no clones. The build the acceleration |
107 | 107 | object (which includes the grid cloner) and add it to the 3D rendering: |
108 | 108 |
|
109 | 109 | ```julia |
110 | 110 | rt_settings = RTSettings(nx = 0, ny = 0) |
111 | | -acc_one = accelerate(scene, settings = rt_settings); |
112 | | -render(scene) |
| 111 | +acc_one = accelerate(mesh, settings = rt_settings); |
| 112 | +render(mesh) |
113 | 113 | render!(acc_one.grid) |
114 | 114 | ``` |
115 | 115 |
|
116 | 116 | We can see that bounding box extends to the tips of the leaves, as they grow beyond the soil |
117 | | -area allocated to the plant. If we now create multiple clones of this scene, we should |
| 117 | +area allocated to the plant. If we now create multiple clones of this mesh, we should |
118 | 118 | displace them by a distance of `10dx` along the x-axis and `10dy` along the y-axis. This |
119 | 119 | will ensure that the soil tiles of clones do not overlap but the plants will. In other words, |
120 | 120 | we emulate additional rows and plants within rows while respecting the same spacing between |
121 | 121 | them: |
122 | 122 |
|
123 | 123 | ```julia |
124 | 124 | rt_settings = RTSettings(nx = 1, ny = 1, dx = 10dx, dy = 10dy) |
125 | | -acc = accelerate(scene, settings = rt_settings); |
| 125 | +acc = accelerate(mesh, settings = rt_settings); |
126 | 126 | ``` |
127 | 127 |
|
128 | | -We can now add all the bounding boxes of the clones to the scene: |
| 128 | +We can now add all the bounding boxes of the clones to the mesh: |
129 | 129 |
|
130 | 130 | ```julia |
131 | | -render(scene) |
| 131 | +render(mesh) |
132 | 132 | render!(acc.grid) |
133 | 133 | ``` |
134 | 134 |
|
135 | 135 | We can see that the bounding boxes of the clones overlap, as expected. Currently there is no |
136 | 136 | way in VPL to visualize the actual clones (since that additional geometry is never actually |
137 | 137 | generated, see details about *instancing* above). We can do this manually by manually changing |
138 | | -the meshes of the scene using the method `VirtualPlantLab.translate!`. We add the bounding |
139 | | -box of the original scene too: |
| 138 | +the meshes of the mesh using the method `VirtualPlantLab.translate!`. We add the bounding |
| 139 | +box of the original mesh too: |
140 | 140 |
|
141 | 141 | ```julia |
142 | | -scenes = Scene[] |
| 142 | +meshes = Mesh[] |
143 | 143 | for i in -10:10 |
144 | 144 | for j in -10:10 |
145 | | - new_scene = deepcopy(scene) |
146 | | - VirtualPlantLab.translate!(new_scene.mesh, Vec(i*10dx, j*10dy, 0.0)) |
147 | | - push!(scenes, new_scene) |
| 145 | + new_mesh = deepcopy(mesh) |
| 146 | + VirtualPlantLab.translate!(new_mesh, Vec(i*10dx, j*10dy, 0.0)) |
| 147 | + push!(meshes, new_mesh) |
148 | 148 | end |
149 | 149 | end |
150 | | -render(Scene(scenes), axes = false) |
| 150 | +render(Mesh(meshes), axes = false) |
151 | 151 | render!(acc_one.grid, alpha = 0.8) |
152 | 152 | ``` |
153 | 153 |
|
|
0 commit comments