Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Vector3f GetCameraPos( float scale , float *d = NULL , float * ss = NULL , Vector3f * p = NULL )
- {
- //if( scale < 0.0001f ) return P;
- //if( scale > 0.9999f ) return next -> P;
- double seek_distance = distance * scale;
- double dist = d ? *d : 0.0, old_dist , last_distance;
- double s = 0.05 , last = ss ? *ss : 0.0 , old_last ;
- Vector3f pos = p ? *p : P;
- Vector3f old_p;
- do
- {
- old_dist = dist;
- old_last = last;
- old_p = pos;
- pos = SPline( P , P + T , next->P - next->T , next->P , 1.0 - ( last + s ) );
- last_distance = sqrt( ( pos - old_p ) . length_cubic() );
- if( dist + last_distance > seek_distance )
- {
- s *= 0.2;
- if( s < 0.00005 ) break;
- }
- else
- {
- last += s;
- dist += last_distance;
- }
- }
- while( 1 );
- if( ss ) *ss = old_last;
- if( p ) *p = old_p;
- if( d ) *d = old_dist;
- //s = ( seek_distance - old_dist ) / last_distance;
- //last = old_last + last_distance * s;
- //pos = SPline( P , P + T , next->P - next->T , next->P , clamp( 1.0 - last , 0.0, 1.0 ) );
- return pos;
- }
Add Comment
Please, Sign In to add comment