Changeset 2740 for GTP/trunk/Lib/Vis/Preprocessing
- Timestamp:
- 06/05/08 18:48:10 (17 years ago)
- Location:
- GTP/trunk/Lib/Vis/Preprocessing
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/Preprocessing/scripts/run_gvs_vps.sh
r2738 r2740 19 19 #SCENE=../data/vienna/vienna_rep.obj 20 20 21 #SCENE=../data/vienna/vienna_cropped.obj21 SCENE=../data/vienna/vienna_cropped.obj 22 22 VIEWCELLS=../data/vienna/vienna_cropped-gradient-viewcells.xml.gz 23 23 VIEWPOINTS=../data/vienna/testwalk.vp … … 42 42 -gvs_samples_per_pass=1000000 \ 43 43 -gvs_initial_samples=16 \ 44 -gvs_max_viewcells= 3\44 -gvs_max_viewcells=1 \ 45 45 -gvs_min_contribution=200 \ 46 46 -gvs_per_viewcell=true \ -
GTP/trunk/Lib/Vis/Preprocessing/src/AxisAlignedBox3.cpp
r2723 r2740 9 9 #include "VssRay.h" 10 10 #include "IntersectableWrapper.h" 11 12 11 #include "SimpleRay.h" 13 12 #include <cassert> 14 13 15 14 15 16 16 using namespace std; 17 17 18 namespace GtpVisibilityPreprocessor { 18 19 namespace GtpVisibilityPreprocessor 20 { 19 21 20 22 #define FATAL Debug … … 2632 2634 } 2633 2635 2634 } 2635 2636 2637 Rectangle3 AxisAlignedBox3::GetNearestFace(const Vector3 &pt) const 2638 { 2639 float minDist = 1e20f; 2640 int face = 0; 2641 2642 if ((pt.x - mMin.x) < minDist) {minDist = (pt.x - mMin.x); face = 0;} 2643 if ((mMax.x - pt.x) < minDist) {minDist = (mMax.x - pt.x); face = 1;} 2644 if ((pt.y - mMin.y) < minDist) {minDist = (pt.y - mMin.y); face = 2;} 2645 if ((mMax.y - pt.y) < minDist) {minDist = (mMax.y - pt.y); face = 3;} 2646 if ((pt.z - mMin.z) < minDist) {minDist = (pt.z - mMin.z); face = 4;} 2647 if ((mMax.z - pt.z) < minDist) {minDist = (mMax.z - pt.z); face = 5;} 2648 2649 return GetFace(face); 2650 } 2651 2652 2653 bool AxisAlignedBox3::Intersects(const SimpleRay &ray, float &tnear, float &tfar) const 2654 { 2655 tnear = -1e20f; 2656 tfar = 1e20f; 2657 2658 const Vector3 origin = ray.mOrigin; 2659 const Vector3 dir = ray.mDirection; 2660 2661 float t1, t2; 2662 2663 // ray is parallel to the planes 2664 if (dir.x == 0) 2665 { 2666 if ((origin.x < mMin.x) || (origin.x > mMax.x)) 2667 return false; // origin not between planes 2668 } 2669 else 2670 { 2671 // time at which ray intersects minimum X plane 2672 t1 = (mMin.x - origin.x) / dir.x; 2673 // time at which ray intersects maximum X plane 2674 t2 = (mMax.x - origin.x) / dir.x; 2675 2676 if (t1 > t2) 2677 swap(t1, t2); 2678 2679 if (t1 > tnear) 2680 tnear = t1; 2681 2682 if (t2 < tfar) 2683 tfar = t2; 2684 2685 if (tnear > tfar) 2686 return false; 2687 2688 if (tfar < 0) 2689 return false; 2690 } 2691 2692 if (dir.y == 0) // ray is parallel to the planes 2693 { 2694 if ((origin.y < mMin.y) || (origin.y > mMax.y)) 2695 return false; // origin not between planes) 2696 } 2697 else 2698 { 2699 t1 = (mMin.y - origin.y) / dir.y; 2700 t2 = (mMax.y - origin.y) / dir.y; 2701 2702 if (t1 > t2) 2703 swap(t1, t2); 2704 2705 if (t1 > tnear) 2706 tnear = t1; 2707 2708 if (t2 < tfar) 2709 tfar = t2; 2710 2711 if (tnear > tfar) 2712 return false; 2713 2714 if (tfar < 0) 2715 return false; 2716 } 2717 2718 if (dir.z == 0) // ray is parallel to the planes 2719 { 2720 if ((origin.z < mMin.z) || (origin.z > mMax.z)) 2721 return false; // origin not between planes) 2722 } 2723 else 2724 { 2725 t1 = (mMin.z - origin.z) / dir.z; 2726 t2 = (mMax.z - origin.z) / dir.z; 2727 2728 if (t1 > t2) 2729 swap(t1, t2); 2730 2731 if (t1 > tnear) 2732 tnear = t1; 2733 2734 if (t2 < tfar) 2735 tfar = t2; 2736 2737 if (tnear > tfar) 2738 return false; 2739 2740 if (tfar < 0) 2741 return false; 2742 } 2743 2744 return true; 2745 } 2746 2747 } 2748 -
GTP/trunk/Lib/Vis/Preprocessing/src/AxisAlignedBox3.h
r2720 r2740 392 392 AxisAlignedBox3 &right) const; 393 393 394 bool Intersects(const SimpleRay &ray, float &tnear, float &tfar) const; 395 396 Rectangle3 GetNearestFace(const Vector3 &pt) const; 397 394 398 #define __EXTENT_HACK 395 399 // get the extent of face -
GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp
r2739 r2740 677 677 // handle cast rays 678 678 EnqueueRays(vssRays); 679 679 680 681 #if 0 680 682 for (size_t i = 0; i < vssRays.size(); ++ i) 681 683 { … … 684 686 } 685 687 686 #if 0 687 688 688 689 // recursivly subdivide each edge 689 690 for (int i = 0; i < numBorderSamples; ++ i) … … 791 792 if (mPerViewCell) 792 793 { 793 if (!Intersect ViewCell(newOrigin,newDir))794 if (!IntersectsViewCell(newOrigin, -newDir)) 794 795 return false; 795 796 } … … 801 802 802 803 803 bool GvsPreprocessor::IntersectViewCell(Vector3 &origin, Vector3 &dir) const 804 { 805 // send ray to view cell 806 static Ray testRay; 807 808 testRay.Clear(); 809 testRay.Init(origin, -dir, Ray::LOCAL_RAY); 810 804 bool GvsPreprocessor::IntersectsViewCell(Vector3 &origin, const Vector3 &dir) const 805 { 806 AxisAlignedBox3 box = mCurrentViewCell->GetBox(); 807 808 if (box.IsInside(origin)) 809 { 810 //cout<<"z"; 811 return true; 812 } 813 814 // intersect ray with view cell and 815 SimpleRay ray(origin, dir, 0, 1.0f); 816 817 float tnear, tfar; 818 811 819 // check if ray intersects view cell 812 if (!mCurrentViewCell-> CastRay(testRay))820 if (!mCurrentViewCell->GetBox().Intersects(ray, tnear, tfar)) 813 821 return false; 814 822 815 Ray::Intersection &hit = testRay.intersections[0]; 816 817 // the ray starts from the view cell 818 origin = testRay.Extrap(hit.mT); 819 823 origin = origin + dir * tnear; 824 //cout<<"r"; 820 825 return true; 821 826 } … … 2043 2048 size_t currentNumber = rays.size(); 2044 2049 2045 while ((rays.size() - currentNumber) < number) 2050 int tries = 0; 2051 2052 while (((rays.size() - currentNumber) < number) && (tries ++ < 20)) 2046 2053 { 2047 2054 SimpleRay ray; … … 2049 2056 rays.push_back(ray); 2050 2057 } 2058 2059 //cout << "generated " << rays.size() << " rays" << endl; 2051 2060 } 2052 2061 … … 2057 2066 SimpleRay &ray) 2058 2067 { 2059 Vector3 nd = triangle.GetNormal(); 2060 2068 //Vector3 nd = triangle.GetNormal(); 2069 const AxisAlignedBox3 box = mCurrentViewCell->GetBox(); 2070 Vector3 nd = box.GetNearestFace(origin).GetNormal(); 2071 //cout << "pt: " << origin << " face: " << box.GetNearestFace(origin) << endl; 2072 nd.Normalize(); 2073 2061 2074 // Compute right handed coordinate system from direction 2062 2075 Vector3 U, V; … … 2077 2090 const Vector3 shift = gaussvec2.xx * U + gaussvec2.yy * V; 2078 2091 2079 Vector3 newOrigin = origin; 2080 2081 //cout << "t: " << termination; 2082 newOrigin += shift; 2083 //cout << " new t: " << termination << endl; 2092 Vector3 newOrigin = origin + shift; 2093 //cout << "o: " << origin << " new o: " << newOrigin << endl; 2094 2084 2095 Vector3 direction = termination - newOrigin; 2085 2096 … … 2091 2102 direction /= len; 2092 2103 2093 if (!IntersectViewCell(newOrigin, direction)) 2104 if (!IntersectsViewCell(newOrigin, -direction)) 2105 { 2106 //cout << "x"; 2094 2107 return false; 2095 2108 } 2109 2110 //cout << "y"; 2096 2111 // $$ jb the pdf is yet not correct for all sampling methods! 2097 2112 const float pdf = 1.0f; -
GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.h
r2739 r2740 83 83 ObjectContainer mKdPvs; 84 84 85 float RaysPerSec() const { if (!mTotalTime) return 0; return (float)(mTotalSamples / mTotalTime) * 1e-6f; } 85 float RaysPerSec() const 86 { 87 if (!mTotalTime) return 0; 88 return (float)(mTotalSamples / mTotalTime) * 1e-6f; 89 } 86 90 87 91 void Print(ostream &app) const; … … 304 308 SimpleRay &ray); 305 309 306 inline bool Intersect ViewCell(Vector3 &origin,Vector3 &dir) const;310 inline bool IntersectsViewCell(Vector3 &origin, const Vector3 &dir) const; 307 311 308 312
Note: See TracChangeset
for help on using the changeset viewer.