diff --git a/Project.toml b/Project.toml index a2c65ac..a17d479 100644 --- a/Project.toml +++ b/Project.toml @@ -1,33 +1,27 @@ name = "VPLDocs" uuid = "19246b20-85cd-4f94-a989-28bb6828320f" authors = ["Alejandro Morales Sierra and contributors"] -version = "0.1.0" +version = "0.0.7" [deps] -Distributions = "31c24e10-a181-5473-b8eb-7969acd0382f" Ecophys = "19467474-d12d-47c9-939f-3e50fbfd93ad" -FastGaussQuadrature = "442a2c76-b920-505d-bb47-c5924d526838" PlantGeomPrimitives = "7eef3cc5-4580-4ff0-8f6f-933507db6664" PlantGeomTurtle = "7d6e2781-1c99-4c66-97ec-106669f3e96e" PlantGraphs = "615ad455-9aac-4340-9247-71ef610f781a" PlantRayTracer = "78485975-e4aa-407d-b3bb-ded5a4265d05" PlantSimEngine = "9a576370-710b-4269-adf9-4f603a9c6423" PlantViz = "358bd95d-d12c-439f-94b7-04b17e500c7f" -Plots = "91a5bcdd-55d7-5caf-9e0b-520d859cae80" SkyDomes = "1838625c-7cf7-40c6-898b-904883e4b556" VirtualPlantLab = "b977ecfa-1b9a-418d-909d-4ebe565736ce" [compat] -Distributions = "0.25.120" Ecophys = "0.1.0" -FastGaussQuadrature = "1.0.2" -PlantGeomPrimitives = "0.1.0" -PlantGeomTurtle = "0.1.0" -PlantGraphs = "0.1.0" -PlantRayTracer = "0.1.0" +PlantGeomPrimitives = "0.0.5" +PlantGeomTurtle = "0.0.6" +PlantGraphs = "0.0.3" +PlantRayTracer = "0.0.8" PlantSimEngine = "0.9" -PlantViz = "0.1.0" -Plots = "1.40.17" -SkyDomes = "0.1.9" -VirtualPlantLab = "0.1.0" +PlantViz = "0.0.8" +SkyDomes = "0.1.8" +VirtualPlantLab = "0.0.7" julia = "1.11" diff --git a/docs/src/manual/Geometry/Primitives.md b/docs/src/manual/Geometry/Primitives.md index 2ebbc8a..e701196 100644 --- a/docs/src/manual/Geometry/Primitives.md +++ b/docs/src/manual/Geometry/Primitives.md @@ -39,38 +39,32 @@ to ensure that the transparency is enabled when rendering the mesh. ## Triangle ```julia -turtle = Turtle() -p = Triangle!(turtle; length = 1.0, width = 1.0, colors = rand(RGBA)) -render(Mesh(turtle), wireframe = true) +p = Triangle(length = 1.0, width = 1.0) +render(p, wireframe = true, normals = true, color = RGBA(0,1,0,0.5), transparency = true) ``` ## Rectangle ```julia -turtle = Turtle() -p = Rectangle!(turtle; length = 1.0, width = 1.0, colors = rand(RGBA)) -render(Mesh(turtle), wireframe = true) +p = Rectangle(length = 1.0, width = 1.0) +render(p, wireframe = true, normals = true, color = RGBA(0,1,0,0.5), transparency = true) ``` ## Trapezoid ```julia -turtle = Turtle() -p = Trapezoid!(turtle; length = 1.0, width = 1.0, ratio = 0.5, colors = rand(RGBA)) -render(Mesh(turtle), wireframe = true) +p = Trapezoid(length = 1.0, width = 1.0, ratio = 0.5) +render(p, wireframe = true, normals = true, color = RGBA(0,1,0,0.5), transparency = true) ``` ## Ellipse ```julia -turtle = Turtle() -p = Ellipse!(turtle; length = 1.0, width = 1.0, n = 30, colors = rand(RGBA)) -render(Mesh(turtle), wireframe = true) +p = Ellipse(length = 1.0, width = 1.0, n = 30) +render(p, wireframe = true, normals = true, color = RGBA(0,1,0,0.5), transparency = true) ``` ## Axis-aligned bounding box ```julia -turtle = Turtle() p = BBox(Vec(0.0, 0.0, 0.0), Vec(1.0, 1.0, 1.0)) -Mesh!(turtle, p, colors = rand(RGBA)) -render(Mesh(turtle), wireframe = true) +render(p, wireframe = true, normals = true, color = RGBA(0,1,0,0.5), transparency = true) ``` ## Cube @@ -78,42 +72,31 @@ render(Mesh(turtle), wireframe = true) Solid version ```julia -turtle = Turtle() -p = SolidCube!(turtle; length = 1.0, width = 1.0, height = 1.0, colors = rand(RGBA)) -render(Mesh(turtle), wireframe = true) +p = SolidCube(length = 1.0, width = 1.0, height = 1.0) +render(p, wireframe = true, normals = true, color = RGBA(0,1,0,0.5), transparency = true) ``` Hollow version ```julia -turtle = Turtle() -p = HollowCube!(turtle; length = 1.0, width = 1.0, height = 1.0, colors = rand(RGBA)) -render(Mesh(turtle), wireframe = true)e) +p = HollowCube(length = 1.0, width = 1.0, height = 1.0) +render(p, wireframe = true, normals = true, color = RGBA(0,1,0,0.5), transparency = true) ``` - -## Primitives with (semi-)circular bases - -The following primitive types share a parameter n, which is the number of triangles to discretize the cylinder into. -The lower is number n, cicle base shape will be more rough (e.g., n = 20, base shape is a pentagon). -The higher is number n, cicle base shape will be more smooth (e.g., n = 80, base shape is a circle). - ## Cylinder Solid version ```julia -turtle = Turtle() -p = SolidCylinder!(turtle; length = 1.0, width = 1.0, height = 1.0, n = 80, colors = rand(RGBA)) -render(Mesh(turtle), wireframe = true) +p = SolidCylinder(length = 1.0, width = 1.0, height = 1.0, n = 80) +render(p, wireframe = true, normals = true, color = RGBA(0,1,0,0.5), transparency = true) ``` Hollow version ```julia -turtle = Turtle() -p = HollowCylinder!(turtle; length = 1.0, width = 1.0, height = 1.0, n = 80, colors = rand(RGBA)) -render(Mesh(turtle), wireframe = true) +p = HollowCylinder(length = 1.0, width = 1.0, height = 1.0, n = 40) +render(p, wireframe = true, normals = true, color = RGBA(0,1,0,0.5), transparency = true) ``` ## Frustum @@ -121,17 +104,15 @@ render(Mesh(turtle), wireframe = true) Solid version ```julia -turtle = Turtle() -p = SolidFrustum!(turtle; length = 1.0, width = 1.0, height = 1.0, ratio = 0.5, n = 80, colors = rand(RGBA)) -render(Mesh(turtle), wireframe = true) +p = SolidFrustum(length = 1.0, width = 1.0, height = 1.0, ratio = 0.5, n = 80) +render(p, wireframe = true, normals = true, color = RGBA(0,1,0,0.5), transparency = true) ``` Hollow version ```julia -turtle = Turtle() -p = HollowFrustum!(turtle; length = 1.0, width = 1.0, height = 1.0, ratio = 0.5, n = 80, colors = rand(RGBA)) -render(Mesh(turtle), wireframe = true) +p = HollowFrustum(length = 1.0, width = 1.0, height = 1.0, ratio = 0.5, n = 40) +render(p, wireframe = true, normals = true, color = RGBA(0,1,0,0.5), transparency = true) ``` ## Cone @@ -139,15 +120,13 @@ render(Mesh(turtle), wireframe = true) Solid version ```julia -turtle = Turtle() -p = SolidCone!(turtle; length = 1.0, width = 1.0, height = 1.0, n = 80, colors = rand(RGBA)) -render(Mesh(turtle), wireframe = true) +p = SolidCone(length = 1.0, width = 1.0, height = 1.0, n = 40) +render(p, wireframe = true, normals = true, color = RGBA(0,1,0,0.5), transparency = true) ``` Hollow version ```julia -turtle = Turtle() -p = HollowCone!(turtle; length = 1.0, width = 1.0, height = 1.0, n = 80, colors = rand(RGBA)) -render(Mesh(turtle), wireframe = true) +p = HollowCone(length = 1.0, width = 1.0, height = 1.0, n = 20) +render(p, wireframe = true, normals = true, color = RGBA(0,1,0,0.5), transparency = true) ``` diff --git a/docs/src/tutorials/from_tree_forest/raytracedforest.md b/docs/src/tutorials/from_tree_forest/raytracedforest.md index d2687b8..1da9f64 100644 --- a/docs/src/tutorials/from_tree_forest/raytracedforest.md +++ b/docs/src/tutorials/from_tree_forest/raytracedforest.md @@ -247,7 +247,7 @@ function `sky()` (this last step requires the 3D scene as input in order to plac the light sources adequately). ```julia -function create_sky(;mesh, lat = 52.0*π/180.0, DOY = 182) +function create_sky(;scene, lat = 52.0*π/180.0, DOY = 182) # Fraction of the day and day length fs = collect(0.1:0.1:0.9) dec = declination(DOY) @@ -264,7 +264,7 @@ function create_sky(;mesh, lat = 52.0*π/180.0, DOY = 182) Idir_PAR = f_dir.*Idir Idif_PAR = f_dif.*Idif # Create the dome of diffuse light - dome = sky(mesh, + dome = sky(scene, Idir = 0.0, ## No direct solar radiation Idif = sum(Idir_PAR)/10*DL, ## Daily Diffuse solar radiation nrays_dif = 1_000_000, ## Total number of rays for diffuse solar radiation @@ -274,7 +274,7 @@ function create_sky(;mesh, lat = 52.0*π/180.0, DOY = 182) nphi = 12) ## Number of discretization steps in the azimuth angle # Add direct sources for different times of the day for I in Idir_PAR - push!(dome, sky(mesh, Idir = I/10*DL, nrays_dir = 100_000, Idif = 0.0)[1]) + push!(dome, sky(scene, Idir = I/10*DL, nrays_dir = 100_000, Idif = 0.0)[1]) end return dome end @@ -299,9 +299,10 @@ for details). The acceleration structure allows speeding up the ray tracing by avoiding testing all rays against all objects in the scene. ```julia -function create_raytracer(acc_mesh, sources) +function create_raytracer(mesh, sources) settings = RTSettings(pkill = 0.9, maxiter = 4, nx = 5, ny = 5, parallel = true) - RayTracer(acc_mesh, sources, settings = settings); + RayTracer(mesh, sources, settings = settings, acceleration = BVH, + rule = SAH{3}(5, 10)); end ``` @@ -313,9 +314,8 @@ the `Material` objects (see `feed!()` above): ```julia function run_raytracer!(forest; DOY = 182) mesh = create_scene(forest) - acc_mesh = accelerate(mesh, acceleration = BVH, rule = SAH{3}(5, 10)) - sources = create_sky(mesh = acc_mesh, DOY = DOY) - rtobj = create_raytracer(acc_mesh, sources) + sources = create_sky(mesh = mesh, DOY = DOY) + rtobj = create_raytracer(mesh, sources) trace!(rtobj) return nothing end @@ -393,7 +393,7 @@ plot(0:1:50, x -> sink_strength(TreeTypes.Leaf(age = x), TreeTypes.treeparams()) xlabel = "Age", ylabel = "Sink strength", label = "Leaf") sink_strength(int) = pdf(int.sink, int.age) -plot!(0:1:50, x -> sink_strength(TreeTypes.Internode(age = x)), label = "Internode") +plot!(0:1:50, x -> sink_strength(TreeTypes.Leaf(age = x)), label = "Internode") ``` Now we need a function that updates the biomass of the tree, allocates it to the