SLProject  4.2.000
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
SLCylinder Class Reference

SLCylinder is creates sphere mesh based on its SLRevolver methods. More...

#include <SLCylinder.h>

Inheritance diagram for SLCylinder:
[legend]

Public Member Functions

 SLCylinder (SLAssetManager *assetMgr, SLfloat cylinderRadius, SLfloat cylinderHeight, SLuint stacks=1, SLuint slices=16, SLbool hasTop=true, SLbool hasBottom=true, SLstring name="cylinder mesh", SLMaterial *mat=nullptr)
 
SLfloat radius ()
 
SLfloat height ()
 
SLbool hasTop ()
 
SLbool hasBottom ()
 
- Public Member Functions inherited from SLRevolver
 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 More...
 
 SLRevolver (SLAssetManager *assetMgr, SLstring name)
 ctor for derived revolver shapes More...
 
void buildMesh (SLMaterial *mat=nullptr)
 
SLuint stacks ()
 
SLuint slices ()
 
- Public Member Functions inherited from SLMesh
 SLMesh (SLAssetManager *assetMgr, const SLstring &name="Mesh")
 Construct a new SLMesh::SLMesh object. More...
 
 ~SLMesh () override
 The destructor deletes everything by calling deleteData. More...
 
virtual void init (SLNode *node)
 SLMesh::shapeInit sets the transparency flag of the AABB. More...
 
virtual void draw (SLSceneView *sv, SLNode *node, SLuint intances=0)
 
void drawIntoDepthBuffer (SLSceneView *sv, SLNode *node, SLMaterial *depthMat)
 Simplified drawing method for shadow map creation. More...
 
void addStats (SLNodeStats &stats)
 
virtual void buildAABB (SLAABBox &aabb, const SLMat4f &wmNode)
 
void updateAccelStruct ()
 
SLbool hit (SLRay *ray, SLNode *node)
 
virtual void preShade (SLRay *ray)
 
virtual void deleteData ()
 SLMesh::deleteData deletes all mesh data and vbo's. More...
 
virtual void deleteDataGpu ()
 
void deleteSelected (SLNode *node)
 Deletes the rectangle selected vertices and the dependent triangles. More...
 
void deleteUnused ()
 Deletes unused vertices (= vertices that are not indexed in I16 or I32) More...
 
virtual void calcMinMax ()
 
virtual void calcNormals ()
 SLMesh::calcNormals recalculates vertex normals for triangle meshes. More...
 
void calcCenterRad (SLVec3f &center, SLfloat &radius)
 
SLbool hitTriangleOS (SLRay *ray, SLNode *node, SLuint iT)
 
virtual void generateVAO (SLGLVertexArray &vao)
 Generate the Vertex Array Object for a specific shader program. More...
 
void computeHardEdgesIndices (float angleRAD, float epsilon)
 computes the hard edges and stores the vertex indexes separately More...
 
void transformSkin (bool forceCPUSkinning, const std::function< void(SLMesh *)> &cbInformNodes)
 Transforms the vertex positions and normals with by joint weights. More...
 
void deselectPartialSelection ()
 
SLMaterialmat () const
 
SLMaterialmatOut () const
 
SLGLPrimitiveType primitive () const
 
const SLAnimSkeletonskeleton () const
 
SLuint numI () const
 
SLGLVertexArrayvao ()
 
SLbool isSelected () const
 
SLfloat edgeAngleDEG () const
 
SLfloat edgeWidth () const
 
SLCol4f edgeColor () const
 
SLVec3f finalP (SLuint i)
 
SLVec3f finalN (SLuint i)
 
SLbool accelStructIsOutOfDate ()
 
void mat (SLMaterial *m)
 
void matOut (SLMaterial *m)
 
void primitive (SLGLPrimitiveType pt)
 
void skeleton (SLAnimSkeleton *skel)
 
void isSelected (bool isSelected)
 
void edgeWidth (SLfloat ew)
 
void edgeAngleDEG (SLfloat ea)
 
void edgeColor (const SLCol4f &ec)
 
void vertexPosEpsilon (SLfloat eps)
 
- Public Member Functions inherited from SLObject
 SLObject (const SLstring &Name="", const SLstring &url="")
 
virtual ~SLObject ()
 
void name (const SLstring &Name)
 
void url (const SLstring &url)
 
const SLstringname () const
 
const SLstringurl () const
 

Private Attributes

SLfloat _radius
 radius of cylinder More...
 
SLfloat _height
 height of cylinder More...
 
