CShapeLine.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: 2164 $
41 */
42 //==============================================================================
43 
44 //------------------------------------------------------------------------------
45 #ifndef CShapeLineH
46 #define CShapeLineH
47 //------------------------------------------------------------------------------
48 #include "world/CGenericObject.h"
49 #include "materials/CMaterial.h"
50 //------------------------------------------------------------------------------
51 
52 //------------------------------------------------------------------------------
53 namespace chai3d {
54 //------------------------------------------------------------------------------
55 
56 //==============================================================================
63 //==============================================================================
64 
65 //==============================================================================
76 //==============================================================================
77 class cShapeLine : public cGenericObject
78 {
79  //--------------------------------------------------------------------------
80  // CONSTRUCTOR & DESTRUCTOR:
81  //--------------------------------------------------------------------------
82 
83 public:
84 
86  cShapeLine();
87 
89  cShapeLine(const cVector3d& a_pointA, const cVector3d& a_pointB);
90 
92  cShapeLine(cGenericObject* a_objectA, cGenericObject* a_objectB);
93 
95  cShapeLine(cGenericObject* a_objectA, const cVector3d& a_pointA,
96  cGenericObject* a_objectB, const cVector3d& a_pointB);
97 
99  virtual ~cShapeLine() {};
100 
101 
102  //--------------------------------------------------------------------------
103  // PUBLIC METHODS:
104  //--------------------------------------------------------------------------
105 
106 public:
107 
109  cShapeLine* copy(const bool a_duplicateMaterialData = false,
110  const bool a_duplicateTextureData = false,
111  const bool a_duplicateMeshData = false,
112  const bool a_buildCollisionDetector = false);
113 
115  inline void setLineWidth(const double a_lineWidth) { m_lineWidth = fabs(a_lineWidth); }
116 
118  inline double getLineWidth() const { return (m_lineWidth); }
119 
121  void setLineStipple(const GLint a_stippleFactor, const GLushort a_stipplePattern);
122 
124  GLint getLineStippleFactor() { return (m_stippleFactor); }
125 
127  GLushort getLineStipplePattern() { return (m_stipplePattern); }
128 
129 
130  //--------------------------------------------------------------------------
131  // PUBLIC MEMBERS: (cShapeLine)
132  //--------------------------------------------------------------------------
133 
134 public:
135 
138 
141 
144 
147 
150 
153 
154 
155  //--------------------------------------------------------------------------
156  // PROTECTED VIRTUAL METHODS:
157  //--------------------------------------------------------------------------
158 
159 protected:
160 
162  virtual void render(cRenderOptions& a_options);
163 
165  virtual void updateBoundaryBox();
166 
168  virtual void scaleObject(const double& a_scaleFactor);
169 
171  virtual void computeLocalInteraction(const cVector3d& a_toolPos,
172  const cVector3d& a_toolVel,
173  const unsigned int a_IDN);
174 
176  virtual bool computeOtherCollisionDetection(cVector3d& a_segmentPointA,
177  cVector3d& a_segmentPointB,
178  cCollisionRecorder& a_recorder,
179  cCollisionSettings& a_settings);
180 
181 
182  //-----------------------------------------------------------------------
183  // PROTECTED METHODS:
184  //-----------------------------------------------------------------------
185 
186 protected:
187 
190  const bool a_duplicateMaterialData,
191  const bool a_duplicateTextureData,
192  const bool a_duplicateMeshData,
193  const bool a_buildCollisionDetector);
194 
195  // Initialize line object.
196  void reset();
197 
198  // Update position of line extremities.
199  void updateLinePoints();
200 
201 
202  //--------------------------------------------------------------------------
203  // PROTECTED MEMBERS:
204  //--------------------------------------------------------------------------
205 
206 protected:
207 
209  double m_lineWidth;
210 
213 
216 
217  // Point A in local coordinates
219 
220  // Point A in local coordinates
222 
223 };
224 
225 //------------------------------------------------------------------------------
226 } // namespace chai3d
227 //------------------------------------------------------------------------------
228 
229 //------------------------------------------------------------------------------
230 #endif
231 //------------------------------------------------------------------------------
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 ~cShapeLine()
Destructor of cShapeLine.
Definition: CShapeLine.h:99
cVector3d m_linePointA
Definition: CShapeLine.h:218
GLint getLineStippleFactor()
This method returns the line stipple factor value.
Definition: CShapeLine.h:124
void reset()
Definition: CShapeLine.cpp:153
cShapeLine()
Constructor of cShapeLine.
Definition: CShapeLine.cpp:60
double m_lineWidth
Line width.
Definition: CShapeLine.h:209
GLushort m_stipplePattern
Specifies a 16-bit integer whose bit pattern determine which fragments of a line will be drawn when t...
Definition: CShapeLine.h:215
virtual void scaleObject(const double &a_scaleFactor)
This method scales the size of this object with given scale factor.
Definition: CShapeLine.cpp:381
cColorf m_colorPointA
Color of point A of line.
Definition: CShapeLine.h:143
GLint m_stippleFactor
Specifies a multiplier for each bit in the line stipple pattern.
Definition: CShapeLine.h:212
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: CShapeLine.cpp:470
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
virtual void updateBoundaryBox()
This method updates the boundary box of this object.
Definition: CShapeLine.cpp:362
void updateLinePoints()
Definition: CShapeLine.cpp:427
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: CShapeLine.cpp:331
This structure stores the collision settings that are passed to a collision detector when querying fo...
Definition: CCollisionBasics.h:242
double getLineWidth() const
This method returns the line width.
Definition: CShapeLine.h:118
cGenericObject * m_objectA
Object A to wich line extremity is attached.
Definition: CShapeLine.h:149
void setLineStipple(const GLint a_stippleFactor, const GLushort a_stipplePattern)
This method sets the line properties.
Definition: CShapeLine.cpp:412
cVector3d m_pointA
Point A of line.
Definition: CShapeLine.h:137
Implements a base class for all objects.
cVector3d m_linePointB
Definition: CShapeLine.h:221
This class defines a color using a GLfloat representation for each component.
Definition: CColor.h:138
cVector3d m_pointB
Point A of line.
Definition: CShapeLine.h:140
cColorf m_colorPointB
Color of point B of line.
Definition: CShapeLine.h:146
GLushort getLineStipplePattern()
This method returns the stipple pattern value.
Definition: CShapeLine.h:127
Implements material properties.
void copyShapeLineProperties(cShapeLine *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: CShapeLine.cpp:219
Definition: CAudioBuffer.cpp:56
virtual void render(cRenderOptions &a_options)
This method renders this object graphically using OpenGL.
Definition: CShapeLine.cpp:254
void setLineWidth(const double a_lineWidth)
This method sets the line width.
Definition: CShapeLine.h:115
This class implements a 3D line.
Definition: CShapeLine.h:77
cShapeLine * 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: CShapeLine.cpp:188
cGenericObject * m_objectB
Object B to wich line extremity is attached.
Definition: CShapeLine.h:152