vrecko
virtual reality framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
MotionTrail.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "BrushStroke.h"
4 
5 using namespace vrecko;
6 
7 namespace APDYNAMICART
8 {
9 
10 
12 
17 class MotionTrail : public BrushStroke
18 {
19 public:
20 
22  ~MotionTrail();
23 
24 // /// Add control point to this MotionTrail - at last position in vector of control points
25 // /**
26 // *
27 // * \param pos position of new point
28 // * \param list list of control points to witch new point will be added
29 // * \param type of point - sampled, interpolated or temporary
30 // * \param tvalue interpolation value
31 // * \return ref. pointer to new control point
32 // */
33 // ref_ptr_DAControlPoint addControlPoint(osg::Vec3 pos, std::vector<ref_ptr_DAControlPoint>* list, DAControlPointType type, double tvalue = 0.0);
34 //
35 // /// Add control point to this MotionTrail - at last position in vector of control points
36 // ref_ptr_DAControlPoint addControlPoint(DASample *sample, std::vector<ref_ptr_DAControlPoint>* list, DAControlPointType type, double mutliplicator = 1.0);
37 //
38 // /// Add control point - create new object as a copy of the one given
39 // ref_ptr_DAControlPoint addControlPoint(DAControlPoint *point, std::vector<ref_ptr_DAControlPoint>* list);
40 //
41 //
42 // std::string createMenuStructure(void) const;
43 //
44 // /// export the current state of the motion trail to a file
45 // /**
46 // * \todo use osg function to write Node to file
47 // */
48 // void exportToFile(std::string file);
49 //
50 // void importControlPoints( const std::vector<osg::Vec3> *importedSamples, const std::vector<osg::Vec4> *importedColours );
51 //
52 // //gets
53 // inline std::vector<ref_ptr_DAControlPoint>* getControlPoints() { return this->controlPoints; }
54 // inline osg::Vec4 getColour(double value = 0.0) const { return this->brush->getColour(value); }
55 // inline MTBrushParameterType getColouringType() const { return this->brush->getColouringType(); }
56 // inline MTBrushParameterType getCrossSectionType() const { return this->brush->getcrossSectionType(); }
57 // inline double getDiameter(double value = 0.0) const {return this->brush->getDiameter(value); }
58 // inline int getInterpolation() const { return this->brush->getInterpolationSteps(); }
59 // inline std::vector<DASample>* getSamples() const {return this->samples; }
60 // inline double getSmoothness() const { return this->smoothness; }
61 //
62 // int load(XERCES_CPP_NAMESPACE_QUALIFIER DOMNode* MotionTrailNode);
63 //
64 // void menuItemClicked(const char* itemID);
65 //
66 // void menuSliderChanged(const char* sliderID, float sliderPos);
67 //
68 // void pointed(bool pointed);
69 //
70 // void preInicialize();
71 //
72 // /// Create new set of control points from samples based on chosen parameters.
73 // /*
74 // * "the liver of a poodle" of Motion trail.
75 // *
76 // * phase 0 - clear old data
77 // * phase 1 - create control points from "all" samples
78 // * phase 2 - compute rotation frame for each control points
79 // * phase 3 - compute local characteristics of all control points
80 // * phase 4 - smoothing - reduce number of control points
81 // * phase 5 - interpolate - compute additional points between existing point to create smoother triangulation
82 // * phase 6 - (re)compute rotation frames and characteristics of control points
83 // * phase 7 - triangulate
84 // *
85 // */
86 // bool recreateControlPoints(int startingPhase = -1);
87 //
88 //
89 // /// Save PoA as one node to .xml file
90 // void save(XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument* Document, XERCES_CPP_NAMESPACE_QUALIFIER DOMNode* poaNode);
91 //
92 // //sets
93 // void setColor(osg::Vec4 newColour);
94 // void setColourType(int type);
95 // void setColourType(MTBrushParameterType type);
96 //
97 // void setCrossSectionInterpolation(int interpol);
98 // void setCrossSectionType(int type);
99 // void setCrossSectionType(MTBrushParameterType type);
100 // void setCrossSectionShape(int shape);
101 // /*
102 // * Set new diameter value at given interpolation value
103 // *
104 // * \param dia new diameter value
105 // * \param value of interpolation across curve - 0.0 means at curve start, 1.0 means at curve end
106 // */
107 // void setDiameter(double dia, double value = 0.0);
108 //
109 // void setInterpolation(int interpol);
110 // void setSmoothness(double smooth);
111 // void setUpdating(MotionTrailUpdateType p_type);
112 //
113 // /// Create triangle mesh from control points
114 // void triangulate();
115 //
116 // void stopSampling();
117 //
118 // /// Switch between polygon = FILL and wireframe = LINE modes
119 // void switchRenderingMethod();
120 //
121 // void update(void);
122 //
123 // /// Switch on or off showing box-likes visualization of control points of MotionTrail
124 // void visualizeControlPoints(bool show);
125 //
126 //
127 //protected:
128 //
129 // /// All samples tracked during creation of MotionTrail
130 // /**
131 // * used for compute control points, local and global characteristics
132 // */
133 // std::vector<DASample>* samples;
134 //
135 // /// All control points of MotionTrail
136 // std::vector<ref_ptr_DAControlPoint>* controlPoints;
137 //
138 // /// Type of rotation frame
139 // RotationFrameType frame;
140 //
141 // /// Type of update
142 // MotionTrailUpdateType updatingType;
143 //
144 // //computing control points from samples
145 // unsigned int lastAnalyzedSample; ///< index of last already analyzed sampe
146 // unsigned int lastControlPointsWithChars; ///< with computed characteristics
147 // double segmentLength; ///< accumulated length of actual computed segment
148 //
149 // osg::ref_ptr<osg::Group> boxesGroup; ///< mainly for debug - group of all SimpleBoxes of this MotionTrail
150 //
151 // //Global Characteristics
152 // double length; ///< sum of length of all segments
153 //
154 // ///\todo - redefined in Brush (for triangulation)
155 // double minSpeed;
156 // double maxSpeed;
157 // double meanSpeed;
158 //
159 // double minCurvature;
160 // double maxCurvature;
161 // double meanCurvature;
162 //
163 // double minTorsion;
164 // double maxTorsion;
165 // double meanTorsion;
166 //
167 //
168 // osg::ref_ptr<MTBrush> brush;
169 //
170 // double smoothness;
171 // osg::ref_ptr<MotionTrailTriangulator> triangulator;
172 //
173 // bool visibleControlPointsGizmo;
174 //
175 // double awaitingColorChangeValue; ///< value of new color (choosed by Color Chooser)
176 //
177 // //Private functions
178 //
179 // ///computes global and local (at each control point) characteristics of MotionTrail
180 // /**
181 // * for all, or only specified range of control points, given characteristics are recomputed and store into points.
182 // * In different stages of Motion trail life-cycle, different characteristics are necessary or useless
183 // * to speed-up, what characteristics will be computed is specified by parameters.
184 // *
185 // * \param cpoints list of control points
186 // * \param[in] first index of first point to be analyzed
187 // * \param[in] count number points to be analyzed
188 // * \param[in] compute characteristics only from sampled points
189 // * \param[in] lengths - compute also lengths of segments
190 // * \param[in] speeds - compute also speed of movement in control points
191 // * \param[in] priorities - compute also priorities of control points
192 // * \param[in] globalChars - compute also global characteristics of MotionTrail
193 // * TODO CRITICAL - rethink, rewrite whole function - uses phases from recreateControlPoints()
194 // */
195 // void computeFrenetFrame(std::vector<ref_ptr_DAControlPoint>* cpoints, int first, int count, bool onlySampled, bool lengths, bool speeds, bool priorities, bool globalChars);
196 //
197 //
198 // ///Global characteristics computation
199 // /**
200 // * min, max, mean value of speed, curvature and torsion\
201 // */
202 // void computeGlobalCharacteristics();
203 //
204 // /// evaluate priority of each control point
205 // /// based on segment length and curvature and torsion of poit
206 // void computeControlPointsPriorities();
207 //
208 // /// compute speed of all control points
209 // /*
210 // * based on segments lengths
211 // * speed of SAMPLED points is calculated only ONCE and did not change even when some points are deleted or new interpolated points are added.
212 // *
213 // * \param onlySampled - compute speed only at SAMPLED points (there are probably no other points)
214 // */
215 // void computeControlPointsSpeeds(bool onlySampled);
216 //
217 // /// computes Frenet Frame for given control point, store data into given point
218 // void computePointCharacteristics(DAControlPoint *point, DAControlPoint *prevPoint, osg::Vec3 p0, osg::Vec3 p1, osg::Vec3 p2, osg::Vec3 p3);
219 //
220 // /// computes Frenet Frame for given INTERPOLATED control point
221 // void computeInterpolatedPointCharacteristics(DAControlPoint *point, DAControlPoint *spoint0, DAControlPoint *spoint1, DAControlPoint *spoint2, DAControlPoint *spoint3);
222 //
223 //
224 // /// computes Rotation Minimizing Frame for all points
225 // /**
226 // *
227 // * for more details, see paper at:
228 // * http://portal.acm.org/citation.cfm?id=1330513&dl=ACM&coll=DL&CFID=12922836&CFTOKEN=38716133
229 // * especialy, page 7
230 // *
231 // * \param controlPoints set of control points to compute with
232 // */
233 // void computeRMF(std::vector<ref_ptr_DAControlPoint>* controlPoints);
234 //
235 //
236 // /// Compute segment lengths of actual set of control points
237 // /**
238 // * this is necessary for computation of speed and also for better interpolation of control points.
239 // */
240 // void computeSegmentLengths(std::vector<ref_ptr_DAControlPoint>* controlPoints, std::vector<osg::Vec3> *interpolatedPoints, int interpolationSteps);
241 //
242 // /// Remove some control points and thus smooth and simplify spine curve of trail
243 // /*
244 // *
245 // *
246 // */
247 // void optimizeControlPoints(std::vector<ref_ptr_DAControlPoint>** controlPoints, double smoothness);
248 //
249 //
250 // /// Return distance between two samples
251 // inline double sampleDistance(DASample *s1, DASample *s2);
252 
253 };
254 
255 }
256