Changeset 13041 for OpenSceneGraph/trunk/src/osg/ShadowVolumeOccluder.cpp
 Timestamp:
 03/21/12 18:36:20 (4 years ago)
 Files:

 1 modified
Legend:
 Unmodified
 Added
 Removed

OpenSceneGraph/trunk/src/osg/ShadowVolumeOccluder.cpp
r6248 r13041 1 /* *c++* OpenSceneGraph  Copyright (C) 19982006 Robert Osfield 1 /* *c++* OpenSceneGraph  Copyright (C) 19982006 Robert Osfield 2 2 * 3 * This library is open source and may be redistributed and/or modified under 4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 3 * This library is open source and may be redistributed and/or modified under 4 * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or 5 5 * (at your option) any later version. The full license is in LICENSE file 6 6 * included with this distribution, and on the openscenegraph.org website. 7 * 7 * 8 8 * This library is distributed in the hope that it will be useful, 9 9 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 11 * OpenSceneGraph Public License for more details. 12 12 */ … … 67 67 { 68 68 unsigned int i_1 = (i+1)%in.size(); // do the mod to wrap the index round back to the start. 69 69 70 70 if (distance[i]>=0.0f) 71 71 { 72 72 out.push_back(in[i]); 73 74 73 74 75 75 if (distance[i_1]<0.0f) 76 76 { … … 79 79 out.push_back(Point(mask,in[i].second*r+in[i_1].second*(1.0fr))); 80 80 } 81 81 82 82 } 83 83 else if (distance[i_1]>0.0f) … … 88 88 } 89 89 } 90 90 91 91 return out.size(); 92 92 } … … 98 98 PointList in; 99 99 copyVertexListToPointList(vin,in); 100 100 101 101 unsigned int planeMask = 0x1; 102 102 for(Polytope::PlaneList::const_iterator itr=planeList.begin(); … … 191 191 // take a reference to the projection matrix. 192 192 _projectionMatrix = &P; 193 193 194 194 // initialize the volume 195 195 _volume = 0.0f; 196 196 197 197 198 198 // compute the inverse of the projection matrix. 199 199 Matrix invP; 200 200 invP.invert(P); 201 201 202 202 float volumeview = cullStack.getFrustumVolume(); 203 203 204 204 205 205 // compute the transformation matrix which takes form local coords into clip space. 206 206 Matrix MVP(MV*P); 207 207 208 208 // for the occluder polygon and each of the holes do 209 209 // first transform occluder polygon into clipspace by multiple it by c[i] = v[i]*(MV*P) … … 212 212 // compute orientation of front plane, if normal.z()<0 then facing away from eye pont, so reverse the polygons, or simply invert planes. 213 213 // compute volume (quality) betwen front polygon in projection space and back polygon in projection space. 214 215 214 215 216 216 const VertexList& vertices_in = occluder.getOccluder().getVertexList(); 217 217 218 218 PointList points; 219 219 220 220 if (clip(cullingset.getFrustum().getPlaneList(),vertices_in,points)>=3) 221 221 { … … 226 226 pushToFarPlane(farPoints); 227 227 transform(farPoints,invP); 228 228 229 229 // move the occlude points into projection space. 230 230 transform(points,MV); … … 242 242 243 243 _occluderVolume.setupMask(); 244 244 245 245 // if the front face is pointing away from the eye point flip the whole polytope. 246 246 if (occludePlane[3]>0.0f) … … 248 248 _occluderVolume.flip(); 249 249 } 250 250 251 251 _volume = computePolytopeVolume(points,farPoints)/volumeview; 252 252 253 253 254 254 for(ConvexPlanarOccluder::HoleList::const_iterator hitr=occluder.getHoleList().begin(); 255 255 hitr!=occluder.getHoleList().end(); … … 293 293 _volume = computePolytopeVolume(points,farPoints)/volumeview; 294 294 } 295 295 296 296 } 297 297