Ejemplo n.º 1
0
  MotiveBenchmarker() {
    MatrixInit::Register();
    SplineInit::Register();

    // Create compact splines by modifying some basic functions (straight
    // line and sign wave). The straight line, in this case, represents an
    // angle that travels a total of 2pi, so it ends up where it started.
    CreateSpline(kStraightLine, MOTIVE_ARRAY_SIZE(kStraightLine),
                 kLinearOrbitPeriod, kTwoPi, &splines_[kLinearOrbit]);
    CreateSpline(kSinWave, MOTIVE_ARRAY_SIZE(kSinWave),
                 kOscillatingSlowlyPeriod, kOscillatingSlowlyAmplitude,
                 &splines_[kOscillatingSlowly]);
    CreateSpline(kSinWave, MOTIVE_ARRAY_SIZE(kSinWave),
                 kOscillatingQuicklyPeriod, kOscillatingQuicklyAmplitude,
                 &splines_[kOscillatingQuickly]);

    // Create a matrix initializer with a series of basic matrix operations.
    // The final matrix will be created by applying these operations, in turn.
    matrix_ops_.AddOp(motive::kRotateAboutY, kRotateInit,
                      splines_[kLinearOrbit]);
    matrix_ops_.AddOp(motive::kTranslateX, kTranslateInit,
                      splines_[kOscillatingSlowly]);
    matrix_ops_.AddOp(motive::kTranslateY, kTranslateInit,
                      splines_[kOscillatingQuickly]);

    // Initialize the large array of matrix motivators. Note that the
    // one dimensional motivators that drive the matrix motivators are created
    // by the matrix motivators themselves.
    for (size_t i = 0; i < kNumMatrices; ++i) {
      MatrixMotivator4f& m = matrices_[i];
      m.Initialize(MatrixInit(matrix_ops_), &engine_);
    }
  }