CShapeTorus.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: 1869 $
41 */
42 //==============================================================================
43 
44 //------------------------------------------------------------------------------
45 #ifndef CShapeTorusH
46 #define CShapeTorusH
47 //------------------------------------------------------------------------------
48 #include "materials/CMaterial.h"
49 #include "materials/CTexture2d.h"
50 #include "world/CGenericObject.h"
51 //------------------------------------------------------------------------------
52 
53 //------------------------------------------------------------------------------
54 namespace chai3d {
55 //------------------------------------------------------------------------------
56 
57 //==============================================================================
64 //==============================================================================
65 
66 //==============================================================================
77 //==============================================================================
79 {
80  //--------------------------------------------------------------------------
81  // CONSTRUCTOR & DESTRUCTOR:
82  //--------------------------------------------------------------------------
83 
84 public:
85 
87  cShapeTorus(const double& a_innerRadius,
88  const double& a_outerRadius,
89  cMaterialPtr a_material = cMaterialPtr());
90 
92  virtual ~cShapeTorus() {};
93 
94 
95  //--------------------------------------------------------------------------
96  // PUBLIC METHODS:
97  //--------------------------------------------------------------------------
98 
99 public:
100 
102  cShapeTorus* copy(const bool a_duplicateMaterialData = false,
103  const bool a_duplicateTextureData = false,
104  const bool a_duplicateMeshData = false,
105  const bool a_buildCollisionDetector = false);
106 
108  void setSize(const double& a_innerRadius,
109  const double& a_outerRadius);
110 
112  inline double getInnerRadius() const { return (m_innerRadius); }
113 
115  inline double getOuterRadius() const { return (m_outerRadius); }
116 
117 
118  //--------------------------------------------------------------------------
119  // PROTECTED VIRTUAL METHODS:
120  //--------------------------------------------------------------------------
121 
122 protected:
123 
125  virtual void render(cRenderOptions& a_options);
126 
128  virtual void updateBoundaryBox();
129 
131  virtual void scaleObject(const double& a_scaleFactor);
132 
134  virtual void computeLocalInteraction(const cVector3d& a_toolPos,
135  const cVector3d& a_toolVel,
136  const unsigned int a_IDN);
137 
139  virtual bool computeOtherCollisionDetection(cVector3d& a_segmentPointA,
140  cVector3d& a_segmentPointB,
141  cCollisionRecorder& a_recorder,
142  cCollisionSettings& a_settings);
143 
144 
145  //-----------------------------------------------------------------------
146  // PROTECTED METHODS:
147  //-----------------------------------------------------------------------
148 
149 protected:
150 
153  const bool a_duplicateMaterialData,
154  const bool a_duplicateTextureData,
155  const bool a_duplicateMeshData,
156  const bool a_buildCollisionDetector);
157 
158 
159  //--------------------------------------------------------------------------
160  // PROTECTED MEMBERS:
161  //--------------------------------------------------------------------------
162 
163 protected:
164 
167 
170 
172  unsigned int m_resolution;
173 };
174 
175 //------------------------------------------------------------------------------
176 } // namespace chai3d
177 //------------------------------------------------------------------------------
178 
179 //------------------------------------------------------------------------------
180 #endif
181 //------------------------------------------------------------------------------
This class implements a 3D vector.
Definition: CVector3d.h:88
This structures provide a containers for storing rendering options that are passed through the sceneg...
Definition: CRenderOptions.h:82
cShapeTorus * 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: CShapeTorus.cpp:103
double getInnerRadius() const
This method returns the inner radius of the torus.
Definition: CShapeTorus.h:112
cShapeTorus(const double &a_innerRadius, const double &a_outerRadius, cMaterialPtr a_material=cMaterialPtr())
Constructor of cShapeTorus.
Definition: CShapeTorus.cpp:61
virtual void render(cRenderOptions &a_options)
This method renders this object graphically using OpenGL.
Definition: CShapeTorus.cpp:184
double m_outerRadius
Outside radius of the torus.
Definition: CShapeTorus.h:169
virtual void scaleObject(const double &a_scaleFactor)
This method scales the size of this object with given scale factor.
Definition: CShapeTorus.cpp:344
std::shared_ptr< cMaterial > cMaterialPtr
Definition: CMaterial.h:67
This class implements a base class for all 2D or 3D objects in CHAI3D.
Definition: CGenericObject.h:112
This class implements a collision detection recorder that stores all collision events that are report...
Definition: CCollisionBasics.h:185
This structure stores the collision settings that are passed to a collision detector when querying fo...
Definition: CCollisionBasics.h:242
double m_innerRadius
Inside radius of the torus.
Definition: CShapeTorus.h:166
double getOuterRadius() const
This method returns the outer radius of the torus.
Definition: CShapeTorus.h:115
Implements a base class for all objects.
virtual void updateBoundaryBox()
This method updates the boundary box of this object.
Definition: CShapeTorus.cpp:329
void copyShapeTorusProperties(cShapeTorus *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: CShapeTorus.cpp:134
void setSize(const double &a_innerRadius, const double &a_outerRadius)
This method sets the inner and outer radii of the torus.
Definition: CShapeTorus.cpp:162
virtual ~cShapeTorus()
Destructor of cShapeTorus.
Definition: CShapeTorus.h:92
This class implements a 3D shape torus.
Definition: CShapeTorus.h:78
Implements material properties.
Definition: CAudioBuffer.cpp:56
Implements 2D textures.
virtual bool computeOtherCollisionDetection(cVector3d &a_segmentPointA, cVector3d &a_segmentPointB, cCollisionRecorder &a_recorder, cCollisionSettings &a_settings)
This method computes collisions between a segment and this object.
Definition: CShapeTorus.cpp:376
virtual void computeLocalInteraction(const cVector3d &a_toolPos, const cVector3d &a_toolVel, const unsigned int a_IDN)
This method updates the geometric relationship between the tool and the current object.
Definition: CShapeTorus.cpp:270
unsigned int m_resolution
Resolution of the graphical model.
Definition: CShapeTorus.h:172