Guest User

Untitled

a guest
Jul 22nd, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.35 KB | None | 0 0
  1.     Vector3f GetCameraPos( float scale , float *d = NULL , float * ss = NULL , Vector3f * p = NULL )
  2.     {
  3.  
  4.         //if( scale < 0.0001f ) return P;
  5.         //if( scale > 0.9999f ) return next -> P;
  6.  
  7.         double seek_distance = distance * scale;
  8.  
  9.         double dist = d ? *d : 0.0, old_dist , last_distance;
  10.         double s = 0.05 , last = ss ? *ss : 0.0 , old_last ;
  11.  
  12.         Vector3f pos = p ? *p : P;
  13.  
  14.         Vector3f old_p;
  15.  
  16.         do
  17.         {
  18.  
  19.             old_dist = dist;
  20.             old_last = last;
  21.             old_p    = pos;
  22.  
  23.             pos = SPline( P , P + T , next->P - next->T , next->P , 1.0 - ( last + s ) );
  24.  
  25.             last_distance = sqrt( ( pos - old_p ) . length_cubic() );
  26.  
  27.             if( dist + last_distance > seek_distance )
  28.             {
  29.  
  30.                 s *= 0.2;
  31.  
  32.                 if( s < 0.00005 ) break;
  33.  
  34.             }
  35.             else
  36.             {
  37.                 last += s;
  38.                 dist += last_distance;
  39.             }
  40.  
  41.         }
  42.         while( 1 );
  43.  
  44.  
  45.         if( ss ) *ss = old_last;
  46.         if( p ) *p = old_p;
  47.         if( d ) *d = old_dist;
  48.  
  49.  
  50.         //s = ( seek_distance - old_dist ) / last_distance;
  51.         //last = old_last + last_distance * s;
  52.  
  53.         //pos = SPline( P , P + T , next->P - next->T , next->P , clamp( 1.0 - last , 0.0, 1.0 ) );
  54.  
  55.         return pos;
  56.     }
Add Comment
Please, Sign In to add comment