My Project
Loading...
Searching...
No Matches
CShapeBox.h
Go to the documentation of this file.
1//==============================================================================
2/*
3 Software License Agreement (BSD License)
4 Copyright (c) 2003-2024, 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.3.0
41*/
42//==============================================================================
43
44//------------------------------------------------------------------------------
45#ifndef CShapeBoxH
46#define CShapeBoxH
47//------------------------------------------------------------------------------
49#include "materials/CMaterial.h"
51//------------------------------------------------------------------------------
52
53//------------------------------------------------------------------------------
54namespace chai3d {
55//------------------------------------------------------------------------------
56
57//==============================================================================
64//==============================================================================
65
66//==============================================================================
77//==============================================================================
79{
80 //--------------------------------------------------------------------------
81 // CONSTRUCTOR & DESTRUCTOR:
82 //--------------------------------------------------------------------------
83
84public:
85
87 cShapeBox(const double& a_sizeX,
88 const double& a_sizeY,
89 const double& a_sizeZ,
90 cMaterialPtr a_material = cMaterialPtr());
91
93 virtual ~cShapeBox() {};
94
95
96 //--------------------------------------------------------------------------
97 // PUBLIC METHODS:
98 //--------------------------------------------------------------------------
99
100public:
101
103 virtual std::string getClassName() { return ("ShapeBox"); }
104
106 cShapeBox* copy(const bool a_duplicateMaterialData = false,
107 const bool a_duplicateTextureData = false,
108 const bool a_duplicateMeshData = false,
109 const bool a_buildCollisionDetector = true);
110
112 void setSize(const double& a_sizeX,
113 const double& a_sizeY,
114 const double& a_sizeZ);
115
117 inline double getSizeX() const { return (2.0 * m_hSizeX); }
118
120 inline double getSizeY() const { return (2.0 * m_hSizeY); }
121
123 inline double getSizeZ() const { return (2.0 * m_hSizeZ); }
124
125
126 //--------------------------------------------------------------------------
127 // PROTECTED VIRTUAL METHODS:
128 //--------------------------------------------------------------------------
129
130protected:
131
133 virtual void render(cRenderOptions& a_options);
134
136 virtual void updateBoundaryBox();
137
139 virtual void scaleObject(const double& a_scaleFactor);
140
142 virtual void computeLocalInteraction(const cVector3d& a_toolPos,
143 const cVector3d& a_toolVel,
144 const unsigned int a_IDN);
145
147 virtual bool computeOtherCollisionDetection(cVector3d& a_segmentPointA,
148 cVector3d& a_segmentPointB,
149 cCollisionRecorder& a_recorder,
150 cCollisionSettings& a_settings);
151
152
153 //-----------------------------------------------------------------------
154 // PROTECTED METHODS:
155 //-----------------------------------------------------------------------
156
157protected:
158
161 const bool a_duplicateMaterialData,
162 const bool a_duplicateTextureData,
163 const bool a_duplicateMeshData,
164 const bool a_buildCollisionDetector);
165
166
167 //--------------------------------------------------------------------------
168 // PROTECTED MEMBERS: (cShapeBox)
169 //--------------------------------------------------------------------------
170
171 protected:
172
174 double m_hSizeX;
175
177 double m_hSizeY;
178
180 double m_hSizeZ;
181};
182
183//------------------------------------------------------------------------------
184} // namespace chai3d
185//------------------------------------------------------------------------------
186
187//------------------------------------------------------------------------------
188#endif
189//------------------------------------------------------------------------------
Implements a base class for all objects.
Implements material properties.
Implements 2D textures.
This class implements a collision detection recorder that stores all collision events that are report...
Definition CCollisionBasics.h:186
This class implements a base class for all 2D or 3D objects in CHAI3D.
Definition CGenericObject.h:113
This class implements a 3D shape box.
Definition CShapeBox.h:79
double getSizeY() const
This method returns the box length along axis Y.
Definition CShapeBox.h:120
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 CShapeBox.cpp:295
virtual std::string getClassName()
This method returns the name of the object class.
Definition CShapeBox.h:103
virtual ~cShapeBox()
Destructor of cShapeBox.
Definition CShapeBox.h:93
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 CShapeBox.cpp:443
virtual void updateBoundaryBox()
This method updates the boundary box of this object.
Definition CShapeBox.cpp:395
double m_hSizeZ
half length of box along axis Z.
Definition CShapeBox.h:180
void setSize(const double &a_sizeX, const double &a_sizeY, const double &a_sizeZ)
This method sets the dimensions of the box along each axis.
Definition CShapeBox.cpp:165
double m_hSizeY
half length of box along axis Y.
Definition CShapeBox.h:177
double m_hSizeX
half length of box along axis Z.
Definition CShapeBox.h:174
void copyShapeBoxProperties(cShapeBox *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 CShapeBox.cpp:136
cShapeBox * copy(const bool a_duplicateMaterialData=false, const bool a_duplicateTextureData=false, const bool a_duplicateMeshData=false, const bool a_buildCollisionDetector=true)
This method creates a copy of itself.
Definition CShapeBox.cpp:103
double getSizeX() const
This method returns the box length along axis X.
Definition CShapeBox.h:117
double getSizeZ() const
This method returns the box length along axis Z.
Definition CShapeBox.h:123
virtual void scaleObject(const double &a_scaleFactor)
This method scales the size of this object with given scale factor.
Definition CShapeBox.cpp:410
virtual void render(cRenderOptions &a_options)
This method renders this object graphically using OpenGL.
Definition CShapeBox.cpp:187
Definition CAudioBuffer.cpp:57
std::shared_ptr< cMaterial > cMaterialPtr
Definition CMaterial.h:69
This structure stores the collision settings that are passed to a collision detector when querying fo...
Definition CCollisionBasics.h:243
This structures provide a containers for storing rendering options that are passed through the sceneg...
Definition CRenderOptions.h:83
This class implements a 3D vector.
Definition CVector3d.h:89