SLProject  4.2.000
A platform independent 3D computer graphics framework for desktop OS, Android, iOS and online in web browsers
SLPoints.cpp
Go to the documentation of this file.
1 /**
2  * \file SLPoints.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 <SLPoints.h>
11 #include <climits>
12 
13 //-----------------------------------------------------------------------------
14 //! SLPoints ctor with a given vector of points
16  const SLVVec3f& points,
17  const SLstring& name,
18  SLMaterial* material) : SLMesh(assetMgr, name)
19 {
20  assert(!name.empty());
21 
23 
24  if (points.size() > UINT_MAX)
25  SL_EXIT_MSG("SLPoints supports max. 2^32 vertices.");
26 
27  P = points;
28 
29  mat(material);
30 }
31 //-----------------------------------------------------------------------------
32 //! SLPoints ctor with a given vector of points
34  const SLVVec3f& points,
35  const SLVVec3f& normals,
36  const SLstring& name,
37  SLMaterial* material) : SLMesh(assetMgr, name)
38 {
39  assert(!name.empty());
40 
42 
43  if ((SLulong)points.size() > (SLulong)UINT_MAX)
44  SL_EXIT_MSG("SLPoints supports max. 2^32 vertices.");
45  if (points.size() != normals.size())
46  SL_EXIT_MSG("SLPoints: different size of points and normals vector.");
47 
48  P = points;
49  N = normals;
50 
51  mat(material);
52 }
53 //-----------------------------------------------------------------------------
54 //! SLPoints ctor for a random point cloud with the rnd generator.
56  SLuint32 nPoints,
57  SLRnd3f& rnd,
58  const SLstring& name,
59  SLMaterial* material) : SLMesh(assetMgr, name)
60 {
61  assert(!name.empty() && "No name provided in SLPoints!");
62 
64 
65  for (int i = 0; i < (int)nPoints; ++i)
66  P.push_back(rnd.generate());
67 
68  mat(material);
69 }
70 //-----------------------------------------------------------------------------
unsigned long SLulong
Definition: SL.h:165
#define SL_EXIT_MSG(message)
Definition: SL.h:240
string SLstring
Definition: SL.h:158
uint32_t SLuint32
Definition: SL.h:184
@ PT_points
Definition: SLGLEnums.h:31
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
SLGLPrimitiveType _primitive
Primitive type (default triangles)
Definition: SLMesh.h:231
SLVVec3f N
Vector for vertex normals (opt.) layout (location = 1)
Definition: SLMesh.h:204
SLVVec3f P
Vector for vertex positions layout (location = 0)
Definition: SLMesh.h:203
SLMaterial * mat() const
Definition: SLMesh.h:177
const SLstring & name() const
Definition: SLObject.h:38
SLPoints(SLAssetManager *assetMgr, const SLVVec3f &points, const SLstring &name="point cloud", SLMaterial *material=nullptr)
Ctor for a given vector of points.
Definition: SLPoints.cpp:15
Abstract base class for random 3D point generator.
Definition: SLRnd3f.h:18
virtual SLVec3f generate()=0