|
发表于 2011-12-21 11:33:28
|
显示全部楼层
可以参考一下源码,第二种方式的本质也是生成一个Polytope- PolytopeIntersector::PolytopeIntersector(CoordinateFrame cf, const osg::Polytope& polytope):
- Intersector(cf),
- _parent(0),
- _polytope(polytope),
- _dimensionMask( AllDims )
- {
- if (!_polytope.getPlaneList().empty())
- {
- _referencePlane = _polytope.getPlaneList().back();
- }
- }
- PolytopeIntersector::PolytopeIntersector(CoordinateFrame cf, double xMin, double yMin, double xMax, double yMax):
- Intersector(cf),
- _parent(0),
- _dimensionMask( AllDims )
- {
- double zNear = 0.0;
- switch(cf)
- {
- case WINDOW : zNear = 0.0; break;
- case PROJECTION : zNear = 1.0; break;
- case VIEW : zNear = 0.0; break;
- case MODEL : zNear = 0.0; break;
- }
- _polytope.add(osg::Plane(1.0, 0.0, 0.0, -xMin));
- _polytope.add(osg::Plane(-1.0,0.0 ,0.0, xMax));
- _polytope.add(osg::Plane(0.0, 1.0, 0.0,-yMin));
- _polytope.add(osg::Plane(0.0,-1.0,0.0, yMax));
- _polytope.add(osg::Plane(0.0,0.0,1.0, zNear));
- _referencePlane = _polytope.getPlaneList().back();
- }
复制代码 |
|