| | 142 | osg::Group* createOverlay(const osg::Vec3& center, float radius) |
| | 143 | { |
| | 144 | osg::Group* group = new osg::Group; |
| | 145 | |
| | 146 | // create a grid of lines. |
| | 147 | { |
| | 148 | osg::Geometry* geom = new osg::Geometry; |
| | 149 | |
| | 150 | unsigned int num_rows = 10; |
| | 151 | |
| | 152 | osg::Vec3 left = center+osg::Vec3(-radius,-radius,0.0f); |
| | 153 | osg::Vec3 right = center+osg::Vec3(radius,-radius,0.0f); |
| | 154 | osg::Vec3 delta_row = osg::Vec3(0.0f,2.0f*radius/float(num_rows-1),0.0f); |
| | 155 | |
| | 156 | osg::Vec3 top = center+osg::Vec3(-radius,radius,0.0f); |
| | 157 | osg::Vec3 bottom = center+osg::Vec3(-radius,-radius,0.0f); |
| | 158 | osg::Vec3 delta_column = osg::Vec3(2.0f*radius/float(num_rows-1),0.0f,0.0f); |
| | 159 | |
| | 160 | osg::Vec3Array* vertices = new osg::Vec3Array; |
| | 161 | for(unsigned int i=0; i<num_rows; ++i) |
| | 162 | { |
| | 163 | vertices->push_back(left); |
| | 164 | vertices->push_back(right); |
| | 165 | left += delta_row; |
| | 166 | right += delta_row; |
| | 167 | |
| | 168 | vertices->push_back(top); |
| | 169 | vertices->push_back(bottom); |
| | 170 | top += delta_column; |
| | 171 | bottom += delta_column; |
| | 172 | } |
| | 173 | |
| | 174 | geom->setVertexArray(vertices); |
| | 175 | geom->addPrimitiveSet(new osg::DrawArrays(GL_LINES,0,vertices->getNumElements())); |
| | 176 | |
| | 177 | osg::Geode* geode = new osg::Geode; |
| | 178 | geode->addDrawable(geom); |
| | 179 | group->addChild(geode); |
| | 180 | } |
| | 181 | |
| | 182 | return group; |
| | 183 | } |