8 std::vector<std::vector<uint>> U;
12 float azimuth = 2.f *
PI_F * context->
randu();
14 if (context->
randu() < 0.75) {
19 if (context->
randu() < 0.5) {
27std::vector<uint> lateralLeaves(
const float bfrac,
const TomatoParameters params,
const float leaf_scale,
const std::vector<vec3> nodes, std::string texture,
Context *context) {
29 float downangle = 0.1 *
PI_F;
38 std::vector<uint> U1, U2;
56 U1.insert(U1.end(), U2.begin(), U2.end());
61void tomatoShoot(
const TomatoParameters params,
const helios::vec3 base_position,
const helios::vec3 base_direction,
const float length,
const float bend_angle, std::vector<std::vector<uint>> &leaf_UUIDs, std::vector<uint> &branch_UUIDs,
62 std::vector<std::vector<std::vector<uint>>> &fruit_UUIDs,
Context *context) {
64 std::vector<vec3> nodes;
65 std::vector<float> radius;
66 std::vector<RGBcolor> color;
70 vec3 dir = base_direction;
75 float shoot_radius = 0.005;
77 nodes.push_back(base_position);
78 radius.push_back(shoot_radius);
82 for (
int i = 1; i < node_count; i++) {
84 float vfrac = float(i) / float(node_count - 1);
86 radius.push_back(shoot_radius * params.
plant_height * (1.f - 0.8 * vfrac));
90 theta -= bend_angle / float(node_count - 1);
92 nodes.push_back(position);
98 branch_UUIDs.insert(branch_UUIDs.end(), U.begin(), U.end());
108 leaf_UUIDs.push_back(U);
126 fruit_UUIDs.push_back(tomatoCluster(cluster_position, params, context));
132 std::vector<std::vector<uint>> leaf_UUIDs;
133 std::vector<uint> branch_UUIDs;
134 std::vector<std::vector<std::vector<uint>>> fruit_UUIDs;
138 std::vector<vec3> nodes;
139 std::vector<float> radius;
140 std::vector<RGBcolor> color;
144 float stem_radius = 0.02;
146 nodes.push_back(origin);
147 radius.push_back(stem_radius);
150 for (
int i = 1; i < node_count; i++) {
152 float vfrac = float(i) / float(node_count - 1);
154 radius.push_back(stem_radius * params.
plant_height * (1.f - 0.9 * vfrac));
158 nodes.push_back(position);
165 std::vector<float> shoot_heights;
166 shoot_heights.push_back(0.4);
167 shoot_heights.push_back(0.5);
168 shoot_heights.push_back(0.6);
169 shoot_heights.push_back(0.65);
170 shoot_heights.push_back(0.7);
171 shoot_heights.push_back(0.75);
172 shoot_heights.push_back(0.8);
173 shoot_heights.push_back(0.85);
174 shoot_heights.push_back(0.9);
175 shoot_heights.push_back(0.95);
176 shoot_heights.push_back(1);
178 int Nshoots = shoot_heights.size();
180 for (
int i = 0; i < Nshoots; i++) {
186 float tip_angle = 0.5 *
PI_F + 0.2 *
PI_F * float(i) / float(Nshoots - 1);
188 float length = (0.3 + 0.5 * float(i) / float(Nshoots - 1)) * params.
plant_height;
190 tomatoShoot(params, position, base_direction, length, tip_angle, leaf_UUIDs, branch_UUIDs, fruit_UUIDs, context);
193 UUID_leaf.push_back(leaf_UUIDs);
194 UUID_branch.push_back(branch_UUIDs);
195 UUID_fruit.push_back(fruit_UUIDs);
197 return UUID_leaf.size() - 1;