|
| 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 |
0 commit comments