Changeset 1981


Ignore:
Timestamp:
01/15/07 16:28:59 (17 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/Lib/Vis/Preprocessing/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/Lib/Vis/Preprocessing/src/AxisAlignedBox3.cpp

    r1951 r1981  
    23532353} 
    23542354 
    2355  
    2356 } 
    2357  
     2355/* 
     2356int inline GetIntersection(const float fDst1,  
     2357                                                   const float fDst2,  
     2358                                                   const Vector3 p1,  
     2359                                                   const Vector3 p2,  
     2360                                                   const Vector3 &hit)  
     2361{ 
     2362        if ((fDst1 * fDst2) >= 0.0f)  
     2363                return 0; 
     2364     
     2365        if (fDst1 == fDst2)  
     2366                return 0;  
     2367     
     2368        hit = p1 + (p2 - p1) * (-fDst1 / (fDst2 - fDst1)); 
     2369         
     2370        return 1; 
     2371} 
     2372 
     2373 
     2374int inline InBox( CVec3 Hit, CVec3 B1, CVec3 B2, const int Axis) { 
     2375if ( Axis==1 && Hit.z > B1.z && Hit.z < B2.z && Hit.y > B1.y && Hit.y < B2.y) return 1; 
     2376if ( Axis==2 && Hit.z > B1.z && Hit.z < B2.z && Hit.x > B1.x && Hit.x < B2.x) return 1; 
     2377if ( Axis==3 && Hit.x > B1.x && Hit.x < B2.x && Hit.y > B1.y && Hit.y < B2.y) return 1; 
     2378return 0; 
     2379} 
     2380 
     2381// returns true if line (L1, L2) intersects with the box (B1, B2) 
     2382// returns intersection point in Hit 
     2383int CheckLineBox( CVec3 B1, CVec3 B2, CVec3 L1, CVec3 L2, CVec3 &Hit) 
     2384{ 
     2385if (L2.x < B1.x && L1.x < B1.x) return false; 
     2386if (L2.x > B2.x && L1.x > B2.x) return false; 
     2387if (L2.y < B1.y && L1.y < B1.y) return false; 
     2388if (L2.y > B2.y && L1.y > B2.y) return false; 
     2389if (L2.z < B1.z && L1.z < B1.z) return false; 
     2390if (L2.z > B2.z && L1.z > B2.z) return false; 
     2391if (L1.x > B1.x && L1.x < B2.x && 
     2392    L1.y > B1.y && L1.y < B2.y && 
     2393    L1.z > B1.z && L1.z < B2.z)  
     2394    {Hit = L1;  
     2395    return true;} 
     2396if ( (GetIntersection( L1.x-B1.x, L2.x-B1.x, L1, L2, Hit) && InBox( Hit, B1, B2, 1 )) 
     2397  || (GetIntersection( L1.y-B1.y, L2.y-B1.y, L1, L2, Hit) && InBox( Hit, B1, B2, 2 ))  
     2398  || (GetIntersection( L1.z-B1.z, L2.z-B1.z, L1, L2, Hit) && InBox( Hit, B1, B2, 3 ))  
     2399  || (GetIntersection( L1.x-B2.x, L2.x-B2.x, L1, L2, Hit) && InBox( Hit, B1, B2, 1 ))  
     2400  || (GetIntersection( L1.y-B2.y, L2.y-B2.y, L1, L2, Hit) && InBox( Hit, B1, B2, 2 ))  
     2401  || (GetIntersection( L1.z-B2.z, L2.z-B2.z, L1, L2, Hit) && InBox( Hit, B1, B2, 3 ))) 
     2402        return true; 
     2403 
     2404return false; 
     2405} 
     2406*/ 
     2407 
     2408} 
     2409 
  • GTP/trunk/Lib/Vis/Preprocessing/src/GvsPreprocessor.cpp

    r1977 r1981  
    445445        const float offset = 0.5f; 
    446446        const Vector3 newOrigin = newPoint - newDir * offset; 
     447 
     448        static Ray ray(newOrigin, newDir, Ray::LOCAL_RAY); 
     449        ray.Precompute(); 
     450 
     451        // check if ray intersects view cell 
     452        if (mPerViewCell && !mCurrentViewCell->CastRay(ray)) 
     453                return NULL; 
    447454 
    448455        const SimpleRay simpleRay(newOrigin, newDir, SamplingStrategy::GVS, 1.0f); 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Mesh.cpp

    r1867 r1981  
    220220                faceIndex++) { 
    221221    hits += CastRayToFace(faceIndex, 
    222                                                                                                         ray, 
    223                                                                                                         nearestT, 
    224                                                                                                         nearestNormal, 
    225                                                                                                         nearestFace, 
    226                                                                                                         instance); 
     222                                                  ray, 
     223                                                  nearestT, 
     224                                                  nearestNormal, 
     225                                                  nearestFace, 
     226                                                  instance); 
    227227    if (mIsConvex && nearestFace != -1) 
    228228      break; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.cpp

    r1977 r1981  
    22922292                return 0.0f; 
    22932293 
    2294         static Ray hray; 
    2295         hray.Init(ray); 
    2296  
    2297         float tmin = 0, tmax = 1.0; 
    2298  
    2299         if (!GetViewSpaceBox().GetRaySegment(hray, tmin, tmax) || (tmin > tmax)) 
    2300         { 
    2301                 // cerr<<"ray outside view space box\n"; 
    2302                 return 0; 
    2303         } 
    2304  
    2305         Vector3 origin = hray.Extrap(tmin); 
    2306         Vector3 termination = hray.Extrap(tmax); 
    2307  
    2308         // traverse the view space subdivision 
    2309         if (!LineSegmentIntersects(origin,  
    2310                                                            termination,  
    2311                                                            currentViewCell)) 
    2312         { 
    2313                 return 0; 
    2314         } 
    2315          
    23162294        // optain pvs entry (can be different from hit object) 
    23172295        Intersectable *terminationObj = GetIntersectable(ray, true); 
     
    23262304        float c = 0.0f; 
    23272305        if (terminationObj)  
    2328           c = ray.Length(); 
     2306                c = ray.Length(); 
     2307 
    23292308        ray.mRelativePvsContribution = ray.mPvsContribution = c; 
    23302309        return c; 
     
    59425921                mColorCode = 0; // 0 = random, 1 = export pvs 
    59435922 
     5923                if (0) 
    59445924                mHierarchyManager->ExportObjectSpaceHierarchy(exporter, objects,  
    59455925                                                                                                          CLAMP_TO_BOX ? &bbox : NULL, maxRenderCost, false); 
     
    59795959                const float maxRenderCost = -1; 
    59805960 
     5961                if (0) 
    59815962                mHierarchyManager->ExportObjectSpaceHierarchy(exporter, objects,  
    59825963                                                                                                          CLAMP_TO_BOX ? &bbox : NULL, maxRenderCost, false); 
     
    59925973        } 
    59935974 
    5994 #if 0 
    5995         // export final object partition 
    5996         exporter = Exporter::GetExporter("final_object_partition.wrl"); 
    5997  
    5998         if (exporter) 
    5999         { 
    6000                 if (CLAMP_TO_BOX) 
    6001                 {        
    6002                         exporter->mClampToBox = true;    
    6003                 } 
    6004  
    6005                 const long starttime = GetTime(); 
    6006  
    6007                 // matt: hack for making visualization smaller in size 
    6008                 AxisAlignedBox3 bbox = mHierarchyManager->GetObjectSpaceBox(); 
    6009                 bbox.Scale(scale); 
    6010  
    6011                 cout << "exporting object space hierarchy ... "; 
    6012                 mHierarchyManager->ExportObjectSpaceHierarchy(exporter, objects, CLAMP_TO_BOX ? &bbox : NULL, -1); 
    6013  
    6014                 delete exporter; 
    6015                 cout << "finished in " << TimeDiff(starttime, GetTime()) * 1e-3f << " secs" << endl; 
    6016         } 
    6017 #endif 
    6018  
    6019         // visualization of the view cells 
     5975        // visualization of the merged view cells 
    60205976    if (0)  
    60215977        {        
  • GTP/trunk/Lib/Vis/Preprocessing/src/ViewCellsManager.h

    r1977 r1981  
    141141                                                                         const bool storeViewCells); 
    142142 
    143         /** Add sample contributions to the viewcells they intersect  
    144         */ 
    145         //void AddSampleContributions(const VssRayContainer &rays); 
    146    
    147  
    148143        /** Computes sample contribution of a simgle ray to the view cells PVS. 
    149144                @param ray finds intersections with view cells and holds the contribution 
     
    153148        */ 
    154149        virtual float ComputeSampleContribution(VssRay &ray,  
    155                                                                                         const bool addRays, 
     150                                                                                        const bool addContributions, 
    156151                                                                                        const bool storeViewCells); 
    157152 
     
    159154        */ 
    160155        virtual float ComputeSampleContribution(VssRay &ray,  
    161                                                                                         const bool addRays, 
     156                                                                                        const bool addContributions, 
    162157                                                                                        ViewCell *currentViewCell); 
    163158 
Note: See TracChangeset for help on using the changeset viewer.