Untitled

mail@pastecode.io avatar
unknown
plain_text
24 days ago
1.1 kB
0
Indexable
Never
!pip install openalea.plantgl

from openalea.plantgl.all import *

# Create a scene graph for the flower bouquet
scene = Scene()

# Create a tulip flower
tulip = Shape(Translated((0, 0, 0), Sphere(0.5)))
tulip.appearance = Material((0, 0, 1))
scene.add(tulip)

# Create a stem for the tulip
stem = Shape(Cylinder(0.05, Vector3(0, 0, 1)))
stem.appearance = Material((0, 1, 0))
scene.add(Translated((0, 0, -0.5), stem))

# Create leaves for the tulip
leaf1 = Shape(Translated((0.3, 0, 0), Sphere(0.2)))
leaf1.appearance = Material((0, 1, 0))
scene.add(Translated((0, 0, -0.5), leaf1))

leaf2 = Shape(Translated((-0.3, 0, 0), Sphere(0.2)))
leaf2.appearance = Material((0, 1, 0))
scene.add(Translated((0, 0, -0.5), leaf2))

# Create roots for the flower bouquet
root1 = Shape(Translated((0.3, 0, 0), Sphere(0.2)))
root1.appearance = Material((1, 0, 0))
scene.add(Translated((0, 0, 0.5), root1))

root2 = Shape(Translated((-0.3, 0, 0), Sphere(0.2)))
root2.appearance = Material((1, 0, 0))
scene.add(Translated((0, 0, 0.5), root2))

# Display the scene
Viewer.display(scene)
Leave a Comment