| | 25 | |
| | 26 | void getPolytope(osg::Polytope& polytope, float margin=0.1) const |
| | 27 | { |
| | 28 | float delta = _bb.radius()*margin; |
| | 29 | polytope.add( osg::Plane(0.0, 0.0, 1.0, -(_bb.zMin()-delta)) ); |
| | 30 | polytope.add( osg::Plane(0.0, 0.0, -1.0, (_bb.zMax()+delta)) ); |
| | 31 | |
| | 32 | polytope.add( osg::Plane(1.0, 0.0, 0.0, -(_bb.xMin()-delta)) ); |
| | 33 | polytope.add( osg::Plane(-1.0, 0.0, 0.0, (_bb.xMax()+delta)) ); |
| | 34 | |
| | 35 | polytope.add( osg::Plane(0.0, 1.0, 0.0, -(_bb.yMin()-delta)) ); |
| | 36 | polytope.add( osg::Plane(0.0, -1.0, 0.0, (_bb.yMax()+delta)) ); |
| | 37 | } |
| 142 | | const osg::BoundingBox& bb = cbbv.getBoundingBox(); |
| 143 | | osg::Plane basePlane(0.0, 0.0, 1.0, -bb.zMin() ); |
| 144 | | |
| 145 | | osg::ref_ptr<osg::Geode> geode = new osg::Geode; |
| 146 | | |
| 147 | | osg::ref_ptr<osgShadow::OccluderGeometry> occluder = new osgShadow::OccluderGeometry; |
| 148 | | occluder->computeOccluderGeometry(model.get()); |
| 149 | | occluder->getBoundingPolytope().add(basePlane); |
| | 161 | cbbv.getPolytope(occluder->getBoundingPolytope(),0.001); |
| | 162 | osg::BoundingBox bb = cbbv.getBoundingBox(); |
| | 163 | |
| 154 | | #if 0 |
| 155 | | occluder->comptueShadowVolumeGeometry(osg::Vec4(bb.xMin(), bb.yMin(), bb.zMax() + bb.radius() ,1.0f), *shadowVolume); |
| | 168 | #if 1 |
| | 169 | // occluder->comptueShadowVolumeGeometry(osg::Vec4(bb.xMin()+ bb.radius(), bb.yMin()+ bb.radius(), bb.zMax() + bb.radius() ,1.0f), *shadowVolume); |
| | 170 | occluder->comptueShadowVolumeGeometry(osg::Vec4(bb.center().x(), bb.center().y(), bb.zMax() + bb.radius() ,1.0f), *shadowVolume); |