void edTerrainNode::fixupTexCoords(osg::Vec2Array &coords) { if (coords.size()<1) return; osg::Vec2 min(coords[0]); osg::Vec2 max(coords[0]); for (unsigned int i=1; i<coords.size(); i++) { if (coords[i].x()>max.x()) max.x()= coords[i].x(); if (coords[i].x()<min.x()) min.x()= coords[i].x(); if (coords[i].y()>max.y()) max.y()= coords[i].y(); if (coords[i].y()<min.y()) min.y()= coords[i].y(); } osg::Vec2 delta( floor((min.x()+max.x())*0.5+0.5),floor((min.y()+max.y())*0.5+0.5) ) ; for (unsigned int i=0; i<coords.size(); i++) coords[i]-= delta; }
virtual void apply(osg::Vec2Array& array) { if (_pointList.size()!=array.size()) return; for(unsigned int i=0;i<_pointList.size();++i) { _pointList[i] = new EdgeCollector::Point; _pointList[i]->_index = i; osgUtil::ConvertVec<osg::Vec2, osg::Vec3d>::convert(array[i], _pointList[i]->_vertex); } }