Skip to content

Commit c2dd976

Browse files
authored
Add files via upload
Very basic, solo versions of the leaf and apple geometries
1 parent b9597b9 commit c2dd976

File tree

2 files changed

+143
-0
lines changed

2 files changed

+143
-0
lines changed

other_files/apple_model.lpy

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
2+
import random as rd
3+
4+
def make_apple_curve():
5+
y1 = rd.uniform(.65,1)
6+
y2 = rd.uniform(.8,1)
7+
y3 = rd.uniform(.4,.5)
8+
9+
base_points = [
10+
#point 0 #point 1 #point 2 #point 3
11+
(0, 0, 1), (0, y1, 1), (1, y2, 1),(1, y3, 1)
12+
]
13+
14+
top_points = [
15+
(0, y3, 1),(0, 0.118695, 1),(0.909233, 0.146624, 1),(1, -0.0977491, 1)
16+
]
17+
18+
base_point_list = Point3Array(base_points)
19+
curve1 = NurbsCurve2D(base_point_list)
20+
base_curve = QuantisedFunction(curve1)
21+
22+
top_point_list = Point3Array(top_points)
23+
curve2 = BezierCurve2D(top_point_list)
24+
top_curve = QuantisedFunction(curve2)
25+
26+
return [base_curve,top_curve]
27+
28+
29+
30+
def make_stem_curve():
31+
32+
points = [
33+
(-1.48289, 0.982887, 1),(-0.559816, 1.22861, 1.05),(1.05126, 1.57262, 1),(1.70403, -0.0245722, 1)
34+
]
35+
ctrlPointList = Point3Array(points)
36+
stem_curve = NurbsCurve2D(ctrlPointList)
37+
return stem_curve
38+
39+
40+
41+
42+
Axiom: A(.1, .09)
43+
44+
45+
derivation length: 2
46+
production:
47+
A(bh, r):
48+
curves = make_apple_curve()
49+
base_curve = curves[0]
50+
print("BASE CURVE " + str(base_curve) )
51+
print(base_curve)
52+
top_curve = curves[1]
53+
nproduce SetColor(230,0,0) SectionResolution(60)
54+
produce nF(bh, .01, r, base_curve) ^(180) nF(bh/5, .01, r, top_curve)^(180)S(bh/1.5, r/10)
55+
56+
57+
S(sh, r):
58+
stem_curve = make_stem_curve()
59+
nproduce SetColor(100,65,23)
60+
produce SetGuide(stem_curve, sh) _(r)nF(sh, .01, r)
61+
62+
63+
64+
interpretation:
65+
66+
67+
endlsystem
68+
###### INITIALISATION ######
69+
70+
__lpy_code_version__ = 1.1
71+
72+
def __initialiseContext__(context):
73+
import openalea.plantgl.all as pgl
74+
bc = pgl.NurbsCurve2D(
75+
ctrlPointList = pgl.Point3Array([(0, 0, 1),(0, 1.70191, 1),(1, 2.01708, 1),(1, 0.192308, 1)]) ,
76+
)
77+
bc.name = "bc"
78+
parameter = pgl.NurbsCurve2D(
79+
ctrlPointList = pgl.Point3Array([(0, 0.0195083, 1),(0, 0.994923, 1),(0.289506, 1.07946, 1),(1, 0.903884, 1)]) ,
80+
)
81+
parameter.name = "parameter"
82+
import openalea.plantgl.all as pgl
83+
parameter_2 = pgl.BezierCurve2D(
84+
pgl.Point3Array([(0.00549451, 0.00549451, 1),(-0.0018315, 0.204393, 1),(0.106227, 0.243688, 1),(0.106178, 0.117389, 1)]) ,
85+
)
86+
parameter_2.name = "parameter_2"
87+
panel_0 = ({'name': 'Panel 1', 'active': True, 'visible': True},[('Function',bc),('Function',parameter),('Curve2D',parameter_2)])
88+
parameterset = [panel_0,]
89+
context["__functions__"] = [('bc',bc),('parameter',parameter),]
90+
context["__curves__"] = [('parameter_2',parameter_2),]
91+
context["__parameterset__"] = parameterset
92+
context["bc"] = pgl.QuantisedFunction(bc)
93+
context["parameter"] = pgl.QuantisedFunction(parameter)
94+
context["parameter_2"] = parameter_2

other_files/leaf_model.lpy

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
import random as rd
2+
def make_leaf_guide():
3+
4+
x1 = rd.uniform(0,.25)
5+
x2 = rd.uniform(.65,.85)
6+
y1 = rd.uniform(.45,.55)
7+
y2 = rd.uniform(.25,.35)
8+
9+
control_points = [
10+
Vector3(0,0,0),
11+
Vector3(x1,y1,0),
12+
Vector3(x2,y2,0),
13+
Vector3(1,0,0),
14+
]
15+
16+
inverse_points = [
17+
Vector3(0,0,0),
18+
Vector3(x1,-y1,0),
19+
Vector3(x2,-y2,0),
20+
Vector3(1,0,0),
21+
]
22+
23+
side1 = Point3Array(control_points)
24+
side2 = Point3Array(inverse_points)
25+
26+
curve1 = BezierCurve2D(side1)
27+
curve2 = BezierCurve2D(side2)
28+
29+
return [curve1, curve2]
30+
31+
Axiom: L
32+
33+
derivation length: 1
34+
production:
35+
36+
L:
37+
nproduce SetColor(0,225,0)
38+
39+
curves = make_leaf_guide()
40+
curve1 = curves[0]
41+
curve2 = curves[1]
42+
43+
produce _(.0025) F(.1){[SetGuide(curve1, 1) _(.001).nF(1, .1)][SetGuide(curve2, 1)_(.001).nF(1, .1)]}(True)
44+
45+
46+
interpretation:
47+
48+
49+
endlsystem

0 commit comments

Comments
 (0)