CShapeSphere.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.1.1 $Rev: 1869 $
41 */
42 //==============================================================================
43 
44 //------------------------------------------------------------------------------
45 #ifndef CShapeSphereH
46 #define CShapeSphereH
47 //------------------------------------------------------------------------------
48 #include "world/CGenericObject.h"
49 #include "materials/CMaterial.h"
50 #include "materials/CTexture2d.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  cShapeSphere(const double& a_radius,
88  cMaterialPtr a_material = cMaterialPtr());
89 
91  virtual ~cShapeSphere() {};
92 
93 
94  //--------------------------------------------------------------------------
95  // PUBLIC METHODS:
96  //--------------------------------------------------------------------------
97 
98 public:
99 
101  cShapeSphere* copy(const bool a_duplicateMaterialData = false,
102  const bool a_duplicateTextureData = false,
103  const bool a_duplicateMeshData = false,
104  const bool a_buildCollisionDetector = false);
105 
107  void setRadius(const double& a_radius);
108 
110  inline double getRadius() const { return (m_radius); }
111 
112 
113  //--------------------------------------------------------------------------
114  // PROTECTED METHODS:
115  //--------------------------------------------------------------------------
116 
117 protected:
118 
120  virtual void render(cRenderOptions& a_options);
121 
123  virtual void updateBoundaryBox();
124 
126  virtual void scaleObject(const double& a_scaleFactor);
127 
129  virtual void computeLocalInteraction(const cVector3d& a_toolPos,
130  const cVector3d& a_toolVel,
131  const unsigned int a_IDN);
132 
134  virtual bool computeOtherCollisionDetection(cVector3d& a_segmentPointA,
135  cVector3d& a_segmentPointB,
136  cCollisionRecorder& a_recorder,
137  cCollisionSettings& a_settings);
138 
139 
140  //-----------------------------------------------------------------------
141  // PROTECTED METHODS:
142  //-----------------------------------------------------------------------
143 
144 protected:
145 
148  const bool a_duplicateMaterialData,
149  const bool a_duplicateTextureData,
150  const bool a_duplicateMeshData,
151  const bool a_buildCollisionDetector);
152 
153 
154  //--------------------------------------------------------------------------
155  // PROTECTED MEMBERS:
156  //--------------------------------------------------------------------------
157 
158 protected:
159 
161  double m_radius;
162 };
163 
164 //------------------------------------------------------------------------------
165 } // namespace chai3d
166 //------------------------------------------------------------------------------
167 
168 //------------------------------------------------------------------------------
169 #endif
170 //------------------------------------------------------------------------------
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
virtual void render(cRenderOptions &a_options)
This method renders this object graphically using OpenGL.
Definition: CShapeSphere.cpp:179
std::shared_ptr< cMaterial > cMaterialPtr
Definition: CMaterial.h:67
cShapeSphere(const double &a_radius, cMaterialPtr a_material=cMaterialPtr())
Constructor of cShapeSphere.
Definition: CShapeSphere.cpp:68
virtual void updateBoundaryBox()
This method updates the boundary box of this object.
Definition: CShapeSphere.cpp:280
double getRadius() const
This method returns the radius of the sphere.
Definition: CShapeSphere.h:110
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
void copyShapeSphereProperties(cShapeSphere *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: CShapeSphere.cpp:134
virtual void scaleObject(const double &a_scaleFactor)
This method scales the size of this object with given scale factor.
Definition: CShapeSphere.cpp:294
cShapeSphere * 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: CShapeSphere.cpp:100
This structure stores the collision settings that are passed to a collision detector when querying fo...
Definition: CCollisionBasics.h:242
Implements a base class for all objects.
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: CShapeSphere.cpp:242
This class implements a 3D shape sphere.
Definition: CShapeSphere.h:78
virtual ~cShapeSphere()
Destructor of cShapeSphere.
Definition: CShapeSphere.h:91
double m_radius
Radius of sphere.
Definition: CShapeSphere.h:161
Implements material properties.
Definition: CAudioBuffer.cpp:56
Implements 2D textures.
void setRadius(const double &a_radius)
This method sets the radius of the sphere.
Definition: CShapeSphere.cpp:159
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: CShapeSphere.cpp:325