SLProject  4.2.000
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
SLRevolver.h
Go to the documentation of this file.
1 /**
2  * \file SLRevolver.h
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 #ifndef SLREVOLVER_H
11 #define SLREVOLVER_H
12 
13 #include <SLMesh.h>
14 
15 #include <utility>
16 
17 class SLAssetManager;
18 
19 //-----------------------------------------------------------------------------
20 /**
21  * @brief SLRevolver is an SLMesh object built out of revolving points.
22  * @details SLRevolver is an SLMesh object that is built out of points that
23  * are revolved in slices around and axis. The surface will be outwards if the
24  * points in the array _revPoints increase towards the axis direction. If all
25  * points in the array _revPoints are different the normals will be smoothed.
26  * If two consecutive points are identical the normals will define a hard edge.
27  * Texture coords. are cylindrically mapped. See the online example
28  * \subpage example-revolver with various revolver objects.
29  * @remarks It is important that during instantiation NO OpenGL functions (gl*)
30  * get called because this constructor will be most probably called in a parallel
31  * thread from within an SLScene::registerAssetsToLoad or SLScene::assemble
32  * function. All objects that get rendered have to do their OpenGL initialization
33  * when they are used the first time during rendering in the main thread.
34  * For this mesh it means that the objects for OpenGL drawing (_vao, _vaoP,
35  * _vaoN, _vaoT and _vaoS) remain unused until the first frame is rendered.
36  */
37 class SLRevolver : public SLMesh
38 {
39 public:
40  //! ctor for generic revolver mesh
41  SLRevolver(SLAssetManager* assetMgr,
42  SLVVec3f revolvePoints,
43  SLVec3f revolveAxis,
44  SLuint slices = 36,
45  SLbool smoothFirst = false,
46  SLbool smoothLast = false,
47  SLstring name = "revolver mesh",
48  SLMaterial* mat = nullptr);
49 
50  //! ctor for derived revolver shapes
51  SLRevolver(SLAssetManager* assetMgr, SLstring name) : SLMesh(assetMgr, std::move(name)) { ; }
52 
53  void buildMesh(SLMaterial* mat = nullptr);
54  SLuint stacks() { return _stacks; }
55  SLuint slices() { return _slices; }
56 
57 protected:
58  SLVVec3f _revPoints; //!< Array revolving points
59  SLVec3f _revAxis; //!< axis of revolution
60  SLuint _stacks; //!< No. of stacks (mostly used)
61  SLuint _slices; //!< NO. of slices
62 
63  //! flag if the normal of the first point is eqaual to -revAxis
65 
66  //! flag if the normal of the last point is eqaual to revAxis
68 };
69 //-----------------------------------------------------------------------------
70 #endif // SLREVOLVER_H
unsigned int SLuint
Definition: SL.h:171
bool SLbool
Definition: SL.h:175
string SLstring
Definition: SL.h:158
vector< SLVec3f > SLVVec3f
Definition: SLVec3.h:325
Toplevel holder of the assets meshes, materials, textures and shaders.
Defines a standard CG material with textures and a shader program.
Definition: SLMaterial.h:56
An SLMesh object is a triangulated mesh, drawn with one draw call.
Definition: SLMesh.h:134
SLMaterial * mat() const
Definition: SLMesh.h:177
const SLstring & name() const
Definition: SLObject.h:38
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 stacks()
Definition: SLRevolver.h:54
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
SLRevolver(SLAssetManager *assetMgr, SLstring name)
ctor for derived revolver shapes
Definition: SLRevolver.h:51
void buildMesh(SLMaterial *mat=nullptr)
Definition: SLRevolver.cpp:43
SLVVec3f _revPoints
Array revolving points.
Definition: SLRevolver.h:58
SLRevolver(SLAssetManager *assetMgr, SLVVec3f revolvePoints, SLVec3f revolveAxis, SLuint slices=36, SLbool smoothFirst=false, SLbool smoothLast=false, SLstring name="revolver mesh", SLMaterial *mat=nullptr)
ctor for generic revolver mesh
Definition: SLRevolver.cpp:16
SLuint _stacks
No. of stacks (mostly used)
Definition: SLRevolver.h:60