Ignore:
Timestamp:
01/18/07 20:20:48 (17 years ago)
Author:
mattausch
Message:
 
File:
1 edited

Legend:

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

    r1994 r1996  
    2020HaltonSequence HwGlobalLinesDistribution::sHalton; 
    2121 
     22HaltonSequence ViewCellBasedDistribution::sHalton; 
    2223 
    2324SamplingStrategy::SamplingStrategy(Preprocessor &preprocessor):  
     
    651652                                  } else 
    652653                                        if (strcmp(curr, "mutation")==0) { 
    653                                           mDistributions.push_back(new MutationBasedDistribution(mPreprocessor)); 
     654                                                // temp matt: still no mutationstrategy! 
     655                                          //mDistributions.push_back(new MutationBasedDistribution(mPreprocessor)); 
    654656                                        }  
    655657         
     
    738740 
    739741 
    740 } 
    741  
    742  
     742bool ViewCellBasedDistribution::GenerateSample(SimpleRay &ray) 
     743{ 
     744        Vector3 origin, direction;  
     745 
     746        ViewCellContainer &viewCells =  
     747                mPreprocessor.mViewCellsManager->GetViewCells(); 
     748 
     749        Vector3 point; 
     750        Vector3 normal, normal2; 
     751         
     752        float r[1]; 
     753        sHalton.GetNext(1, r); 
     754 
     755        const int objIdx = (int)(r[0] * (float)mPreprocessor.mObjects.size() - 1.0f); 
     756                                //      = (int)RandomValue(0, (float)mPreprocessor.mObjects.size() - 0.5f); 
     757        Intersectable *object = mPreprocessor.mObjects[objIdx]; 
     758 
     759        //cout << "obj: " << objIdx << endl; 
     760 
     761        object->GetRandomSurfacePoint(point, normal); 
     762        mViewCell->GetRandomSurfacePoint(origin, normal2); 
     763 
     764        direction = point - origin; 
     765 
     766        // move a little bit back to avoid piercing through walls 
     767        // that bound the view cell 
     768        origin -= 0.01f * normal2; 
     769 
     770        // $$ jb the pdf is yet not correct for all sampling methods! 
     771        const float c = Magnitude(direction); 
     772 
     773        if ((c <= Limits::Small) /*|| (DotProd(direction, normal) < 0)*/) 
     774        { 
     775                return false; 
     776        } 
     777 
     778        // $$ jb the pdf is yet not correct for all sampling methods! 
     779        const float pdf = 1.0f; 
     780 
     781        direction *= 1.0f / c; 
     782        ray = SimpleRay(origin, direction, VIEWCELL_BASED_DISTRIBUTION, pdf); 
     783 
     784        //cout << "ray: " << ray.mOrigin << " " << ray.mDirection << endl; 
     785 
     786        return true; 
     787} 
     788 
     789 
     790} 
     791 
     792 
Note: See TracChangeset for help on using the changeset viewer.