- Timestamp:
- 09/10/08 08:29:37 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling/src
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ShadowMapping.cpp
r2924 r2925 209 209 /////////////// 210 210 //-- We apply the lispsm algorithm in order to calculate an optimal light projection matrix 211 212 213 ////////214 211 //-- first find the free parameter values n, and P (the projection center), and the projection depth 215 212 216 const float n = 1e6;//ComputeN(bounds_ls); 213 //const float n = 1e6f; 214 const float n = ComputeN(bounds_ls); 217 215 218 216 cout << "n: " << n << endl; … … 230 228 231 229 // the new projection center 232 Vector3 projCenter = startPt + Vector3::UNIT_Z() * n ;230 Vector3 projCenter = startPt + Vector3::UNIT_Z() * n * 1000; 233 231 234 232 cout <<"start: " << startPt << " " << projCenter << " " << Distance(lightSpace * mCamera->GetPosition(), startPt) << endl; … … 268 266 } 269 267 270 268 #if 0 271 269 Vector3 ShadowMap::GetNearCameraPointE(const VertexArray &pts) const 272 270 { 271 float maxDist = -1e25f; 272 Vector3 nearest = Vector3::ZERO(); 273 274 Matrix4x4 eyeView; 275 mCamera->GetModelViewMatrix(eyeView); 276 277 VertexArray newPts; 278 polyhedron->CollectVertices(newPts); 279 280 //the LVS volume is always in front of the camera 281 VertexArray::const_iterator it, it_end = pts.end(); 282 283 for (it = pts.begin(); it != it_end; ++ it) 284 { 285 Vector3 pt = *it; 286 Vector3 ptE = eyeView * pt; 287 //cout<<"i"<< pt.z; 288 if (ptE.z > 0) cerr <<"should not happen " << ptE.z << endl; 289 else 290 if (ptE.z > maxDist) 291 { 292 cout << " d " << ptE.z; 293 294 maxDist = ptE.z; 295 nearest = pt; 296 } 297 } 298 299 // Invert(eyeView); return eyeView * nearest; 300 return nearest; 301 } 302 303 #else 304 305 Vector3 ShadowMap::GetNearCameraPointE(const VertexArray &pts) const 306 { 307 VertexArray newPts; 308 polyhedron->CollectVertices(newPts); 309 273 310 Vector3 nearest = Vector3::ZERO(); 274 311 float minDist = 1e25f; … … 276 313 const Vector3 camPos = mCamera->GetPosition(); 277 314 278 /*Matrix4x4 inverseCamView; 279 mCamera->GetModelViewMatrix(invervseCamView); 280 inverseCamView.Invert();*/ 281 282 VertexArray::const_iterator it, it_end = pts.end(); 283 284 for (it = pts.begin(); it != it_end; ++ it) 315 VertexArray::const_iterator it, it_end = newPts.end(); 316 317 for (it = newPts.begin(); it != it_end; ++ it) 285 318 { 286 319 Vector3 pt = *it; … … 298 331 } 299 332 333 #endif 300 334 301 335 Vector3 ShadowMap::GetProjViewDir(const Matrix4x4 &lightSpace, const VertexArray &pts) const … … 376 410 //calculate a frame matrix that uses the projViewDir[lightspace] as up vector 377 411 //look(from position, into the direction of the projected direction, with unchanged up-vector) 378 Matrix4x4 frame = LookAt(Vector3::ZERO(), projViewDir, Vector3::UNIT_Y());412 const Matrix4x4 frame = LookAt(Vector3::ZERO(), projViewDir, Vector3::UNIT_Y()); 379 413 380 414 cout << "frame\n " << frame << endl; … … 386 420 CalcLispSMTransform(lightView * lightProj, extremalPoints, frustumPoints); 387 421 388 Vector3 mydummy = Vector3::UNIT_Z(); 389 390 cout << "yoyo: " << Normalize(lightView * lightProj * mydummy) << endl; 422 Vector3 mydummy = projViewDir;//Vector3::UNIT_Z(); 423 //cout << "transformed unit z vector: " << Normalize(lightView * lightProj * mydummy) << endl; 424 cout << "transformed unit z vector: " << Normalize(frame * mydummy) << endl; 425 391 426 lightProj = lightProj * matLispSM; 392 427 … … 537 572 ////////////// 538 573 //-- compute texture matrix 574 539 575 static Matrix4x4 biasMatrix(0.5f, 0.0f, 0.0f, 0.5f, 540 576 0.0f, 0.5f, 0.0f, 0.5f, -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
r2914 r2925 70 70 int renderMode = RenderTraverser::CHCPLUSPLUS; 71 71 // eye near plane distance 72 float nearDist = 0.2f;72 float nearDist = 2.0f; 73 73 /// the field of view 74 74 float fov = 50.0f;
Note: See TracChangeset
for help on using the changeset viewer.