+ if(!cow_rend->create()) {
+ fprintf(stderr, "Failed to create renderer for cows.\n");
+ return false;
+ }
+
+ /* create cow objects */
+ Object *cow0 = cow_scene->objects[0];
+ cow0->transform.rotation_y(M_PI);
+ cow_scene->objects.clear();
+
+ float disk_radius = std::min(p.xsz, p.ysz) / 2.0 * 0.65;
+ std::vector<Vec2> cow_pos;
+
+ for(int i=0; i<num_cows; i++) {
+ Object *cow = new Object;
+ *cow = *cow0;
+
+ if(!gen_poisson(cow_pos, cow_gap, disk_radius))
+ goto cowgen_end;
+ Vec2 pos = cow_pos.back();
+ float y = terrain.get_height(Vec3(pos.x, 1, pos.y));
+
+ cow->transform.translate(pos.x, y, pos.y);
+ cow_scene->objects.push_back(cow);
+ }
+
+cowgen_end:
+ printf("generated: %d cows from %d\n", (int)cow_pos.size(), num_cows);
+ delete cow0;