Motion Path
Motion Path
h"
#include <string>
#include <fstream>
#include <iostream>
MotionPath::MotionPath(std::string filename)
: filename_(filename), reverse_(false) {}
Vect MotionPath::GetPositionForTime(float t)
{
if (reverse_)
{
t = 1.0 - t;
}
Bezier b = beziers_[segment_num];
float bezier_position = (t - static_cast<float>(segment_num) * segment_size) /
segment_size;
return b.FindPoint(bezier_position);
}
void MotionPath::Init()
{
std::cout << "Loading Bezier curves." << std::endl;
std::ifstream infile;
infile.open(filename_);
while (infile >> p0type >> p0x >> p0y >> p0z
>> c0type >> c0x >> c0y >> c0z
>> c1type >> c1x >> c1y >> c1z
>> p1type >> p1x >> p1y >> p1z)
{
if (p0type != 'p' || p1type != 'p' || c0type != 'c' || c1type != 'c')
{
std::cout << "invalid file" << std::endl;
throw 1;
}