SLbool _hasTop
 Flag if cylinder has a top. More...
 
SLbool _hasBottom
 Flag if cylinder has a bottom. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from SLMesh
static void calcTex3DMatrix (SLNode *node)
 
- Public Attributes inherited from SLMesh
SLVVec3f P
 Vector for vertex positions layout (location = 0) More...
 
SLVVec3f N
 Vector for vertex normals (opt.) layout (location = 1) More...
 
SLVVec2f UV [2]
 Array of 2 Vectors for tex. coords. (opt.) layout (location = 2) More...
 
SLVCol4f C
 Vector of vertex colors (opt.) layout (location = 4) More...
 
SLVVec4f T
 Vector of vertex tangents (opt.) layout (location = 5) More...
 
SLVVuchar Ji
 2D Vector of per vertex joint ids (opt.) layout (location = 6) More...
 
SLVVfloat Jw
 2D Vector of per vertex joint weights (opt.) layout (location = 7) More...
 
SLVVec3f skinnedP
 temp. vector for CPU skinned vertex positions More...
 
SLVVec3f skinnedN
 temp. vector for CPU skinned vertex normals More...
 
SLVushort I16
 Vector of vertex indices 16 bit. More...
 
SLVuint I32
 Vector of vertex indices 32 bit. More...
 
SLVuint IS32
 Vector of rectangle selected vertex indices 32 bit. More...
 
SLVushort IE16
 Vector of hard edges vertex indices 16 bit (see computeHardEdgesIndices) More...
 
SLVuint IE32
 Vector of hard edges vertex indices 32 bit (see computeHardEdgesIndices) More...
 
SLVec3f minP
 min. vertex in OS More...
 
SLVec3f maxP
 max. vertex in OS More...
 
- Protected Attributes inherited from SLRevolver
SLVVec3f _revPoints
 Array revolving points. More...
 
SLVec3f _revAxis
 axis of revolution More...
 
SLuint _stacks
 No. of stacks (mostly used) More...
 
SLuint _slices
 NO. of slices. More...
 
SLbool _smoothFirst
 flag if the normal of the first point is eqaual to -revAxis More...
 
SLbool _smoothLast
 flag if the normal of the last point is eqaual to revAxis More...
 
- Protected Attributes inherited from SLMesh
SLGLPrimitiveType _primitive
 Primitive type (default triangles) More...
 
SLMaterial_mat
 Pointer to the inside material. More...
 
SLMaterial_matOut
 Pointer to the outside material. More...
 
SLGLVertexArray _vao
 Main OpenGL Vertex Array Object for drawing. More...
 
SLGLVertexArrayExt _vaoN
 OpenGL VAO for optional normal drawing. More...
 
SLGLVertexArrayExt _vaoT
 OpenGL VAO for optional tangent drawing. More...
 
SLGLVertexArrayExt _vaoS
 OpenGL VAO for optional selection drawing. More...
 
SLbool _isSelected
 Flag if mesh is partially of fully selected. More...
 
SLfloat _edgeAngleDEG
 Edge crease angle in degrees between face normals (30 deg. default) More...
 
SLfloat _edgeWidth
 Line width for hard edge drawing. More...
 
SLCol4f _edgeColor
 Color for hard edge drawing. More...
 
SLfloat _vertexPosEpsilon
 Vertex position epsilon used in computeHardEdgesIndices. More...
 
SLbool _isVolume
 Flag for RT if mesh is a closed volume. More...
 
SLAccelStruct_accelStruct
 KD-tree or uniform grid. More...
 
SLbool _accelStructIsOutOfDate
 Flag if accel. struct needs update. More...
 
SLAnimSkeleton_skeleton
 The skeleton this mesh is bound to. More...
 
SLVMat4f _jointMatrices
 Joint matrix vector for this mesh. More...
 
SLbool _isCPUSkinned
 Flag if mesh has been skinned on CPU during update. More...
 
SLVVec3f_finalP
 Pointer to final vertex position vector. More...
 
SLVVec3f_finalN
 pointer to final vertex normal vector More...
 
- Protected Attributes inherited from SLObject
SLstring _name
 name of an object More...
 
SLstring _url
 uniform resource locator More...
 

Detailed Description

SLCylinder is creates sphere mesh based on its SLRevolver methods.

