CGenericWidget.h
Go to the documentation of this file.
1 //==============================================================================
2 /*
3  Software License Agreement (BSD License)
4  Copyright (c) 2003-2016, CHAI3D.
5  (www.chai3d.org)
6 
7  All rights reserved.
8 
9  Redistribution and use in source and binary forms, with or without
10  modification, are permitted provided that the following conditions
11  are met:
12 
13  * Redistributions of source code must retain the above copyright
14  notice, this list of conditions and the following disclaimer.
15 
16  * Redistributions in binary form must reproduce the above
17  copyright notice, this list of conditions and the following
18  disclaimer in the documentation and/or other materials provided
19  with the distribution.
20 
21  * Neither the name of CHAI3D nor the names of its contributors may
22  be used to endorse or promote products derived from this software
23  without specific prior written permission.
24 
25  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
26  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
27  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
28  FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
29  COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
30  INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
31  BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
32  LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
33  CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
34  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
35  ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36  POSSIBILITY OF SUCH DAMAGE.
37 
38  \author <http://www.chai3d.org>
39  \author Francois Conti
40  \version 3.2.0 $Rev: 2167 $
41 */
42 //==============================================================================
43 
44 //------------------------------------------------------------------------------
45 #ifndef CGenericWidgetH
46 #define CGenericWidgetH
47 //------------------------------------------------------------------------------
48 #include "world/CMesh.h"
49 //------------------------------------------------------------------------------
50 
51 //------------------------------------------------------------------------------
52 namespace chai3d {
53 //------------------------------------------------------------------------------
54 
55 //==============================================================================
62 //==============================================================================
63 
64 //==============================================================================
76 //==============================================================================
77 class cGenericWidget : public cMesh
78 {
79  //--------------------------------------------------------------------------
80  // CONSTRUCTOR & DESTRUCTOR:
81  //--------------------------------------------------------------------------
82 
83 public:
84 
87 
89  virtual ~cGenericWidget() {};
90 
91 
92  //--------------------------------------------------------------------------
93  // VIRTUAL PUBLIC METHODS:
94  //--------------------------------------------------------------------------
95 
96 public:
97 
99  virtual cGenericWidget* copy(const bool a_duplicateMaterialData = false,
100  const bool a_duplicateTextureData = false,
101  const bool a_duplicateMeshData = false,
102  const bool a_buildCollisionDetector = false);
103 
104 
105  //--------------------------------------------------------------------------
106  // VIRTUAL PUBLIC METHODS: SIZES
107  //--------------------------------------------------------------------------
108 
109 public:
110 
112  virtual double getWidth() const { return (m_width); }
113 
115  virtual double getHeight() const { return (m_height); }
116 
118  virtual void updateBoundaryBox()
119  {
120  m_boundaryBoxMin.set(0.0, 0.0, 0.0);
122  }
123 
124 
125  //--------------------------------------------------------------------------
126  // VIRTUAL PUBLIC METHODS: ROTATING WIDGETS
127  //--------------------------------------------------------------------------
128 
129 public:
130 
132  virtual void rotateWidgetDeg(double a_angleDeg) { rotateAboutLocalAxisDeg(cVector3d(0,0,1), a_angleDeg); }
133 
135  virtual void rotateWidgetRad(double a_angleRad) { rotateAboutLocalAxisRad(cVector3d(0,0,1), a_angleRad); }
136 
138  virtual void rotateWidgetAroundCenterDeg(double a_angleDeg) { rotateWidgetAroundCenterRad(cDegToRad(a_angleDeg)); }
139 
141  virtual void rotateWidgetAroundCenterRad(double a_angleRad);
142 
143 
144  //--------------------------------------------------------------------------
145  // PROTECTED METHODS:
146  //--------------------------------------------------------------------------
147 
148 protected:
149 
152  const bool a_duplicateMaterialData,
153  const bool a_duplicateTextureData,
154  const bool a_duplicateMeshData,
155  const bool a_buildCollisionDetector);
156 
157 
158  //--------------------------------------------------------------------------
159  // PROTECTED MEMBERS:
160  //--------------------------------------------------------------------------
161 
162 protected:
163 
165  double m_width;
166 
168  double m_height;
169 };
170 
171 //------------------------------------------------------------------------------
172 } // namespace chai3d
173 //------------------------------------------------------------------------------
174 
175 //------------------------------------------------------------------------------
176 #endif
177 //------------------------------------------------------------------------------
This class implements a 3D vector.
Definition: CVector3d.h:88
virtual double getWidth() const
This method returns the width of the widget.
Definition: CGenericWidget.h:112
Implements a class to model polygonal meshes.
virtual void rotateWidgetRad(double a_angleRad)
This method rotates the widget around the z-axis with an angle defined in radians.
Definition: CGenericWidget.h:135
virtual cGenericWidget * copy(const bool a_duplicateMaterialData=false, const bool a_duplicateTextureData=false, const bool a_duplicateMeshData=false, const bool a_buildCollisionDetector=false)
This method creates a copy of itself.
Definition: CGenericWidget.cpp:85
double cDegToRad(const double &a_angleDeg)
This function converts an angle from degrees to radians.
Definition: CMaths.h:633
void set(const double &a_x, const double &a_y, const double &a_z)
This method initializes this vector with components x, y, and z passed as arguments.
Definition: CVector3d.h:298
void copyGenericWidgetProperties(cGenericWidget *a_obj, const bool a_duplicateMaterialData, const bool a_duplicateTextureData, const bool a_duplicateMeshData, const bool a_buildCollisionDetector)
This method copies all properties of this object to another.
Definition: CGenericWidget.cpp:116
virtual void updateBoundaryBox()
This method updates the bounding box of the widget.
Definition: CGenericWidget.h:118
virtual void rotateWidgetDeg(double a_angleDeg)
This method rotates the widget around the z-axis with an angle defined in degrees.
Definition: CGenericWidget.h:132
cVector3d m_boundaryBoxMax
Maximum position of boundary box.
Definition: CGenericObject.h:777
cGenericWidget()
Constructor of cGenericWidget.
Definition: CGenericWidget.cpp:57
This class implements a base class for widgets.
Definition: CGenericWidget.h:77
cVector3d m_boundaryBoxMin
Minimum position of boundary box.
Definition: CGenericObject.h:774
This class implements a 3D polygonal mesh.
Definition: CMesh.h:108
double m_width
Width of this widget.
Definition: CGenericWidget.h:165
virtual void rotateWidgetAroundCenterDeg(double a_angleDeg)
This method rotates the widget around its center point with an angle defined in degrees.
Definition: CGenericWidget.h:138
Definition: CAudioBuffer.cpp:56
virtual ~cGenericWidget()
Destructor of cGenericWidget.
Definition: CGenericWidget.h:89
void rotateAboutLocalAxisDeg(const cVector3d &a_axis, const double a_angleDeg)
This method rotates this object around a local axis. Angle magnitude is defined in degrees...
Definition: CGenericObject.h:236
void rotateAboutLocalAxisRad(const cVector3d &a_axis, const double a_angleRad)
This method rotates this object around a local axis. Angle magnitude is defined in radians...
Definition: CGenericObject.cpp:269
virtual double getHeight() const
This method returns the height of the widget.
Definition: CGenericWidget.h:115
virtual void rotateWidgetAroundCenterRad(double a_angleRad)
This method rotates the widget around its center point with an angle defined in radians.
Definition: CGenericWidget.cpp:144
double m_height
Height of this widget.
Definition: CGenericWidget.h:168