Changeset 1587


Ignore:
Timestamp:
10/09/06 16:40:52 (18 years ago)
Author:
mattausch
Message:

fixed bug in TriangleIntersectable::GetRandomSurfacePoint?

Location:
GTP/trunk/Lib/Vis/Preprocessing/src
Files:
4 edited

Legend:

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

    r1586 r1587  
    5959{ 
    6060        // random barycentric coordinates 
    61         const float a = RandomValue(0, 1); 
    62         const float b = RandomValue(0, 1); 
    63         const float c = 1.0 - a - b; 
     61        float a = RandomValue(0,1); 
     62        float b = RandomValue(0,1); 
     63        float c = RandomValue(0,1); 
    6464         
    65         point = mItem.mVertices[0] + a * (mItem.mVertices[1] - mItem.mVertices[0]) + 
    66                         mItem.mVertices[0] + b * (mItem.mVertices[2] - mItem.mVertices[0]) + 
    67                         mItem.mVertices[1] + c * (mItem.mVertices[2] - mItem.mVertices[1]); 
    68          
     65        const float sum = a + b + c; 
     66 
     67        // scale so we get value between zero and one 
     68        if (sum) 
     69        { 
     70                a /= sum; 
     71                b /= sum; 
     72                c /= sum; 
     73        } 
     74 
     75        //cout << "a " << a << "b: " << b << "c: " << c << endl; 
     76        point = mItem.mVertices[0] * a + mItem.mVertices[1] * b + mItem.mVertices[2] * c; 
    6977        normal = mItem.GetNormal(); 
    7078 
     
    7280} 
    7381 
     82 
     83int TriangleIntersectable::GetRandomVisibleSurfacePoint(Vector3 &point, 
     84                                                                                                                Vector3 &normal, 
     85                                                                                                                const Vector3 &viewpoint, 
     86                                                                                                                const int maxTries) 
     87{ 
     88        return GetRandomSurfacePoint(point, normal); 
     89} 
    7490  
    7591} 
  • GTP/trunk/Lib/Vis/Preprocessing/src/IntersectableWrapper.h

    r1586 r1587  
    187187 
    188188        int GetRandomSurfacePoint(Vector3 &point, Vector3 &normal); 
     189 
     190        int GetRandomVisibleSurfacePoint( 
     191                Vector3 &point, 
     192                Vector3 &normal, 
     193                const Vector3 &viewpoint, 
     194                const int maxTries); 
    189195}; 
    190196 
  • GTP/trunk/Lib/Vis/Preprocessing/src/Mesh.cpp

    r1586 r1587  
    810810int TransformedMeshInstance::GetRandomSurfacePoint(Vector3 &point, Vector3 &normal) 
    811811{ 
    812   int index = mMesh->GetRandomSurfacePoint(point, normal); 
    813   point = mWorldTransform*point; 
     812  const int index = mMesh->GetRandomSurfacePoint(point, normal); 
     813  point = mWorldTransform * point; 
    814814  normal = TransformNormal(mWorldTransform, normal); 
    815815  return index; 
  • GTP/trunk/Lib/Vis/Preprocessing/src/SamplingStrategy.cpp

    r1576 r1587  
    6262{        
    6363        Vector3 origin, direction;  
    64     const int i = (int)RandomValue(0, (Real)((int)mPreprocessor.mObjects.size() - 1)); 
     64    const int i = (int)RandomValue(0, (Real)mPreprocessor.mObjects.size() - 0.5f); 
    6565        Intersectable *object = mPreprocessor.mObjects[i]; 
    6666         
Note: See TracChangeset for help on using the changeset viewer.