Remarks
It is important that during instantiation NO OpenGL functions (gl*) get called because this constructor will be most probably called in a parallel thread from within an SLScene::registerAssetsToLoad or SLScene::assemble function. All objects that get rendered have to do their OpenGL initialization when they are used the first time during rendering in the main thread. For this mesh it means that the objects for OpenGL drawing (_vao, _vaoP, _vaoN, _vaoT and _vaoS) remain unused until the first frame is rendered.

Definition at line 26 of file SLCylinder.h.

Constructor & Destructor Documentation

◆ SLCylinder()

SLCylinder::SLCylinder ( SLAssetManager assetMgr,
SLfloat  cylinderRadius,
SLfloat  cylinderHeight,
SLuint  stacks = 1,
SLuint  slices = 16,
SLbool  hasTop = true,
SLbool  hasBottom = true,
SLstring  name = "cylinder mesh",
SLMaterial mat = nullptr 
)

SLCylinder::SLCylinder ctor for cylindric revolution object around the z-axis.

Definition at line 18 of file SLCylinder.cpp.

26  : SLRevolver(assetMgr, std::move(name))
27 {
28  assert(slices >= 3 && "Error: Not enough slices.");
29  assert(slices > 0 && "Error: Not enough stacks.");
30 
31  _radius = cylinderRadius;
32  _height = cylinderHeight;
33  _hasTop = hasTop;
35 
36  _stacks = stacks;
37  _slices = slices;
40  _revAxis.set(0, 0, 1);
41  SLuint nPoints = stacks + 1;
42  if (hasTop) nPoints += 2;
43  if (hasBottom) nPoints += 2;
44  _revPoints.reserve(nPoints);
45 
46  SLfloat dHeight = cylinderHeight / stacks;
47  SLfloat h = 0;
48 
49  if (hasBottom)
50  { // define double points for sharp edges
51  _revPoints.push_back(SLVec3f(0, 0, 0));
52  _revPoints.push_back(SLVec3f(cylinderRadius, 0, 0));
53  }
54 
55  for (SLuint i = 0; i <= stacks; ++i)
56  {
57  _revPoints.push_back(SLVec3f(cylinderRadius, 0, h));
58  h += dHeight;
59  }
60 
61  if (hasTop)
62  { // define double points for sharp edges
63  _revPoints.push_back(SLVec3f(cylinderRadius, 0, cylinderHeight));
64  _revPoints.push_back(SLVec3f(0, 0, cylinderHeight));
65  }
66 
67  buildMesh(mat);
68 }
float SLfloat
Definition: SL.h:173
unsigned int SLuint
Definition: SL.h:171
SLVec3< SLfloat > SLVec3f
Definition: SLVec3.h:318
SLfloat _height
height of cylinder
Definition: SLCylinder.h:47
SLbool _hasBottom
Flag if cylinder has a bottom.
Definition: SLCylinder.h:49
SLbool hasTop()
Definition: SLCylinder.h:42
SLbool hasBottom()
Definition: SLCylinder.h:43
SLfloat _radius
radius of cylinder
Definition: SLCylinder.h:46
SLbool _hasTop
Flag if cylinder has a top.
Definition: SLCylinder.h:48
SLMaterial * mat() const
Definition: SLMesh.h:177
const SLstring & name() const
Definition: SLObject.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
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
void set(const T X, const T Y, const T Z)
Definition: SLVec3.h:59

Member Function Documentation

◆ hasBottom()

SLbool SLCylinder::hasBottom ( )
inline

Definition at line 43 of file SLCylinder.h.

43 { return _hasBottom; }

◆ hasTop()

SLbool SLCylinder::hasTop ( )
inline

Definition at line 42 of file SLCylinder.h.

42 { return _hasTop; }

◆ height()

SLfloat SLCylinder::height ( )
inline

Definition at line 41 of file SLCylinder.h.

41 { return _height; }

◆ radius()

SLfloat SLCylinder::radius ( )
inline

Definition at line 40 of file SLCylinder.h.

40 { return _radius; }

Member Data Documentation

◆ _hasBottom

SLbool SLCylinder::_hasBottom
private

Flag if cylinder has a bottom.

Definition at line 49 of file SLCylinder.h.

◆ _hasTop

SLbool SLCylinder::_hasTop
private

Flag if cylinder has a top.

Definition at line 48 of file SLCylinder.h.

◆ _height

SLfloat SLCylinder::_height
private

height of cylinder

Definition at line 47 of file SLCylinder.h.

◆ _radius

SLfloat SLCylinder::_radius
private

radius of cylinder

Definition at line 46 of file SLCylinder.h.


The documentation for this class was generated from the following files: