14 #include <xercesc/parsers/XercesDOMParser.hpp>
18 #include <osg/Geometry>
20 #include <osg/ShapeDrawable>
29 namespace APCameraPath {
31 #define SHOW_VIEW_LINE false
32 #define PATH_POINT_RADIUS 0.5
34 #define SHOW_LINES_WHILE_ANIMATING false
36 #define ANIMATION_TIME 10 //s
37 #define DYNAMIC_SPEED false
38 #define TRANSPARENCY 1.0 //0.0 is invisible, 1.0 is non-transparent
40 #define AUTO_RUN false;
57 virtual bool initialize(XERCES_CPP_NAMESPACE_QUALIFIER
DOMNode *parameters = NULL) {
bool bRet = ControllableAbility::initialize();
Init();
UpdatePath();
return bRet; };
118 void ComputePath(std::vector<ControlPoint> &ControlPoints, osg::Vec3Array* Path, osg::Vec3Array* View);
122 void ComputeSpline(
const std::vector<osg::Vec3> &PointList, osg::Vec3Array* arrayToStorePoints,
123 bool bDynamicSpeed,
const std::vector<double>* LengthsOfParts);
127 std::vector<double>
ArcLength(osg::Vec3Array* PointList,
int PointsOnPart = 100);
138 const osg::Matrix &rotationMatrix, osg::Vec3 &position);
150 void InitAnimation(osg::Vec3Array* path, osg::Vec3Array* view);
167 bool FindPoint(
double dDistance, osg::Vec3Array* PointList, osg::Vec3Array* newControlPoints);
182 bool LoadAnimation(
const char* FileName,std::vector<osg::Vec3> &newPathControlPoints,
183 std::vector<osg::Vec3> &newViewControlPoints);
204 inline float F1(
float t) {
return (2*pow(t,2)-pow(t,3)-t); }
205 inline float F2(
float t) {
return (3*pow(t,3)-(5*pow(t,2))+2); }
206 inline float F3(
float t) {
return (4*pow(t,2)-(3*pow(t,3))+t); }
207 inline float F4(
float t) {
return (pow(t,3)-pow(t,2)); }