示例#1
0
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;
}
示例#2
0
        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);
            }
        }
示例#3
0
void DrawUpdateCallback::interpolate(double t, const osg::Vec2Array& src, const osg::Vec2Array& dst, osg::Vec2Array& result)
{
    result.resize(4);
    if (t >= 1.0) {
        for (int i = 0; i < 4; i++) {
            result[i] = dst[i];
        }
        return;
    } else if (t <= 0) {
        for (int i = 0; i < 4; i++) {
            result[i] = src[i];
        }
        return;
    }

    double t1 = 1.0 - t;
    for (int i = 0; i < 4; i++) {
        result[i] = src[i]*t1 + dst[i]*t;
    }
}