SLProject  4.2.000
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
SLDisk.cpp
Go to the documentation of this file.
1 /**
2  * \file SLDisk.cpp
3  * \date July 2014
4  * \authors Marcus Hudritsch
5  * \copyright http://opensource.org/licenses/GPL-3.0
6  * \remarks Please use clangformat to format the code. See more code style on
7  * https://github.com/cpvrlab/SLProject4/wiki/SLProject-Coding-Style
8 */
9 
10 #include <SLDisk.h>
11 
12 #include <utility>
13 
14 //-----------------------------------------------------------------------------
15 /*!
16 SLDisk::SLDisk ctor for disk revolution object around the z-axis
17 */
19  SLfloat radius,
20  const SLVec3f& revolveAxis,
21  SLuint slices,
22  SLbool doubleSided,
23  SLstring name,
24  SLMaterial* mat) : SLRevolver(assetMgr, std::move(name))
25 {
26  assert(slices >= 3 && "Error: Not enough slices.");
27 
28  _radius = radius;
29  _doubleSided = doubleSided;
30  _slices = slices;
31  _smoothFirst = true;
32  _revAxis = revolveAxis;
33 
34  // add the centre & radius point
35  if (_doubleSided)
36  {
37  _revPoints.reserve(4);
38  _revPoints.push_back(SLVec3f(0, 0, 0));
39  _revPoints.push_back(SLVec3f(radius, 0, 0));
40  _revPoints.push_back(SLVec3f(radius, 0, 0));
41  _revPoints.push_back(SLVec3f(0, 0, 0));
42  _smoothLast = true;
43  }
44  else
45  {
46  _revPoints.reserve(2);
47  _revPoints.push_back(SLVec3f(0, 0, 0));
48  _revPoints.push_back(SLVec3f(radius, 0, 0));
49  _smoothLast = false;
50  }
51 
52  buildMesh(mat);
53 }
54 //-----------------------------------------------------------------------------
float SLfloat
Definition: SL.h:173
unsigned int SLuint
Definition: SL.h:171
bool SLbool
Definition: SL.h:175
string SLstring
Definition: SL.h:158
SLVec3< SLfloat > SLVec3f
Definition: SLVec3.h:318
Toplevel holder of the assets meshes, materials, textures and shaders.
SLDisk(SLAssetManager *assetMgr, SLfloat radius=1.0f, const SLVec3f &revolveAxis=SLVec3f::AXISY, SLuint slices=36, SLbool doubleSided=false, SLstring name="disk mesh", SLMaterial *mat=nullptr)
Definition: SLDisk.cpp:18
SLfloat radius()
Definition: SLDisk.h:38
SLbool _doubleSided
flag if disk has two sides
Definition: SLDisk.h:42
SLfloat _radius
radius of cone
Definition: SLDisk.h:41
Defines a standard CG material with textures and a shader program.
Definition: SLMaterial.h:56
SLMaterial * mat() const
Definition: SLMesh.h:177
SLRevolver is an SLMesh object built out of revolving points.
Definition: SLRevolver.h:38
SLbool _smoothLast
flag if the normal of the last point is eqaual to revAxis
Definition: SLRevolver.h:67
SLVec3f _revAxis
axis of revolution
Definition: SLRevolver.h:59
SLuint slices()
Definition: SLRevolver.h:55
SLbool _smoothFirst
flag if the normal of the first point is eqaual to -revAxis
Definition: SLRevolver.h:64
SLuint _slices
NO. of slices.
Definition: SLRevolver.h:61
void buildMesh(SLMaterial *mat=nullptr)
Definition: SLRevolver.cpp:43
SLVVec3f _revPoints
Array revolving points.
Definition: SLRevolver.h:58