| 102 | } |
| 103 | |
| 104 | void instantiate(Ref<SceneGraph::GroupNode>& group) |
| 105 | { |
| 106 | for (size_t i=0; i<N; i++) |
| 107 | { |
| 108 | Vec2f r = Vec2f(random<float>(),random<float>()); |
| 109 | Vec2f p = dist->sample(r); |
| 110 | p.x *= rcp(float(dist->width)); p.y *= rcp(float(dist->height)); |
| 111 | float angle = 2.0f*float(pi)*random<float>(); |
| 112 | const AffineSpace3fa space = heightField->get(p)*AffineSpace3fa::rotate(Vec3fa(0,1,0),angle); |
| 113 | group->add(new SceneGraph::TransformNode(space,object)); |
| 114 | } |
| 115 | } |
| 116 | |
| 117 | private: |
| 118 | Ref<HeightField> heightField; |