CHAI3D  3.0.0
CShapeCylinder.h
Go to the documentation of this file.
1 //==============================================================================
2 /*
3  Software License Agreement (BSD License)
4  Copyright (c) 2003-2015, 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 Sebastien Grange
40  \version 3.0.0 $Rev: 1656 $
41 */
42 //==============================================================================
43 
44 //------------------------------------------------------------------------------
45 #ifndef CShapeCylinderH
46 #define CShapeCylinderH
47 //------------------------------------------------------------------------------
48 #include "world/CGenericObject.h"
49 #include "materials/CMaterial.h"
50 #include "materials/CTexture2d.h"
51 //------------------------------------------------------------------------------
52 #ifdef C_USE_OPENGL
53 #ifdef MACOSX
54 #include "OpenGL/glu.h"
55 #else
56 #include "GL/glu.h"
57 #endif
58 #endif
59 //------------------------------------------------------------------------------
60 //------------------------------------------------------------------------------
61 namespace chai3d {
62 //------------------------------------------------------------------------------
63 
64 //==============================================================================
71 //==============================================================================
72 
73 //==============================================================================
84 //==============================================================================
86 {
87  //--------------------------------------------------------------------------
88  // CONSTRUCTOR & DESTRUCTOR:
89  //--------------------------------------------------------------------------
90 
91 public:
92 
94  cShapeCylinder(const double a_baseRadius,
95  const double a_topRadius,
96  const double a_height,
97  cMaterialPtr a_material = cMaterialPtr());
98 
100  virtual ~cShapeCylinder() {};
101 
102 
103  //--------------------------------------------------------------------------
104  // PUBLIC METHODS:
105  //--------------------------------------------------------------------------
106 
107 public:
108 
110  cShapeCylinder* copy(const bool a_duplicateMaterialData = false,
111  const bool a_duplicateTextureData = false,
112  const bool a_duplicateMeshData = false,
113  const bool a_buildCollisionDetector = false);
114 
116  void setBaseRadius(double a_baseRadius) { m_baseRadius = fabs(a_baseRadius); updateBoundaryBox(); markForUpdate(false);}
117 
119  void setTopRadius(double a_topRadius) { m_topRadius = fabs(a_topRadius); updateBoundaryBox(); markForUpdate(false);}
120 
122  void setHeight(double a_height) { m_height = fabs(a_height); updateBoundaryBox(); markForUpdate(false);}
123 
125  inline double getBaseRadius() const { return (m_baseRadius); }
126 
128  inline double getTopRadius() const { return (m_topRadius); }
129 
131  inline double getHeight() const { return (m_height); }
132 
133 
134  //--------------------------------------------------------------------------
135  // PROTECTED VIRTUAL METHODS:
136  //--------------------------------------------------------------------------
137 
138 protected:
139 
141  virtual void render(cRenderOptions& a_options);
142 
144  virtual void updateBoundaryBox();
145 
147  virtual void scaleObject(const double& a_scaleFactor);
148 
150  virtual void computeLocalInteraction(const cVector3d& a_toolPos,
151  const cVector3d& a_toolVel,
152  const unsigned int a_IDN);
153 
155  virtual bool computeOtherCollisionDetection(cVector3d& a_segmentPointA,
156  cVector3d& a_segmentPointB,
157  cCollisionRecorder& a_recorder,
158  cCollisionSettings& a_settings);
159 
160 
161  //--------------------------------------------------------------------------
162  // PROTECTED METHODS:
163  //--------------------------------------------------------------------------
164 
165 protected:
166 
169  const bool a_duplicateMaterialData,
170  const bool a_duplicateTextureData,
171  const bool a_duplicateMeshData,
172  const bool a_buildCollisionDetector);
173 
174 
175  //--------------------------------------------------------------------------
176  // PROTECTED MEMBERS: (cShapeCylinder)
177  //--------------------------------------------------------------------------
178 
179 protected:
180 
182  double m_baseRadius;
183 
185  double m_topRadius;
186 
188  double m_height;
189 
191  GLUquadricObj *m_quadric;
192 };
193 
194 //------------------------------------------------------------------------------
195 } // namespace chai3d
196 //------------------------------------------------------------------------------
197 
198 //------------------------------------------------------------------------------
199 #endif
200 //------------------------------------------------------------------------------
This class implements a 3D vector.
Definition: CVector3d.h:85
This structures provide a containers for storing rendering options that are passed through the sceneg...
Definition: CRenderOptions.h:82
double m_baseRadius
base radius of cylinder.
Definition: CShapeCylinder.h:182
cShapeCylinder(const double a_baseRadius, const double a_topRadius, const double a_height, cMaterialPtr a_material=cMaterialPtr())
Constructor of cShapeCylinder.
Definition: CShapeCylinder.cpp:64
void setTopRadius(double a_topRadius)
This method sets the top radius of the cylinder.
Definition: CShapeCylinder.h:119
virtual void markForUpdate(const bool a_affectChildren=false)
This method invalidates any existing display lists, optionally propagating the operation to its child...
Definition: CGenericObject.cpp:1135
GLUquadricObj * m_quadric
rendering object.
Definition: CShapeCylinder.h:191
double getHeight() const
This method returns the height of the cylinder.
Definition: CShapeCylinder.h:131
This class implements a 3D shape cylinder.
Definition: CShapeCylinder.h:85
double m_topRadius
top radius of cylinder.
Definition: CShapeCylinder.h:185
void setHeight(double a_height)
This method sets the height of the cylinder.
Definition: CShapeCylinder.h:122
std::shared_ptr< cMaterial > cMaterialPtr
Definition: CMaterial.h:67
void setBaseRadius(double a_baseRadius)
This method sets the base radius of the cylinder.
Definition: CShapeCylinder.h:116
This class implements a base class for all 2D or 3D objects in CHAI3D.
Definition: CGenericObject.h:112
double getTopRadius() const
This method returns the top radius of the cylinder.
Definition: CShapeCylinder.h:128
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
cShapeCylinder * 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: CShapeCylinder.cpp:113
double m_height
height of cylinder.
Definition: CShapeCylinder.h:188
virtual ~cShapeCylinder()
Destructor of cShapeCylinder.
Definition: CShapeCylinder.h:100
void copyShapeCylinderProperties(cShapeCylinder *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: CShapeCylinder.cpp:144
Implements a base class for all objects.
virtual void scaleObject(const double &a_scaleFactor)
This method scales the size of this object with given scale factor.
Definition: CShapeCylinder.cpp:321
double getBaseRadius() const
This method returns the base radius of the cylinder.
Definition: CShapeCylinder.h:125
virtual void updateBoundaryBox()
This method updates the boundary box of this object.
Definition: CShapeCylinder.cpp:305
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: CShapeCylinder.cpp:354
Implements material properties.
virtual void render(cRenderOptions &a_options)
This method renders this object graphically using OpenGL.
Definition: CShapeCylinder.cpp:171
Definition: CAudioBuffer.cpp:56
Implements 2D textures.
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: CShapeCylinder.cpp:235

CHAI3D 3.0.0 documentation
Please address any questions to support@chai3d.org
(C) 2003-2015 - CHAI3D
All Rights Reserved.