CPrimitives.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: 2161 $
41 */
42 //==============================================================================
43 
44 //------------------------------------------------------------------------------
45 #ifndef CPrimitivesH
46 #define CPrimitivesH
47 //------------------------------------------------------------------------------
48 
49 //------------------------------------------------------------------------------
50 #include "world/CMesh.h"
51 //------------------------------------------------------------------------------
52 
53 //------------------------------------------------------------------------------
54 namespace chai3d {
55 //------------------------------------------------------------------------------
56 
57 //==============================================================================
65 //==============================================================================
66 
67 //------------------------------------------------------------------------------
68 // GENERAL PURPOSE FUNCTIONS
69 //------------------------------------------------------------------------------
70 
71 //------------------------------------------------------------------------------
75 //------------------------------------------------------------------------------
76 
78 
80 void cCreatePlane(cMesh* a_mesh,
81  const double& a_lengthX,
82  const double& a_lengthY,
83  const cVector3d& a_pos = cVector3d(0,0,0),
84  const cMatrix3d& a_rot = cIdentity3d(),
85  const cColorf& a_color = cColorf(1.0, 1.0, 1.0, 1.0));
86 
88 void cCreatePlane2(cMesh* a_mesh,
89  const double& a_lengthX,
90  const double& a_lengthY,
91  const cVector3d& a_pos = cVector3d(0,0,0),
92  const cMatrix3d& a_rot = cIdentity3d(),
93  const cColorf& a_colorTopLeft = cColorf(1.0, 1.0, 1.0, 1.0),
94  const cColorf& a_colorTopRight = cColorf(1.0, 1.0, 1.0, 1.0),
95  const cColorf& a_colorBottomLeft = cColorf(1.0, 1.0, 1.0, 1.0),
96  const cColorf& a_colorBottomRight = cColorf(1.0, 1.0, 1.0, 1.0));
97 
99 void cCreateMap(cMesh* a_mesh,
100  const double& a_lengthX,
101  const double& a_lengthY,
102  const unsigned int a_numSidesX = 10,
103  const unsigned int a_numSidesY = 10,
104  const cVector3d& a_pos = cVector3d(0,0,0),
105  const cMatrix3d& a_rot = cIdentity3d(),
106  const cColorf& a_color = cColorf(1.0, 1.0, 1.0, 1.0));
107 
109 void cCreateDisk(cMesh* a_mesh,
110  const double& a_radiusX,
111  const double& a_radiusY,
112  const unsigned int a_numSlices = 36,
113  const cVector3d& a_pos = cVector3d(0,0,0),
114  const cMatrix3d& a_rot = cIdentity3d(),
115  const cColorf& a_color = cColorf(1.0, 1.0, 1.0, 1.0));
116 
118 void cCreatePanel(cMesh* a_mesh,
119  const double& a_lengthX,
120  const double& a_lengthY,
121  const double& a_radiusCorners = 0,
122  const int& a_numSegmentsPerCorner = 8,
123  const cVector3d& a_pos = cVector3d(0,0,0),
124  const cMatrix3d& a_rot = cIdentity3d(),
125  const cColorf& a_color = cColorf(1.0, 1.0, 1.0, 1.0));
126 
128 void cCreatePanel2(cMesh* a_mesh,
129  const double& a_lengthX,
130  const double& a_lengthY,
131  const double& a_cornerTopLeftRadius = 0,
132  const double& a_cornerTopRightRadius = 0,
133  const double& a_cornerBottomLeftRadius = 0,
134  const double& a_cornerBottomRightRadius = 0,
135  const int& a_numSegmentsPerCorner = 8,
136  const cVector3d& a_pos = cVector3d(0,0,0),
137  const cMatrix3d& a_rot = cIdentity3d(),
138  const cColorf& a_colorTopLeft = cColorf(0.5f, 0.5f, 0.5f, 1.0f),
139  const cColorf& a_colorTopRight = cColorf(0.5f, 0.5f, 0.5f, 1.0f),
140  const cColorf& a_colorBottomLeft = cColorf(0.3f, 0.3f, 0.3f, 1.0f),
141  const cColorf& a_colorBottomRight = cColorf(0.3f, 0.3f, 0.3f, 1.0f));
142 
144 void cCreateBox(cMesh* a_mesh,
145  const double& a_lengthX,
146  const double& a_lengthY,
147  const double& a_lengthZ,
148  const cVector3d& a_pos = cVector3d(0,0,0),
149  const cMatrix3d& a_rot = cIdentity3d(),
150  const cColorf& a_color = cColorf(1.0, 1.0, 1.0, 1.0));
151 
153 void cCreateTeaPot(cMesh* a_mesh,
154  const double& a_size,
155  const cVector3d& a_pos = cVector3d(0,0,0),
156  const cMatrix3d& a_rot = cIdentity3d(),
157  const cColorf& a_color = cColorf(1.0, 1.0, 1.0, 1.0));
158 
160 void cCreateTeaPot(cMesh* a_mesh,
161  const double& a_size,
162  const int& a_quality = 4,
163  const cVector3d& a_pos = cVector3d(0, 0, 0),
164  const cMatrix3d& a_rot = cIdentity3d(),
165  const cColorf& a_color = cColorf(1.0, 1.0, 1.0, 1.0));
166 
168 void cCreateCylinder(cMesh* a_mesh,
169  const double& a_height,
170  const double& a_radius,
171  const unsigned int a_numSides = 32,
172  const unsigned int a_numHeightSegments = 1,
173  const unsigned int a_numRings = 1,
174  const bool a_includeTop = true,
175  const bool a_includeBottom = true,
176  const cVector3d& a_pos = cVector3d(0,0,0),
177  const cMatrix3d& a_rot = cIdentity3d(),
178  const cColorf& a_color = cColorf(1.0, 1.0, 1.0, 1.0));
179 
181 void cCreatePipe(cMesh* a_mesh,
182  const double& a_height,
183  const double& a_innerRadius,
184  const double& a_outerRadius,
185  const unsigned int a_numSides = 32,
186  const unsigned int a_numHeightSegments = 1,
187  const cVector3d& a_pos = cVector3d(0,0,0),
188  const cMatrix3d& a_rot = cIdentity3d(),
189  const cColorf& a_color = cColorf(1.0, 1.0, 1.0, 1.0));
190 
192 void cCreateSphere(cMesh* a_mesh,
193  const double& a_radius,
194  const unsigned int a_numSlices = 32,
195  const unsigned int a_numStacks = 32,
196  const cVector3d& a_pos = cVector3d(0,0,0),
197  const cMatrix3d& a_rot = cIdentity3d(),
198  const cColorf& a_color = cColorf(1.0, 1.0, 1.0, 1.0));
199 
201 void cCreateEllipsoid(cMesh* a_mesh,
202  const double& a_radiusX,
203  const double& a_radiusY,
204  const double& a_radiusZ,
205  const unsigned int a_numSlices = 32,
206  const unsigned int a_numStacks = 32,
207  const cVector3d& a_pos = cVector3d(0,0,0),
208  const cMatrix3d& a_rot = cIdentity3d(),
209  const cColorf& a_color = cColorf(1.0, 1.0, 1.0, 1.0));
210 
212 void cCreateRing(cMesh* a_mesh,
213  const double& a_innerRadius,
214  const double& a_outerRadius,
215  const unsigned int a_numSides = 32,
216  const unsigned int a_numRings = 32,
217  const cVector3d& a_pos = cVector3d(0,0,0),
218  const cMatrix3d& a_rot = cIdentity3d(),
219  const cColorf& a_color = cColorf(1.0, 1.0, 1.0, 1.0));
220 
222 void cCreateRingSection(cMesh* a_mesh,
223  const double& a_innerRadius0,
224  const double& a_innerRadius1,
225  const double& a_outerRadius,
226  const double& a_coverageAngleDEG = 360,
227  const bool a_includeExtremityFaces = true,
228  const unsigned int a_numSides = 32,
229  const unsigned int a_numRings = 32,
230  const cVector3d& a_pos = cVector3d(0,0,0),
231  const cMatrix3d& a_rot = cIdentity3d(),
232  const cColorf& a_color = cColorf(1.0, 1.0, 1.0, 1.0));
233 
235 void cCreateCone(cMesh* a_mesh,
236  const double& a_height,
237  const double& a_radiusBottom,
238  const double& a_radiusTop = 0.0,
239  const unsigned int a_numSides = 32,
240  const unsigned int a_numHeightSegments = 1,
241  const unsigned int a_numRings = 1,
242  const bool a_includeBottom = true,
243  const bool a_includeTop = true,
244  const cVector3d& a_pos = cVector3d(0,0,0),
245  const cMatrix3d& a_rot = cIdentity3d(),
246  const cColorf& a_color = cColorf(1.0, 1.0, 1.0, 1.0));
247 
249 void cCreateSquarePyramid(cMesh* a_mesh,
250  const double& a_height,
251  const double& a_baseSize,
252  const bool a_includeBottom = true,
253  const cVector3d& a_pos = cVector3d(0,0,0),
254  const cMatrix3d& a_rot = cIdentity3d(),
255  const cColorf& a_color = cColorf(1.0, 1.0, 1.0, 1.0));
256 
258 void cCreateArrow(cMesh* a_mesh,
259  const double& a_length = 0.4,
260  const double& a_radiusShaft = 0.01,
261  const double& a_lengthTip = 0.1,
262  const double& a_radiusTip = 0.03,
263  const bool a_includeTipsAtBothExtremities = false,
264  const unsigned int a_numSides = 32,
265  const cVector3d& a_direction = cVector3d(0,0,1),
266  const cVector3d& a_pos = cVector3d(0,0,0),
267  const cColorf& a_color = cColorf(1.0, 1.0, 1.0, 1.0));
268 
270 void cCreateCircularArrow(cMesh* a_mesh,
271  const double& a_innerRadius0 = 0.05,
272  const double& a_innerRadius1 = 0.05,
273  const double& a_outerRadius = 0.3,
274  const double& a_lengthTip = 0.2,
275  const double& a_radiusTip = 0.1,
276  const double& a_coverageAngleDEG = 270,
277  const bool a_includeTipsAtBothExtremities = false,
278  const unsigned int a_numSides = 32,
279  const unsigned int a_numRings = 32,
280  const cVector3d& a_direction = cVector3d(0,0,1),
281  const cVector3d& a_pos = cVector3d(0,0,0),
282  const cColorf& a_color = cColorf(1.0, 1.0, 1.0, 1.0));
283 
285 void cCreateBezierPatch(cMesh* a_mesh,
286  const cVector3d *a_controlPoints,
287  const int a_numDivisions = 8,
288  const cVector3d& a_pos = cVector3d(0, 0, 0),
289  const cMatrix3d& a_rot = cIdentity3d(),
290  const cColorf& a_color = cColorf(1.0, 1.0, 1.0, 1.0));
291 
293 
294 //------------------------------------------------------------------------------
295 } // namespace chai3d
296 //------------------------------------------------------------------------------
297 
298 //------------------------------------------------------------------------------
299 #endif
300 //------------------------------------------------------------------------------
301 
302 
void cCreateCylinder(cMesh *a_mesh, const double &a_height, const double &a_radius, const unsigned int a_numSides, const unsigned int a_numHeightSegments, const unsigned int a_numRings, const bool a_includeTop, const bool a_includeBottom, const cVector3d &a_pos, const cMatrix3d &a_rot, const cColorf &a_color)
This function creates a cylinder.
Definition: CPrimitives.cpp:642
void cCreateRingSection(cMesh *a_mesh, const double &a_innerRadius0, const double &a_innerRadius1, const double &a_outerRadius, const double &a_coverageAngleDEG, const bool a_includeExtremityFaces, const unsigned int a_numSides, const unsigned int a_numRings, const cVector3d &a_pos, const cMatrix3d &a_rot, const cColorf &a_color)
This function creates a ring section.
Definition: CPrimitives.cpp:1252
void cCreateBox(cMesh *a_mesh, const double &a_lengthX, const double &a_lengthY, const double &a_lengthZ, const cVector3d &a_pos, const cMatrix3d &a_rot, const cColorf &a_color)
This function creates a box.
Definition: CPrimitives.cpp:558
void cCreateEllipsoid(cMesh *a_mesh, const double &a_radiusX, const double &a_radiusY, const double &a_radiusZ, const unsigned int a_numSlices, const unsigned int a_numStacks, const cVector3d &a_pos, const cMatrix3d &a_rot, const cColorf &a_color)
This function creates an ellipsoid.
Definition: CPrimitives.cpp:1087
void cCreateTeaPot(cMesh *a_mesh, const double &a_size, const int &a_resolution, const cVector3d &a_pos, const cMatrix3d &a_rot, const cColorf &a_color)
This function creates a tea pot.
Definition: CPrimitives.cpp:1457
void cCreateRing(cMesh *a_mesh, const double &a_innerRadius, const double &a_outerRadius, const unsigned int a_numSides, const unsigned int a_numRings, const cVector3d &a_pos, const cMatrix3d &a_rot, const cColorf &a_color)
This function creates a ring.
Definition: CPrimitives.cpp:1173
Implements a class to model polygonal meshes.
void cCreateMap(cMesh *a_mesh, const double &a_lengthX, const double &a_lengthY, const unsigned int a_numSidesX, const unsigned int a_numSidesY, const cVector3d &a_pos, const cMatrix3d &a_rot, const cColorf &a_color)
This function creates a height map. Similar to a map, but with more triangles.
Definition: CPrimitives.cpp:185
void cCreateCircularArrow(cMesh *a_mesh, const double &a_innerRadius0, const double &a_innerRadius1, const double &a_outerRadius, const double &a_lengthTip, const double &a_radiusTip, const double &a_coverageAngleDeg, const bool a_includeTipsAtBothExtremities, const unsigned int a_numSides, const unsigned int a_numRings, const cVector3d &a_direction, const cVector3d &a_pos, const cColorf &a_color)
This function creates an circular arrow.
Definition: CPrimitives.cpp:1801
void cCreatePanel(cMesh *a_mesh, const double &a_lengthX, const double &a_lengthY, const double &a_radiusCorners, const int &a_numSegmentsPerCorner, const cVector3d &a_pos, const cMatrix3d &a_rot, const cColorf &a_color)
This function creates a panel with optional rounded corners.
Definition: CPrimitives.cpp:334
void cCreateBezierPatch(cMesh *a_mesh, const cVector3d *a_controlPoints, const int a_numDivisions, const cVector3d &a_pos, const cMatrix3d &a_rot, const cColorf &a_color)
This function creates a Bezier patch.
Definition: CPrimitives.cpp:1923
void cCreatePlane(cMesh *a_mesh, const double &a_lengthX, const double &a_lengthY, const cVector3d &a_pos, const cMatrix3d &a_rot, const cColorf &a_color)
This function creates a plane.
Definition: CPrimitives.cpp:70
void cCreatePipe(cMesh *a_mesh, const double &a_height, const double &a_innerRadius, const double &a_outerRadius, const unsigned int a_numSides, const unsigned int a_numHeightSegments, const cVector3d &a_pos, const cMatrix3d &a_rot, const cColorf &a_color)
This function creates a pipe.
Definition: CPrimitives.cpp:879
void cCreateArrow(cMesh *a_mesh, const double &a_length, const double &a_radiusShaft, const double &a_lengthTip, const double &a_radiusTip, const bool a_includeTipsAtBothExtremities, const unsigned int a_numSides, const cVector3d &a_direction, const cVector3d &a_pos, const cColorf &a_color)
This function creates an arrow.
Definition: CPrimitives.cpp:1665
void cCreateCone(cMesh *a_mesh, const double &a_height, const double &a_radiusBottom, const double &a_radiusTop, const unsigned int a_numSides, const unsigned int a_numHeightSegments, const unsigned int a_numRings, const bool a_includeBottom, const bool a_includeTop, const cVector3d &a_pos, const cMatrix3d &a_rot, const cColorf &a_color)
This function creates a cone.
Definition: CPrimitives.cpp:689
void cCreateDisk(cMesh *a_mesh, const double &a_radiusX, const double &a_radiusY, const unsigned int a_numSlices, const cVector3d &a_pos, const cMatrix3d &a_rot, const cColorf &a_color)
This function creates a disk.
Definition: CPrimitives.cpp:262
cMatrix3d cIdentity3d(void)
This function return a 3x3 identity matrix.
Definition: CMaths.h:1047
void cCreateSphere(cMesh *a_mesh, const double &a_radius, const unsigned int a_numSlices, const unsigned int a_numStacks, const cVector3d &a_pos, const cMatrix3d &a_rot, const cColorf &a_color)
This function creates a sphere.
Definition: CPrimitives.cpp:1051
void cCreatePanel2(cMesh *a_mesh, const double &a_lengthX, const double &a_lengthY, const double &a_cornerTopLeftRadius, const double &a_cornerTopRightRadius, const double &a_cornerBottomLeftRadius, const double &a_cornerBottomRightRadius, const int &a_numSegmentsPerCorner, const cVector3d &a_pos, const cMatrix3d &a_rot, const cColorf &a_colorTopLeft, const cColorf &a_colorTopRight, const cColorf &a_colorBottomLeft, const cColorf &a_colorBottomRight)
This function creates a panel with optional rounded corners.
Definition: CPrimitives.cpp:381
Definition: CAudioBuffer.cpp:56
void cCreateSquarePyramid(cMesh *a_mesh, const double &a_height, const double &a_baseSize, const bool a_includeBottom, const cVector3d &a_pos, const cMatrix3d &a_rot, const cColorf &a_color)
This function creates a pyramid.
Definition: CPrimitives.cpp:1378
void cCreatePlane2(cMesh *a_mesh, const double &a_lengthX, const double &a_lengthY, const cVector3d &a_pos, const cMatrix3d &a_rot, const cColorf &a_colorTopLeft, const cColorf &a_colorTopRight, const cColorf &a_colorBottomLeft, const cColorf &a_colorBottomRight)
This function creates a plane.
Definition: CPrimitives.cpp:106