Game Development Reference
In-Depth Information
3.
The GetPosition() method inds a segment for the given parameter t and
calculates a linearly interpolated coordinate of a point on the curve:
vec3 GetPosition( float t ) const
{
if ( t <= T[0] ) { return P[0]; }
int N = (int)T.size();
int i = N - 1;
for ( int s = 0 ; s < N - 1 ; s++ )
{
if ( t > T[s] && t <= T[s + 1] )
{
i = s;
break;
}
}
if ( i >= N - 1 ) { return P[N - 1]; }
vec3 k = ( P[i + 1] - P[i] ) / ( T[i + 1] - T[i] );
return k * ( t - T[i] ) + P[i];
}
4.
The control points and corresponding arguments are stored in two vectors:
std::vector<float> T;
std::vector<vec3> P;
};
5.
A 3D image selector control logic is implemented in the clFlowUI class:
class clFlowUI: public iObject
{
public:
clFlowUI( clPtr<clFlowFlinger> Flinger, int NumQuads )
{
FFlinger = Flinger;
6.
Create a 3D camera for our UI:
mtx4 RotationMatrix;
RotationMatrix.FromPitchPanRoll( 0.0f, -90.0f, 0.0f );
FView = mtx4::GetTranslateMatrix(
-vec3( 0.0f, -13.2f, 1.2f ) ) * RotationMatrix;
7.
A standard perspective camera is used:
FProjection = Math::Perspective(
45.0f, 1.33333f, 0.4f, 2000.0f );
float Y[] = { c_Height, c_Height, 0, 0 };
float Offs[] = { -c_PeakOffset, c_PeakOffset,
 
Search WWH ::




Custom Search