18 #include <osg/Geometry>
19 #include <osg/Drawable>
20 #include <osg/ShapeDrawable>
23 using namespace vrecko;
25 namespace AP_CableEditor {
27 #define SPHERE_RADIUS 2.0;
29 #define INTERPOLATION_CATMULL_ROM_ITERATE 1 //iterativni vyhlazovani - vzdy se puli interval (algoritmus se provede n-krat)
30 #define INTERPOLATION_CATMULL_ROM_PER_SEGMENT 2 //nastaveni pevneho poctu bodu na segment (mezi 2 kontrolnimi body bude n interpolovanych)
104 void updateSpheresPosition();
107 virtual int processNotification(
BaseClass *sender,
unsigned long notificationType,
108 void *notificationData);
112 void createSpheres();
120 void updateControlPoints();
127 virtual void preInitialize();
128 virtual void postInitialize();
133 void setShape( osg::ref_ptr<osg::Vec3Array> points ){ shapePoints = points; }
134 osg::ref_ptr<osg::Vec3Array>
getShape(){
return shapePoints; }
137 void getInterpolation(
unsigned int *
type,
unsigned int *num) { *type = this->interpolationType; *num = this->interpolationsNum; }
139 void setRadius(
float radius){ this->cableRadius = radius; }
147 void updateControlSpheresRadius();
174 void addControlPoint(
unsigned int position, osg::Vec3f point);
177 void addControlPointBetweenLine(osg::Vec3f position);
180 osg::Vec3f getInterpolatedPoint(osg::Vec3 p0, osg::Vec3 p1, osg::Vec3 p2, osg::Vec3 p3,
double t = 0.5)
const;
185 return createSphere(center, this->cableColor, radius);
188 EnvironmentObject *createSphere(osg::Vec3f center, osg::Vec4f color,
float radius = 0.25);
198 osg::ref_ptr<osg::Vec3Array> interpolateCatPerSegment(osg::ref_ptr<osg::Vec3Array> inputPoints,
unsigned int pointsPerSegment)
const;
204 osg::ref_ptr<osg::Vec3Array> interpolateCatIterate(osg::ref_ptr<osg::Vec3Array> inputPoints,
unsigned int numIterations)
const;
211 void setUpdate(
bool state);
217 virtual void update();
222 int computeRMF(osg::Vec3Array *points, osg::Vec3Array *tangents, osg::Vec3Array *normals, osg::Vec3Array *binormals);
228 osg::Vec3Array *transformVectors(osg::Vec3Array *vectors, osg::Vec3f point, osg::Vec3f tangent, osg::Vec3f normal, osg::Vec3f binormal,
float scale = 1);
238 osg::ref_ptr<osg::Geode> wrap(osg::Vec3Array *shapeVectors, osg::Vec3Array *points, osg::Vec3Array *tangents, osg::Vec3Array *normals, osg::Vec3Array *binormals,
239 float scale = 1,
unsigned int wrapFrom = 1,
unsigned int wrapNum = 0);
243 void visualizeVectors(osg::Vec3Array *points, osg::Vec3Array *tangents, osg::Vec3Array *normals, osg::Vec3Array *binormals);