OpenFrames
Vector.hpp
Go to the documentation of this file.
1 /***********************************
2  Copyright 2018 Ravishankar Mathur
3 
4  Licensed under the Apache License, Version 2.0 (the "License");
5  you may not use this file except in compliance with the License.
6  You may obtain a copy of the License at
7 
8  http://www.apache.org/licenses/LICENSE-2.0
9 
10  Unless required by applicable law or agreed to in writing, software
11  distributed under the License is distributed on an "AS IS" BASIS,
12  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  See the License for the specific language governing permissions and
14  limitations under the License.
15 ***********************************/
16 
21 #ifndef _OF_VECTOR_
22 #define _OF_VECTOR_
23 
24 #include <OpenFrames/Export.h>
25 
26 #include <osg/ShapeDrawable>
27 #include <osg/Referenced>
28 #include <osg/ref_ptr>
29 
30 namespace OpenFrames
31 {
42  class OF_EXPORT Vector : public osg::Referenced
43  {
44  public:
45  Vector( const osg::Vec3d& vec );
46 
48  void setLength( const double &body, const double &head );
49  void getLength( double &body, double &head) const;
50  double getTotalLength() const;
51 
53  void setRadius( const double &body, const double &head );
54  void getRadius( double &body, double &head) const;
55 
57  void setBasePosition( const osg::Vec3d& b );
58  inline const osg::Vec3d& getBasePosition() const { return _basepos; }
59 
61  void setDirection( const osg::Vec3d& d );
62  inline const osg::Vec3d& getDirection() const { return _dir; }
63 
65  inline osg::ShapeDrawable* getVector() const { return _vec.get(); }
66 
67  void reposition();
68 
69  protected:
70  virtual ~Vector();
71 
72  osg::ref_ptr<osg::Cylinder> _body;
73  osg::ref_ptr<osg::Cone> _head;
74  osg::ref_ptr<osg::ShapeDrawable> _vec;
75 
76  osg::Vec3d _basepos; // Vector base position
77  osg::Vec3d _dir; // Vector direction
78  };
79 
80 } // ! namespace OpenFrames
81 
82 #endif // ! _OF_VECTOR_
This class defines an actual drawable Vector of variable geometry.
Definition: Vector.hpp:42
Definition: CoordinateAxes.hpp:29
osg::ShapeDrawable * getVector() const
Definition: Vector.hpp:65