vrecko
virtual reality framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
RegularPolygonSpline.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include "Spline.h"
4 #include "Utils.h"
5 #include <osg\BoundsChecking>
6 
7 static const double PI_SQUARED = 6.28318530717958647692;
8 
9 class RegularPolygonSpline : public Spline
10 {
11 public:
12  enum PlaneType
13  {
14  XY,
15  XZ,
17  };
18 
20  RegularPolygonSpline(double radius, unsigned int segmentCount, double rotationShiftInDegress = 0.0, PlaneType plane = XY);
21 
23  META_DAObject(RegularPolygonSpline, "Regular Polygon Spline")
24 
25  virtual Vec3ArrayPtr getPoints();
26  virtual bool isClosed() { return true; }
27 
29  double getRadius() const { return _radius; }
30  inline void setRadius(double val);
31 
32  unsigned int getSegmentCount() const { return _segmentCount; }
33  inline void setSegmentCount(unsigned int val);
34 
37 
38  double getRotationShift() const { return _rotationInDegress; }
39  inline void setRotationShift(double val);
40 
41 protected:
42  unsigned int _segmentCount;
44  double _radius;
47  double _shift;
48 };
49 
50 typedef osg::ref_ptr<RegularPolygonSpline> RegularPolygonSplinePtr;
51 
53 {
54  _radius = osg::clampAbove(val, 0.0);
55  _dirty = true;
56 }
57 
58 void RegularPolygonSpline::setSegmentCount( unsigned int val )
59 {
60  _segmentCount = val;
61  osg::clampGEQUAL<unsigned int>(_segmentCount, 3, "segmentCount");
62  _invSegmentCount = PI_SQUARED / _segmentCount;
63 
64  _dirty = true;
65 }
66 
68 {
69  _plane = val;
70  _dirty = true;
71 }
72 
74 {
75  _rotationInDegress = val;
76  _shift = osg::DegreesToRadians(_rotationInDegress);
77  _dirty = true;
78 }