12 std::vector<vec3> node_stem;
13 vector<RGBcolor> Color_stem;
15 std::vector<float> radius_stem;
20 for (
float n = 0; n < params.
s1_stem_length + stem_sects; n = n + stem_sects) {
25 node_stem.push_back(
make_vec3(x, y, z) + origin);
30 std::vector<std::vector<uint>> s1_UUID_stem_plant;
31 s1_UUID_stem_plant.resize(1);
33 std::vector<uint> UUID_stem_top = context->
addDisk(params.
s1_stem_subdivisions,
make_vec3(0, 0, 0),
make_vec2(params.
s1_stem_radius, params.
s1_stem_radius),
make_SphericalCoord(0, 0, 0),
RGBcolor(0.44, 0.58, 0.19));
38 s1_UUID_stem_plant.push_back(context->
copyPrimitive(UUID_stem));
39 s1_UUID_stem_plant.push_back(context->
copyPrimitive(UUID_stem_top));
44 float angle = ((context->
randu(0, 90) *
PI_F) /
float(180));
45 for (
float i = 1; i < 4; i++) {
46 float leaf_length, leaf_width, rotation_value1, leaf_bend, rotation_value2, frac, leaf_curve, x_adj;
52 leaf_bend = leaf_length * 0.2;
55 leaf_curve = leaf_width * 0.25;
61 rotation_value1 =
PI_F;
62 leaf_bend = leaf_length * 0.2;
65 leaf_curve = leaf_width * 0.25;
71 rotation_value1 =
PI_F * 0.5;
72 leaf_bend = leaf_length * 0.2;
75 leaf_curve = leaf_width * 0.25;
79 std::vector<uint> UUIDs4;
91 float dx = leaf_length / Nx;
92 float dy = leaf_width / Ny;
94 float A_3 = leaf_length / float(0.08);
97 float A_2 = leaf_length / float(80);
99 for (
int i = 0; i < Nx; i++) {
100 for (
float j = 0; j < Ny; j++) {
103 float y_frac = j / Ny;
104 float Ny_frac_1, Ny_frac_2;
107 Ny_frac_1 = (1 - y_frac) * 2;
108 Ny_frac_2 = Ny_frac_1 - frac;
110 }
else if (y_frac < 0.5) {
111 Ny_frac_1 = y_frac * 2;
112 Ny_frac_2 = Ny_frac_1 + frac;
114 Ny_frac_1 = (1 - y_frac) * 2;
115 Ny_frac_2 = Ny_frac_1 - frac;
124 float x_i = x *
PI_F / (Nx * dx);
125 float sx_i = (x + sx) *
PI_F / (Nx * dx);
127 float z_1 = (x *
PI_F) / ((Nx * dx) / (A_3));
128 float z_2 = ((x + sx) *
PI_F) / ((Nx * dx) / (A_3));
136 leaf_wave_1 = A_2 * sin(z_1);
137 leaf_wave_2 = A_2 * sin(z_2);
139 leaf_wave_1 = -leaf_curve * Ny_frac_1;
140 leaf_wave_2 = -leaf_curve * Ny_frac_1;
143 z = leaf_bend * sin(x_i) + leaf_wave_1;
146 z = leaf_bend * sin(sx_i) + leaf_wave_2;
147 vec3 v1(x + sx, y, z);
150 leaf_wave_3 = A_2 * sin(z_2);
151 leaf_wave_4 = A_2 * sin(z_1);
153 leaf_wave_3 = -leaf_curve * Ny_frac_2;
154 leaf_wave_4 = -leaf_curve * Ny_frac_2;
157 z = leaf_bend * sin(sx_i) + leaf_wave_3;
158 vec3 v2(x + sx, y + sy, z);
160 z = leaf_bend * sin(x_i) + leaf_wave_4;
161 vec3 v3(x, y + sy, z);
163 vec2 uv0(x / (Nx * dx), y / (leaf_width));
164 vec2 uv1((x + sx) / (Nx * dx), y / (leaf_width));
165 vec2 uv2((x + sx) / (Nx * dx), (y + sy) / (leaf_width));
166 vec2 uv3(x / (Nx * dx), (y + sy) / (leaf_width));
173 std::vector<std::vector<uint>> s1_UUID_leaf_plant;
174 s1_UUID_leaf_plant.push_back(context->
copyPrimitive(UUIDs4));
177 vec3 translation(-x_adj, -leaf_width * 0.5, 0);
178 float rotation_1 = -rotation_value2 *
PI_F / float(180);
180 float rotation_2 = angle + rotation_value1;
189 vector<vector<vector<uint>>> s1_UUID_panicle_plant;
190 std::vector<uint> s1_UUID_branch_plant;
192 UUID_trunk.push_back(s1_UUID_stem_plant.front());
193 UUID_leaf.push_back(s1_UUID_leaf_plant);
194 UUID_fruit.push_back(s1_UUID_panicle_plant);
195 UUID_branch.push_back(s1_UUID_branch_plant);
201 std::vector<vec3> node_stem;
202 vector<RGBcolor> Color_stem;
204 std::vector<float> radius_stem;
209 for (
float n = 0; n < params.
s2_stem_length + stem_sects; n = n + stem_sects) {
214 node_stem.push_back(
make_vec3(x, y, z) + origin);
219 std::vector<std::vector<uint>> s2_UUID_stem_plant;
220 s2_UUID_stem_plant.resize(1);
221 std::vector<uint> UUID_stem = context->
addTube(50, node_stem, radius_stem, Color_stem);
222 std::vector<uint> UUID_stem_top = context->
addDisk(50,
make_vec3(0, 0, 0),
make_vec2(params.
s2_stem_radius, params.
s2_stem_radius),
make_SphericalCoord(0, 0, 0),
RGBcolor(0.302, 0.4314, 0.2392));
227 s2_UUID_stem_plant.push_back(context->
copyPrimitive(UUID_stem));
228 s2_UUID_stem_plant.push_back(context->
copyPrimitive(UUID_stem_top));
232 float angle = ((context->
randu(0, 90) *
PI_F) /
float(180));
233 for (
float i = 1; i < 6; i++) {
234 float leaf_length, leaf_width, rotation_value1, leaf_bend, rotation_value2, frac, leaf_curve, leaf_wave_no, leaf_wave;
240 leaf_bend = leaf_length * 0.2;
241 rotation_value2 = 25;
243 leaf_curve = leaf_width * 0.25;
250 rotation_value1 =
PI_F;
251 leaf_bend = leaf_length * 0.2;
252 rotation_value2 = 50;
254 leaf_curve = leaf_width * 0.5;
261 rotation_value1 =
PI_F + ((context->
randu(0, 45) *
PI_F) /
float(180));
262 leaf_bend = leaf_length * 0.3;
263 rotation_value2 = 15;
265 leaf_curve = leaf_width * 0.5;
272 rotation_value1 = ((context->
randu(0, 45) *
PI_F) /
float(180));
273 leaf_bend = leaf_length * 0.3;
274 rotation_value2 = 25;
276 leaf_curve = leaf_width * 0.5;
283 rotation_value1 =
PI_F + ((context->
randu(0, 45) *
PI_F) /
float(180));
284 leaf_bend = leaf_length * 0.3;
285 rotation_value2 = 10;
287 leaf_curve = leaf_width * 0.5;
292 std::vector<std::vector<uint>> s2_UUID_leaf_plant;
294 std::vector<uint> UUIDs4;
305 float dx = leaf_length / Nx;
306 float dy = leaf_width / Ny;
308 float A_3 = leaf_length * leaf_wave_no;
311 float A_2 = leaf_length * leaf_wave;
313 for (
int i = 0; i < Nx; i++) {
314 for (
float j = 0; j < Ny; j++) {
317 float y_frac = j / Ny;
318 float Ny_frac_1, Ny_frac_2;
321 Ny_frac_1 = (1 - y_frac) * 2;
322 Ny_frac_2 = Ny_frac_1 - frac;
324 }
else if (y_frac < 0.5) {
325 Ny_frac_1 = y_frac * 2;
326 Ny_frac_2 = Ny_frac_1 + frac;
328 Ny_frac_1 = (1 - y_frac) * 2;
329 Ny_frac_2 = Ny_frac_1 - frac;
338 float x_i = x *
PI_F / (Nx * dx);
339 float sx_i = (x + sx) *
PI_F / (Nx * dx);
341 float z_1 = (x *
PI_F) / ((Nx * dx) / (A_3));
342 float z_2 = ((x + sx) *
PI_F) / ((Nx * dx) / (A_3));
350 leaf_wave_1 = A_2 * sin(z_1);
351 leaf_wave_2 = A_2 * sin(z_2);
353 leaf_wave_1 = -leaf_curve * Ny_frac_1;
354 leaf_wave_2 = -leaf_curve * Ny_frac_1;
357 z = leaf_bend * sin(x_i) + leaf_wave_1;
360 z = leaf_bend * sin(sx_i) + leaf_wave_2;
361 vec3 v1(x + sx, y, z);
364 leaf_wave_3 = A_2 * sin(z_2);
365 leaf_wave_4 = A_2 * sin(z_1);
367 leaf_wave_3 = -leaf_curve * Ny_frac_2;
368 leaf_wave_4 = -leaf_curve * Ny_frac_2;
371 z = leaf_bend * sin(sx_i) + leaf_wave_3;
372 vec3 v2(x + sx, y + sy, z);
374 z = leaf_bend * sin(x_i) + leaf_wave_4;
375 vec3 v3(x, y + sy, z);
377 vec2 uv0(x / (Nx * dx), y / (leaf_width));
378 vec2 uv1((x + sx) / (Nx * dx), y / (leaf_width));
379 vec2 uv2((x + sx) / (Nx * dx), (y + sy) / (leaf_width));
380 vec2 uv3(x / (Nx * dx), (y + sy) / (leaf_width));
387 s2_UUID_leaf_plant.push_back(context->
copyPrimitive(UUIDs4));
390 vec3 translation(-0.00015 * rotation_value2, -leaf_width * 0.5, 0);
391 float rotation_1 = -rotation_value2 *
PI_F / float(180);
393 float rotation_2 = angle + rotation_value1;
401 vector<vector<vector<uint>>> s2_UUID_panicle_plant;
402 std::vector<uint> s2_UUID_branch_plant;
404 UUID_trunk.push_back(s2_UUID_stem_plant.front());
405 UUID_leaf.push_back(s2_UUID_leaf_plant);
406 UUID_fruit.push_back(s2_UUID_panicle_plant);
407 UUID_branch.push_back(s2_UUID_branch_plant);
415 std::vector<vec3> node_stem;
416 vector<RGBcolor> Color_stem;
417 std::vector<float> radius_stem;
422 for (
float n = 0; n < params.
s3_stem_length + stem_sects; n = n + stem_sects) {
427 node_stem.push_back(
make_vec3(x, y, z) + origin);
438 float rotation_x1 = (context->
randu(0, 360) *
PI_F) /
float(180);
439 std::vector<std::vector<uint>> s3_UUID_leaf_plant;
441 for (
int i = 1; i < (nodes_no + 1); i++) {
443 std::vector<uint> UUIDs4;
456 if (i >= (nodes_no - 1) || i == 1) {
471 for (
int i = 0; i < Nx; i++) {
472 for (
float j = 0; j < Ny; j++) {
475 float y_frac = j / Ny;
476 float Ny_frac_1, Ny_frac_2;
479 Ny_frac_1 = (1 - y_frac) * 2;
480 Ny_frac_2 = Ny_frac_1 - frac;
482 }
else if (y_frac < 0.5) {
483 Ny_frac_1 = y_frac * 2;
484 Ny_frac_2 = Ny_frac_1 + frac;
486 Ny_frac_1 = (1 - y_frac) * 2;
487 Ny_frac_2 = Ny_frac_1 - frac;
496 float x_i = x *
PI_F / (Nx * dx);
497 float sx_i = (x + sx) *
PI_F / (Nx * dx);
499 float z_1 = (x *
PI_F) / ((Nx * dx) / (A_3));
500 float z_2 = ((x + sx) *
PI_F) / ((Nx * dx) / (A_3));
508 leaf_wave_1 = A_2 * sin(z_1);
509 leaf_wave_2 = A_2 * sin(z_2);
515 z = leaf_amplitude * sin(x_i) + leaf_wave_1;
518 z = leaf_amplitude * sin(sx_i) + leaf_wave_2;
519 vec3 v1(x + sx, y, z);
522 leaf_wave_3 = A_2 * sin(z_2);
523 leaf_wave_4 = A_2 * sin(z_1);
529 z = leaf_amplitude * sin(sx_i) + leaf_wave_3;
530 vec3 v2(x + sx, y + sy, z);
532 z = leaf_amplitude * sin(x_i) + leaf_wave_4;
533 vec3 v3(x, y + sy, z);
546 s3_UUID_leaf_plant.push_back(context->
copyPrimitive(UUIDs4));
556 frac = 1 - ((i - (context->
randu() / float(2))) / float((nodes_no + 1)));
561 float rotation_x2 = (context->
randu(0, 45) *
PI_F) /
float(180);
562 float rotation_2 = rotation_x1 + rotation_x2;
563 float rotation_3 = rotation_2 +
PI_F;
580 vector<vector<vector<uint>>> s3_UUID_panicle_plant;
581 std::vector<uint> s3_UUID_branch_plant;
583 UUID_trunk.push_back(s3_UUID_stem_plant);
584 UUID_leaf.push_back(s3_UUID_leaf_plant);
585 UUID_fruit.push_back(s3_UUID_panicle_plant);
586 UUID_branch.push_back(s3_UUID_branch_plant);
592 std::vector<vec3> node_stem;
594 vector<RGBcolor> Color_stem;
596 std::vector<float> radius_stem;
601 for (
float n = 0; n < params.
s4_stem_length + stem_sects; n = n + stem_sects) {
606 node_stem.push_back(
make_vec3(x, y, z) + origin);
615 vector<vector<vector<uint>>> s4_UUID_panicle_plant;
616 s4_UUID_panicle_plant.resize(1);
617 vector<RGBcolor> Color_panicle_stalk;
618 std::vector<vec3> nodes_panicle_stalk;
619 std::vector<float> radius_panicle_stalk;
623 for (
float n = 0; n < m; n = n + 0.0125) {
628 nodes_panicle_stalk.push_back(
make_vec3(x, y, z));
631 Color_panicle_stalk.push_back(
make_RGBcolor(0.302, 0.4314, 0.2392));
634 std::vector<uint> UUID1 = context->
addTube(params.
s4_stem_subdivisions, nodes_panicle_stalk, radius_panicle_stalk, Color_panicle_stalk);
636 s4_UUID_panicle_plant.front().push_back(context->
copyPrimitive(UUID1));
640 std::vector<vec3> nodes_panicle;
641 std::vector<float> radius_panicle;
645 for (
float n = 0; n < (width_panicle); n++) {
648 float dz = n * (0.01);
650 float angle = n *
PI_F / width_panicle;
651 float dr = 0.01 * sin(angle);
653 nodes_panicle.push_back(
make_vec3(x, y, z));
654 radius_panicle.push_back(dr);
663 std::vector<uint> UUIDs2_copy = context->
copyPrimitive(UUIDs2);
665 float rotation_angle;
668 rotation_angle = 0.26;
670 rotation_angle = i * 0.0867;
674 z_value = z_value + dz;
675 vec3 tra1(0, 0, z_value - dz);
677 float rot1 = rotation_angle;
682 s4_UUID_panicle_plant.front().push_back(UUIDs2_copy);
684 float i_value_1, i_value_2;
696 for (
int ii = 0; ii < i_value_1; ii++) {
697 s4_UUID_panicle_plant.front().push_back(context->
copyPrimitive(UUIDs2_copy));
698 float rot2 = ii * i_value_2 *
PI_F / float(180);
699 context->
rotatePrimitive(s4_UUID_panicle_plant.front().back(), rot2,
"z");
711 float rotation_x1 = (context->
randu(0, 360) *
PI_F) /
float(180);
712 std::vector<std::vector<uint>> s4_UUID_leaf_plant;
714 for (
int i = 1; i < (nodes_no + 1); i++) {
716 std::vector<uint> UUIDs4;
729 if (i >= (nodes_no - 1) || i == 1) {
747 for (
int i = 0; i < Nx; i++) {
748 for (
float j = 0; j < Ny; j++) {
751 float y_frac = j / Ny;
752 float Ny_frac_1, Ny_frac_2;
755 Ny_frac_1 = (1 - y_frac) * 2;
756 Ny_frac_2 = Ny_frac_1 - frac;
758 }
else if (y_frac < 0.5) {
759 Ny_frac_1 = y_frac * 2;
760 Ny_frac_2 = Ny_frac_1 + frac;
762 Ny_frac_1 = (1 - y_frac) * 2;
763 Ny_frac_2 = Ny_frac_1 - frac;
772 float x_i = x *
PI_F / (Nx * dx);
773 float sx_i = (x + sx) *
PI_F / (Nx * dx);
775 float z_1 = (x *
PI_F) / ((Nx * dx) / A_3);
776 float z_2 = ((x + sx) *
PI_F) / ((Nx * dx) / A_3);
784 leaf_wave_1 = A_2 * sin(z_1);
785 leaf_wave_2 = A_2 * sin(z_2);
791 z = leaf_amplitude * sin(x_i) + leaf_wave_1;
794 z = leaf_amplitude * sin(sx_i) + leaf_wave_2;
795 vec3 v1(x + sx, y, z);
798 leaf_wave_3 = A_2 * sin(z_2);
799 leaf_wave_4 = A_2 * sin(z_1);
805 z = leaf_amplitude * sin(sx_i) + leaf_wave_3;
806 vec3 v2(x + sx, y + sy, z);
808 z = leaf_amplitude * sin(x_i) + leaf_wave_4;
809 vec3 v3(x, y + sy, z);
822 s4_UUID_leaf_plant.push_back(context->
copyPrimitive(UUIDs4));
830 frac = (1 - ((i - (context->
randu() / float(2))) / float((nodes_no + 1) * 1.2))) - 0.15;
835 float rotation_x2 = (context->
randu(0, 45) *
PI_F) /
float(180);
836 float rotation_2 = rotation_x1 + rotation_x2;
837 float rotation_3 = rotation_2 +
PI_F;
854 std::vector<uint> s4_UUID_branch_plant;
856 UUID_trunk.push_back(s4_UUID_stem_plant);
857 UUID_fruit.push_back(s4_UUID_panicle_plant);
858 UUID_leaf.push_back(s4_UUID_leaf_plant);
859 UUID_branch.push_back(s4_UUID_branch_plant);
864 std::vector<vec3> nodes_stem;
866 std::vector<float> radius_stem;
867 vector<RGBcolor> Color_stem;
870 float dx = 1.f / float(Nx_stem);
876 float i_mid = (mid_height) * (180 /
float(params.
s5_stem_length)) *
PI_F /
float(180);
879 if (nx <= mid_height) {
889 nodes_stem.push_back(
make_vec3(x, y, z) + origin);
904 vector<vector<vector<uint>>> s5_UUID_panicle_plant;
905 s5_UUID_panicle_plant.resize(1);
907 vector<RGBcolor> Color_panicle_stalk;
908 std::vector<vec3> nodes_panicle_stalk;
909 std::vector<float> radius_panicle_stalk;
913 for (
float n = 0; n < m; n = n + 0.0125) {
918 nodes_panicle_stalk.push_back(
make_vec3(x, y, z));
920 Color_panicle_stalk.push_back(
make_RGBcolor(0.302, 0.4314, 0.2392));
923 std::vector<uint> UUID1 = context->
addTube(params.
s5_stem_subdivisions, nodes_panicle_stalk, radius_panicle_stalk, Color_panicle_stalk);
925 s5_UUID_panicle_plant.front().push_back(context->
copyPrimitive(UUID1));
929 std::vector<vec3> nodes_panicle;
930 std::vector<float> radius_panicle;
934 for (
float n = 0; n < width_panicle; n++) {
937 float dz = n * (0.01);
939 float angle = n *
PI_F / width_panicle;
940 float dr = 0.01 * sin(angle);
942 nodes_panicle.push_back(
make_vec3(x, y, z));
943 radius_panicle.push_back(dr);
955 std::vector<uint> UUIDs_copy = context->
copyPrimitive(UUIDs2);
957 float rotation_angle;
960 rotation_angle = 0.26;
962 rotation_angle = i * 0.0867;
966 z_value = z_value + dz;
967 vec3 tra1(0, 0, z_value - dz);
969 float rot1 = rotation_angle;
976 s5_UUID_panicle_plant.front().push_back(UUIDs_copy);
978 float i_value_1, i_value_2;
990 for (
int ii = 0; ii < i_value_1; ii++) {
991 s5_UUID_panicle_plant.front().push_back(context->
copyPrimitive(UUIDs_copy));
992 float rot2 = ii * i_value_2 *
PI_F / float(180);
993 context->
rotatePrimitive(s5_UUID_panicle_plant.front().back(), rot2,
"z");
1002 vec3 V_3 = V_1 - V_2;
1016 float rotation_x1 = (context->
randu(0, 360) *
PI_F) /
float(180);
1017 std::vector<std::vector<uint>> s5_UUID_leaf_plant;
1019 for (
int i = 1; i < (nodes_no + 1); i++) {
1021 std::vector<uint> UUIDs4;
1034 if (i >= (nodes_no - 1) || i == 1) {
1050 for (
int i = 0; i < Nx; i++) {
1051 for (
float j = 0; j < Ny; j++) {
1059 float x_i = x *
PI_F / (Nx * dx);
1060 float sx_i = (x + sx) *
PI_F / (Nx * dx);
1062 float z_1 = (x *
PI_F) / ((Nx * dx) / A_3);
1063 float z_2 = ((x + sx) *
PI_F) / ((Nx * dx) / A_3);
1071 leaf_wave_1 = A_2 * sin(z_1);
1072 leaf_wave_2 = A_2 * sin(z_2);
1078 z = leaf_amplitude * sin(x_i) + leaf_wave_1;
1081 z = leaf_amplitude * sin(sx_i) + leaf_wave_2;
1082 vec3 v1(x + sx, y, z);
1085 leaf_wave_3 = A_2 * sin(z_2);
1086 leaf_wave_4 = A_2 * sin(z_1);
1092 z = leaf_amplitude * sin(sx_i) + leaf_wave_3;
1093 vec3 v2(x + sx, y + sy, z);
1095 z = leaf_amplitude * sin(x_i) + leaf_wave_4;
1096 vec3 v3(x, y + sy, z);
1108 s5_UUID_leaf_plant.push_back(context->
copyPrimitive(UUIDs4));
1118 frac = (1 - ((i - (context->
randu() / float(2))) / float((nodes_no + 1) * 1.2))) - 0.15;
1123 float rotation_x2 = (context->
randu(0, 45) *
PI_F) /
float(180);
1124 float rotation_2 = rotation_x1 + rotation_x2;
1125 float rotation_3 = rotation_2 +
PI_F;
1142 float plant_rotation = (context->
randu(0, 360) *
PI_F) /
float(180);
1148 std::vector<uint> s5_UUID_branch_plant;
1150 UUID_trunk.push_back(s5_UUID_stem_plant);
1151 UUID_fruit.push_back(s5_UUID_panicle_plant);
1152 UUID_leaf.push_back(s5_UUID_leaf_plant);
1153 UUID_branch.push_back(s5_UUID_branch_plant);
1156 return UUID_leaf.size() - 1;